same hct in a week
parent
9f7ed34999
commit
f84eced255
|
@ -9,7 +9,7 @@
|
|||
</head>
|
||||
<group form_layout="stacked" attrs='{"readonly":[["state","=","completed"]]}'>
|
||||
<field name="number" span="2"/>
|
||||
<field name="sickbed_id" string="Sickbed (Available)" attrs='{"readonly":[["state","in",["completed","waiting_payment","paid","cancelled"]]]}' domain="[['state','=','available'],['department_id','=',department_id]]" required="3" span="2"/>
|
||||
<field name="sickbed_id" string="Sickbed (Available)" attrs='{"readonly":[["state","in",["completed","waiting_payment","paid","cancelled"]]]}' domain="[['state','=','available'],['department_id','=',department_id]]" required="1" span="2"/>
|
||||
<field name="patient_id" span="2" onchange="onchange_patient"/>
|
||||
<field name="patient_type_id" span="2"/>
|
||||
<field name="cycle_id" span="2" required="1" onchange="onchange_cycle"/>
|
||||
|
@ -35,7 +35,7 @@
|
|||
<newline/>
|
||||
<field name="wt_start" span="2" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
|
||||
<field name="wt_stop" span="2"/>
|
||||
<field name="hct" span="2" onchange="onchange_hct" attrs='{"invisible":[["hct_include","=",false]]}'/>
|
||||
<field name="hct" span="2" onchange="onchange_hct" attrs='{"invisible":[["hct_include","=",false]],"required": [["hct_include","=", true]]}'/>
|
||||
<field name="hct_msg" span="4" readonly="1" attrs='{"invisible":[["hct_include","=",false]]}'/>
|
||||
<newline/>
|
||||
<field name="bp_start" span="2"/>
|
||||
|
|
|
@ -63,6 +63,7 @@ class AccountInvoice(Model):
|
|||
total_amt=0.0
|
||||
total_base=0.0
|
||||
total_tax=0.0
|
||||
hdcase=obj.related_id
|
||||
for line in obj.lines:
|
||||
cur_amt=get_model("currency").convert(line.amount,obj.currency_id.id,settings.currency_id.id,date=obj.date,rate_type=rate_type)
|
||||
total_amt+=cur_amt
|
||||
|
@ -92,6 +93,8 @@ class AccountInvoice(Model):
|
|||
"partner_id": partner.id,
|
||||
}
|
||||
lines.append(line_vals)
|
||||
if hdcase:
|
||||
pass
|
||||
for comp_id,tax_vals in taxes.items():
|
||||
comp=get_model("account.tax.component").browse(comp_id)
|
||||
acc_id=comp.account_id.id
|
||||
|
@ -162,6 +165,7 @@ class AccountInvoice(Model):
|
|||
else:
|
||||
line["debit"]=0
|
||||
line["credit"]=-amt
|
||||
|
||||
amt=0
|
||||
for line in group_lines:
|
||||
amt-=line["debit"]-line["credit"]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import time
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timedelta
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.utils import get_data_path, get_file_path
|
||||
from netforce.access import get_active_user,set_active_user
|
||||
|
@ -91,7 +91,7 @@ class HDCase(Model):
|
|||
"vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."),
|
||||
"bid_flow_rate": fields.Integer("BFR (ml/min)"),
|
||||
"ultrafittration": fields.Float("Ultrafiltration (kg.)"),
|
||||
"hct": fields.Integer("Hct",required=True),
|
||||
"hct": fields.Integer("Hct"),
|
||||
"hct_msg" : fields.Char(""),
|
||||
'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),
|
||||
|
@ -153,15 +153,15 @@ class HDCase(Model):
|
|||
"time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
|
||||
'number': '/',
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
'wt_start': 0.0,
|
||||
'wt_stop': 0.0,
|
||||
'bp_start': '0/0',
|
||||
'bp_stop': '0/0',
|
||||
"bid_flow_rate": 0.0,
|
||||
"ultrafittration": 0.0,
|
||||
#'wt_start': 0.0,
|
||||
#'wt_stop': 0.0,
|
||||
#'bp_start': '0/0',
|
||||
#'bp_stop': '0/0',
|
||||
#"bid_flow_rate": 0.0,
|
||||
#"ultrafittration": 0.0,
|
||||
'hd_acc': 'o',
|
||||
'hd_mode': 'chronic',
|
||||
'hct': 0,
|
||||
#'hct': 0,
|
||||
'hct_msg': "สามารถเบิกค่ายาสูงสุดไม่เกิน 1,125บาท ต่อ สัปดาห์",
|
||||
'invoice_option': 'fee',
|
||||
'invoice_policy': 'fee',
|
||||
|
@ -1031,6 +1031,40 @@ class HDCase(Model):
|
|||
break
|
||||
return vals
|
||||
|
||||
def get_hct(self,vals,patient_id):
|
||||
fmt="%Y-%m-%d"
|
||||
datenow=datetime.strptime(vals['time_start'][0:10],fmt)
|
||||
wd=datenow.weekday()
|
||||
date_week=[datenow.strftime(fmt)]
|
||||
count=1
|
||||
res=''
|
||||
for i in list(range(0,wd)):
|
||||
if i < wd:
|
||||
res=(datenow-timedelta(days=count)).strftime(fmt)
|
||||
else:
|
||||
res=(datenow+timedelta(days=count)).strftime(fmt)
|
||||
date_week.append(res)
|
||||
count+=1
|
||||
count=1
|
||||
for i in list(range(wd,6)):
|
||||
if i < wd:
|
||||
res=(datenow-timedelta(days=count)).strftime(fmt)
|
||||
else:
|
||||
res=(datenow+timedelta(days=count)).strftime(fmt)
|
||||
date_week.append(res)
|
||||
count+=1
|
||||
print("day week", date_week)
|
||||
# search hct from monday to sunday
|
||||
dom=[]
|
||||
dom.append(['patient_id','=',patient_id])
|
||||
dom.append(['date', 'in',date_week])
|
||||
# 1. get date between weekend
|
||||
# 2. if date out of dat gen set 0 else copy previous hct
|
||||
for hdcase in self.search_browse(dom):
|
||||
vals['hct']=hdcase.hct or 0
|
||||
#break
|
||||
return vals
|
||||
|
||||
def create(self,vals,**kw):
|
||||
patient_id=vals['patient_id']
|
||||
if 'vascular_acc' in vals.keys():
|
||||
|
@ -1039,6 +1073,7 @@ class HDCase(Model):
|
|||
'vascular_acc': vals['vascular_acc']
|
||||
})
|
||||
vals=self.get_staff_line(vals,patient_id)
|
||||
vals=self.get_hct(vals,patient_id)
|
||||
new_id=super().create(vals,**kw)
|
||||
self.function_store([new_id])
|
||||
return new_id
|
||||
|
|
|
@ -198,7 +198,14 @@ class Patient(Model):
|
|||
if 'active' in vals.keys():
|
||||
if not vals['active']:
|
||||
vals['resign_date']=time.strftime("%Y-%m-%d")
|
||||
|
||||
for obj in self.browse(ids):
|
||||
if 'doctor_id' in vals.keys():
|
||||
for vs in get_model("clinic.visit").search_browse([['state','in',['draft','pending']],['patient_id','=',obj.id]]):
|
||||
vs.write({
|
||||
'doctor_id': vals['doctor_id'],
|
||||
})
|
||||
print("update doctor %s to patient %s"%(vals['doctor_id'], obj.name))
|
||||
#if not obj.addresses:
|
||||
#raise Exception("Address not found - %s!"%obj.name)
|
||||
partner_id=obj.partner_id
|
||||
|
|
|
@ -102,17 +102,17 @@ class ClinicSetting(Model):
|
|||
return True
|
||||
|
||||
def run_script(self,ids,context={}):
|
||||
user_id=get_active_user
|
||||
user_id=get_active_user()
|
||||
if user_id !=1:
|
||||
print("Only admin!!")
|
||||
return
|
||||
count=1
|
||||
for hd_case in get_model("clinic.hd.case").search_browse([]):
|
||||
hd_case.write({
|
||||
'patient_type_id': hd_case.patient_id.type_id.id,
|
||||
})
|
||||
print(count, " update ", hd_case.patient_id.type_id.id)
|
||||
count+=1
|
||||
for vs in get_model("clinic.visit").search_browse([['state','in', ['draft','pending']],['doctor_id','=',None]]):
|
||||
doctor=vs.patient_id.doctor_id
|
||||
if doctor:
|
||||
vs.write({
|
||||
'doctor_id': doctor.id,
|
||||
})
|
||||
print("update visit.date ", vs.visit_date)
|
||||
print("Done! ")
|
||||
|
||||
def reset_last_import(self,ids,context={}):
|
||||
|
|
Loading…
Reference in New Issue