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