clinic/netforce_clinic/models/report_hd.py

64 lines
1.7 KiB
Python
Raw Normal View History

2014-10-09 10:53:01 +00:00
import time
from netforce.model import Model, fields, get_model
2014-10-09 10:53:01 +00:00
class HDReport(Model):
_name="clinic.hd.report"
_string="HD Report"
_transient=True
_fields={
"date": fields.Date("Date"),
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
2014-10-09 10:53:01 +00:00
}
_defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"),
}
_order="cycle_id desc"
2014-10-09 10:53:01 +00:00
def get_report_data(self,ids,context={}):
2014-10-14 04:36:29 +00:00
obj=self.browse(ids)[0]
lines=[]
2014-10-14 04:36:29 +00:00
PATIENT_TYPE={
"mg":"Medical Government",
"sc":"Social Security",
"nhso":"NHSO (30฿)",
"personal": "Personal",
"others": "Others",
}
dom=[]
dom.append([
'state','=','completed',
])
if obj.cycle_id:
dom.append([
'cycle_id','=',obj.cycle_id.id,
])
if obj.date:
dom.append(['time_start', ">=", obj.date+" 00:00:00"])
dom.append(['time_stop', "<=", obj.date+" 23:59:59"])
print("dom ", dom)
for hd_case in get_model("clinic.hd.case").search_browse(dom):
patient_type=hd_case.patient_id.type
patient_type=PATIENT_TYPE.get(patient_type)
lines.append({
2014-10-14 04:36:29 +00:00
'cycle' : hd_case.cycle_id.name,
'patient': hd_case.patient_id.name,
'patient_type' : patient_type,
'doctor' : hd_case.doctor_id.name,
'total' : hd_case.fee,
'rc_no' : hd_case.number,
'nurse' : hd_case.nurse_id.name,
})
2014-10-09 10:53:01 +00:00
data={
'lines': lines,
2014-10-09 10:53:01 +00:00
}
return data
HDReport.register()