report hd case summary
parent
96a6d721f9
commit
88fa7ac039
|
@ -1,9 +1,10 @@
|
|||
<form model="clinic.report.hd.case.detail">
|
||||
<!--<field name="date" span="3" mode="month" onchange="onchange_date"/>-->
|
||||
<field name="date" mode="month" onchange="onchange_date" span="2"/>
|
||||
<field name="date_from" onchange="onchange_date_from" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="patient_id" span="2"/>
|
||||
<field name="patient_type_id" span="2"/>
|
||||
<field name="patient_type_id" attrs='{"required":[["report_type","=","topic6"]]}' span="2"/>
|
||||
<field name="branch_id" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
<field name="report_type" span="6"/>
|
||||
<field name="hdcase_type" attrs='{"required":[["report_type","=","topic1"]]}' span="2"/>
|
||||
</form>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="hdcase_type" required="1" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_branch" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
<field name="report_type" span="2"/>
|
||||
</form>
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class HDCasePopupDlz(Model):
|
||||
_name="clinic.hd.case.popup.dlz"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
|
||||
'product_id': fields.Many2One("product", "Product",required=True),
|
||||
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
|
||||
"max_use_time": fields.Integer("Max Use Time"),
|
||||
"exp_date": fields.Date("Expiry Date"),
|
||||
"note": fields.Text("Note"),
|
||||
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
||||
}
|
||||
|
||||
def __get_hd_case_id(self,context={}):
|
||||
hd_case_id=context.get("refer_id")
|
||||
print("clinic.hd.case.popup.dlz default")
|
||||
if not hd_case_id:
|
||||
return None
|
||||
return int(hd_case_id)
|
||||
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
hdcase_id=defaults.get('hd_case_id')
|
||||
dialyzer_type=defaults.get('dialyzer_type')
|
||||
if not hdcase_id:
|
||||
hdcase_id=context.get("refer_id")
|
||||
if hdcase_id:
|
||||
hdcase=get_model('clinic.hd.case').browse(hdcase_id)
|
||||
dom=[]
|
||||
for dlz in get_model('clinic.dialyzer').search_browse(dom):
|
||||
dialyzer_type=dlz.dialyzer_type or "low"
|
||||
pass
|
||||
res={
|
||||
'hd_case_id': hdcase_id,
|
||||
'dialyzer_type': 'low',
|
||||
'max_use_time': 10,
|
||||
}
|
||||
print('res', res)
|
||||
return res
|
||||
|
||||
def new_dlz(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
hd_case=obj.hd_case_id
|
||||
res={}
|
||||
if hd_case:
|
||||
context['is_wiz']=True
|
||||
context['pop_id']=obj.id
|
||||
res=hd_case.new_dialyzer(context=context)
|
||||
print('res ', res)
|
||||
return res
|
||||
|
||||
def onchange_product(self,context={}):
|
||||
data=context['data']
|
||||
hdcase_id=data['hd_case_id']
|
||||
patient=None
|
||||
if hdcase_id:
|
||||
hdcase=get_model('clinic.hd.case').browse(hdcase_id)
|
||||
patient=hdcase.patient_id
|
||||
product_id=data['product_id']
|
||||
data['membrane_type']=None
|
||||
data['dialyzer_type']=None
|
||||
data['max_use_time']=10
|
||||
dom=[]
|
||||
if patient:
|
||||
dom.append(['patient_id','=',patient.id])
|
||||
for dlz in get_model("clinic.dialyzer").search_browse(dom):
|
||||
prod=dlz.product_id
|
||||
if prod.id==product_id:
|
||||
data['membrane_type']=dlz.membrane_type
|
||||
data['dialyzer_type']=dlz.dialyzer_type or "low"
|
||||
data['max_use_time']=dlz.max_use_time or 10
|
||||
break
|
||||
return data
|
||||
|
||||
HDCasePopupDlz.register()
|
|
@ -28,8 +28,12 @@ class ReportCycleItem(Model):
|
|||
date_from=defaults.get('date_from','%s-%s-01'%(year,month))
|
||||
date_to=defaults.get('date_to','%s-%s-01'%(year,month))
|
||||
branch_id=defaults.get('branch_id')
|
||||
ptype_id=defaults.get('ptype_id')
|
||||
if branch_id:
|
||||
branch_id=int(branch_id)
|
||||
department_id=defaults.get('department_id')
|
||||
if department_id:
|
||||
department_id=int(department_id)
|
||||
ptype_id=defaults.get('ptype_id')
|
||||
res=get_model('select.company').get_select()
|
||||
if res:
|
||||
if not branch_id:
|
||||
|
@ -45,8 +49,9 @@ class ReportCycleItem(Model):
|
|||
'date_to': date_to,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
'ptype_id': ptype_id,
|
||||
}
|
||||
print('res', res)
|
||||
print('report.cycle.item.defautls', res)
|
||||
return res
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
|
@ -122,9 +127,11 @@ class ReportCycleItem(Model):
|
|||
dlz_drop=True
|
||||
cancel=False
|
||||
row_color=''
|
||||
if hdcase.state=='cancelled':
|
||||
cancel=True
|
||||
row_color='#b6b6b6'
|
||||
if hdcase.state not in ('paid', 'waiting_payment'):
|
||||
continue
|
||||
#if hdcase.state=='cancelled':
|
||||
#cancel=True
|
||||
#row_color='#b6b6b6'
|
||||
lines.append({
|
||||
'dlz_drop': dlz_drop,
|
||||
'cancel': cancel,
|
||||
|
|
|
@ -4,6 +4,8 @@ from calendar import monthrange
|
|||
from netforce.model import Model,fields,get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
from . import utils
|
||||
|
||||
|
||||
class ReportHDCaseDetail(Model):
|
||||
_name="clinic.report.hd.case.detail"
|
||||
|
@ -14,139 +16,332 @@ class ReportHDCaseDetail(Model):
|
|||
"date": fields.Date("Month"),
|
||||
"date_from": fields.Date("From", required=True),
|
||||
"date_to": fields.Date("To", required=True),
|
||||
'patient_type_id': fields.Many2One("clinic.patient.type","Payers"),
|
||||
'patient_id': fields.Many2One("clinic.patient","Patient",domain=[['state','=','admit']]),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type"),
|
||||
'hdcase_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"HDCase Type"),
|
||||
'report_type': fields.Selection([
|
||||
['topic1','จำนวนครั้งการทำ Hemodialysis'],
|
||||
['topic2','จำนวนผู้ป่วยยกมาจากเดือน'],
|
||||
['topic3','จำนวนผู้ป่วยรับใหม่เดือน'],
|
||||
['topic4','จำนวนผู้ป่วยจำหน่ายเดือน'],
|
||||
['topic5','จำนวนผู้ป่วยยกไปเดือน'],
|
||||
['topic6','ประเภทผู้ป่วย'],
|
||||
],"Repor Type",required=True),
|
||||
}
|
||||
|
||||
def _get_date_from(self,context={}):
|
||||
return time.strftime("%Y-%m-%d")
|
||||
|
||||
def _get_date_to(self,context={}):
|
||||
return time.strftime("%Y-%m-%d")
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'date_from': _get_date_from,
|
||||
'date_to': _get_date_to,
|
||||
}
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
company_id=get_active_company()
|
||||
company=get_model('company').browse(company_id)
|
||||
date_from=time.strftime("%Y-%m-%d")
|
||||
date_to=time.strftime("%Y-%m-%d")
|
||||
ptype_id=None
|
||||
pid=None
|
||||
dpt_id=None
|
||||
bid=None
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
date_from=obj.date_from
|
||||
date_to=obj.date_to
|
||||
pid=obj.patient_id.id
|
||||
ptype_id=obj.patient_type_id.id
|
||||
dpt_id=obj.department_id.id
|
||||
bid=obj.branch_id.id
|
||||
lines=[]
|
||||
dom=[]
|
||||
dom.append(['date','>=',date_from])
|
||||
dom.append(['date','<=',date_to])
|
||||
if pid:
|
||||
dom.append(['patient_id','=',pid])
|
||||
if ptype_id:
|
||||
dom.append(['patient_type_id','=',ptype_id])
|
||||
if dpt_id:
|
||||
dom.append(['department_id','=',dpt_id])
|
||||
if bid:
|
||||
dom.append(['branch_id','=',bid])
|
||||
|
||||
draft=0
|
||||
wait_treat=0
|
||||
wait_pay=0
|
||||
in_progress=0
|
||||
finish_treat=0
|
||||
cancel=0
|
||||
paid=0
|
||||
no=1
|
||||
for hdcase in get_model("clinic.hd.case").search_browse(dom):
|
||||
state=hdcase.state
|
||||
if state=='in_progress':
|
||||
in_progress+=1
|
||||
elif state=='paid':
|
||||
paid+=1
|
||||
elif state=='cancelled':
|
||||
cancel+=1
|
||||
elif state=='waiting_treatment':
|
||||
wait_treat+=1
|
||||
elif state=='waiting_payment':
|
||||
wait_pay+=1
|
||||
elif state=='completed':
|
||||
finish_treat+=1
|
||||
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("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
date_from=defaults.get('date_from','%s-%s-01'%(year,month))
|
||||
date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
|
||||
report_type=defaults.get('report_type',"topic1")
|
||||
if report_type:
|
||||
index=''
|
||||
for r in report_type:
|
||||
if r.isdigit():
|
||||
index+=r
|
||||
if int(index)>=6:
|
||||
report_type='topic6'
|
||||
branch_id=defaults.get('branch_id',None)
|
||||
hdcase_type=defaults.get("hdcase_type","completed")
|
||||
patient_type_id=defaults.get('patient_type_id')
|
||||
if patient_type_id:
|
||||
patient_type_id=int(patient_type_id)
|
||||
select_dpt=get_model('select.company').get_select()
|
||||
if not branch_id:
|
||||
if select_dpt:
|
||||
branch_id=select_dpt['branch_id']
|
||||
else:
|
||||
branch_id=int(branch_id or "0")
|
||||
department_id=defaults.get('department_id',None)
|
||||
if not department_id:
|
||||
if select_dpt.get('department_ids'):
|
||||
department_id=select_dpt['department_ids'][0]
|
||||
else:
|
||||
draft+=1
|
||||
|
||||
epo=[]
|
||||
fee_amt=0
|
||||
dlz_new='N'
|
||||
for dlz in hdcase.dialyzers:
|
||||
if dlz.use_time==1:
|
||||
dlz_new='Y'
|
||||
for line in hdcase.lines:
|
||||
prod=line.product_id
|
||||
categ=line.product_categ_id
|
||||
if categ.code=='EPO':
|
||||
epo.append(line.description or '')
|
||||
elif categ.code=='FEE':
|
||||
fee_amt+=line.amount
|
||||
if not epo:
|
||||
epo='-'
|
||||
else:
|
||||
epo=', '.join([e for e in epo])
|
||||
patient=hdcase.patient_id
|
||||
rmb_amt=hdcase.rmb_amount or 0
|
||||
more_amt=hdcase.due_amount or 0
|
||||
rmb=0
|
||||
if rmb_amt > 0:
|
||||
rmb=1
|
||||
lines.append({
|
||||
'no': no,
|
||||
'number': hdcase.number or '',
|
||||
'hd_case_id': hdcase.id or '',
|
||||
'time_start': hdcase.time_start,
|
||||
'epo': epo,
|
||||
'patient_name': patient.name,
|
||||
'patient_id': patient.id,
|
||||
'patient_number': patient.number or '',
|
||||
'patient_type': patient.type_id.name or '',
|
||||
'hct': hdcase.hct or 0,
|
||||
'rmb': rmb,
|
||||
'more_amt': more_amt,
|
||||
'fee_amt': fee_amt,
|
||||
'dlz_new': dlz_new,
|
||||
})
|
||||
no+=1
|
||||
|
||||
sub_title=''
|
||||
if bid:
|
||||
sub_title+="%s "%(obj.branch_id.name or "")
|
||||
if dpt_id:
|
||||
sub_title+="%s "%(obj.department_id.name or "")
|
||||
data={
|
||||
'company_name': company.name or "",
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
'lines': lines,
|
||||
department_id=select_dpt['department_id']
|
||||
else:
|
||||
department_id=int(department_id)
|
||||
res={
|
||||
'date': date,
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
'sub_title': sub_title,
|
||||
'draft': draft,
|
||||
'wait_treat': wait_treat,
|
||||
'wait_pay': wait_pay,
|
||||
'in_progress': in_progress,
|
||||
'cancel': cancel,
|
||||
'paid': paid,
|
||||
'finish_treat': finish_treat,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
'report_type': report_type,
|
||||
'hdcase_type': hdcase_type,
|
||||
'patient_type_id': patient_type_id,
|
||||
}
|
||||
#print('report.hd.case.detail.defaults ', res)
|
||||
return res
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
company_id=get_active_company()
|
||||
company=get_model("company").browse(company_id)
|
||||
defaults=self.default_get(context=context)
|
||||
date=defaults.get('date',time.strftime("%Y-%m-%d"))
|
||||
year=int(date[0:4])
|
||||
crr_month=int(date[5:7])
|
||||
weekday, crr_total_day=monthrange(year, crr_month)
|
||||
date_from=defaults.get('date_from',date)
|
||||
date_to=defaults.get('date_to',date)
|
||||
branch_id=defaults.get("branch_id",None)
|
||||
department_id=defaults.get("department_id",None)
|
||||
hdcase_type=defaults.get('hdcase_type')
|
||||
report_type=defaults.get('report_type','topic1')
|
||||
patient_type_id=defaults.get('patient_type_id')
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
titles=dict(self._fields['report_type'].selection)
|
||||
title=titles.get(report_type,'no title')
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
branch_id=obj.branch_id.id
|
||||
department_id=obj.department_id.id
|
||||
date=obj.date
|
||||
crr_month=int(date[5:7])
|
||||
time_start=obj.date_from
|
||||
time_stop=obj.date_to
|
||||
year=int(date[0:4])
|
||||
date_from=obj.date_from
|
||||
date_to=obj.date_to
|
||||
report_type=obj.report_type or 'topic1'
|
||||
hdcase_type=obj.hdcase_type or 'completed'
|
||||
patient_type_id=obj.patient_type_id.id
|
||||
prev_year=year
|
||||
next_year=year
|
||||
prev_month=crr_month-1
|
||||
next_month=crr_month+1
|
||||
if crr_month==1:
|
||||
prev_month=12
|
||||
prev_year-=1
|
||||
if crr_month==12:
|
||||
next_month=1
|
||||
next_year+=1
|
||||
month_str=utils.MONTHS['th_TH'][crr_month]
|
||||
next_month_str=utils.MONTHS['th_TH'][next_month]
|
||||
prev_month_str=utils.MONTHS['th_TH'][prev_month]
|
||||
|
||||
def replace_quote(dom=""):
|
||||
dom=dom.replace("False","false")
|
||||
dom=dom.replace("True","true")
|
||||
return dom.replace("'","\"")
|
||||
dom=[]
|
||||
lines=[]
|
||||
total=0
|
||||
# current hd case
|
||||
if report_type=='topic1':
|
||||
title=titles.get(report_type,'no title')
|
||||
dom=[]
|
||||
dom.append(["date",">=",date_from])
|
||||
dom.append(["date","<=",date_to])
|
||||
if hdcase_type=='completed':
|
||||
dom.append(["state","in",["waiting_payment","paid"]])
|
||||
else:
|
||||
dom.append(["state","not in",["waiting_payment","paid"]])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
total=0
|
||||
for hdcase in get_model("clinic.hd.case").search_browse(dom,order="number"):
|
||||
patient=hdcase.patient_id
|
||||
lines.append({
|
||||
'number': hdcase.number,
|
||||
'date': hdcase.date,
|
||||
'name': patient.name,
|
||||
'note': hdcase.note,
|
||||
})
|
||||
total+=1
|
||||
# number of patient from previous month
|
||||
elif report_type=='topic2':
|
||||
title=titles.get(report_type,'no title')
|
||||
title+=' '+prev_month_str
|
||||
prev_weekday, prev_total_day=monthrange(prev_year, prev_month)
|
||||
reg_date='%s-%s-%s'%(prev_year,str(prev_month).zfill(2),str(prev_total_day).zfill(2))
|
||||
print('topic2 ', reg_date)
|
||||
dom=[]
|
||||
dom.append(['reg_date','<=',reg_date])
|
||||
dom.append(['walkin','=',"no"])
|
||||
#dom.append(['dispose','=',False])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
total=0
|
||||
for patient in get_model("clinic.patient").search_browse(dom):
|
||||
if patient.dispose and patient.resign_date:
|
||||
if patient.resign_date < date_from:
|
||||
print('continue >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
continue
|
||||
elif patient.resign_date > date_to:
|
||||
pass
|
||||
elif not patient.resign_date > date_to:
|
||||
print('pass >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
elif not (patient.resign_date>=date_from and patient.resign_date<=date_to):
|
||||
print('continue >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
continue
|
||||
print('pass >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
lines.append({
|
||||
'number': patient.hn_no,
|
||||
'pid': patient.id,
|
||||
'name': patient.name,
|
||||
'note': patient.note,
|
||||
'date': patient.reg_date,
|
||||
})
|
||||
total+=1
|
||||
# new patient of this month
|
||||
elif report_type=='topic3':
|
||||
title=titles.get(report_type,'no title')
|
||||
title+=' '+month_str
|
||||
dom=[]
|
||||
dom.append(['reg_date','>=',time_start])
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['walkin','=',"no"])
|
||||
dom.append(['dispose','=',False])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
total=0
|
||||
for patient in get_model('clinic.patient').search_browse(dom):
|
||||
#if patient.dispose and patient.resign_date < date_from:
|
||||
#continue
|
||||
lines.append({
|
||||
'number': patient.hn_no,
|
||||
'pid': patient.id,
|
||||
'name': patient.name,
|
||||
'note': patient.note,
|
||||
'date': patient.reg_date,
|
||||
})
|
||||
total+=1
|
||||
# number for patient who resign for this month
|
||||
elif report_type=='topic4':
|
||||
title=titles.get(report_type,'no title')
|
||||
title+=' '+month_str
|
||||
dom=[]
|
||||
dom.append(['resign_date','>=',time_start])
|
||||
dom.append(['resign_date','<=',time_stop])
|
||||
dom.append(['walkin','=',"no"])
|
||||
dom.append(['dispose','=',True])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
total=0
|
||||
for patient in get_model('clinic.patient').search_browse(dom):
|
||||
lines.append({
|
||||
'number': patient.hn_no,
|
||||
'pid': patient.id,
|
||||
'name': patient.name,
|
||||
'note': patient.note,
|
||||
'date': patient.resign_date,
|
||||
})
|
||||
total+=1
|
||||
# all patient who are in hospital on select month
|
||||
elif report_type=='topic5':
|
||||
title=titles.get(report_type,'no title')
|
||||
title+=' '+next_month_str
|
||||
dom=[]
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
print('topic5 ', time_stop)
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
dom.append(['walkin','=',"no"])
|
||||
#dom.append(['dispose','=',False])
|
||||
total=0
|
||||
for patient in get_model('clinic.patient').search_browse(dom,order="reg_date"):
|
||||
if patient.dispose and patient.resign_date:
|
||||
if patient.resign_date < date_from:
|
||||
print('1. continue >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
continue
|
||||
elif patient.resign_date > date_to:
|
||||
pass
|
||||
elif patient.resign_date > date_to:
|
||||
print('2. pass >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
elif (patient.resign_date>=date_from and patient.resign_date<=date_to):
|
||||
print('3. continue >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
continue
|
||||
print('4. pass >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
lines.append({
|
||||
'number': patient.hn_no,
|
||||
'pid': patient.id,
|
||||
'name': patient.name,
|
||||
'note': patient.note,
|
||||
'date': patient.reg_date,
|
||||
'dispose': patient.dispose and 'yes' or 'no',
|
||||
})
|
||||
total+=1
|
||||
elif report_type=='topic6':
|
||||
#title=titles.get(report_type,'no title')
|
||||
ptype=None
|
||||
if patient_type_id:
|
||||
ptype=get_model('clinic.patient.type').browse(patient_type_id)
|
||||
if not ptype:
|
||||
return {'total': 0}
|
||||
title=ptype.name or ''
|
||||
dom=[]
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['type_id','=',ptype['id']])
|
||||
dom.append(['walkin','=',"no"])
|
||||
#dom.append(['dispose','=',False])
|
||||
dom.append(['type_id','=',ptype.id])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
total=0
|
||||
print('topic6')
|
||||
for patient in get_model("clinic.patient").search_browse(dom):
|
||||
if patient.resign_date:
|
||||
if patient.dispose and patient.resign_date < date_from:
|
||||
print('1. continue >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
continue
|
||||
elif patient.resign_date > date_to:
|
||||
pass
|
||||
elif patient.resign_date > date_to:
|
||||
print('2. pass >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
elif (patient.resign_date>=date_from and patient.resign_date<=date_to):
|
||||
print('3. continue >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
continue
|
||||
print('4. pass >>> ', patient.name, patient.resign_date, date_from, date_to)
|
||||
lines.append({
|
||||
'pid': patient.id,
|
||||
'number': patient.hn_no,
|
||||
'name': patient.name or '',
|
||||
'date': patient.reg_date,
|
||||
})
|
||||
total+=1
|
||||
sub_name=''
|
||||
if department_id:
|
||||
dpt=get_model("clinic.department").browse(department_id)
|
||||
sub_name="(%s)" % dpt.name or ""
|
||||
elif branch_id:
|
||||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
sub_name="(%s)" % branch.name or ""
|
||||
no=1
|
||||
for line in lines:
|
||||
line['no']="{0:,.0f}".format(no)
|
||||
no+=1
|
||||
data={
|
||||
'total_txt': "{0:,.0f}".format(total),
|
||||
'total': total,
|
||||
'title': title,
|
||||
'report_type': report_type,
|
||||
'date': date,
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
'month': month_str,
|
||||
'year': year,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
'lines': lines,
|
||||
'company_name': '%s %s'% (company.name or "", sub_name),
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
}
|
||||
return data
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class ReportHDCaseSummary(Model):
|
|||
"date_to": fields.Date("To", required=True),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'department_id': fields.Many2One("clinic.department","Departments"),
|
||||
'report_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"Report Type"),
|
||||
'hdcase_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"HDCase Type"),
|
||||
}
|
||||
|
||||
def _get_date_from(self,context={}):
|
||||
|
@ -50,7 +50,7 @@ class ReportHDCaseSummary(Model):
|
|||
'date_to': _get_date_to,
|
||||
'branch_id': _get_branch,
|
||||
'department_id': _get_department,
|
||||
'report_type': 'completed',
|
||||
'hdcase_type': 'completed',
|
||||
}
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
|
@ -65,25 +65,21 @@ class ReportHDCaseSummary(Model):
|
|||
date_to=defaults.get('date_to',date)
|
||||
branch_id=defaults.get("branch_id",None)
|
||||
department_id=defaults.get("department_id",None)
|
||||
report_type=defaults.get('report_type','completed')
|
||||
hdcase_type=defaults.get('hdcase_type','completed')
|
||||
if branch_id:
|
||||
branch_id=branch_id[0]
|
||||
if department_id:
|
||||
department_id=department_id[0]
|
||||
time_start='%s-%s-01 00:00:00'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s 23:59:59'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
branch_id=obj.branch_id.id
|
||||
department_id=obj.department_id.id
|
||||
date=obj.date
|
||||
crr_month=int(date[5:7]) #XXX
|
||||
time_start='%s 00:00:00'%obj.date_from
|
||||
time_stop='%s 23:59:59'%obj.date_to
|
||||
year=int(date[0:4])
|
||||
date_from=obj.date_from
|
||||
date_to=obj.date_to
|
||||
report_type=obj.report_type or 'completed'
|
||||
hdcase_type=obj.hdcase_type or 'completed'
|
||||
prev_year=year
|
||||
next_year=year
|
||||
prev_month=crr_month-1
|
||||
|
@ -105,171 +101,145 @@ class ReportHDCaseSummary(Model):
|
|||
return dom
|
||||
|
||||
def replace_quote(dom=""):
|
||||
dom=dom.replace("False","false") #XXX
|
||||
dom=dom.replace("True","true") #XXX
|
||||
dom=dom.replace("False","false")
|
||||
dom=dom.replace("True","true")
|
||||
return dom.replace("'","\"")
|
||||
|
||||
count=1
|
||||
|
||||
def set_default(dom=[],topic='topic1'):
|
||||
dom_txt=''
|
||||
for f,op,v in dom:
|
||||
if 'in' in op: #XXX
|
||||
continue
|
||||
dom_txt+='defaults.%s%s%s&'%(f,op,v)
|
||||
if date:
|
||||
dom_txt+='&defaults.date=%s'%date
|
||||
if date_from:
|
||||
dom_txt+='&defaults.date_from=%s'%date_from
|
||||
if date_to:
|
||||
dom_txt+='&defaults.date_to=%s'%date_to
|
||||
if topic:
|
||||
dom_txt+='&defaults.report_type=%s'%topic
|
||||
if hdcase_type:
|
||||
dom_txt+='&defaults.hdcase_type=%s'%hdcase_type
|
||||
return dom_txt
|
||||
|
||||
def set_ctx(dom=[],topic='topic1'):
|
||||
ctx={'defaults': {}}
|
||||
ctx['defaults'].update({
|
||||
'report_type': topic,
|
||||
'hdcase_type': hdcase_type,
|
||||
'date': date,
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
})
|
||||
for f,op,v in dom:
|
||||
if 'in' in op: #XXX
|
||||
continue
|
||||
ctx['defaults'].update({
|
||||
f: v,
|
||||
})
|
||||
return ctx
|
||||
|
||||
# number of hd case of this month
|
||||
dom=[]
|
||||
dom.append(["date",">=",date_from])
|
||||
dom.append(["date","<=",date_to])
|
||||
if report_type=='completed':
|
||||
dom.append(["state","in",["waiting_payment","paid"]])
|
||||
else:
|
||||
dom.append(["state","not in",["waiting_payment","paid"]])
|
||||
#dom.append(['patient_id.walkin','=','no'])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
crr_total=len(get_model("clinic.hd.case").search(dom))
|
||||
print('---> dom ', dom)
|
||||
|
||||
topic='topic1'
|
||||
dom_txt=set_default(dom,topic)
|
||||
ctx=set_ctx(dom,topic)
|
||||
items={}
|
||||
items['topic%s'%count]={
|
||||
item_vals={
|
||||
'month': month_str,
|
||||
'qty': crr_total or 0,
|
||||
'action': 'clinic_hd_case',
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%dom),
|
||||
'qty': get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total'],
|
||||
'link': 'clinic_report_cycle_item&%s'%dom_txt,
|
||||
}
|
||||
count+=1
|
||||
if hdcase_type!='completed':
|
||||
item_vals['link']='clinic_report_hd_case_detail&%s'%dom_txt
|
||||
items[topic]=item_vals
|
||||
|
||||
# number of patient from previous
|
||||
dom=[]
|
||||
weekday, prev_total_day=monthrange(prev_year, prev_month)
|
||||
time_stop='%s-%s-%s'%(prev_year,str(prev_month).zfill(2),prev_total_day)
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['walkin','=',"no"])
|
||||
dom.append(['dispose','=',False])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
print("dom ==> ", dom)
|
||||
npatient=len(get_model("clinic.patient").search(dom))
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic%s'%count]={
|
||||
topic='topic2'
|
||||
dom_txt=set_default(dom,topic)
|
||||
ctx=set_ctx(dom,topic)
|
||||
items[topic]={
|
||||
'month': prev_month_str,
|
||||
'qty': npatient or 0,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
'qty': get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total'],
|
||||
'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
|
||||
}
|
||||
count+=1
|
||||
|
||||
topic='topic3'
|
||||
dom_txt=set_default(dom,topic)
|
||||
ctx=set_ctx(dom,topic)
|
||||
# new patient of this month
|
||||
dom=[]
|
||||
weekday, crr_total_day=monthrange(prev_year, crr_month)
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['reg_date','>=',time_start])
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['walkin','=',"no"])
|
||||
dom.append(['dispose','=',False])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
new_patients=get_model('clinic.patient').search_browse(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic%s'%count]={
|
||||
items[topic]={
|
||||
'month': month_str,
|
||||
'qty': len(new_patients) or 0,
|
||||
'qty': get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total'],
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
|
||||
}
|
||||
count+=1
|
||||
|
||||
# number for patient who resign for this month
|
||||
dom=[]
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['resign_date','>=',time_start])
|
||||
dom.append(['resign_date','<=',time_stop])
|
||||
dom.append(['walkin','=',"no"])
|
||||
dom.append(['dispose','=',True])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
resign_patients_qty=0
|
||||
resign_patients=[]
|
||||
for pt in get_model('clinic.patient').search_browse(dom):
|
||||
resign_patients_qty+=1
|
||||
resign_patients.append(pt.id)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic%s'%count]={
|
||||
topic='topic4'
|
||||
dom_txt=set_default(dom,topic)
|
||||
ctx=set_ctx(dom,topic)
|
||||
resign_qty=get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total']
|
||||
items[topic]={
|
||||
'month': month_str,
|
||||
'qty': resign_patients_qty,
|
||||
'qty': resign_qty,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=3'%dom,
|
||||
'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
|
||||
}
|
||||
count+=1
|
||||
# all patient who are in hospital on select month
|
||||
dom=[]
|
||||
weekday, crr_total_day=monthrange(year, crr_month)
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
dom.append(['walkin','=',"no"])
|
||||
dom.append(['dispose','=',False])
|
||||
total_patient=get_model('clinic.patient').search_browse(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
total_patient_qty=len(total_patient) or 0
|
||||
items['topic%s'%count]={
|
||||
topic='topic5'
|
||||
dom_txt=set_default(dom,topic)
|
||||
ctx=set_ctx(dom,topic)
|
||||
total_qty=get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total']
|
||||
|
||||
items[topic]={
|
||||
'month': next_month_str,
|
||||
'qty': total_patient_qty-resign_patients_qty,
|
||||
#'qty': total_qty-resign_qty,
|
||||
'qty': total_qty,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
|
||||
}
|
||||
count+=1
|
||||
|
||||
topics=utils.TOPICS
|
||||
for ptype in get_model("clinic.patient.type").search_read([[]],['name']):
|
||||
tkey='topic%s'%count
|
||||
count=6
|
||||
for ptype in get_model("clinic.patient.type").search_browse([[]]):
|
||||
topic='topic%s'%count
|
||||
topics.update({
|
||||
tkey:{
|
||||
'name': ptype['name'],
|
||||
topic:{
|
||||
'name': ptype.name,
|
||||
'unit': 'คน',
|
||||
}
|
||||
})
|
||||
dom=[]
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['type_id','=',ptype['id']])
|
||||
dom.append(['walkin','=',"no"])
|
||||
dom.append(['dispose','=',False])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
npatients_qty=0
|
||||
for pt in get_model("clinic.patient").search(dom):
|
||||
npatients_qty+=1
|
||||
dom=replace_quote('%s'%dom)
|
||||
items[tkey]={
|
||||
dom2=dom+[['patient_type_id','=',ptype.id]]
|
||||
dom_txt=set_default(dom2,topic)
|
||||
ctx=set_ctx(dom2,topic)
|
||||
qty=get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total']
|
||||
items[topic]={
|
||||
'month': '',
|
||||
'qty': npatients_qty,
|
||||
'qty': qty,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&tab_no=0&search_domain=%s'%dom,
|
||||
'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
|
||||
}
|
||||
count+=1
|
||||
|
||||
lines=[]
|
||||
index=1
|
||||
for item in items:
|
||||
topic='topic%s'%index
|
||||
name=utils.TOPICS[topic]['name']
|
||||
unit=utils.TOPICS[topic]['unit']
|
||||
name=topics[topic]['name']
|
||||
unit=topics[topic]['unit']
|
||||
line=items[topic]
|
||||
line['topic']=name
|
||||
line['unit']=unit
|
||||
lines.append(line)
|
||||
index+=1
|
||||
if report_type=='not_completed':
|
||||
if hdcase_type=='not_completed':
|
||||
lines[0]['topic']='%s (ไม่สำเร็จ)'%lines[0]['topic']
|
||||
context['defaults']={
|
||||
'date': date,
|
||||
|
@ -277,7 +247,7 @@ class ReportHDCaseSummary(Model):
|
|||
'date_to': date_to,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
'report_type': report_type,
|
||||
'hdcase_type': hdcase_type,
|
||||
}
|
||||
|
||||
medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)
|
||||
|
@ -290,7 +260,7 @@ class ReportHDCaseSummary(Model):
|
|||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
sub_name="(%s)" % branch.name or ""
|
||||
data={
|
||||
'report_type': report_type,
|
||||
'hdcase_type': hdcase_type,
|
||||
'branch_id': branch_id,
|
||||
'department_id': department_id,
|
||||
'date_from': date_from,
|
||||
|
|
|
@ -96,7 +96,7 @@ class VisitBoard(Model):
|
|||
branch_id=obj.branch_id.id
|
||||
def auto_gen_visit(dom=[]):
|
||||
dom.append(['dispose','=',False])
|
||||
dom.append(['walkin','=','no'])
|
||||
#dom.append(['walkin','=','no']) #XXX
|
||||
def daterange(start_date, end_date):
|
||||
for n in range(int ((end_date - start_date).days)):
|
||||
yield start_date + timedelta(n)
|
||||
|
@ -123,10 +123,9 @@ class VisitBoard(Model):
|
|||
department=pc.department_id
|
||||
if weekday==w:
|
||||
dom2=[
|
||||
['visit_date','>=',date_txt],
|
||||
['visit_date','<=',date_txt],
|
||||
['visit_date','=',date_txt],
|
||||
['patient_id','=',pt.id],
|
||||
['cycle_id','=',cycle.id],
|
||||
#['cycle_id','=',cycle.id], #XXX
|
||||
['department_id','=',department.id],
|
||||
]
|
||||
res=get_model("clinic.visit").search(dom2)
|
||||
|
|
Binary file not shown.
|
@ -1,57 +1,43 @@
|
|||
<center>
|
||||
<h3>
|
||||
{{parent_company_name}} {{company_name}}
|
||||
{{title}}
|
||||
</h3>
|
||||
<h4>
|
||||
{{sub_title}}</br>
|
||||
From {{date_from}} To {{date_to}}
|
||||
</h4>
|
||||
<h5>Draft: {{draft}} Waiting Treatment: {{wait_treat}}, In progress : {{in_progress}}, Finish Treatment: {{finish_treat}}, Waiting Payment: {{wait_pay}} Paid: {{paid}}, Cancelled: {{cancel}} </h5>
|
||||
</center>
|
||||
<table class="table">
|
||||
<thead class="scroll-header">
|
||||
<th>#</th>
|
||||
<th>Number</th>
|
||||
<th>BegHD</th>
|
||||
<th>Epo</th>
|
||||
<th>HN</th>
|
||||
<th>Patient</th>
|
||||
<th>Payers</th>
|
||||
<th>DlzNew</th>
|
||||
<th>HCT</th>
|
||||
<th>Paychk</th>
|
||||
<th>Amount</th>
|
||||
<th>HDCharge</th>
|
||||
<tr>
|
||||
<th colspan="6" style="text-align:center">
|
||||
<span class="label label-primary">TOTAL: {{total_txt}}</span>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="text-align:left">#</th>
|
||||
<th>Date</th>
|
||||
<th>Number</th>
|
||||
<th>Name</th>
|
||||
<th>Note</th>
|
||||
<th>Dispose</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#if lines}}
|
||||
{{#each lines}}
|
||||
<tr>
|
||||
<td>{{no}}</td>
|
||||
<td>
|
||||
{{view "link" string=number action="clinic_hd_case" action_options="mode=form" active_id=hd_case_id}}
|
||||
</td>
|
||||
<td>{{time_start}}</td>
|
||||
<td>{{epo}}</td>
|
||||
<td>{{patient_number}}</td>
|
||||
<td>
|
||||
{{view "link" string=patient_name action="clinic_patient" action_options="mode=form" active_id=patient_id}}
|
||||
</td>
|
||||
<td>{{patient_type}}</td>
|
||||
<td>{{dlz_new}}</td>
|
||||
<td>{{hct}}</td>
|
||||
<td>{{rmb}}</td>
|
||||
<td>{{more_amt}}</td>
|
||||
<td>{{fee_amt}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
{{else}}
|
||||
<tr>
|
||||
<td>
|
||||
No items to display.
|
||||
</td>
|
||||
{{#each lines}}
|
||||
<tr>
|
||||
<td style="text-align:left;width:3%">{{no}}</td>
|
||||
<td style="width:10%">{{date}}</td>
|
||||
<td style="width:10%">{{number}}</td>
|
||||
<td>{{name}}</td>
|
||||
<td>{{note}}</td>
|
||||
<td>{{dispose}}</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<center>
|
||||
<h2>
|
||||
ใบสรุปการทำ Hemodialysis
|
||||
{{title}}
|
||||
</h2>
|
||||
<h3>
|
||||
{{parent_company_name}} {{company_name}}<br/>
|
||||
</h3>
|
||||
<h4>
|
||||
ประจำเดือน {{month}} {{year}}
|
||||
From {{date_from}} To {{date_to}}
|
||||
</h4>
|
||||
</center>
|
||||
<table class="table">
|
||||
|
@ -25,7 +25,10 @@
|
|||
<td>เท่ากับ</td>
|
||||
{{#if qty}}
|
||||
<td>
|
||||
<!--
|
||||
{{view "link" string=qty action=action action_options=action_options}}
|
||||
-->
|
||||
<a href='/ui#name={{link}}' target="_blank">{{qty}}</a>
|
||||
</td>
|
||||
{{else}}
|
||||
<td>
|
||||
|
|
|
@ -8,3 +8,6 @@
|
|||
|
||||
> note:
|
||||
แก้ไขยาก หากมาเจอข้อผิดพลาดบางครั้ง
|
||||
|
||||
> report K. boy
|
||||
- number of treatment is not correct
|
||||
|
|
Loading…
Reference in New Issue