From 6f437ceba72b712644b71bec831509294c398d84 Mon Sep 17 00:00:00 2001 From: "chayut.s" Date: Tue, 14 Oct 2014 11:36:29 +0700 Subject: [PATCH] report hd --- netforce_clinic/models/report_hd.py | 42 ++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/netforce_clinic/models/report_hd.py b/netforce_clinic/models/report_hd.py index f9aff13..225e5a9 100644 --- a/netforce_clinic/models/report_hd.py +++ b/netforce_clinic/models/report_hd.py @@ -19,21 +19,43 @@ class HDReport(Model): _order="cycle_id desc" def get_report_data(self,ids,context={}): + obj=self.browse(ids)[0] lines=[] - hd_case_ids=get_model("clinic.dialyzer").search([["state","=","completed"]]) - hd_cases=get_model("clinic.hd.case").search_browse([]) - for hd_case_ids in hd_cases: + 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({ - 'cycle' : hd_case_ids.cycle_id.name, - 'patient': hd_case_ids.patient_id.name, - 'doctor' : hd_case_ids.doctor_id.name, - 'total' : hd_case_ids.fee, - 'rc_no' : hd_case_ids.number, - 'nurse' : hd_case_ids.nurse_id.name, + '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, }) data={ - 'cycle_id': hd_case_ids.cycle or "Empty Cyle", 'lines': lines, } return data