merge
commit
442f4e4e08
|
@ -0,0 +1,11 @@
|
|||
<action>
|
||||
<field name="string">Period Line</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.period.line</field>
|
||||
<field name="menu">account_menu</field>
|
||||
<field name="tabs">[
|
||||
["All",[]],
|
||||
["Open",[["state","=","open"]]],
|
||||
["Close",[["state","=","close"]]]
|
||||
]</field>
|
||||
</action>
|
|
@ -0,0 +1,8 @@
|
|||
<action>
|
||||
<field name="string">Report Cycle Setting</field>
|
||||
<field name="view_cls">report</field>
|
||||
<field name="model">clinic.report.cycle.setting</field>
|
||||
<field name="report_template">report_cycle_setting</field>
|
||||
<field name="report_template_xls">report_cycle_setting</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -0,0 +1,6 @@
|
|||
<action>
|
||||
<field name="string">Share Location</field>
|
||||
<field name="view_cls">form_popup</field>
|
||||
<field name="model">clinic.share.location</field>
|
||||
<field name="target">_popup</field>
|
||||
</action>
|
|
@ -1,9 +1,10 @@
|
|||
<form model="clinic.compute.labor.cost" title="Compute Labor Cost">
|
||||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="branch_id" onchange='onchange_branch' span="3"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
|
||||
<!--<field name="date" span="2" mode="month" onchange="onchange_date"/>-->
|
||||
<field name="period_id" domain='[["state","=","open"]]' onchange="onchange_period" span="4"/>
|
||||
<field name="date_from" span="4"/>
|
||||
<field name="date_to" span="4"/>
|
||||
<field name="branch_id" onchange='onchange_branch' span="4"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="4"/>
|
||||
<foot replace="1">
|
||||
<button string="Compute" method="compute" icon="repeat" type="default"/>
|
||||
</foot>
|
||||
|
|
|
@ -44,11 +44,12 @@
|
|||
<item string="RD Shop" action="clinic_shop" perm="clinic_shop"/>
|
||||
<item string="Sickbed" action="clinic_sickbed"/>
|
||||
</item>
|
||||
<item string="Reporting" perm="clinic_report">
|
||||
<item string="HD Case Expense" action="clinic_report_claim"/>
|
||||
<item string="RD Shop Expense" action="clinic_report_shop"/>
|
||||
<item string="Reports" perm="clinic_report">
|
||||
<item string="Report Cycle Setting" action="clinic_report_cycle_setting"/>
|
||||
<item string="Cycle Item Summary" action="clinic_report_cycle_item"/>
|
||||
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
||||
<item string="HD Case Expense" action="clinic_report_claim"/>
|
||||
<item string="RD Shop Expense" action="clinic_report_shop"/>
|
||||
</item>
|
||||
<item string="Settings" perm="clinic_settings">
|
||||
<item string="Titles" action="clinic_name_title" perm="clinic_name_title"/>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<head>
|
||||
<field name="type_id"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<!--<item string="Generate Visit" action="clinic_gen_visit"/>-->
|
||||
<item string="Share To Another Location" action="clinic_share_location"/>
|
||||
</button>
|
||||
</head>
|
||||
<field name="number"/>
|
||||
|
@ -15,8 +15,9 @@
|
|||
<field name="last_name" required="1"/>
|
||||
<field name="doctor_id" required="1"/>
|
||||
<field name="department_id" required="1"/>
|
||||
<field name="walkin"/>
|
||||
<field name="walkin" onchange="onchange_walkin"/>
|
||||
<field name="vascular_acc"/>
|
||||
<field name="location" readonly="1"/>
|
||||
<field name="active" invisible="1"/>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
|
@ -95,6 +96,7 @@
|
|||
</group>
|
||||
</tab>
|
||||
-->
|
||||
<!--
|
||||
<tab string="HD Departments">
|
||||
<field name="departments" nolabel="1"/>
|
||||
<group span="8" columns="1">
|
||||
|
@ -107,6 +109,7 @@
|
|||
<group span="4" columns="1">
|
||||
</group>
|
||||
</tab>
|
||||
-->
|
||||
<tab string="Accounting" perm="clinic_patient_account">
|
||||
<field name="partner_id" domain='[["is_patient","=","true"]]'/>
|
||||
</tab>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<form model="clinic.period">
|
||||
<head>
|
||||
<button string="Options" dropdown="1">
|
||||
<!--<item string="Copy" method="copy"/>-->
|
||||
<item string="Generate Period" method="gen_period"/>
|
||||
</button>
|
||||
</head>
|
||||
<group form_layout="stacked">
|
||||
|
@ -15,11 +15,11 @@
|
|||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
<field name="day_total"/>
|
||||
<field name="close"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
</field>
|
||||
</group>
|
||||
<foot>
|
||||
<button string="Generate" type="default" icon="arrow-right" method="gen_period"/>
|
||||
<button string="Close Period" type="danger" method="close_period"/>
|
||||
</foot>
|
||||
</form>
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<form model="clinic.period.line" attrs='{"readonly":[["state","in",["close"]]]}'>
|
||||
<head>
|
||||
<field name="state"/>
|
||||
</head>
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
<field name="day_total"/>
|
||||
<foot>
|
||||
<button string="Close" states="open" method="do_close" type="danger"/>
|
||||
<button string="Reopen" states="close" method="do_open" icon="repeat" type="default"/>
|
||||
</foot>
|
||||
</form>
|
|
@ -0,0 +1,6 @@
|
|||
<list model="clinic.period.line">
|
||||
<field name="date_start"/>
|
||||
<field name="date_stop"/>
|
||||
<field name="day_total"/>
|
||||
<field name="state"/>
|
||||
</list>
|
|
@ -0,0 +1,5 @@
|
|||
<form model="clinic.report.cycle.setting">
|
||||
<field name="cycle_id" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_type" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
</form>
|
|
@ -1,5 +1,6 @@
|
|||
<form model="clinic.report.labor.cost">
|
||||
<field name="date" mode="month" onchange="onchange_date" span="2"/>
|
||||
<field name="period_id" onchange="onchange_period" domain='[["state","=","open"]]' span="2"/>
|
||||
<!--<field name="date" mode="month" onchange="onchange_date" span="2"/>-->
|
||||
<field name="date_from" onchange="onchange_from" required="1" span="2"/>
|
||||
<field name="date_to" required="1" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_branch" span="2"/>
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
<field name="date" required="1" span="2"/>
|
||||
<field name="staff_type" onchange="onchange_type" span="2"/>
|
||||
<field name="staff_id" domain='[["type","=",type]]' span="2"/>
|
||||
<field name="department_id" span="2"/>
|
||||
<field name="branch_id" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
</form>
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<form model="clinic.share.location" title="Share To Another Location">
|
||||
<group form_layout="stacked">
|
||||
<field name="location" span="8"/>
|
||||
<field name="loc_select" selection="get_location" onchange="onchange_location" span="4"/>
|
||||
<field name="patient_id" invisible="1" span="2"/>
|
||||
</group>
|
||||
<foot>
|
||||
<button string="Share" type="primary" icon="share-alt" method="do_share"/>
|
||||
<button string="Clear" type="default" method="do_clear"/>
|
||||
</foot>
|
||||
</form>
|
|
@ -85,20 +85,6 @@
|
|||
<field name="cstate"/>
|
||||
</form>
|
||||
</field>
|
||||
<!--<field name="patients">-->
|
||||
<field name="patients" attrs='{"readonly":1,"invisible":[["type","in",["nurse","staff"]]]}'>
|
||||
<list>
|
||||
<field name="reg_date"/>
|
||||
<field name="hn_no"/>
|
||||
<field name="trt_no"/>
|
||||
<field name="card_no"/>
|
||||
<field name="name"/>
|
||||
<field name="type_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="walkin"/>
|
||||
<field name="dispose"/>
|
||||
</list>
|
||||
</field>
|
||||
<field name="comments"/>
|
||||
</related>
|
||||
</form>
|
||||
|
|
|
@ -135,5 +135,7 @@ from . import report_thai_wht_certif
|
|||
from . import num2word
|
||||
from . import province
|
||||
from . import change_visit
|
||||
from . import share_location
|
||||
from . import report_cycle_setting
|
||||
#from . import district
|
||||
#from . import subdistrict
|
||||
|
|
|
@ -9,6 +9,7 @@ class ComputeLaborCost(Model):
|
|||
_transient=True
|
||||
|
||||
_fields={
|
||||
"period_id": fields.Many2One("clinic.period.line","Period"),
|
||||
"date": fields.Date("Month"),
|
||||
"date_from": fields.Date("From", required=True),
|
||||
"date_to": fields.Date("To", required=True),
|
||||
|
@ -25,11 +26,25 @@ class ComputeLaborCost(Model):
|
|||
weekday, total_day=monthrange(int(year), int(month))
|
||||
return "%s-%s-%s"%(year,month,total_day)
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'date_from': _get_date_from,
|
||||
'date_to': _get_date_to,
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
date_from=defaults.get("date_from", self._get_date_from())
|
||||
date_to=defaults.get("date_to", self._get_date_to())
|
||||
yearnow=date_from.split("-")[0]
|
||||
for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
|
||||
for line in period.lines:
|
||||
if line.state=='open':
|
||||
period_id=line.id
|
||||
date_from=line.date_start
|
||||
date_to=line.date_stop
|
||||
break
|
||||
res={
|
||||
'period_id': period_id,
|
||||
'date': time.strftime("%Y-%m-%d"),
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
}
|
||||
return res
|
||||
|
||||
def compute(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
|
@ -70,4 +85,12 @@ class ComputeLaborCost(Model):
|
|||
data['department_id']=None
|
||||
return data
|
||||
|
||||
def onchange_period(self,context={}):
|
||||
data=context['data']
|
||||
period_id=data['period_id']
|
||||
period=get_model('clinic.period.line').browse(period_id)
|
||||
data['date_from']=period.date_start
|
||||
data['date_to']=period.date_stop
|
||||
return data
|
||||
|
||||
ComputeLaborCost.register()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from netforce.model import Model, fields
|
||||
from netforce.access import get_active_user, set_active_user
|
||||
|
||||
class CycleItemLine(Model):
|
||||
_name="clinic.cycle.item.line"
|
||||
|
@ -6,6 +7,8 @@ class CycleItemLine(Model):
|
|||
|
||||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
user_id=get_active_user()
|
||||
set_active_user(1)
|
||||
for obj in self.browse(ids):
|
||||
citem=obj.cycle_item_id
|
||||
pt_total=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('waiting_payment','paid')])
|
||||
|
@ -13,6 +16,7 @@ class CycleItemLine(Model):
|
|||
'cstate': citem.state,
|
||||
'pt_total': pt_total,
|
||||
}
|
||||
set_active_user(user_id)
|
||||
return res
|
||||
|
||||
_fields={
|
||||
|
|
|
@ -1458,8 +1458,6 @@ class HDCase(Model):
|
|||
vals=self.get_hct(vals,patient_id)
|
||||
new_id=super().create(vals,**kw)
|
||||
self.function_store([new_id])
|
||||
#obj=self.browse(new_id)
|
||||
#self.check_hct(obj)
|
||||
return new_id
|
||||
|
||||
def check_hct(self,obj):
|
||||
|
|
|
@ -142,7 +142,7 @@ class LaborCost(Model):
|
|||
nurse=line.nurse_id
|
||||
level=line.level_id or nurse.level_id
|
||||
if not level:
|
||||
raise Exception("Please specify level for %s"%nurse.name)
|
||||
raise Exception("Please specify level %s for %s"%(nurse.name,item.name))
|
||||
levels[level.id]['total']+=1
|
||||
|
||||
st_levels={}
|
||||
|
@ -410,7 +410,6 @@ class LaborCost(Model):
|
|||
doctor_lines.append(('create',line))
|
||||
else:
|
||||
nurse_lines.append(('create',line))
|
||||
|
||||
obj.write({
|
||||
'doctor_lines': doctor_lines,
|
||||
'nurse_lines': nurse_lines,
|
||||
|
|
|
@ -31,7 +31,7 @@ class LaborCostLine(Model):
|
|||
|
||||
_fields={
|
||||
"labor_cost_id": fields.Many2One("clinic.labor.cost","Labor Cost",required=True,on_delete="cascade"),
|
||||
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Staff Type",required=True,search=True,function="_get_store",function_multi=True),
|
||||
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Staff Type",required=True,search=True,function="_get_store",function_multi=True,store=True),
|
||||
'staff_id': fields.Many2One("clinic.staff", "Staff",search=True),
|
||||
'level_id': fields.Many2One("clinic.staff.level", "Level",search=True),
|
||||
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
||||
|
|
|
@ -74,9 +74,6 @@ class Patient(Model):
|
|||
dpt_codes=set()
|
||||
# main department
|
||||
dpt_codes.update({obj.department_id.code})
|
||||
# hd department
|
||||
for dpt in obj.departments:
|
||||
dpt_codes.update({dpt.code})
|
||||
# cycle settings
|
||||
for cline in obj.cycles:
|
||||
dpt_codes.update({cline.department_id.code})
|
||||
|
@ -178,9 +175,10 @@ class Patient(Model):
|
|||
"vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."),
|
||||
'state': fields.Selection([['admit','Admit'],['dispose','Dispose']],'State'),
|
||||
'walkin': fields.Selection([['yes','Yes'],['no','No']],"Walkin"),
|
||||
'departments': fields.Many2Many("clinic.department","Departments"),
|
||||
'department_names': fields.Text("Departments",function="_get_department_names"),
|
||||
'location': fields.Char("Location",function="_get_location",store=True), #to filter
|
||||
#'department_names': fields.Text("Departments",function="_get_department_names"),
|
||||
'location': fields.Char("Location"), #to filter
|
||||
'cw_time': fields.DateTime("Cycle Updated"),
|
||||
'cw_uid': fields.Many2One("base.user"," Cycle Edit"),
|
||||
}
|
||||
|
||||
def _get_number(self,context={}):
|
||||
|
@ -275,7 +273,6 @@ class Patient(Model):
|
|||
}
|
||||
|
||||
_sql_constraints=("clinic_patient_key_uniq","unique(name_check)","name should be unique"),
|
||||
#_order="reg_date desc"
|
||||
|
||||
def check_idcard(self,card_type,idcard=''):
|
||||
res=True
|
||||
|
@ -354,13 +351,14 @@ class Patient(Model):
|
|||
datenow=time.strftime("%Y-%m-%d")
|
||||
vdom=[
|
||||
['patient_id','in',ids],
|
||||
['visit_date','>',datenow],
|
||||
['visit_date','>=',datenow],
|
||||
['state','=','pending'],
|
||||
['manual','=',False],
|
||||
]
|
||||
visit_ids=get_model("clinic.visit").search(vdom)
|
||||
print('removing visit .. ', len(visit_ids))
|
||||
get_model("clinic.visit").delete(visit_ids)
|
||||
vals['cw_time']=time.strftime("%Y-%m-%d %H:%M:%S")
|
||||
vals['cw_uid']=get_active_user()
|
||||
|
||||
if 'type_id' in vals.keys():
|
||||
#update patient in hd case which state is condition below
|
||||
|
@ -566,4 +564,14 @@ class Patient(Model):
|
|||
|
||||
return data
|
||||
|
||||
def onchange_walkin(self,context={}):
|
||||
data=context['data']
|
||||
if data['walkin']=='yes':
|
||||
res=get_model('clinic.staff').search([['number','=','walkin'],['type','=','doctor']])
|
||||
if res:
|
||||
data['doctor_id']=res[0]
|
||||
else:
|
||||
data['doctor_id']=None
|
||||
return data
|
||||
|
||||
Patient.register()
|
||||
|
|
|
@ -3,6 +3,7 @@ from netforce.model import Model, fields
|
|||
class PatientCycle(Model):
|
||||
_name="clinic.patient.cycle"
|
||||
_string="Patient Cycle"
|
||||
_audit_log=True
|
||||
|
||||
_fields={
|
||||
"patient_id": fields.Many2One('clinic.patient',"Patient",required=True,on_delete="cascade",search=True,domain=[['state','=','admit']]),
|
||||
|
|
|
@ -12,7 +12,7 @@ class Period(Model):
|
|||
for obj in self.browse(ids):
|
||||
last_id=None
|
||||
for line in obj.lines:
|
||||
if line.close:
|
||||
if line.state=='close':
|
||||
last_id=line.id
|
||||
res[obj.id]=last_id
|
||||
return res
|
||||
|
@ -41,6 +41,13 @@ class Period(Model):
|
|||
'nmonth': 12,
|
||||
}
|
||||
|
||||
def close_period(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
for line in obj.lines:
|
||||
line.write({
|
||||
'state': 'close',
|
||||
})
|
||||
|
||||
def gen_period(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
for line in obj.lines:
|
||||
|
|
|
@ -19,24 +19,30 @@ class PeriodLine(Model):
|
|||
def _get_name(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
res[obj.id]='%s - %s'%(obj.date_start, obj.date_stop)
|
||||
res[obj.id]={
|
||||
'name': '%s - %s'%(obj.date_start, obj.date_stop),
|
||||
}
|
||||
return res
|
||||
|
||||
_fields={
|
||||
'name': fields.Char("Name",function="_get_name",store=True),
|
||||
'name': fields.Char("Name",function="_get_name", function_multi=True, store=True),
|
||||
"period_id": fields.Many2One("clinic.period", "Period"),
|
||||
'date_start': fields.Date("Date Start"),
|
||||
'date_stop': fields.Date("Date Stop"),
|
||||
'date_stop': fields.Date("Date End"),
|
||||
'day_total': fields.Integer("Duration (Day)",function="_get_total"),
|
||||
'state': fields.Selection([['draft','Draft'],['done','Done']],"State"),
|
||||
'close': fields.Boolean("Close"),
|
||||
'state': fields.Selection([['open','Open'],['close','Close']],"State"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'state': 'draft',
|
||||
'close': False,
|
||||
'state': 'open',
|
||||
}
|
||||
|
||||
def delete(self,ids,context={}):
|
||||
for obj in self.browse(ids):
|
||||
if obj.state=='close':
|
||||
raise Exception("Can delete object which state is closed!")
|
||||
super().delete(ids,context)
|
||||
|
||||
def create(self,vals,**kw):
|
||||
id=super().create(vals,**kw)
|
||||
self.function_store([id])
|
||||
|
@ -46,4 +52,30 @@ class PeriodLine(Model):
|
|||
super().write(ids,vals,**kw)
|
||||
self.function_store(ids)
|
||||
|
||||
def do_close(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'close',
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_period_line',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
}
|
||||
|
||||
def do_open(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'open',
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_period_line',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
}
|
||||
|
||||
PeriodLine.register()
|
||||
|
|
|
@ -24,9 +24,10 @@ class ReportCycleItem(Model):
|
|||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
date=defaults.get('date',time.strftime("%Y-%m-%d"))
|
||||
year,month=time.strftime("%Y-%m").split("-")
|
||||
date_from=defaults.get('date_from','%s-%s-01'%(year,month))
|
||||
date_to=defaults.get('date_to','%s-%s-01'%(year,month))
|
||||
#year,month=time.strftime("%Y-%m").split("-")
|
||||
datenow=time.strftime("%Y-%m-%d")
|
||||
date_from=defaults.get('date_from',datenow)
|
||||
date_to=defaults.get('date_to',datenow)
|
||||
branch_id=defaults.get('branch_id')
|
||||
if branch_id:
|
||||
branch_id=int(branch_id)
|
||||
|
@ -63,6 +64,7 @@ class ReportCycleItem(Model):
|
|||
branch_id=defaults.get("branch_id")
|
||||
department_id=defaults.get("department_id")
|
||||
ptype_id=defaults.get("ptype_id")
|
||||
print('date_from ', date_from)
|
||||
month=date_from.split("-")[1]
|
||||
cycle_id=None
|
||||
if ids:
|
||||
|
@ -122,7 +124,12 @@ class ReportCycleItem(Model):
|
|||
dpt=hdcase.department_id
|
||||
dlz_use=hdcase.dlz_use or 0
|
||||
dlz_drop=False
|
||||
if dlz_use==hdcase.dlz_max:
|
||||
#if dlz_use==hdcase.dlz_max:
|
||||
#dlz_use="%sทิ้ง"%dlz_use
|
||||
#dlz_drop=True
|
||||
for dlz_line in hdcase.dialyzers:
|
||||
dlz=dlz_line.dialyzer_id
|
||||
if dlz.state in ('drop','expire'):
|
||||
dlz_use="%sทิ้ง"%dlz_use
|
||||
dlz_drop=True
|
||||
cancel=False
|
||||
|
@ -146,7 +153,7 @@ class ReportCycleItem(Model):
|
|||
'date': hdcase.date,
|
||||
'epo': hdcase.epo,
|
||||
'mdc': hdcase.mdc,
|
||||
'mdc_name': hdcase.mdc_name,
|
||||
'mdc_name': hdcase.mdc_name or hdcase.epo,
|
||||
'fee': abs(hdcase.fee),
|
||||
'dlz_name': hdcase.dlz_name,
|
||||
'dlz_use': dlz_use,
|
||||
|
|
|
@ -0,0 +1,165 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class ReportCycleSetting(Model):
|
||||
_name="clinic.report.cycle.setting"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
|
||||
}
|
||||
|
||||
def _get_branch(self,context={}):
|
||||
res=get_model('select.company').get_select()
|
||||
if res:
|
||||
return res['branch_id']
|
||||
|
||||
def _get_department(self,context={}):
|
||||
res=get_model('select.company').get_select()
|
||||
if res:
|
||||
if res.get("department_ids"):
|
||||
return res['department_ids'][0]
|
||||
else:
|
||||
return res['department_id']
|
||||
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
branch_id=defaults.get('branch_id')
|
||||
if branch_id:
|
||||
branch_id=int(branch_id)
|
||||
else:
|
||||
branch_id=self._get_branch(context=context)
|
||||
|
||||
department_id=defaults.get('department_id')
|
||||
if department_id:
|
||||
department_id=int(department_id)
|
||||
else:
|
||||
department_id=self._get_department(context=context)
|
||||
res={
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
}
|
||||
print('report.cycle.item.setting', res)
|
||||
return res
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
defaults=self.default_get(context=context)
|
||||
department_id=defaults.get('department_id',None)
|
||||
branch_id=defaults.get('branch_id',None)
|
||||
cycle_id=defaults.get('cycle_id',None)
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
department_id=obj.department_id.id
|
||||
branch_id=obj.branch_id.id
|
||||
cycle_id=obj.cycle_id.id
|
||||
pts={}
|
||||
dom=[]
|
||||
dom.append(['patient_id.state','=','admit'])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
if cycle_id:
|
||||
dom.append(['cycle_id','=',cycle_id])
|
||||
pcs=get_model("clinic.patient.cycle").search_browse(dom)
|
||||
if not pcs:
|
||||
# Create patient cycle with that department
|
||||
for pt in get_model("clinic.patient").search_browse([['department_id','=',department_id]]):
|
||||
if pt.walkin=='yes':
|
||||
continue
|
||||
for pc in pt.cycles:
|
||||
vals={
|
||||
'patient_id': pt.id,
|
||||
'department_id': pt.department_id.id,
|
||||
'cycle_id': pc.cycle_id.id,
|
||||
'day': pc.day,
|
||||
}
|
||||
res=get_model("clinic.patient.cycle").search([[
|
||||
['patient_id','=',pt.id],
|
||||
['day','=',pc.day],
|
||||
['cycle_id','=',pc.cycle_id.id],
|
||||
['department_id','=', pt.department_id.id],
|
||||
]])
|
||||
if not res:
|
||||
pcycle_id=get_model("clinic.patient.cycle").create(vals)
|
||||
print("create ", pcycle_id)
|
||||
else:
|
||||
print("exist ", res)
|
||||
pcs=get_model("clinic.patient.cycle").search_browse(dom)
|
||||
if not pcs:
|
||||
raise Exception("Please go to menu 'Patients -> Patient Cycles' and import data for %s"%(department_id))
|
||||
for pc in pcs:
|
||||
patient=pc.patient_id
|
||||
dpt=pc.department_id
|
||||
branch=dpt.branch_id
|
||||
if not branch:
|
||||
continue
|
||||
if branch_id and branch_id!=branch.id:
|
||||
continue
|
||||
if patient.resign_date:
|
||||
continue
|
||||
key=(patient.id,dpt.id)
|
||||
if not pts.get(key):
|
||||
login=''
|
||||
if patient.cw_uid:
|
||||
login=patient.cw_uid.login
|
||||
pts[key]={
|
||||
'w_time': patient.cw_time,
|
||||
'w_uid': login,
|
||||
'patient_name': patient.name,
|
||||
'department_name': dpt.name,
|
||||
'mon_cycle_id': None,
|
||||
'tue_cycle_id': None,
|
||||
'wed_cycle_id': None,
|
||||
'thu_cycle_id': None,
|
||||
'fri_cycle_id': None,
|
||||
'sat_cycle_id': None,
|
||||
'sun_cycle_id': None,
|
||||
}
|
||||
cycle=pc.cycle_id
|
||||
day=pc.day or ''
|
||||
if day=='mon':
|
||||
pts[key]['mon_cycle_id']=cycle.name
|
||||
elif day=='tue':
|
||||
pts[key]['tue_cycle_id']=cycle.name
|
||||
elif day=='wed':
|
||||
pts[key]['wed_cycle_id']=cycle.name
|
||||
elif day=='thu':
|
||||
pts[key]['thu_cycle_id']=cycle.name
|
||||
elif day=='fri':
|
||||
pts[key]['fri_cycle_id']=cycle.name
|
||||
elif day=='sat':
|
||||
pts[key]['sat_cycle_id']=cycle.name
|
||||
else:
|
||||
pts[key]['sun_cycle_id']=cycle.name
|
||||
|
||||
lines=[]
|
||||
for k, vals in pts.items():
|
||||
pt_id, dpt_id=k
|
||||
if pt_id:
|
||||
vals['patient_id']=pt_id
|
||||
if not dpt_id:
|
||||
pt=get_model("clinic.patient").browse(pt_id)
|
||||
dpt_id=pt.department_id.id
|
||||
if dpt_id:
|
||||
vals['department_id']=dpt_id
|
||||
lines.append(vals)
|
||||
|
||||
no=1
|
||||
nlines=[]
|
||||
for line in sorted(lines,key=lambda x:x['patient_name']):
|
||||
line['no']=no
|
||||
nlines.append(line)
|
||||
no+=1
|
||||
|
||||
data={
|
||||
'lines': nlines,
|
||||
'department_id': department_id,
|
||||
}
|
||||
return data
|
||||
|
||||
def onchange_branch(self,context={}):
|
||||
data=context['data']
|
||||
data['department_id']=None
|
||||
return data
|
||||
|
||||
ReportCycleSetting.register()
|
|
@ -4,7 +4,7 @@ import urllib.parse as urllib
|
|||
from datetime import datetime
|
||||
from calendar import monthrange
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company
|
||||
from netforce.access import get_active_company, get_active_user
|
||||
|
||||
from . import utils
|
||||
|
||||
|
@ -271,7 +271,10 @@ class ReportHDCaseSummary(Model):
|
|||
plines=medicals['plines']
|
||||
prod_titles=medicals['prod_titles']
|
||||
date_print=time.strftime("%m/%d/%Y %H:%M:%S")
|
||||
user_id=get_active_user()
|
||||
user=get_model('base.user').browse(user_id)
|
||||
data={
|
||||
'user_name': user.name,
|
||||
'hdcase_type': hdcase_type,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
|
|
|
@ -11,6 +11,7 @@ class ReportLaborCost(Model):
|
|||
|
||||
_fields={
|
||||
"date": fields.Date("Month"),
|
||||
"period_id": fields.Many2One("clinic.period.line","Period"),
|
||||
"date_from": fields.Date("From", required=True),
|
||||
"date_to": fields.Date("To", required=True),
|
||||
"branch_id": fields.Many2One("clinic.branch","Branch"),
|
||||
|
@ -37,7 +38,16 @@ class ReportLaborCost(Model):
|
|||
date_to=defaults.get("date_to", self._get_date_to())
|
||||
report_type=defaults.get("report_type","cross")
|
||||
print('defaults ', defaults)
|
||||
yearnow=date_from.split("-")[0]
|
||||
for period in get_model('clinic.period').search_browse([['name','=',yearnow]]):
|
||||
for line in period.lines:
|
||||
if line.state=='open':
|
||||
period_id=line.id
|
||||
date_from=line.date_start
|
||||
date_to=line.date_stop
|
||||
break
|
||||
res={
|
||||
'period_id': period_id,
|
||||
'date': time.strftime("%Y-%m-%d"),
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
|
@ -206,8 +216,7 @@ class ReportLaborCost(Model):
|
|||
for categ_name,vals in ctdata.items():
|
||||
amount=vals['amount'] or 0
|
||||
categ_id=vals['categ_id']
|
||||
total_amount+=amount
|
||||
ctlines.append({
|
||||
ct_vals={
|
||||
'name': categ_name,
|
||||
'amount': round(amount,0),
|
||||
'branch_id': branch_id,
|
||||
|
@ -215,7 +224,9 @@ class ReportLaborCost(Model):
|
|||
'department_id': department_id,
|
||||
'staff_type': 'nurse',
|
||||
'cycle_id': cycle_id,
|
||||
})
|
||||
}
|
||||
total_amount+=ct_vals['amount']
|
||||
ctlines.append(ct_vals)
|
||||
ctlines.append({
|
||||
'name': 'รวม',
|
||||
'amount': round(total_amount,0),
|
||||
|
@ -343,6 +354,30 @@ class ReportLaborCost(Model):
|
|||
nlines[-1]['qty']+=nline['qty'] or 0
|
||||
nlines[-1]['cost']+=nline['cost'] or 0
|
||||
nlines[-1]['total']+=nline['total'] or 0
|
||||
|
||||
def con2float(r):
|
||||
if type(r)==type(''):
|
||||
return r
|
||||
return "{0:,.2f}".format(r)
|
||||
|
||||
def v2h(keys=[],lines=[]):
|
||||
lines2=[]
|
||||
for key in keys:
|
||||
no=0
|
||||
vals={'desc': False}
|
||||
if key=='name':
|
||||
vals['desc']=True
|
||||
for line in lines:
|
||||
vals[no]=con2float(line[key])
|
||||
no+=1
|
||||
lines2.append(vals)
|
||||
return lines2
|
||||
|
||||
def reformat(lines=[]):
|
||||
for line in lines:
|
||||
line['amount']=con2float(line['amount'])
|
||||
return lines
|
||||
|
||||
data={
|
||||
'company_name': '%s %s' % (company.name or "", sub_name),
|
||||
'date': date,
|
||||
|
@ -350,8 +385,11 @@ class ReportLaborCost(Model):
|
|||
'date_to': date_to,
|
||||
'lines': lines,
|
||||
'dlines': dlines,
|
||||
'dlines2': v2h(['name','qty','qty2','total_qty','cost'],dlines),
|
||||
'nlines': nlines,
|
||||
'nlines2': v2h(['name','qty','cost'],nlines),
|
||||
'ctlines': ctlines,
|
||||
'ctlines2': reformat(ctlines),
|
||||
'total_hdcase': total_hdcase,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
|
@ -379,4 +417,12 @@ class ReportLaborCost(Model):
|
|||
data['date_to']=data['date_from']
|
||||
return data
|
||||
|
||||
def onchange_period(self,context={}):
|
||||
data=context['data']
|
||||
period_id=data['period_id']
|
||||
period=get_model('clinic.period.line').browse(period_id)
|
||||
data['date_from']=period.date_start
|
||||
data['date_to']=period.date_stop
|
||||
return data
|
||||
|
||||
ReportLaborCost.register()
|
||||
|
|
|
@ -13,6 +13,7 @@ class ReportLaborCostDaily(Model):
|
|||
"staff_type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"),
|
||||
'staff_id': fields.Many2One("clinic.staff","Staff"),
|
||||
'department_id': fields.Many2One("clinic.department",'Department'),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
}
|
||||
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
|
@ -21,11 +22,13 @@ class ReportLaborCostDaily(Model):
|
|||
staff_type=defaults.get("staff_type","doctor")
|
||||
staff_id=int(defaults.get('staff_id', "0"))
|
||||
department_id=int(defaults.get('department_id', "0"))
|
||||
branch_id=int(defaults.get('branch_id', "0"))
|
||||
res={
|
||||
'date': date,
|
||||
'staff_type': staff_type,
|
||||
'staff_id': staff_id and staff_id or None,
|
||||
'department_id': department_id and department_id or None,
|
||||
'branch_id': branch_id and branch_id or None,
|
||||
}
|
||||
print("res ", res)
|
||||
return res
|
||||
|
@ -37,6 +40,7 @@ class ReportLaborCostDaily(Model):
|
|||
date=defaults.get("date")
|
||||
staff_id=defaults.get("staff_id")
|
||||
staff_type=defaults.get("staff_type")
|
||||
branch_id=defaults.get("branch_id")
|
||||
dpt_id=defaults.get("department_id")
|
||||
dom=[]
|
||||
if ids:
|
||||
|
@ -44,6 +48,7 @@ class ReportLaborCostDaily(Model):
|
|||
date=obj.date
|
||||
staff_id=obj.staff_id.id
|
||||
staff_type=obj.staff_type
|
||||
branch_id=obj.branch_id.id
|
||||
dpt_id=obj.department_id.id
|
||||
dom.append(['date','>=',date])
|
||||
dom.append(['date','<=',date])
|
||||
|
@ -55,6 +60,8 @@ class ReportLaborCostDaily(Model):
|
|||
dom.append(['staff_id','=',staff_id])
|
||||
if staff_type:
|
||||
dom.append(['type','=',staff_type])
|
||||
if branch_id:
|
||||
dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id])
|
||||
if dpt_id:
|
||||
dom.append(['labor_cost_id.cycle_item_id.department_id','=',dpt_id])
|
||||
print('dom ', dom)
|
||||
|
@ -101,6 +108,7 @@ class ReportLaborCostDaily(Model):
|
|||
pt=hdcase.patient_id
|
||||
lines.append({
|
||||
'no': no,
|
||||
'hdcase_number': hdcase.number,
|
||||
'cycle_item_name': citem.name or '',
|
||||
'cycle_item_id': citem.id,
|
||||
'date': citem.date,
|
||||
|
@ -122,6 +130,7 @@ class ReportLaborCostDaily(Model):
|
|||
'date': date,
|
||||
'comp_name': comp.name or 0,
|
||||
'lines': lines,
|
||||
'date': date,
|
||||
}
|
||||
return data
|
||||
|
||||
|
|
|
@ -108,12 +108,8 @@ class ReportLaborCostDetail(Model):
|
|||
dom.append(['cycle_id','=',cycle_id])
|
||||
if categ_id:
|
||||
dom.append(['staff_id.categ_id','=',categ_id])
|
||||
print('dom ', dom)
|
||||
def replace_quote(dom=""):
|
||||
return dom.replace("'","\"")
|
||||
#prevent to load more data
|
||||
#if not staff_id:
|
||||
#return {}
|
||||
dates={}
|
||||
for line in get_model("clinic.labor.cost.line").search_browse(dom):
|
||||
lcost=line.labor_cost_id
|
||||
|
@ -122,12 +118,12 @@ class ReportLaborCostDetail(Model):
|
|||
if not date:
|
||||
continue
|
||||
dpt=citem.department_id
|
||||
#amt=line.pay_amount or 0 #XXX
|
||||
amt=line.amount or 0 #XXX
|
||||
amt=line.amount or 0
|
||||
staff=line.staff_id
|
||||
qty=0
|
||||
if staff.type=='doctor':
|
||||
for hdcase in citem.hd_cases:
|
||||
if hdcase.state in ('waiting_payment','paid'):
|
||||
doctor_id=hdcase.doctor_id.id
|
||||
if staff.id==doctor_id:
|
||||
qty+=1
|
||||
|
@ -141,6 +137,7 @@ class ReportLaborCostDetail(Model):
|
|||
'staff_id': staff.id,
|
||||
'staff_name': staff.name or "",
|
||||
'staff_type': staff.type,
|
||||
'department_id': department_id,
|
||||
dpt.name: {
|
||||
'amt': 0,
|
||||
'qty': 0,
|
||||
|
@ -153,6 +150,7 @@ class ReportLaborCostDetail(Model):
|
|||
'staff_id': staff.id,
|
||||
'staff_name': staff.name or '',
|
||||
'staff_type': staff.type,
|
||||
'department_id': department_id,
|
||||
dpt.name: {
|
||||
'amt': 0,
|
||||
'qty': 0,
|
||||
|
@ -199,7 +197,8 @@ class ReportLaborCostDetail(Model):
|
|||
'date': kdate,
|
||||
'staff_type': vals.get("staff_type"),
|
||||
'staff_id': vals.get("staff_id"),
|
||||
'labor_cost_id': vals.get("labor_cost_id")
|
||||
'labor_cost_id': vals.get("labor_cost_id"),
|
||||
'department_id': vals.get('department_id'),
|
||||
}
|
||||
total_qty, total_amt=0, 0
|
||||
lvals['sub_lines']=[]
|
||||
|
@ -229,6 +228,8 @@ class ReportLaborCostDetail(Model):
|
|||
# summary as footer
|
||||
dpt_lines=[{'qty': 0, 'amt': 0} for dpt in dpts]
|
||||
for line in lines:
|
||||
line['branch_id']=branch_id
|
||||
line['department_id']=department_id
|
||||
i=0
|
||||
for sub_line in line['sub_lines']:
|
||||
dpt_lines[i]['qty']+=sub_line['qty'] or 0
|
||||
|
@ -271,7 +272,43 @@ class ReportLaborCostDetail(Model):
|
|||
'dpt_lines': dpt_lines,
|
||||
'show_all': show_count <=1 and True or False,
|
||||
}
|
||||
print('.... ', data['show_name'])
|
||||
data['dpts_txt']=[{0: '#', 1: 'วันที่'}]
|
||||
vals={}
|
||||
no=0
|
||||
dpt_len=len(data['dpts_txt'][0])
|
||||
for dpt in dpts:
|
||||
data['dpts_txt'][0][no+dpt_len]=dpt['name']
|
||||
vals[no]=0
|
||||
no+=1
|
||||
count=1
|
||||
items=[]
|
||||
def int2ths(r):
|
||||
if type(r)==type(''):
|
||||
return r
|
||||
if not r:
|
||||
return ""
|
||||
return "{0:,.2f}".format(r)
|
||||
for i in range(len(data['lines'])):
|
||||
line=data['lines'][i]
|
||||
item_vals=vals.copy()
|
||||
item_vals['no']=count
|
||||
item_vals['date']=line['date']
|
||||
no=0
|
||||
for sub_line in line['sub_lines']:
|
||||
item_vals['item%s_qty'%no]=int2ths(sub_line['qty'])
|
||||
item_vals['item%s_amt'%no]=int2ths(sub_line['amt'])
|
||||
no+=1
|
||||
item_vals['total_qty']=int2ths(line['total_qty'])
|
||||
item_vals['total_amt']=int2ths(line['total_amt'])
|
||||
items.append(item_vals)
|
||||
count+=1
|
||||
data['items']=items
|
||||
data['total_lines_txt']=[{}]
|
||||
no=0
|
||||
for tline in data['dpt_lines']:
|
||||
data['total_lines_txt'][0]['item%s_qty'%no]=int2ths(tline['qty'])
|
||||
data['total_lines_txt'][0]['item%s_amt'%no]=int2ths(tline['amt'])
|
||||
no+=1
|
||||
return data
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
|
|
|
@ -104,6 +104,12 @@ class ReportLaborCostOverTime(Model):
|
|||
dom=dom.replace("False","false")
|
||||
dom=dom.replace("True","true")
|
||||
return dom.replace("'","\"")
|
||||
def int2ths(r):
|
||||
if type(r)==type(''):
|
||||
return r
|
||||
if not r:
|
||||
return ""
|
||||
return "{0:,.2f}".format(r)
|
||||
lines=[]
|
||||
snames=sorted(staffs.keys()) #sort by staff name
|
||||
no=1
|
||||
|
|
|
@ -38,10 +38,10 @@ class ReportLaborCostSubDetail(Model):
|
|||
date_to=self._get_date_to()
|
||||
staff_type=defaults.get("staff_type","doctor")
|
||||
staff_id=int(defaults.get('staff_id', "0"))
|
||||
department_id=defaults.get('department_id')
|
||||
department_id=defaults.get('department_id',None)
|
||||
if department_id:
|
||||
department_id=int(department_id)
|
||||
branch_id=defaults.get('branch_id')
|
||||
branch_id=defaults.get('branch_id',None)
|
||||
if branch_id:
|
||||
branch_id=int(branch_id)
|
||||
if not branch_id and department_id:
|
||||
|
@ -56,6 +56,7 @@ class ReportLaborCostSubDetail(Model):
|
|||
'department_id': department_id,
|
||||
'branch_id': branch_id,
|
||||
}
|
||||
print('res ', res)
|
||||
return res
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
|
@ -66,8 +67,8 @@ class ReportLaborCostSubDetail(Model):
|
|||
date_to=defaults.get("date_to")
|
||||
staff_type=defaults.get("staff_type")
|
||||
staff_id=defaults.get("staff_id")
|
||||
branch_id=defaults.get("branch_id")
|
||||
department_id=defaults.get("department_id")
|
||||
branch_id=defaults.get("branch_id",None)
|
||||
department_id=defaults.get("department_id",None)
|
||||
staff_name=''
|
||||
dom=[]
|
||||
if ids:
|
||||
|
@ -107,6 +108,8 @@ class ReportLaborCostSubDetail(Model):
|
|||
if qty:
|
||||
amount=amount/qty
|
||||
for hdcase in citem.hd_cases:
|
||||
if hdcase.state not in ("waiting_payment","paid"):
|
||||
continue
|
||||
patient=hdcase.patient_id
|
||||
doctor=hdcase.doctor_id
|
||||
vals={
|
||||
|
|
|
@ -115,9 +115,12 @@ class ReportLaborCostSummary(Model):
|
|||
dom.append(['labor_cost_id.cycle_item_id.cycle_id','=',cycle_id])
|
||||
staffs={}
|
||||
citems={}
|
||||
print('--> dom: ', dom)
|
||||
total_hdcase=0
|
||||
|
||||
def int2ths(r):
|
||||
if type(r)==type(''):
|
||||
return r
|
||||
return "{0:,.0f}".format(r)
|
||||
total_hdcase=0
|
||||
for line in get_model("clinic.labor.cost.line").search_browse(dom):
|
||||
lcost=line.labor_cost_id
|
||||
citem=lcost.cycle_item_id
|
||||
|
@ -142,8 +145,9 @@ class ReportLaborCostSummary(Model):
|
|||
if staff.level_id:
|
||||
level=get_model("clinic.staff.level").browse(staff.level_id.id)
|
||||
level_name=level.name or ""
|
||||
if not staffs.get(staff.name):
|
||||
staffs[staff.name]={
|
||||
staff_name='%s %s'%(staff.first_name, staff.last_name)
|
||||
if not staffs.get(staff_name):
|
||||
staffs[staff_name]={
|
||||
'number': staff.number or '',
|
||||
'first_name': staff.first_name or "",
|
||||
'staff_id': staff.id,
|
||||
|
@ -156,14 +160,14 @@ class ReportLaborCostSummary(Model):
|
|||
'qty': qty,
|
||||
},
|
||||
}
|
||||
if not staffs[staff.name].get(dpt.name):
|
||||
staffs[staff.name].update({
|
||||
if not staffs[staff_name].get(dpt.name):
|
||||
staffs[staff_name].update({
|
||||
dpt.name: {
|
||||
'amt': 0,
|
||||
'qty': qty,
|
||||
}})
|
||||
staffs[staff.name][dpt.name]['amt']+=amt
|
||||
staffs[staff.name][dpt.name]['qty']+=qty
|
||||
staffs[staff_name][dpt.name]['amt']+=amt
|
||||
staffs[staff_name][dpt.name]['qty']+=qty
|
||||
|
||||
if not citems.get(citem.id):
|
||||
qty=0
|
||||
|
@ -252,10 +256,17 @@ class ReportLaborCostSummary(Model):
|
|||
# run no
|
||||
nlines=[]
|
||||
no=1
|
||||
for line in sorted(lines, key=lambda x: (x['staff_name'],x['first_name'])):
|
||||
sort_key='staff_name'
|
||||
if staff_type=='nurse' and categ_id:
|
||||
categ=get_model('clinic.staff.categ').browse(categ_id)
|
||||
if categ.name in ("FT","HP"):
|
||||
sort_key='number'
|
||||
|
||||
for line in sorted(lines, key=lambda x: (x[sort_key])):
|
||||
line['no']=no
|
||||
nlines.append(line)
|
||||
no+=1
|
||||
|
||||
data={
|
||||
'title': title,
|
||||
'date_from': date_from,
|
||||
|
@ -265,12 +276,43 @@ class ReportLaborCostSummary(Model):
|
|||
'comp_span': len(dpts),
|
||||
'lines': nlines,
|
||||
'total_lines': total_lines,
|
||||
'total_hdcase': total_hdcase or 0,
|
||||
'total_hdcase': int2ths(total_hdcase) or 0,
|
||||
'total_cost': round(total_cost,0) or 0,
|
||||
'staff_type': staff_type,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
}
|
||||
|
||||
# for report xlsx
|
||||
data['dpts_txt']=[{0: '#', 1: 'รหัส', 2: 'ชื่อ-สกุล',}]
|
||||
items=[]
|
||||
vals={}
|
||||
no=0
|
||||
dpt_len=len(data['dpts_txt'][0])
|
||||
for dpt in dpts:
|
||||
data['dpts_txt'][0][no+dpt_len]=dpt['name']
|
||||
vals[no]=0
|
||||
no+=1
|
||||
count=1
|
||||
for i in range(len(data['lines'])):
|
||||
line=data['lines'][i]
|
||||
item_vals=vals.copy()
|
||||
item_vals['no']=count
|
||||
item_vals['number']=line['number']
|
||||
item_vals['staff_name']=line['staff_name']
|
||||
no=0
|
||||
for sub_line in line['sub_lines']:
|
||||
item_vals['item%s'%no]=sub_line['amt']
|
||||
no+=1
|
||||
item_vals['total']=line['total']
|
||||
items.append(item_vals)
|
||||
count+=1
|
||||
data['items']=items
|
||||
data['total_lines_txt']=[{}]
|
||||
no=0
|
||||
for tline in data['total_lines']:
|
||||
data['total_lines_txt'][0]['item%s'%no]=tline['amt']
|
||||
no+=1
|
||||
return data
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import time
|
||||
from datetime import datetime, timedelta
|
||||
from calendar import monthrange
|
||||
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
from netforce.access import get_active_user, set_active_user
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.database import get_connection
|
||||
|
||||
|
||||
class ShareLocation(Model):
|
||||
_name="clinic.share.location"
|
||||
_transient=True
|
||||
_select_patient=None
|
||||
|
||||
_fields={
|
||||
'patient_id': fields.Many2One("clinic.patient","Patient",required=True),
|
||||
'location': fields.Char("Location"),
|
||||
"loc_select": fields.Selection([],"Select Location"),
|
||||
}
|
||||
|
||||
def get_location_user(self,patient_id=None,patient_only=False):
|
||||
user_id=get_active_user()
|
||||
user=get_model('base.user').browse(user_id)
|
||||
department=user.department_id
|
||||
loc=[]
|
||||
if department and not patient_only:
|
||||
loc.append(department.code)
|
||||
if patient_id:
|
||||
patient=get_model('clinic.patient').browse(patient_id)
|
||||
self._select_patient=patient.id
|
||||
department=patient.department_id
|
||||
loc.append(department.code)
|
||||
return loc
|
||||
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
refer_id=context.get("refer_id")
|
||||
patient_id=None
|
||||
location=''
|
||||
if refer_id:
|
||||
patient_id=int(refer_id)
|
||||
patient=get_model('clinic.patient').browse(patient_id)
|
||||
location=patient.location or ''
|
||||
uloc=self.get_location_user(patient.id)
|
||||
new_loc=[]
|
||||
for loc_code in location.split(","):
|
||||
if loc_code in uloc:
|
||||
continue
|
||||
new_loc.append(loc_code)
|
||||
location=','.join(new_loc)
|
||||
res={
|
||||
'patient_id': patient_id,
|
||||
'location': location,
|
||||
}
|
||||
return res
|
||||
|
||||
def get_location(self,context={}):
|
||||
user_id=get_active_user()
|
||||
uloc=self.get_location_user(self._select_patient)
|
||||
set_active_user(1)
|
||||
res=get_model("clinic.department").search_read([],["code","name"])
|
||||
set_active_user(user_id)
|
||||
return [(r["code"],'%s [%s]'%(r['name'],r["code"])) for r in res if r['code'] not in uloc]
|
||||
|
||||
def onchange_location(self,context={}):
|
||||
data=context['data']
|
||||
location=data['location'] or ''
|
||||
location=location.split(",")+[data['loc_select'] or '']
|
||||
sloc=list(set(location))
|
||||
data['location']=','.join([loc for loc in sloc if loc])
|
||||
return data
|
||||
|
||||
def do_share(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
patient=obj.patient_id
|
||||
uloc=self.get_location_user(patient.id,patient_only=True)
|
||||
new_loc=uloc
|
||||
for loc_code in obj.location.split(","):
|
||||
if not loc_code:
|
||||
continue
|
||||
res=get_model('clinic.department').search([['code','=',loc_code]])
|
||||
if not res:
|
||||
raise Exception("Department code %s not found!"%(loc_code))
|
||||
new_loc.append(loc_code)
|
||||
main_loc=patient.department_id.code
|
||||
if main_loc not in new_loc:
|
||||
raise Exception("Can not delete main department %s"%(main_loc))
|
||||
#TODO check user location
|
||||
location=','.join(new_loc)
|
||||
db=get_connection()
|
||||
db.execute("update clinic_patient set location=%s where id=%s",location,patient.id)
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_patient',
|
||||
'mode': 'form',
|
||||
'active_id': patient.id,
|
||||
},
|
||||
}
|
||||
|
||||
def do_clear(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'location': '',
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_share_location',
|
||||
'mode': 'form',
|
||||
'active_id': ids[0],
|
||||
},
|
||||
}
|
||||
|
||||
ShareLocation.register()
|
||||
|
|
@ -100,8 +100,12 @@ class Staff(Model):
|
|||
|
||||
def _get_location(self,ids,context={}):
|
||||
res={}
|
||||
user_id=get_active_user()
|
||||
set_active_user(1)
|
||||
for obj in self.browse(ids):
|
||||
res[obj.id]=",".join([d.code for d in obj.departments])
|
||||
st_codes=set([d.code for d in obj.departments])
|
||||
res[obj.id]=",".join([dcode for dcode in sorted(st_codes)])
|
||||
set_active_user(user_id)
|
||||
return res
|
||||
|
||||
def _get_department_names(self,ids,context={}):
|
||||
|
@ -109,26 +113,11 @@ class Staff(Model):
|
|||
user_id=get_active_user()
|
||||
set_active_user(1)
|
||||
for obj in self.browse(ids):
|
||||
res[obj.id]=','.join([dpt.name for dpt in obj.departments])
|
||||
dpt_st=set([dpt.name for dpt in obj.departments])
|
||||
res[obj.id]=','.join([dpt_name for dpt_name in sorted(dpt_st)])
|
||||
set_active_user(user_id)
|
||||
return res
|
||||
|
||||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
pt_ids=[]
|
||||
if obj.type=='doctor':
|
||||
pt_ids=get_model("clinic.patient").search([['doctor_id','=',obj.id]])
|
||||
elif obj.type=='nurse':
|
||||
p=set()
|
||||
for cline in obj.cycle_item_lines:
|
||||
citem=cline.cycle_item_id
|
||||
for hdcase in citem.hd_cases:
|
||||
p.update({hdcase.patient_id.id})
|
||||
pt_ids=list(p)
|
||||
res[obj.id]=pt_ids
|
||||
return res
|
||||
|
||||
_fields={
|
||||
'employee_id': fields.Many2One("hr.employee","Employee"),
|
||||
"number": fields.Char("Number",required=True,search=True),
|
||||
|
@ -155,8 +144,6 @@ class Staff(Model):
|
|||
"prof_license_expiry" : fields.Date("Expired License"),
|
||||
"birthday": fields.Date("BirthDay",search=True),
|
||||
"department_id": fields.Many2One("clinic.department", "Department",search=True),
|
||||
#"patients": fields.One2Many("clinic.patient","doctor_id","Patients"),
|
||||
"patients": fields.Many2Many("clinic.patient","Patients",function="_get_all"),
|
||||
"addresses": fields.One2Many("address","staff_id","Addresses"),
|
||||
"comments": fields.One2Many("message","related_id","Comments"),
|
||||
"nurse_visits": fields.One2Many("clinic.visit","nurse_id","Visits"),
|
||||
|
|
|
@ -122,6 +122,9 @@ class VisitBoard(Model):
|
|||
for pc in pt.cycles:
|
||||
w=DAYS.get(pc.day,0) #default monday
|
||||
cycle=pc.cycle_id
|
||||
if not cycle:
|
||||
continue
|
||||
#raise Exception('cycle setting for %s is not correct!'%(pt.name))
|
||||
department=pc.department_id
|
||||
if weekday==w:
|
||||
dom2=[
|
||||
|
|
|
@ -87,13 +87,18 @@ class VisitPopupConfirm(Model):
|
|||
obj=self.browse(ids)[0]
|
||||
board=obj.visitboard_id
|
||||
count=0
|
||||
|
||||
user_id=get_active_user()
|
||||
nurse_ids=get_model("clinic.staff").search([['user_id','=',user_id],['type','=','nurse']])
|
||||
vals={}
|
||||
if nurse_ids:
|
||||
vals['nurse_id']=nurse_ids[0]
|
||||
for line in obj.lines:
|
||||
vs=line.visit_id
|
||||
dt=line.doctor_id
|
||||
if dt:
|
||||
vs.write({
|
||||
'doctor_id': dt.id,
|
||||
})
|
||||
vals['doctor_id']=dt.id
|
||||
vs.write(vals)
|
||||
vs.confirm()
|
||||
count+=1
|
||||
return {
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -75,12 +75,6 @@
|
|||
<div>
|
||||
<a href="#name=clinic_visit_board">{{t "Visit Board"}}</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="#name=clinic_visit&mode=form">{{t "New Visit"}}</a>
|
||||
</div>
|
||||
<div>
|
||||
<a href="#name=clinic_make_apt">{{t "Make An Appointment"}}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="nf-board-title">
|
||||
<h3>{{t "HD Cases"}}</h3>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<center>
|
||||
<h3>{{company_name}}</h3>
|
||||
<h4>
|
||||
ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
|
||||
รายชื่อผู้ป่วยระหว่างวันที่ {{date_from}} ถึง {{date_to}}
|
||||
</h4>
|
||||
</center>
|
||||
<table class="table table-condensed table-striped" style="margin-bottom:0px;">
|
||||
|
@ -12,14 +12,10 @@
|
|||
<th>ชื่อ-สกุล</th>
|
||||
<th>แพทย์</th>
|
||||
<th>สิทธ์</th>
|
||||
<!--
|
||||
<th style="text-align:right">จ.น.เงิน</th>
|
||||
-->
|
||||
<th style="text-align:left">ยาฉีด</th>
|
||||
<th>DZ</th>
|
||||
<th>N/U</th>
|
||||
<th>พยาบาล</th>
|
||||
<!--<th>หมายเหตุ</th>-->
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each lines }}
|
||||
|
@ -53,9 +49,6 @@
|
|||
<td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</a></td>
|
||||
<td><a href="/ui#name=clinic_staff&active_id={{did}}&mode=form">{{dname}}</a></td>
|
||||
<td><a href="/ui#name=clinic_patient_type&active_id={{tid}}&mode=form">{{tname}}</a></td>
|
||||
<!--
|
||||
<td style="text-align:right">{{currency fee zero=""}}</td>
|
||||
-->
|
||||
<td style="text-align:left">{{mdc_name}}</td>
|
||||
<td><a href="/ui#name=clinic_dialyzer&active_id={{dlz_id}}&mode=form">{{dlz_name}}</a></td>
|
||||
<td>{{dlz_use}}</td>
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
<div style="margin-top: 20px;" class="alert alert-info" role="alert">
|
||||
<strong>Click</strong> ที่รายชื่อผู้ป่วยเพื่อทำการแก้ไขรอบการรักษา
|
||||
</div>
|
||||
<table class="table table-condensed table-striped" style="margin-bottom:0px;">
|
||||
<thead class="scroll-header">
|
||||
<th>#</th>
|
||||
<th>Patient</th>
|
||||
<th>Last Update</th>
|
||||
<th>Update By</th>
|
||||
{{#unless department_id}}
|
||||
<th>Department</th>
|
||||
{{/unless}}
|
||||
<th>Monday</th>
|
||||
<th>Tuesday</th>
|
||||
<th>Wednesday</th>
|
||||
<th>Thursday</th>
|
||||
<th>Friday</th>
|
||||
<th>Saturday</th>
|
||||
<th>Sunday</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each lines }}
|
||||
<tr>
|
||||
<td>{{no}}</td>
|
||||
<td>
|
||||
{{view "link" string=patient_name action="clinic_patient" action_options="mode=form" active_id=patient_id}}
|
||||
</td>
|
||||
<td>{{w_time}}</td>
|
||||
<td>{{w_uid}}</td>
|
||||
{{#unless ../department_id}}
|
||||
<td>{{department_name}}</td>
|
||||
{{/unless}}
|
||||
<td>{{mon_cycle_id}}</td>
|
||||
<td>{{tue_cycle_id}}</td>
|
||||
<td>{{wed_cycle_id}}</td>
|
||||
<td>{{thu_cycle_id}}</td>
|
||||
<td>{{fri_cycle_id}}</td>
|
||||
<td>{{sat_cycle_id}}</td>
|
||||
<td>{{sun_cycle_id}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
</tfoot>
|
||||
</table>
|
|
@ -157,7 +157,7 @@
|
|||
<tr>
|
||||
<th style="text-align:left;width:14%">{{name}}</th>
|
||||
<td style="text-align:right">
|
||||
<a href="#name=clinic_report_labor_cost_summary&defaults.categ_id={{categ_id}}&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.staff_type=nurse&defaults.cycle_id={{cycle_id}}">{{currency amount}}</a>
|
||||
<a href="#name=clinic_report_labor_cost_summary&defaults.categ_id={{categ_id}}&defaults.date={{../../date}}&defaults.date_from={{../../date_from}}&defaults.date_to={{../../date_to}}&defaults.branch_id={{branch_id}}&defaults.department_id={{department_id}}&defaults.staff_type=nurse&defaults.cycle_id={{cycle_id}}">{{amount}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
|
|
@ -10,7 +10,15 @@
|
|||
{{/if}}
|
||||
<th style="text-align:center" colspan="{{comp_span}}">
|
||||
{{#if show_all}}
|
||||
{{#if department_id}}
|
||||
<a href="#name=clinic_report_labor_cost_sub_detail&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.department_id={{department_id}}">{{comp_name}}</a>
|
||||
{{else}}
|
||||
{{#if branch_id}}
|
||||
<a href="#name=clinic_report_labor_cost_sub_detail&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.branch_id={{branch_id}}">{{comp_name}}</a>
|
||||
{{else}}
|
||||
<a href="#name=clinic_report_labor_cost_sub_detail&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}">{{comp_name}}</a>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{comp_name}}
|
||||
{{/if}}
|
||||
|
@ -79,7 +87,15 @@
|
|||
</td>
|
||||
{{/each}}
|
||||
<td style="text-align:right;">
|
||||
{{#if ../../department_id}}
|
||||
<a href="#name=clinic_report_labor_cost_daily&defaults.date={{date}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.department_id={{../../department_id}}&defaults.branch_id={{../../branch_id}}">{{currency total_qty zero=""}}</a>
|
||||
{{else}}
|
||||
{{#if ../../branch_id}}
|
||||
<a href="#name=clinic_report_labor_cost_daily&defaults.date={{date}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}&defaults.branch_id={{../../branch_id}}">{{currency total_qty zero=""}}</a>
|
||||
{{else}}
|
||||
<a href="#name=clinic_report_labor_cost_daily&defaults.date={{date}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}">{{currency total_qty zero=""}}</a>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</td>
|
||||
<td style="text-align:right;">{{currency total_amt zero=""}}</th>
|
||||
</tr>
|
||||
|
|
|
@ -29,14 +29,11 @@
|
|||
<td style="text-align:right;">
|
||||
<a href="#name=clinic_report_labor_cost_summary&defaults.date_from={{../date_from}}&defaults.date_to={{../date_to}}&defaults.staff_type={{staff_type}}&defaults.staff_id={{staff_id}}">{{currency amount zero=""}}</a>
|
||||
</td>
|
||||
<td style="text-align:right;">{{max_cycle}}</td>
|
||||
<td style="text-align:right;">{{currency max_cycle zero=""}}</td>
|
||||
<td style="text-align:right;">
|
||||
{{view "link" string=cycle_qty action="clinic_labor_cost_item" action_options=action_options}}
|
||||
</td>
|
||||
<!--
|
||||
<td style="text-align:right;">{{cycle_qty}}</th>
|
||||
-->
|
||||
<td style="text-align:right;">{{ot_qty}}</th>
|
||||
<td style="text-align:right;">{{currency ot_qty zero=""}}</th>
|
||||
<td style="text-align:right;">{{currency ot_per_cycle zero=""}}</th>
|
||||
<td style="text-align:right;color:orange">{{currency ot_amount zero=""}}</th>
|
||||
<td style="text-align:right;color:blue">{{currency staff_wage zero=""}}</th>
|
||||
|
@ -51,9 +48,9 @@
|
|||
<th></th>
|
||||
<th>รวม</th>
|
||||
<th style="text-align:right">{{currency total_amount zero=""}}</th>
|
||||
<th style="text-align:right">{{total_max_cycle}}</th>
|
||||
<th style="text-align:right">{{total_cycle_qty}}</th>
|
||||
<th style="text-align:right">{{total_ot_qty}}</th>
|
||||
<th style="text-align:right">{{currency total_max_cycle zero=""}}</th>
|
||||
<th style="text-align:right">{{currency total_cycle_qty zero=""}}</th>
|
||||
<th style="text-align:right">{{currency total_ot_qty zero=""}}</th>
|
||||
<th style="text-align:right">{{currency total_ot_per_cycle zero=""}}</th>
|
||||
<th style="text-align:right">{{currency total_ot_amount zero=""}}</th>
|
||||
<th style="text-align:right">{{currency total_wage zero=""}}</th>
|
||||
|
|
|
@ -19,12 +19,13 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th rowspan="3">#</th>
|
||||
<th rowspan="3">รหัส</th>
|
||||
{{#ifeq staff_type "nurse"}}
|
||||
<th rowspan="3">รหัส</th>
|
||||
<th rowspan="3">ชื่อ-สกุล</th>
|
||||
<th rowspan="3">ตำแหน่ง</th>
|
||||
<th rowspan="3">หมวดหมู่</th>
|
||||
{{else}}
|
||||
<th rowspan="3"></th>
|
||||
<th rowspan="3" colspan="3">ชื่อ-สกุล</th>
|
||||
{{/ifeq}}
|
||||
{{#each dpts}}
|
||||
|
@ -38,14 +39,15 @@
|
|||
{{#each lines }}
|
||||
<tr>
|
||||
<td>{{no}}</th>
|
||||
<td>{{number}}</th>
|
||||
{{#ifeq ../staff_type "nurse"}}
|
||||
<td>{{number}}</th>
|
||||
<td>
|
||||
{{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}}
|
||||
</td>
|
||||
<td>{{staff_level}}</th>
|
||||
<td>{{categ_name}}</th>
|
||||
{{else}}
|
||||
<td></th>
|
||||
<td colspan="3">
|
||||
{{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}}
|
||||
</td>
|
||||
|
|
|
@ -1,13 +1,2 @@
|
|||
> script:
|
||||
- merge
|
||||
- staff -> ok
|
||||
- patient
|
||||
|
||||
> explain nurse
|
||||
กรณีแก้ไขรายชื่อหมอให้ดูรายชื่อแพทย์ให้ดี
|
||||
|
||||
> note:
|
||||
แก้ไขยาก หากมาเจอข้อผิดพลาดบางครั้ง
|
||||
|
||||
> report K. boy
|
||||
total qty of report_labor_cost_staff is not the same report_labor_cost
|
||||
- show log for each model that use _log=True
|
||||
- create report patient cycle setting -> link to patient to change cycle setting
|
||||
|
|
Loading…
Reference in New Issue