hd case state

1. draft
    -create from hd_case
2. waiting treament
3. finish treament
4. waiting payment
    - wait for import payment
5. paid
    - paid by them self (other expense)
    - government paid (matching)
conv_bal
watcha.h 2014-12-04 23:48:38 +07:00
parent 0332ee9246
commit c95e5645bb
9 changed files with 99 additions and 46 deletions

View File

@ -2,7 +2,16 @@
<field name="string">HD Cases</field>
<field name="view_cls">multi_view</field>
<field name="model">clinic.hd.case</field>
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Waiting Treatment",[["state","=","waiting_treatment"]]],["In Progress",[["state","=","in_progress"]]],["Waiting Payment",[["state","=","waiting_payment"]]],["Waiting Approval",[["state","=","waiting_approval"]]],["Completed",[["state","=","completed"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
<!--<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Waiting Treatment",[["state","=","waiting_treatment"]]],["In Progress",[["state","=","in_progress"]]],["Waiting Payment",[["state","=","waiting_payment"]]],["Waiting Approval",[["state","=","waiting_approval"]]],["Completed",[["state","=","completed"]]],["Cancelled",[["state","=","cancelled"]]]]</field>-->
<field name="tabs">[
["All",[]],["Draft",[["state","=","draft"]]],
["Waiting Treatment",[["state","=","waiting_treatment"]]],
["In Progress",[["state","=","in_progress"]]],
["Finish Treatment",[["state","=","completed"]]],
["Waiting Payment",[["state","=","waiting_payment"]]],
["Paid",[["state","=","paid"]]],
["Cancelled",[["state","=","cancelled"]]]
]</field>
<field name="modes">list,form</field>
<field name="menu">clinic_menu</field>
<field name="limit">25</field>

View File

@ -7,13 +7,15 @@
</head>
<group span="6" columns="1">
<field name="date"/>
<field name="hd_case_id"/>
<field name="hd_case_id" domain="[['state','=','completed']]"/>
<field name="payment_id"/>
<field name="invoice_id"/>
<field name="invoice_id" domain="[['state','=','waiting_payment']]"/>
<field name="pt_conflict" help="HD Case not match patient"/>
</group>
<group span="6" columns="1">
<field name="patient_id"/>
<field name="amount"/>
<field name="note"/>
</group>
<foot>
<button string="Approve" type="success" icon="ok" method="approve" states="match"/>

View File

@ -1,4 +1,4 @@
<list model="clinic.hd.case.expense" colors='{"#cfc":[["state","=","approved"]],"#ACD1E9":[["state","=","match"]],"#cccccc":[["state","=","unmatch"]],"#f9e37d":[["state","=","waiting_matching"]],"#bcbbb9":[["state","=","cancelled"]]}'>
<list model="clinic.hd.case.expense" colors='{"#cfc":[["state","=","approved"]],"#88BAA4":[["state","=","match"]],"#cccccc":[["state","=","unmatch"]],"#f9e37d":[["state","=","waiting_matching"]],"#bcbbb9":[["state","=","cancelled"]]}'>
<field name="date"/>
<field name="invoice_id"/>
<field name="payment_id"/>

View File

@ -1,4 +1,4 @@
<form model="clinic.hd.case" attrs='{"readonly":[["state","in",["cancelled","completed"]]]}' show_company="1">
<form model="clinic.hd.case" attrs='{"readonly":[["state","in",["cancelled","paid"]]]}' show_company="1">
<head>
<field name="state"/>
<button string="Options" dropdown="1">
@ -111,11 +111,11 @@
</tab>
</tabs>
<foot>
<button string="Start" type="success" icon="arrow-right" method="do_treatment" states="draft,waiting_treatment"/>
<button string="Do Treatment" type="success" icon="arrow-right" method="do_treatment" states="draft,waiting_treatment"/>
<button string="Done" type="success" icon="ok" method="done" states="in_progress"/>
<button string="Discontinue" type="danger" icon="remove" action="clinic_hd_case_distcont" states="in_progress"/>
<button string="Pay" type="success" icon="ok" action="clinic_payment" states="waiting_payment" />
<button string="Approve" type="success" icon="ok" method="approve" states="waiting_approval" />
<!--<button string="Pay" type="success" icon="ok" action="clinic_payment" states="waiting_payment" />-->
<button string="Pay" type="success" icon="ok" method="pay" states="completed" />
</foot>
<related>
<field name="invoices" click_action="view_invoice">

