HD Case Report Summary [monthly]
parent
3201f414c2
commit
e2a8ec7431
|
@ -1,4 +1,5 @@
|
|||
import time
|
||||
|
||||
from datetime import datetime
|
||||
from calendar import monthrange
|
||||
|
||||
|
@ -19,27 +20,92 @@ class ReportHDMonthly(Model):
|
|||
|
||||
def get_report_data(self,ids,context={}):
|
||||
date=datetime.now().strftime("%Y-%m-%d")
|
||||
datemonth=datetime.now().strftime("%m")
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
date=obj.date
|
||||
year=int(date[0:4])
|
||||
month=int(date[5:7])
|
||||
month_str=datetime.strptime(date,'%Y-%m-%d').strftime("%B")
|
||||
next_month = str(month + 1)
|
||||
if next_month == 13:
|
||||
next_month = 12
|
||||
next_month_str=datetime.strptime(next_month,'%m').strftime("%B")
|
||||
|
||||
previous_month = str(month - 1)
|
||||
if previous_month == 0:
|
||||
previous_month = 12
|
||||
previous_month_str=datetime.strptime(previous_month,'%m').strftime("%B")
|
||||
|
||||
patients=get_model("clinic.patient").search_browse(['type','=','All'])
|
||||
patients_mg=get_model("clinic.patient").search_browse(['type','=','mg'])
|
||||
patients_sc=get_model("clinic.patient").search_browse(['type','=','sc'])
|
||||
patients_nhso=get_model("clinic.patient").search_browse(['type','=','nhso'])
|
||||
patients_pn=get_model("clinic.patient").search_browse(['type','=','personal'])
|
||||
|
||||
new_patients=0
|
||||
if datemonth==month:
|
||||
new_patients= len(patients)
|
||||
|
||||
weekday, total_day=monthrange(year, month)
|
||||
time_start='2014-%s-01 00:00:00'%(month)
|
||||
time_stop='2014-%s-%s 23:59:59'%(month,total_day)
|
||||
lines=[]
|
||||
|
||||
dom=[]
|
||||
dom.append(['state','=','completed'])
|
||||
dom.append(['time_start','>=',time_start])
|
||||
dom.append(['time_stop','<=',time_stop])
|
||||
|
||||
hd_cases=get_model("clinic.hd.case").search_browse(dom)
|
||||
for hd_case in hd_cases:
|
||||
lines.append({
|
||||
|
||||
lines=[
|
||||
{
|
||||
'topic': 'The number of times the Hemodialysis',
|
||||
'month': month_str,
|
||||
'amount': len(hd_cases),
|
||||
})
|
||||
},
|
||||
|
||||
{
|
||||
'topic':'The number of cases brought',
|
||||
'month': previous_month_str,
|
||||
'amount': 'N/A',
|
||||
},
|
||||
{
|
||||
'topic':'Number of new patients',
|
||||
'month': month_str,
|
||||
'amount': new_patients,
|
||||
},
|
||||
{
|
||||
'topic':'Number of patients discharged',
|
||||
'month': month_str,
|
||||
'amount': 'N/A',
|
||||
},
|
||||
{
|
||||
'topic':'The number of cases brought',
|
||||
'month': next_month_str,
|
||||
'amount': 0,
|
||||
},
|
||||
{
|
||||
'topic':'Number of patients withdrawn Social Security',
|
||||
'month': '',
|
||||
'amount': len(patients_sc),
|
||||
},
|
||||
{
|
||||
'topic':'Number of patients withdrawn Medical Government',
|
||||
'month':'',
|
||||
'amount': len(patients_mg),
|
||||
},
|
||||
{
|
||||
'topic':'Number of patients withdrawn NHSO(30B)',
|
||||
'month':'',
|
||||
'amount': len(patients_nhso),
|
||||
},
|
||||
{
|
||||
'topic':'Many patients pay themselves',
|
||||
'month': '',
|
||||
'amount': len(patients_pn),
|
||||
},
|
||||
]
|
||||
|
||||
data={
|
||||
'month': month_str,
|
||||
|
@ -47,6 +113,5 @@ class ReportHDMonthly(Model):
|
|||
'lines': lines,
|
||||
}
|
||||
return data
|
||||
|
||||
|
||||
ReportHDMonthly.register()
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue