improve matching

conv_bal
watcha.h@almacom.co.th 2015-03-11 17:43:24 +07:00
parent f8e8f0f700
commit 4cef271ce4
2 changed files with 25 additions and 9 deletions

View File

@ -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]]):

View File

@ -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()