diff --git a/netforce_clinic/actions/clinic_staff.xml b/netforce_clinic/actions/clinic_staff.xml
index 5b94985..b676961 100644
--- a/netforce_clinic/actions/clinic_staff.xml
+++ b/netforce_clinic/actions/clinic_staff.xml
@@ -2,7 +2,7 @@
Staffs
multi_view
clinic.staff
- [["All",[]],["Archived",[["active","=",false]]],["Staff",[["type","=","staff"]]],["Doctor",[["type","=","doctor"]]],["Nurse",[["type","=","nurse"]]]]
+ [["All",[]],["Archived",[["active","=",false]]],["Staffs",[["type","=","staff"]]],["Doctors",[["type","=","doctor"]]],["Nurses",[["type","=","nurse"]]]]
list,page,form
clinic_menu
25
diff --git a/netforce_clinic/actions/clinic_staff_rotate.xml b/netforce_clinic/actions/clinic_staff_rotate.xml
index cbf6785..a714c6f 100644
--- a/netforce_clinic/actions/clinic_staff_rotate.xml
+++ b/netforce_clinic/actions/clinic_staff_rotate.xml
@@ -4,8 +4,8 @@
clinic.staff.rotation
[
["All",[]],
- ["Nurse",[["type","=","nurse"]]],
- ["Doctor",[["type","=","doctor"]]],
+ ["Nurses",[["type","=","nurse"]]],
+ ["Doctors",[["type","=","doctor"]]],
["Draft",[["state","=","draft"]]],
["Approved",[["state","=","approved"]]]
]
diff --git a/netforce_clinic/layouts/clinic_staff_form.xml b/netforce_clinic/layouts/clinic_staff_form.xml
index 52a43e7..750c17b 100644
--- a/netforce_clinic/layouts/clinic_staff_form.xml
+++ b/netforce_clinic/layouts/clinic_staff_form.xml
@@ -2,7 +2,8 @@
diff --git a/netforce_clinic/layouts/clinic_staff_rotate_form.xml b/netforce_clinic/layouts/clinic_staff_rotate_form.xml
index f025126..4e04a11 100644
--- a/netforce_clinic/layouts/clinic_staff_rotate_form.xml
+++ b/netforce_clinic/layouts/clinic_staff_rotate_form.xml
@@ -7,10 +7,10 @@
-
-
+
+
-
+
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index b5709d2..61bd6a1 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -131,6 +131,40 @@ class HDCase(Model):
set_active_user(user_id)
return res
+ def _get_req_fee(self,ids,context={}):
+ res={}
+ for obj in self.browse(ids):
+ total_amt=0
+ rmb_amt=0
+ for line in obj.lines:
+ amt=line.amount or 0
+ if line.reimbursable=='yes':
+ rmb_amt+=amt
+ total_amt+=amt
+ pm_amt=0
+ for pline in obj.payment_lines:
+ pm_amt+=pline.amount or 0
+ due_amt=total_amt-pm_amt-rmb_amt
+ paid=0
+ if due_amt>0:
+ paid=1
+ res[obj.id]=paid
+ return res
+
+ def _get_hct_msg(self,ids,context={}):
+ res={}
+ for obj in self.browse(ids):
+ msg=""
+ hct=obj.hct or 0
+ if(hct<=36):
+ msg="สามารถเบิกค่ายาสูงสุดไม่เกิน 1,125บาท ต่อ สัปดาห์"
+ elif(hct>36 and hct<=39):
+ msg="สามารถเบิกค่ายาสูงสุดไม่เกิน 750บาท ต่อ สัปดาห์"
+ elif(hct> 39):
+ msg="ไม่สามารถเบิกค่ายาฉีดได้ทุกตัว"
+ res[obj.id]=msg
+ return res
+
_fields={
"number": fields.Char("Number",required=True,search=True),
"epo": fields.Char("EPO",function="_get_expense",function_multi=True),
@@ -161,7 +195,7 @@ class HDCase(Model):
"bid_flow_rate": fields.Integer("BFR (ml/min)"),
"ultrafittration": fields.Float("Ultrafiltration (kg.)"),
"hct": fields.Integer("Hct"),
- "hct_msg" : fields.Char(""),
+ "hct_msg" : fields.Char("",function="_get_hct_msg",store=True),
'hct_include': fields.Boolean("HCT Include", function="_get_store", function_multi=True,store=True),
'type_code': fields.Char("Product Code", function="_get_store", function_multi=True,store=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),
@@ -195,7 +229,7 @@ class HDCase(Model):
'nu': fields.Char("N/U"),
"invoice_policy": fields.Selection([("fee","Only Fee"),("fee_mdc","Fee & Medicine")],"Government pay for:"),
"invoice_option": fields.Selection([("fee_mdc_plus","Combine Fee & Medicine"),("fee_mdc_split","Split Fee & Medicine")],"Invoice:"),
- 'req_fee': fields.Integer("Request Expense"),
+ 'req_fee': fields.Integer("Request Expense",function="_get_req_fee"),
'hd_case_id': fields.Many2One("clinic.hd.case","HD",function="_get_all",function_multi=True), # XXX
'company_id': fields.Many2One("company","Company"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
@@ -1364,62 +1398,6 @@ class HDCase(Model):
patient.write({
'vascular_acc': vals['vascular_acc']
})
-
- ############ to show pay button ###########
- total_amt=0
- due_amt=0
- if 'lines' in vals.keys():
- for line in vals['lines']:
- mode=line[0]
- amt=0
- rmb='no'
- if mode=='create':
- line_vals=line[1]
- amt=line_vals.get("amount",0)
- elif mode=='delete':
- continue
- else:
- mode=line[0]
- if mode=='create':
- prod_id=line[1]['product_id']
- prod=get_model("product").browse(prod_id)
- line['uom_id']=prod.uom_id.id
- continue
- line_id=line[1][0]
- line_vals=line[2]
- rmb=line_vals.get("reimbursable","no")
- line=get_model('clinic.hd.case.line').browse(line_id)
- amt=line.amount or 0
- total_amt+=amt
- if rmb=='no':
- due_amt+=amt
- else:
- for line in obj.lines:
- amt=line.amount or 0
- total_amt+=amt
- if line.reimbursable=='no':
- due_amt+=amt
- pay_amt=0
- if 'payment_lines' in vals.keys():
- for line in vals['payment_lines']:
- mode=line[0]
- if mode=='create':
- line_vals=line[1]
- else:
- line_vals=line[2]
- pay_amt+=line_vals.get("amount",0)
- for pline in obj.payment_lines:
- pay_amt+=pline.amount or 0
- due_amt-=pay_amt
-
- vals['req_fee']=0
- if due_amt<=0:
- vals['req_fee']=0
- elif due_amt>0:
- vals['req_fee']=1
-
- #################################################3
-
if 'sickbed_id' in vals.keys():
user_id=get_active_user()
set_active_user(1)
diff --git a/netforce_clinic/models/hd_case_payment.py b/netforce_clinic/models/hd_case_payment.py
index 2bf213c..402a7c3 100644
--- a/netforce_clinic/models/hd_case_payment.py
+++ b/netforce_clinic/models/hd_case_payment.py
@@ -45,18 +45,24 @@ class HDCasePayment(Model):
hd_case.post_invoices()
if obj.pay_amount:
hd_case.make_payment(context=context)
+ hd_case.do_expense()
+
+ inv_remain_amount=0
+ for inv in hd_case.invoices:
+ inv_remain_amount+=(inv.amount_subtotal-inv.amount_paid)
if obj.complete:
hd_case.create_cycle_item()
- if obj.pay_amount==obj.to_pay:
- vals={
- 'state': 'paid',
- }
- else:
- vals={
- 'state': 'waiting_payment',
- }
- hd_case.write(vals)
- hd_case.do_expense()
+ #due_amount -> only not reimbursable
+ total=hd_case.due_amount-obj.to_pay
+ if total<=0 and inv_remain_amount<=0:
+ vals={
+ 'state': 'paid',
+ }
+ else:
+ vals={
+ 'state': 'waiting_payment',
+ }
+ hd_case.write(vals)
obj.write({
'pay_amount': hd_case.amount,
})
diff --git a/netforce_clinic/models/patient_type.py b/netforce_clinic/models/patient_type.py
index 574e794..bdc05e7 100644
--- a/netforce_clinic/models/patient_type.py
+++ b/netforce_clinic/models/patient_type.py
@@ -14,13 +14,14 @@ class PatientType(Model):
'hct_include': fields.Boolean("HCT Include"),
'main_product': fields.Boolean("Use Main Product for Create GI"),
'company_id': fields.Many2One("company","Company"),
- 'color': fields.Char("Color"),
+ #'color': fields.Char("Color"),
+ 'color': fields.Selection([['default','Default'],['danger','Danger'],['info','Info'],['warning','Warning'],['primary','Primary']],"Color"),
}
_defaults={
'defaults': False,
'company_id': lambda *a: get_active_company(),
-
+ 'color': 'default',
}
def new_contact(self,ids,context={}):
diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py
index faa7e26..d850f09 100644
--- a/netforce_clinic/models/setting.py
+++ b/netforce_clinic/models/setting.py
@@ -150,10 +150,18 @@ class ClinicSetting(Model):
print("Only admin!!")
return
- for rt in get_model("clinic.staff.rotation").search_browse([]):
- rt.write({
- 'note': ' ',
+ dom=[
+ ['type','=','doctor'],
+ ]
+ for st in get_model("clinic.staff").search_browse(dom):
+ dpt_ids=[]
+ for b in get_model("clinic.branch").browse([]):
+ for dpt in b.departments:
+ dpt_ids.append(dpt.id)
+ st.write({
+ 'departments': [('set',dpt_ids)],
})
+ print('dpt_ids ', dpt_ids)
print("Done!")
return