diff --git a/netforce_clinic/models/matching_payment.py b/netforce_clinic/models/matching_payment.py index 2bec042..a37ca75 100644 --- a/netforce_clinic/models/matching_payment.py +++ b/netforce_clinic/models/matching_payment.py @@ -154,7 +154,9 @@ class MatchingPayment(Model): if not contact: raise Exception("contact not found") st=get_model("clinic.setting").browse(1) - patient_hn=st.get_patient_hn() + st_pt=st.get_patient_hn() + patient_hn=st_pt['hns'] + patient_names=st_pt['names'] matches1={} matches2={} matches3={} @@ -174,11 +176,17 @@ class MatchingPayment(Model): patient=hdcase.patient_id #pname=patient.name_check or "" #XXX pname='%s%s'%(patient.first_name or "",patient.last_name or "") + #XXX + if patient_names.get(pname): + pname=patient_names[pname] pname2='%s %s'%(patient.first_name or "",patient.last_name or "") card_no=patient.card_no or "" hn=patient.hn_no elif invoice.ref: pname=invoice.ref or '' + #XXX + if patient_names.get(pname): + pname=patient_names[pname] pname2=pname pname=pname.replace(" ","") # remove space for pt in get_model("clinic.patient").search_browse([['name_check','=',pname]]): diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index a0bc4ec..62bf298 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -811,17 +811,25 @@ class ClinicSetting(Model): def get_patient_hn(self,ids,context={}): obj=self.browse(ids)[0] - res={} + res={ + 'hns':{}, + 'names': {}, + } for line in obj.account_patients: pt=line.patient_id + name=line.partner_id.name or "" + vals={ + 'hn': pt.hn, + 'pid': pt.id, + 'card_no': pt.card_no, + 'name': "%s%s"%(pt.first_name or "", pt.last_name or ""), + } + name=name.replace(" ","") + if name not in res['names'].keys(): + res['names'][name]=vals hn=line.hn - if hn not in res.keys(): - res[hn]={ - 'hn': pt.hn, - 'pid': pt.id, - 'card_no': pt.card_no, - 'name': "%s%s"%(pt.first_name or "", pt.last_name or ""), - } + if hn not in res['hns'].keys(): + res['hns'][hn]=vals return res ClinicSetting.register()