improve
parent
9e9603eca9
commit
bdb5697d7b
|
@ -3,7 +3,7 @@
|
|||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="New Dialyzer" method="new_dialyzer" states="draft,waiting_treatment"/>
|
||||
<item string="To Draft" method="to_draft" states="waiting_treatment,in_progress,completed"/>
|
||||
<item string="To Draft" method="to_draft" states="completed,cancelled"/>
|
||||
</button>
|
||||
</head>
|
||||
<group form_layout="stacked">
|
||||
|
|
|
@ -4,13 +4,8 @@
|
|||
<item string="New Contact" method="new_contact"/>
|
||||
</button>
|
||||
</head>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="contact_id"/>
|
||||
</tab>
|
||||
<tab string="Other">
|
||||
</tab>
|
||||
</tabs>
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="contact_id"/>
|
||||
<field name="default"/>
|
||||
</form>
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
<field name="contact_id"/>
|
||||
<field name="default"/>
|
||||
</list>
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
<list>
|
||||
<field name="date"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="ref"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
|
@ -40,6 +41,7 @@
|
|||
<form>
|
||||
<field name="date"/>
|
||||
<field name="invoice_id"/>
|
||||
<field name="ref"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="hd_case_id"/>
|
||||
<field name="amount"/>
|
||||
|
|
|
@ -779,20 +779,21 @@ class HDCase(Model):
|
|||
return res
|
||||
|
||||
|
||||
def get_staff_line(self,vals,patient_id=None):
|
||||
def get_staff_fee(self,vals,patient_id=None):
|
||||
if not patient_id:
|
||||
return vals
|
||||
# staff
|
||||
patient=get_model("clinic.patient").browse(patient_id)
|
||||
doctor=patient.doctor_id
|
||||
if doctor:
|
||||
vals['staffs']=[]
|
||||
if not vals.get('staffs'):
|
||||
vals['staffs']=[]
|
||||
vals['staffs'].append(('create',{
|
||||
'staff_id': doctor.id,
|
||||
'type': 'doctor',
|
||||
'priop': 'owner',
|
||||
}))
|
||||
|
||||
# fee
|
||||
st=get_model("clinic.setting").browse(1)
|
||||
if not vals.get('lines'):
|
||||
vals['lines']=[]
|
||||
|
@ -837,7 +838,7 @@ class HDCase(Model):
|
|||
|
||||
def create(self,vals,**kw):
|
||||
patient_id=vals['patient_id']
|
||||
vals=self.get_staff_line(vals,patient_id)
|
||||
vals=self.get_staff_fee(vals,patient_id)
|
||||
vals=self.get_invoice_policy(vals,patient_id)
|
||||
new_id=super().create(vals,**kw)
|
||||
return new_id
|
||||
|
@ -846,7 +847,7 @@ class HDCase(Model):
|
|||
patient_id=vals.get('patient_id')
|
||||
# XXX importing problem
|
||||
# when change patient
|
||||
#vals=self.get_staff_line(vals,patient_id)
|
||||
#vals=self.get_staff_fee(vals,patient_id)
|
||||
vals=self.get_invoice_policy(vals,patient_id)
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
|
|
|
@ -96,6 +96,49 @@ class ImportPayment(Model):
|
|||
'node': 'HDBills',
|
||||
}
|
||||
|
||||
def get_patient_invoice(self,state="waiting_payment"):
|
||||
print("getting patient invoice")
|
||||
dom=[]
|
||||
dom.append(['state','=',state])
|
||||
invoices={}
|
||||
for inv in get_model("account.invoice").search_browse(dom):
|
||||
hd_case=inv.related_id
|
||||
patient=hd_case.patient_id
|
||||
key=(inv.date,patient.id)
|
||||
invoices[key]={
|
||||
'id': inv.id,
|
||||
'amount_due': inv.amount_due,
|
||||
'hd_case_id': hd_case.id,
|
||||
}
|
||||
return invoices
|
||||
|
||||
def get_all_patient(self):
|
||||
print("getting patient")
|
||||
patients={}
|
||||
for pt in get_model("clinic.patient").search_read([[]],['name','hn','hn_num']):
|
||||
key=pt['hn_num']
|
||||
patients[key]={
|
||||
'id': pt['id'],
|
||||
'name': pt['name'],
|
||||
}
|
||||
return patients
|
||||
|
||||
|
||||
def get_hd_case(self):
|
||||
print("getting hd case")
|
||||
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'],
|
||||
}
|
||||
return hd_cases
|
||||
|
||||
def get_hn_num(self,hn=""):
|
||||
return ''.join(h for h in hn if h.isdigit())
|
||||
|
||||
def import_payment_pks(self,ids,context={}):
|
||||
fmt='%Y-%m-%d %H:%M:%S'
|
||||
start_time=time.strftime(fmt)
|
||||
|
@ -112,51 +155,18 @@ class ImportPayment(Model):
|
|||
match_qty=0
|
||||
unmatch_qty=0
|
||||
msg+=""*10; msg+="hcode,hn,name,note\n"
|
||||
print("getting invoice")
|
||||
dom=[]
|
||||
dom.append(['state','=','waiting_payment'])
|
||||
invoices={}
|
||||
for inv in get_model("account.invoice").search_browse(dom):
|
||||
hd_case=inv.related_id
|
||||
patient=hd_case.patient_id
|
||||
key=(inv.date,patient.id)
|
||||
invoices[key]={
|
||||
'id': inv.id,
|
||||
'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())
|
||||
invoices=self.get_patient_invoice(state='waiting_payment')
|
||||
patients=self.get_all_patient()
|
||||
hd_cases=self.get_hd_case()
|
||||
|
||||
mlines=[]
|
||||
umlines=[]
|
||||
for line in lines:
|
||||
patient_name=line.get("name14")
|
||||
hn=line.get('hn',"")
|
||||
hn_num=get_hn_num(hn)
|
||||
#hct=line.get("hct","")
|
||||
hn_num=self.get_hn_num(hn)
|
||||
inv_date=line.get("dttran")
|
||||
#amount=line.get('amount23')
|
||||
hcode=line.get('hcode18','0')
|
||||
if not hcode:
|
||||
hcode='0'
|
||||
|
@ -242,22 +252,26 @@ class ImportPayment(Model):
|
|||
lines=utils.read_xml(fpath,node=obj.node)
|
||||
if not lines:
|
||||
raise Exception("No Data to import")
|
||||
total=0.0
|
||||
qty=0
|
||||
import pprint
|
||||
|
||||
invoices=self.get_patient_invoice(state='waiting_payment')
|
||||
patients=self.get_all_patient()
|
||||
hd_cases=self.get_hd_case()
|
||||
|
||||
for line in lines:
|
||||
pprint.pprint(line)
|
||||
date,time=line.get("dttran").split("T")
|
||||
invno=line.get("invno")
|
||||
hdrate=float(line.get("hdrate","0"))
|
||||
hn=line.get("hn")
|
||||
paid=float(line.get("paid","0"))
|
||||
epostat=line.get('epostat')
|
||||
total+=hdrate
|
||||
qty+=1
|
||||
hn=line.get('hn',"")
|
||||
hn_num=self.get_hn_num(hn)
|
||||
#if hn+
|
||||
patient=patients.get(hn_num)
|
||||
if patient:
|
||||
key=(date,patient['id'])
|
||||
if patient['id']==16953:
|
||||
print("key ", patient)
|
||||
#paid=float(line.get("paid","0"))
|
||||
#epostat=line.get('epostat')
|
||||
|
||||
print('Total: ', total)
|
||||
print("Qty: ", qty)
|
||||
obj.write({
|
||||
'match_qty': 0,
|
||||
'unmatch_qty': 0,
|
||||
|
@ -373,4 +387,5 @@ class ImportPayment(Model):
|
|||
data['is_uc']=is_uc
|
||||
return data
|
||||
|
||||
|
||||
ImportPayment.register()
|
||||
|
|
|
@ -7,6 +7,7 @@ class PaymentLine(Model):
|
|||
_fields={
|
||||
'import_payment_id': fields.Many2One("import.clinic.payment","Payment",required=True,on_delete="cascade"),
|
||||
'date': fields.Date("Date"),
|
||||
'ref': fields.Char("Ref"),
|
||||
'invoice_id': fields.Many2One("account.invoice","Invoice"),
|
||||
'patient_id': fields.Many2One("clinic.patient","Patient"),
|
||||
'hd_case_id': fields.Many2One("clinic.hd.case","HDCase"),
|
||||
|
|
|
@ -117,12 +117,21 @@ class Patient(Model):
|
|||
def _get_cause_line(self,context={}):
|
||||
cause_ids=get_model("clinic.cause.chronic").search([])
|
||||
return cause_ids
|
||||
|
||||
def _get_type(self,context={}):
|
||||
ptype_id=None
|
||||
for ptype in get_model("clinic.patient.type").search_browse([]):
|
||||
if ptype.default:
|
||||
ptype_id=ptype.id
|
||||
break
|
||||
return ptype_id
|
||||
|
||||
_defaults={
|
||||
"number": _get_number,
|
||||
"reg_date": lambda *a: time.strftime("%Y-%m-%d"),
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
'card_type': 'identification',
|
||||
'type_id': _get_type,
|
||||
"active" : True,
|
||||
}
|
||||
_order="resign_date desc,number desc"
|
||||
|
|
|
@ -9,6 +9,7 @@ class PatientType(Model):
|
|||
"name": fields.Char("Name",required=True,search=True),
|
||||
"code": fields.Char("Code",required=True,search=True),
|
||||
'contact_id': fields.Many2One("partner","Contact",domain=[['type','=','org']],required=True,search=True),
|
||||
'default': fields.Boolean("Default"),
|
||||
}
|
||||
|
||||
def new_contact(self,ids,context={}):
|
||||
|
@ -27,6 +28,15 @@ class PatientType(Model):
|
|||
obj.write({
|
||||
'contact_id': new_contact_id,
|
||||
})
|
||||
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
default=vals.get('default')
|
||||
if default:
|
||||
for obj in self.search_browse([]):
|
||||
if obj.id not in ids:
|
||||
obj.write({
|
||||
'default': False,
|
||||
})
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
PatientType.register()
|
||||
|
|
|
@ -201,7 +201,7 @@ class Visit(Model):
|
|||
'mode': 'form',
|
||||
'active_id': hd_case_id,
|
||||
},
|
||||
'flash': 'Visit %s has been confirmed'%obj.number,
|
||||
'flash': 'Visit has been confirmed',
|
||||
}
|
||||
|
||||
def discard(self,ids,context={}):
|
||||
|
@ -215,16 +215,20 @@ class Visit(Model):
|
|||
def onchange_patient(self,context={}):
|
||||
data=context['data']
|
||||
patient_id=data['patient_id']
|
||||
patient=get_model("clinic.patient").browse(patient_id)
|
||||
visits=self.search_browse([['patient_id','=',patient_id]],order="number desc")
|
||||
if visits:
|
||||
visit=visits[0]
|
||||
doctor=visit.doctor_id
|
||||
department=visit.department_id
|
||||
if not department:
|
||||
patient=get_model("clinic.patient").browse(patient_id)
|
||||
department=patient.department_id
|
||||
data['doctor_id']=doctor.id
|
||||
data['department_id']=department.id
|
||||
if not patient.doctor_id:
|
||||
patient.write({
|
||||
'doctor_id': doctor.id,
|
||||
})
|
||||
else:
|
||||
data['doctor_id']=None
|
||||
data['department_id']=None
|
||||
|
|
Loading…
Reference in New Issue