View File

@ -1,4 +1,4 @@
<list model="clinic.hd.case" colors='{"#cfc":[["state","=","completed"]],"#f9e37d":[["state","=","in_progress"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]]}'>
<list model="clinic.hd.case" colors='{"#cfc":[["state","=","completed"]],"#f9e37d":[["state","=","in_progress"]],"#bcbbb9":[["state","=","cancelled"]],"#ACD1E9":[["state","=","waiting_payment"]],"#70DB93":[["state","=","paid"]]}'>
<field name="number"/>
<!--<field name="ref"/>-->
<field name="date"/>

View File

@ -81,20 +81,15 @@ class HDCase(Model):
"patient_type": fields.Char("Service Type",function="_get_patient_type"),
"vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."),
"nurse_id": fields.Many2One("clinic.staff","Approve By", domain=[['type','=','nurse']]),
"staff_id": fields.Many2One("clinic.staff", "Staff"), #XXX
"department_id": fields.Many2One("clinic.department", "Department",search=True),
"wt_kg": fields.Float("Wt.kg."),
"bp": fields.Integer("BP"),
"mm_hg": fields.Integer("mmHG"),
"hct": fields.Integer("Hct%(<40)",required=True),
"hct_msg" : fields.Char(""),
"check_goverment_pay" : fields.Boolean("The Government Pay"),
"check_personal_pay" : fields.Boolean("Pay yourself"),
"state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),('waiting_approval','Waiting Approval'),("completed","Completed"),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True),
"state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),("completed","Finish Treatment"),('paid','Paid'),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True),
"staffs": fields.One2Many("clinic.hd.case.staff","hd_case_id","Staffs"),
"staff_id": fields.Many2One("clinic.hd.case.staff","Staff"), #XXX
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
"reconcile_id": fields.Many2One("account.reconcile","Reconcile Id",readonly=True),
"dialyzers": fields.One2Many("clinic.hd.case.dialyzer","hd_case_id","Dialyzers"),
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
@ -655,16 +650,13 @@ class HDCase(Model):
obj.create_cycle_item()
obj.do_expense()
vals={
"state":"completed",
"state":"waiting_payment", # for government
}
st=get_model("clinic.setting").browse(1)
if st.real_time:
timenow=time.strftime("%H:%M:%S")
date=obj.date
vals['time_stop']='%s %s'%(date,timenow)
st=get_model("clinic.setting").browse(1)
if st.waiting_approval:
vals['state']='waiting_approval'
obj.write(vals)
if context.get("called"):
return obj.id
@ -689,6 +681,7 @@ class HDCase(Model):
data['hct']=0
hct=data["hct"]
msg=""
# XXX do not hard code
if(hct<36):
msg="สามารถเบิกค่ายาสูงสุดไม่เกิน 1,125บาท ต่อ สัปดาห์"
elif(hct>=36 and hct<=39):
@ -744,16 +737,33 @@ class HDCase(Model):
},
}
def pay(self,ids,context={}):
obj=self.browse(ids)[0]
if not obj.amount:
obj.update_usetime()
if not obj.amount:
obj.complete()
else:
return {
'next': {
'name': 'clinic_payment',
'refer_id': ids[0], #XXX
}
}
def done(self,ids,context={}):
obj=self.browse(ids)[0]
obj.update_usetime()
state='waiting_payment'
if not obj.amount:
obj.complete()
else:
obj.write({
'state': state,
})
obj.write({
'state': 'completed',
})
return {
'next': {
'name': 'clinic_hd_case',
'mode': 'form',
'active_id': obj.id,
},
'flash': 'Finish treatment!',
}
def get_report_payment_data(self,context={}):
settings=get_model("settings").browse(1)

View File

