conv_bal
watcha.h 2014-11-10 18:33:01 +07:00
parent c933fb1280
commit 27bf15311f
11 changed files with 159 additions and 48 deletions

View File

@ -1,5 +1,3 @@
<form model="clinic.report.discontinue.patient"> <form model="clinic.report.discontinue.patient">
<group> <field name="date" span="3" mode="month"/>
<field name="date" span="3"/>
</group>
</form> </form>

View File

@ -1,5 +1,3 @@
<form model="clinic.report.new.patient"> <form model="clinic.report.new.patient">
<group> <field name="date" span="3" mode="month"/>
<field name="date" span="3"/>
</group>
</form> </form>

View File

@ -105,7 +105,7 @@ class Patient(Model):
_defaults={ _defaults={
"type": "mg", "type": "sc",
"reg_date": lambda *a: time.strftime("%Y-%m-%d"), "reg_date": lambda *a: time.strftime("%Y-%m-%d"),
"number": _get_number, "number": _get_number,
"company_id": lambda *a: get_active_company(), "company_id": lambda *a: get_active_company(),

View File

@ -1,4 +1,5 @@
from netforce.model import Model, fields from netforce.model import Model, fields
from netforce.access import get_active_company
class PersonalCategory(Model): class PersonalCategory(Model):
_name="clinic.personal.categ" _name="clinic.personal.categ"
@ -8,6 +9,11 @@ class PersonalCategory(Model):
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
"type": fields.Selection([("doctor","Doctor"),("nurse","Nurse"),('other','Other')],"Type"), "type": fields.Selection([("doctor","Doctor"),("nurse","Nurse"),('other','Other')],"Type"),
'parent_id': fields.Many2One("clinic.personal.categ","Parent"), 'parent_id': fields.Many2One("clinic.personal.categ","Parent"),
'company_id': fields.Many2One("company","Company"),
}
_defaults={
"company_id": lambda *a: get_active_company(),
} }
PersonalCategory.register() PersonalCategory.register()

View File

@ -1,8 +1,11 @@
import time import time
from calendar import monthrange
from netforce.model import Model,fields,get_model from netforce.model import Model,fields,get_model
from netforce.access import get_active_company from netforce.access import get_active_company
from . import utils
class ReportDiscontinuePatient(Model): class ReportDiscontinuePatient(Model):
_name="clinic.report.discontinue.patient" _name="clinic.report.discontinue.patient"
_string="Report Discontinue Patient" _string="Report Discontinue Patient"
@ -19,10 +22,42 @@ class ReportDiscontinuePatient(Model):
def get_report_data(self,ids,context={}): def get_report_data(self,ids,context={}):
company_id=get_active_company() company_id=get_active_company()
company=get_model('company').browse(company_id) company=get_model('company').browse(company_id)
year, month=time.strftime("%Y-%m").split("-")
if ids:
obj=self.browse(ids)[0]
year,month,day=obj.date.split("-")
# new patient of this month
year=int(year)
month=int(month)
dom=[]
weekday, total_day=monthrange(year, month)
dom=[]
time_start='%s-%s-01'%(year,str(month).zfill(2))
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
dom.append(['resign_date','>=',time_start])
dom.append(['resign_date','<=',time_stop])
dom.append(['active','=',False])
records=get_model('clinic.patient').search_browse(dom)
lines=[]
no=1
for record in records:
lines.append({
'no': no,
'pid': record.id,
'name': record.name or '',
'note': record.note or '',
})
no+=1
month_str=utils.MONTHS['th_TH'][month]
data={ data={
'company_name': company.name or "", 'company_name': company.name or "",
'parent_company_name': company.parent_id.name or "", 'parent_company_name': company.parent_id.name or "",
'lines': lines,
'month': month_str,
'year': year,
} }
return data return data
ReportDiscontinuePatient.register() ReportDiscontinuePatient.register()

View File

@ -4,7 +4,6 @@ import urllib.parse as urllib
from datetime import datetime from datetime import datetime
from calendar import monthrange from calendar import monthrange
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.database import get_connection
from netforce.access import get_active_company from netforce.access import get_active_company
from . import utils from . import utils
@ -23,7 +22,6 @@ class ReportHDCaseSummary(Model):
} }
def get_report_data(self,ids,context={}): def get_report_data(self,ids,context={}):
db=get_connection()
company_id=get_active_company() company_id=get_active_company()
company=get_model("company").browse(company_id) company=get_model("company").browse(company_id)
@ -218,8 +216,8 @@ class ReportHDCaseSummary(Model):
'month': month_str, 'month': month_str,
'year': year, 'year': year,
'lines': lines, 'lines': lines,
'new_patient_lines': new_patient_lines, #'new_patient_lines': new_patient_lines,
'resign_patient_lines': resign_patient_lines, #'resign_patient_lines': resign_patient_lines,
'company_name': company.name or "", 'company_name': company.name or "",
'parent_company_name': company.parent_id.name or "", 'parent_company_name': company.parent_id.name or "",
} }

View File

