From 226e94a34a8ec2fc2ea4d237eea48b6eb577ad21 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Thu, 9 Apr 2015 15:02:24 +0700 Subject: [PATCH] improve matching hdcase --- netforce_clinic/models/matching_hdcase.py | 35 ++++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/netforce_clinic/models/matching_hdcase.py b/netforce_clinic/models/matching_hdcase.py index 7beb6d7..782ccf9 100644 --- a/netforce_clinic/models/matching_hdcase.py +++ b/netforce_clinic/models/matching_hdcase.py @@ -123,10 +123,17 @@ class MatchingHDCase(Model): dom.append(['state','!=','cancelled']) hdcases={} hdcases2={} + hdcases3={} + def get_account_patient_hn(patient_id): + res=get_model("clinic.setting.account.patient").search_read([['patient_id','=',patient_id]],['hn','patient_id']) + if res: + return res[0] + return res + for hdcase in get_model("clinic.hd.case").search_browse(dom): date=hdcase.date hn=hdcase.patient_id.hn_no or "" - hn=hn[0:7] #XXX K.Ekk explain on 03/04/2015 : 0-7 is main of hn + #hn=hn[0:7] #XXX K.Ekk explain on 03/04/2015 : 0-7 is main of hn fee_amt=0 hct=hdcase.hct or "0" hct=round(float(hct),2) @@ -157,7 +164,19 @@ class MatchingHDCase(Model): 'number': hdcase.number or '', 'note': '%s, %s, %s, %s, %s'%(date,hn,hct,prod_name,fee_amt), } - + patient=hdcase.patient_id + result=get_account_patient_hn(patient.id) + if result: + hn=result['hn'] + key3='%s-%s-%s-%s'%(date,hn,prod_name,fee_amt) + hdcases3[key3]={ + 'id': hdcase.id, + 'number': hdcase.number or '', + 'note': '', + 'patient_id': patient.id, + 'patient_name': patient.name, + 'patient_type': patient.type_id.name, + } for row in rows: vals=list(row.values()) date,_time=(vals[5] or "").split() @@ -213,9 +232,7 @@ class MatchingHDCase(Model): key2='%s-%s'%(date,hn) hdcase2=hdcases2.get(key2) - #print("hdcase2 ", hdcase2) if hdcase2: - #line_vals['is_match']=False line_vals['hd_case_id']=hdcase2['id'] line_vals['hd_case_number']=hdcase2['number'] line_vals['note']='' @@ -227,6 +244,16 @@ class MatchingHDCase(Model): line_vals['nf_epo']=nf_epo.title() line_vals['nf_fee']=round(float((nf_fee or "0")),2) lines.append(line_vals) + + key3='%s-%s-%s-%s'%(date,hn,prod_name.upper(),fee_amt) + hdcase=hdcases3.get(key3) + if hdcase: + line_vals['is_match']=True + line_vals['hd_case_id']=hdcase['id'] + line_vals['hd_case_number']=hdcase['number'] + line_vals['patient_id']=hdcase['patient_id'] + line_vals['patient_name']=hdcase['patient_name'] + line_vals['patient_type']=hdcase['patient_type'] no=1 lines2=[] total=0