@ -6,14 +6,28 @@ class HDCaseExpense(Model):
_name="clinic.hd.case.expense"
_string="Expense"
_name_field="date"
def _get_patient_conflict(self,ids,context={}):
res={}
for obj in self.browse(ids):
hd_case=obj.hd_case_id
patient=hd_case.patient_id
conflict=False
if obj.patient_id.id!=patient.id:
conflict=True
res[obj.id]=conflict
return res
_fields={
'date': fields.Date("Date",search=True),
'patient_id': fields.Many2One("clinic.patient","Patient",search=True),
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case",search=True),
'date': fields.Date("Date",required=True,search=True),
'patient_id': fields.Many2One("clinic.patient","Patient",required=True,search=True),
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case",required=True,search=True),
'invoice_id': fields.Many2One("account.invoice","Invoice",search=True),
'payment_id': fields.Many2One("account.payment","Payment",search=True),
'amount': fields.Float("Amount"),
'state': fields.Selection([['draft','Draft'],['waiting_matching','Waiting Matching'],['match','Match'],['unmatch','Unmatch'],['approved','Approved']],'State'),
'note': fields.Text("Note"),
'pt_conflict': fields.Boolean("Patient Conclict",function="_get_patient_conflict"),
}
_defaults={
@ -59,5 +73,4 @@ class HDCaseExpense(Model):
'state': 'cancelled',
})
HDCaseExpense.register()

View File

@ -48,17 +48,15 @@ class HDCasePayment(Model):
context['make_invoice']=False
hd_case.make_invoices(context=context) #XXX
hd_case.post_invoices()
st=get_model("clinic.setting").browse(1)
if obj.pay_amount:
hd_case.make_payment(context=context)
if obj.complete:
hd_case.create_cycle_item()
vals={
'state': 'completed',
}
if st.waiting_approval:
vals['state']='waiting_approval'
hd_case.write(vals)
if obj.pay_amount==obj.to_pay:
vals={
'state': 'paid',
}
hd_case.write(vals)
hd_case.do_expense()
obj.write({
'pay_amount': hd_case.amount,
@ -78,14 +76,12 @@ class HDCasePayment(Model):
hd_case.make_invoices()
hd_case.post_invoices()
hd_case.create_cycle_item()
st=get_model("clinic.setting").browse(1)
vals={
'state': 'completed',
}
if st.waiting_approval:
vals['state']='waiting_approval'
if obj.pay_amount==obj.to_pay:
vals={
'state': 'paid',
}
hd_case.write(vals)
hd_case.do_expense()
hd_case.write(vals)
return {
'next': {
'name': 'clinic_hd_case',

View File

@ -47,7 +47,7 @@ class ImportPayment(Model):
'fail_qty': fields.Integer("Other"),
'match_qty': fields.Integer("Match"),
'unmatch_qty': fields.Integer("UnMatch"),
'state': fields.Selection([['draft','Draft'],['confirmed','Confirmed'],['approved','Approved'],['fail','Fail'],['success','Success']],'State'),
'state': fields.Selection([['draft','Draft'],['confirmed','Confirmed'],['fail','Fail'],['success','Success']],'State'),
'payment_id': fields.Many2One("account.payment","Payment"),
'company_id': fields.Many2One("company","Company"),
'partner_id': fields.Many2One("partner","Fee Contact",function="_get_partner"),
@ -110,6 +110,29 @@ class ImportPayment(Model):
}
return invoices
def get_patient_expense(self):
# XXX date_from, date_to
print("getting expense")
expenses={}
for exp in get_model("clinic.hd.case.expense").search_browse([]):
patient=exp.patient_id
hd_case=exp.hd_case_id
key=(exp.date,patient.id)
expenses[key]={
'id': exp.id,
'amount': exp.amount,
'patient_id': patient.id,
'hd_case_id': hd_case.id,
}
invoice=exp.invoice_id
if invoice:
expenses[key]['invoice_id']=invoice.id
payment=exp.payment_id
if payment:
expenses[key]['payment_id']=payment.id
return expenses
def get_all_patient(self):
print("getting patient")
patients={}