@ -31,24 +31,58 @@ class ReportMedicalSummary(Model):
dom.append([['state','=','completed']]) dom.append([['state','=','completed']])
dom.append([['time_start','>=','%s-%s-01 00:00:00'%(year,month)]]) dom.append([['time_start','>=','%s-%s-01 00:00:00'%(year,month)]])
dom.append([['time_stop','<=','%s-%s-%s 23:59:59'%(year,month,total_day)]]) dom.append([['time_stop','<=','%s-%s-%s 23:59:59'%(year,month,total_day)]])
print("dom ", dom)
products=[] products={}
for prod in get_model("product").search_browse([['type','=','stock']]):
products[prod.code]={}
for patient_type in ('sc','nhso','personal'):
products[prod.code][patient_type]={
'qty': 0,
'name': prod.name,
'code': prod.code,
}
for hd_case in get_model('clinic.hd.case').search_browse(dom): for hd_case in get_model('clinic.hd.case').search_browse(dom):
print("="*30) patient_type=hd_case.patient_id.type
for line in hd_case.lines: for line in hd_case.lines:
prod=line.product_id prod=line.product_id
if line.type=='fee': if line.type=='fee' or prod.type=='service':
continue
if prod.type=='service':
continue continue
products[prod.code][patient_type]['qty']+=line.qty
lines=[]
for prod, records in products.items():
line={
'prod_name': records['sc']['name'], # XXX
}
for patient_type in ('sc','nhso','personal'):
line.update({
patient_type: records[patient_type]['qty'],
})
lines.append(line)
company_id=get_active_company() company_id=get_active_company()
company=get_model('company').browse(company_id) company=get_model('company').browse(company_id)
month_str=utils.MONTHS['th_TH'][month]
lines=sorted(lines, key=lambda x: x['prod_name'])
titles={
'prod_name': 'ชื่อยา',
'sc': utils.PATIENT_TYPE['sc'],
'nhso': utils.PATIENT_TYPE['nhso'],
'personal': utils.PATIENT_TYPE['personal'],
}
data={ data={
'company_name': company.name or "", 'company_name': company.name or "",
'parent_company_name': company.parent_id.name or "", 'parent_company_name': company.parent_id.name or "",
'titles': titles,
'lines': lines,
'month': month_str,
'year': year,
} }
data.update(titles)
return data return data
ReportMedicalSummary.register() ReportMedicalSummary.register()

View File

@ -1,8 +1,11 @@
import time import time
from calendar import monthrange
from netforce.model import Model,fields,get_model from netforce.model import Model,fields,get_model
from netforce.access import get_active_company from netforce.access import get_active_company
from . import utils
class ReportNewPatient(Model): class ReportNewPatient(Model):
_name="clinic.report.new.patient" _name="clinic.report.new.patient"
_string="Report New Patient" _string="Report New Patient"
@ -19,9 +22,38 @@ class ReportNewPatient(Model):
def get_report_data(self,ids,context={}): def get_report_data(self,ids,context={}):
company_id=get_active_company() company_id=get_active_company()
company=get_model('company').browse(company_id) company=get_model('company').browse(company_id)
year, month=time.strftime("%Y-%m").split("-")
if ids:
obj=self.browse(ids)[0]
year,month,day=obj.date.split("-")
# new patient of this month
year=int(year)
month=int(month)
dom=[]
weekday, total_day=monthrange(year, month)
time_start='%s-%s-01'%(year,str(month).zfill(2))
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
dom.append(['reg_date','>=',time_start])
dom.append(['reg_date','<=',time_stop])
records=get_model('clinic.patient').search_browse(dom)
lines=[]
no=1
for record in records:
lines.append({
'no': no,
'name': record.name or '',
'pid': record.id,
'note': record.note or '',
})
no+=1
month_str=utils.MONTHS['th_TH'][month]
data={ data={
'company_name': company.name or "", 'company_name': company.name or "",
'parent_company_name': company.parent_id.name or "", 'parent_company_name': company.parent_id.name or "",
'lines': lines,
'month': month_str,
'year': year,
} }
return data return data

View File

@ -7,6 +7,7 @@
ประจำเดือน {{month}} {{year}} ประจำเดือน {{month}} {{year}}
</h4> </h4>
</center> </center>
{{#if lines}}
<table class="table"> <table class="table">
<thead> <thead>
<th>#</th> <th>#</th>
@ -16,12 +17,17 @@
<tbody> <tbody>
{{#each lines}} {{#each lines}}
<tr> <tr>
<td></td> <td>{{no}}</td>
<td></td> <td>
<td></td> {{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
</td>
<td>{{note}}</td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>
<tfoot> <tfoot>
</tfoot> </tfoot>
</table> </table>
{{else}}
No items to display.
{{/if}}

View File

@ -9,20 +9,18 @@
</center> </center>
<table class="table"> <table class="table">
<thead> <thead>
<th>ยา</th> <th>{{prod_name}}</th>
<th>ประเภทการรักษา</th> <th>{{sc}}</th>
<th>uc</th> <th>{{nhso}}</th>
<th>ซื้อ</th> <th>{{personal}}</th>
<th>รวม</th>
</thead> </thead>
<tbody> <tbody>
{{#each lines}} {{#each lines}}
<tr> <tr>
<td></td> <td>{{prod_name}}</td>
<td></td> <td>{{sc}}</td>
<td></td> <td>{{nhso}}</td>
<td></td> <td>{{personal}}</td>
<td></td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>

View File

@ -7,6 +7,7 @@
ประจำเดือน {{month}} {{year}} ประจำเดือน {{month}} {{year}}
</h4> </h4>
</center> </center>
{{#if lines}}
<table class="table"> <table class="table">
<thead> <thead>
<th>#</th> <th>#</th>
@ -17,7 +18,9 @@
{{#each lines}} {{#each lines}}
<tr> <tr>
<td>{{no}}</td> <td>{{no}}</td>
<td>{{name}}</td> <td>
{{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}}
</td>
<td>{{note}}</td> <td>{{note}}</td>
</tr> </tr>
{{/each}} {{/each}}
@ -25,3 +28,6 @@
<tfoot> <tfoot>
</tfoot> </tfoot>
</table> </table>
{{else}}
No items to display.
{{/if}}