xxxx
parent
d65ca9e339
commit
3da5333667
|
@ -31,12 +31,14 @@
|
|||
<field name="invoice_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="date"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
</tab>
|
||||
|
@ -47,18 +49,26 @@
|
|||
<field name="invoice_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="date"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
</tab>
|
||||
<tab string="Message">
|
||||
<field name="msg" span="6" nolabel="1" width="1000" height="180"/>
|
||||
</tab>
|
||||
<tab string="Accounting">
|
||||
<group form_layout="stacked">
|
||||
<field name="payment_id" span="3" readonly="1"/>
|
||||
<button string="Approve" method="approve" icon="ok" span="3"/>
|
||||
</group>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot replace="1">
|
||||
<button string="Import" method="import_payment" type="primary" icon="arrow-right"/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<form title="Import Visit">
|
||||
<group form_layout="stacked">
|
||||
<field name="file" span="3"/>
|
||||
<field name="hcode" span="3"/>
|
||||
<field name="hcode_id" span="3"/>
|
||||
</group>
|
||||
<foot replace="1">
|
||||
<button string="Import" method="import_visit" type="primary" icon="arrow-right"/>
|
||||
|
|
|
@ -153,13 +153,31 @@ class ImportHDCase(Model):
|
|||
remain_row=len(lines)-blank-did-count
|
||||
if remain_row <= 0:
|
||||
msg="Nothing to import"
|
||||
final_msg=''
|
||||
total_row=len(lines)
|
||||
if done_qty <=0:
|
||||
final_msg="Please import visit first"
|
||||
total_row=0
|
||||
done_qty=0
|
||||
fail_qty=0
|
||||
remain_row=0
|
||||
else:
|
||||
final_msg="Done!"
|
||||
obj.write({
|
||||
'total_row': len(lines),
|
||||
'total_row': total_row,
|
||||
'remain_row': remain_row,
|
||||
'msg': msg,
|
||||
'done_qty': done_qty-1,
|
||||
'done_qty': done_qty and done_qty-1 or 0,
|
||||
'fail_qty': fail_qty,
|
||||
})
|
||||
print("Done!")
|
||||
return {
|
||||
'next': {
|
||||
'name': 'import_clinic_hd_case',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': final_msg,
|
||||
}
|
||||
|
||||
ImportHDCase.register()
|
||||
|
|
|
@ -36,6 +36,7 @@ class ImportPayment(Model):
|
|||
'state': fields.Selection([['draft','Draft'],['confirmed','Confirmed'],['fail','Fail'],['success','Success']],'State'),
|
||||
'match_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","Match",domain=[["state","=","match"]]),
|
||||
'unmatch_lines': fields.One2Many("import.clinic.payment.line","import_payment_id","UnMatch",domain=[["state","=","unmatch"]]),
|
||||
'payment_id': fields.Many2One("account.payment","Payment"),
|
||||
}
|
||||
|
||||
def get_hcode_id(self,context={}):
|
||||
|
@ -72,7 +73,11 @@ class ImportPayment(Model):
|
|||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
lines=utils.read_excel(fpath,show_datetime=False)
|
||||
patient_type=obj.type_id
|
||||
if patient_type.code in ('PKS'):
|
||||
lines=utils.read_excel(fpath,show_datetime=False)
|
||||
else:
|
||||
lines=utils.read_xml(fpath,show_datetime=False)
|
||||
if not lines:
|
||||
raise Exception("Wrong File")
|
||||
msg=""
|
||||
|
@ -86,7 +91,8 @@ class ImportPayment(Model):
|
|||
unmatch_qty=0
|
||||
|
||||
msg+=""*10; msg+="hcode,hn,name\n"
|
||||
|
||||
|
||||
print("getting invoice")
|
||||
dom=[]
|
||||
dom.append(['state','=','waiting_payment'])
|
||||
invoices={}
|
||||
|
@ -99,13 +105,25 @@ class ImportPayment(Model):
|
|||
'amount_due': inv.amount_due,
|
||||
'hd_case_id': hd_case.id,
|
||||
}
|
||||
|
||||
|
||||
print("getting patient")
|
||||
patients={}
|
||||
for pt in get_model("clinic.patient").search_read([[]],['hn','hn_num']):
|
||||
key=pt['hn_num']
|
||||
patients[key]={
|
||||
'id': pt['id'],
|
||||
}
|
||||
|
||||
print("getting hd case")
|
||||
# need to optimize -> from, to
|
||||
hd_cases={}
|
||||
for hd_case in get_model("clinic.hd.case").search_read([[]],['patient_id','date']):
|
||||
patient_id=hd_case['patient_id'][0]
|
||||
date=hd_case['date']
|
||||
key=(date,patient_id)
|
||||
hd_cases[key]={
|
||||
'id': hd_case['id'],
|
||||
}
|
||||
|
||||
def get_hn_num(hn=""):
|
||||
return ''.join(h for h in hn if h.isdigit())
|
||||
|
@ -118,6 +136,7 @@ class ImportPayment(Model):
|
|||
hn_num=get_hn_num(hn)
|
||||
hct=line.get("hct","")
|
||||
inv_date=line.get("dttran")
|
||||
amount=line.get('amount23')
|
||||
hcode=line.get('hcode18','0')
|
||||
if not hcode:
|
||||
hcode='0'
|
||||
|
@ -143,14 +162,20 @@ class ImportPayment(Model):
|
|||
'invoice_id': inv['id'],
|
||||
'hd_case_id': inv['hd_case_id'],
|
||||
'patient_id': patient_id,
|
||||
'amount': inv['amount_due'] or 0.0,
|
||||
'state': 'match',
|
||||
}))
|
||||
match_qty+=1
|
||||
else:
|
||||
umlines.append(('create',{
|
||||
hd_case=hd_cases.get(key)
|
||||
vals={
|
||||
'date': inv_date,
|
||||
'patient_id': patient_id,
|
||||
}))
|
||||
'amount': amount,
|
||||
}
|
||||
if hd_case:
|
||||
vals['hd_case_id']=hd_case['id']
|
||||
umlines.append(('create',vals))
|
||||
unmatch_qty+=1
|
||||
|
||||
for mline in obj.match_lines:
|
||||
|
|
|
@ -12,17 +12,19 @@ class ImportVisit(Model):
|
|||
'date': fields.DateTime("Date"),
|
||||
'file': fields.File("File"),
|
||||
'result': fields.Text("Success"),
|
||||
'hcode': fields.Char("Hospital Code"),
|
||||
'hcode_id': fields.Many2One("clinic.hospital", "Hospital",required=True),
|
||||
}
|
||||
|
||||
def get_hcode(self,context={}):
|
||||
settings=get_model("settings").browse(1)
|
||||
hcode=settings.hospital_code or ""
|
||||
return hcode
|
||||
def get_hcode_id(self,context={}):
|
||||
hp_ids=get_model("clinic.hospital").search([])
|
||||
hp_id=None
|
||||
if hp_ids:
|
||||
hp_id=hp_ids[0]
|
||||
return hp_id
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'hcode': get_hcode,
|
||||
'hcode_id': get_hcode_id,
|
||||
}
|
||||
|
||||
def import_visit(self,ids,context={}):
|
||||
|
@ -39,7 +41,7 @@ class ImportVisit(Model):
|
|||
hcode='0'
|
||||
hcode=int(hcode)
|
||||
hcode=str(hcode)
|
||||
if obj.hcode==hcode:
|
||||
if obj.hcode_id.code==hcode:
|
||||
name=line.get("name14")
|
||||
#hn=line.get('hn')
|
||||
patient_ids=get_model("clinic.patient").search([['name','=',name]])
|
||||
|
@ -78,13 +80,13 @@ class ImportVisit(Model):
|
|||
else:
|
||||
print("found ", name)
|
||||
|
||||
return {
|
||||
'next': {
|
||||
'name': 'import_clinic_visit',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': 'Create visit successully',
|
||||
}
|
||||
return {
|
||||
'next': {
|
||||
'name': 'import_clinic_visit',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': 'Create visit successully',
|
||||
}
|
||||
|
||||
ImportVisit.register()
|
||||
|
|
|
@ -64,6 +64,7 @@ class Schedule(Model):
|
|||
|
||||
def confirm(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.copy2cycle_item()
|
||||
obj.write({
|
||||
'state': 'confirmed',
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue