hd case detail
parent
280e663e0b
commit
b1d8f317ac
|
@ -0,0 +1,8 @@
|
|||
<action>
|
||||
<field name="string">HD Case Report Detail</field>
|
||||
<field name="view_cls">report</field>
|
||||
<field name="model">clinic.report.hd.case.detail</field>
|
||||
<field name="report_template">report_hd_case_detail</field>
|
||||
<field name="report_template_xls">report_hd_case_detail</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -50,6 +50,7 @@
|
|||
<item string="Reporting" perm="clinic_report">
|
||||
<item string="Visit Summary" action="clinic_report_visit"/>
|
||||
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
||||
<item string="HD Case Detail" action="clinic_report_hd_case_detail"/>
|
||||
<item string="Medical Summary" action="clinic_report_medical_summary"/>
|
||||
<item string="Recent Patient" action="clinic_report_recent_patient"/>
|
||||
<item string="Discontinue Patient" action="clinic_report_discontinue_patient"/>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<form model="clinic.report.hd.case.detail">
|
||||
<!--<field name="date" span="3" mode="month" onchange="onchange_date"/>-->
|
||||
<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="branch_id" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
</form>
|
|
@ -63,7 +63,7 @@ from . import load_nurse_line
|
|||
from . import report_clinic
|
||||
from . import report_visit
|
||||
from . import report_hd_case_summary
|
||||
#from . import report_hd_case_detail
|
||||
from . import report_hd_case_detail
|
||||
from . import report_medical_summary
|
||||
from . import report_recent_patient
|
||||
from . import report_discontinue_patient
|
||||
|
|
|
@ -1,213 +1,152 @@
|
|||
import time
|
||||
import urllib.parse as urllib
|
||||
|
||||
from datetime import datetime
|
||||
from calendar import monthrange
|
||||
from netforce.model import Model, fields, get_model
|
||||
|
||||
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"
|
||||
_string="Hemodialysis Report Detail"
|
||||
_string="Report HDCase Detail"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
"date": fields.Date("Month", required=True),
|
||||
"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"),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
}
|
||||
|
||||
def _get_date_from(self,context={}):
|
||||
year,month=time.strftime("%Y-%m").split("-")
|
||||
return '%s-%s-01'%(year,month)
|
||||
return time.strftime("%Y-%m-%d")
|
||||
|
||||
def _get_date_to(self,context={}):
|
||||
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
return "%s-%s-%s"%(year,month,total_day)
|
||||
return time.strftime("%Y-%m-%d")
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'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=datetime.now().strftime("%Y-%m-%d")
|
||||
year=int(date[0:4])
|
||||
crr_month=int(date[5:7])
|
||||
weekday, crr_total_day=monthrange(year, crr_month)
|
||||
|
||||
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)
|
||||
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=obj.date
|
||||
time_start='%s 00:00:00'%obj.date_from
|
||||
time_stop='%s 23:59:59'%obj.date_to
|
||||
year=int(date[0:4])
|
||||
|
||||
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 encode_url(dom):
|
||||
dom='%s'%dom
|
||||
dom=urllib.quote(dom.encode('utf-8'))
|
||||
return dom
|
||||
|
||||
def replace_quote(dom=""):
|
||||
return dom.replace("'","\"")
|
||||
|
||||
count=1
|
||||
# number of hd case of this month
|
||||
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(["time_start",">=",time_start])
|
||||
dom.append(["time_stop","<=",time_stop])
|
||||
dom.append(["state","in",["completed","waiting_payment","paid"]])
|
||||
crr_total=len(get_model("clinic.hd.case").search(dom))
|
||||
items={}
|
||||
items['topic%s'%count]={
|
||||
'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),
|
||||
}
|
||||
count+=1
|
||||
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])
|
||||
|
||||
# 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])
|
||||
npatient=len(get_model("clinic.patient").search(dom))
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic%s'%count]={
|
||||
'month': prev_month_str,
|
||||
'qty': npatient or 0,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
}
|
||||
count+=1
|
||||
|
||||
# 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])
|
||||
new_patients=get_model('clinic.patient').search_browse(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic%s'%count]={
|
||||
'month': month_str,
|
||||
'qty': len(new_patients) or 0,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
}
|
||||
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(['active','=',False])
|
||||
resign_patients=get_model('clinic.patient').search_browse(dom)
|
||||
del dom[-1]
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic%s'%count]={
|
||||
'month': month_str,
|
||||
'qty': len(resign_patients) or 0,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=1'%dom,
|
||||
}
|
||||
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])
|
||||
total_patient=get_model('clinic.patient').search_browse(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic%s'%count]={
|
||||
'month': next_month_str,
|
||||
'qty': len(total_patient) or 0,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
}
|
||||
count+=1
|
||||
|
||||
topics=utils.TOPICS
|
||||
for ptype in get_model("clinic.patient.type").search_read([[]],['name']):
|
||||
tkey='topic%s'%count
|
||||
topics.update({
|
||||
tkey:{
|
||||
'name': ptype['name'],
|
||||
'unit': 'คน',
|
||||
}
|
||||
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
|
||||
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,
|
||||
})
|
||||
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_start])
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['type_id','=',ptype['id']])
|
||||
npatients=get_model("clinic.patient").search(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items[tkey]={
|
||||
'month': '',
|
||||
'qty': len(npatients),
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
}
|
||||
count+=1
|
||||
|
||||
lines=[]
|
||||
index=1
|
||||
for item in items:
|
||||
topic='topic%s'%index
|
||||
name=utils.TOPICS[topic]['name']
|
||||
unit=utils.TOPICS[topic]['unit']
|
||||
line=items[topic]
|
||||
line['topic']=name
|
||||
line['unit']=unit
|
||||
lines.append(line)
|
||||
index+=1
|
||||
|
||||
context['defaults']={'date': date}
|
||||
|
||||
medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)
|
||||
year=year+543
|
||||
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={
|
||||
'date': date,
|
||||
'month': month_str,
|
||||
'year': year,
|
||||
'lines': lines,
|
||||
'recent_patients': get_model("clinic.report.recent.patient").get_report_data(ids=[],context=context)['lines'],
|
||||
'resign_patients': get_model("clinic.report.discontinue.patient").get_report_data(ids=[],context=context)['lines'],
|
||||
'medicals': medicals['lines'],
|
||||
'titles': medicals['titles'],
|
||||
'company_name': company.name or "",
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
'lines': lines,
|
||||
'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,
|
||||
}
|
||||
return data
|
||||
|
||||
|
@ -220,4 +159,9 @@ class ReportHDCaseDetail(Model):
|
|||
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||
return data
|
||||
|
||||
def onchange_date_from(self,context={}):
|
||||
data=context['data']
|
||||
data['date_to']=data['date_from']
|
||||
return data
|
||||
|
||||
ReportHDCaseDetail.register()
|
||||
|
|
Binary file not shown.
|
@ -0,0 +1,57 @@
|
|||
<center>
|
||||
<h3>
|
||||
{{parent_company_name}} {{company_name}}
|
||||
</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>
|
||||
</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>
|
||||
</tr>
|
||||
{{/if}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue