improve matching hdcase

conv_bal
watcha.h@almacom.co.th 2015-04-09 15:02:24 +07:00
parent 1e61cafb39
commit 226e94a34a
1 changed files with 31 additions and 4 deletions

View File

@ -123,10 +123,17 @@ class MatchingHDCase(Model):
dom.append(['state','!=','cancelled']) dom.append(['state','!=','cancelled'])
hdcases={} hdcases={}
hdcases2={} 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): for hdcase in get_model("clinic.hd.case").search_browse(dom):
date=hdcase.date date=hdcase.date
hn=hdcase.patient_id.hn_no or "" 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 fee_amt=0
hct=hdcase.hct or "0" hct=hdcase.hct or "0"
hct=round(float(hct),2) hct=round(float(hct),2)
@ -157,7 +164,19 @@ class MatchingHDCase(Model):
'number': hdcase.number or '', 'number': hdcase.number or '',
'note': '%s, %s, %s, %s, %s'%(date,hn,hct,prod_name,fee_amt), '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: for row in rows:
vals=list(row.values()) vals=list(row.values())
date,_time=(vals[5] or "").split() date,_time=(vals[5] or "").split()
@ -213,9 +232,7 @@ class MatchingHDCase(Model):
key2='%s-%s'%(date,hn) key2='%s-%s'%(date,hn)
hdcase2=hdcases2.get(key2) hdcase2=hdcases2.get(key2)
#print("hdcase2 ", hdcase2)
if hdcase2: if hdcase2:
#line_vals['is_match']=False
line_vals['hd_case_id']=hdcase2['id'] line_vals['hd_case_id']=hdcase2['id']
line_vals['hd_case_number']=hdcase2['number'] line_vals['hd_case_number']=hdcase2['number']
line_vals['note']='' line_vals['note']=''
@ -227,6 +244,16 @@ class MatchingHDCase(Model):
line_vals['nf_epo']=nf_epo.title() line_vals['nf_epo']=nf_epo.title()
line_vals['nf_fee']=round(float((nf_fee or "0")),2) line_vals['nf_fee']=round(float((nf_fee or "0")),2)
lines.append(line_vals) 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 no=1
lines2=[] lines2=[]
total=0 total=0