154 lines
4.1 KiB
Python
154 lines
4.1 KiB
Python
import time
|
|
|
|
from datetime import datetime
|
|
from calendar import monthrange
|
|
from netforce.model import Model,fields
|
|
|
|
class ReportHDMadical(Model):
|
|
_name="clinic.report.hd.madical"
|
|
_string="Hemodialysis Report Madical Summary"
|
|
_transient=True
|
|
|
|
_fields={
|
|
"date": fields.Date("Month", required=True),
|
|
}
|
|
|
|
_defaults={
|
|
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
|
}
|
|
|
|
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")
|
|
|
|
#madical=get_model("clinic.hd.case.gm.line").search_browse()
|
|
#patients_mg=get_model("clinic.patient").search_browse(['type','=','mg'])
|
|
|
|
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)
|
|
|
|
dom=[]
|
|
dom.append(['state','=','completed'])
|
|
dom.append(['time_start','>=',time_start])
|
|
dom.append(['time_stop','<=',time_stop])
|
|
#hd_cases=get_model("clinic.hd.case.gm.line").search_browse(dom)
|
|
|
|
lines=[
|
|
{
|
|
'madical' : 'H4',
|
|
'sc': '437',
|
|
'uc': '',
|
|
'buy' : '4',
|
|
'total' : '441',
|
|
},
|
|
{
|
|
'madical' : 'H2',
|
|
'sc': '',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '',
|
|
},
|
|
{
|
|
'madical' : 'Epr4',
|
|
'sc': '216',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '216',
|
|
},
|
|
{
|
|
'madical' : 'Epr2',
|
|
'sc': '',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '',
|
|
},
|
|
{
|
|
'madical' : 'Epk4',
|
|
'sc': '70',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '70',
|
|
},
|
|
{
|
|
'madical' : 'Epk2',
|
|
'sc': '',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '',
|
|
},
|
|
{
|
|
'madical' : 'Epg4',
|
|
'sc': '98',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '98',
|
|
},
|
|
{
|
|
'madical' : 'Epg2',
|
|
'sc': '',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '',
|
|
},
|
|
{
|
|
'madical' : 'Rng4',
|
|
'sc': '34',
|
|
'uc': '',
|
|
'buy' : '9',
|
|
'total' : '43',
|
|
},
|
|
{
|
|
'madical' : 'Rng2',
|
|
'sc': '',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '',
|
|
},
|
|
{
|
|
'madical' : 'Epi4',
|
|
'sc': '264',
|
|
'uc': '',
|
|
'buy' : '9',
|
|
'total' : '43',
|
|
},
|
|
{
|
|
'madical' : 'Epi2',
|
|
'sc': '',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '',
|
|
},
|
|
{
|
|
'madical' : 'Vnf',
|
|
'sc': '',
|
|
'uc': '',
|
|
'buy' : '',
|
|
'total' : '',
|
|
},
|
|
]
|
|
|
|
data={
|
|
'month': month_str,
|
|
'year': year,
|
|
'lines': lines,
|
|
}
|
|
return data
|
|
|
|
ReportHDMadical.register()
|