184 lines
5.0 KiB
Python
184 lines
5.0 KiB
Python
|
import time
|
||
|
|
||
|
from datetime import datetime
|
||
|
from calendar import monthrange
|
||
|
from netforce.model import Model,fields,get_model
|
||
|
|
||
|
class ReportHDMedical(Model):
|
||
|
_name="clinic.report.hd.medical"
|
||
|
_string="Hemodialysis Report Medical 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={}):
|
||
|
|
||
|
for item in get_model("company").search_browse([]):
|
||
|
company_name=item.name
|
||
|
|
||
|
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")
|
||
|
|
||
|
#dom=[]
|
||
|
#dom.append(['fee_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])
|
||
|
|
||
|
for product in get_model("clinic.hd.case.gm.line").search_browse([]):
|
||
|
product_id=product.product_id.Product_id
|
||
|
#product_total=len(product_id)
|
||
|
#print(product_id)
|
||
|
if product_id:
|
||
|
product_name=product.description or ""
|
||
|
#product_id=product.product_id.id or ""
|
||
|
|
||
|
|
||
|
lines=[
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : product_name,
|
||
|
'mg': '',
|
||
|
'uc': '437',
|
||
|
'sc': '',
|
||
|
'buy' : '4',
|
||
|
'total' : '441',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'H2',
|
||
|
'mg': '',
|
||
|
'uc': '',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Epr4',
|
||
|
'mg': '',
|
||
|
'uc': '216',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '216',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Epr2',
|
||
|
'mg': '437',
|
||
|
'uc': '',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Epk4',
|
||
|
'mg': '437',
|
||
|
'uc': '70',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '70',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Epk2',
|
||
|
'mg': '437',
|
||
|
'uc': '',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Epg4',
|
||
|
'mg': '437',
|
||
|
'uc': '98',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '98',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Epg2',
|
||
|
'mg': '437',
|
||
|
'uc': '',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Rng4',
|
||
|
'mg': '437',
|
||
|
'uc': '34',
|
||
|
'sc': '',
|
||
|
'buy' : '9',
|
||
|
'total' : '43',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Rng2',
|
||
|
'mg': '437',
|
||
|
'uc': '',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Epi4',
|
||
|
'mg': '437',
|
||
|
'uc': '264',
|
||
|
'sc': '',
|
||
|
'buy' : '9',
|
||
|
'total' : '43',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Epi2',
|
||
|
'mg': '437',
|
||
|
'uc': '',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '',
|
||
|
},
|
||
|
{
|
||
|
'product_id' : 'MD-XXXX',
|
||
|
'madical' : 'Vnf',
|
||
|
'mg': '437',
|
||
|
'uc': '',
|
||
|
'sc': '',
|
||
|
'buy' : '',
|
||
|
'total' : '',
|
||
|
},
|
||
|
]
|
||
|
|
||
|
data={
|
||
|
'month': month_str,
|
||
|
'year': year,
|
||
|
'lines': lines,
|
||
|
'company_name': company_name,
|
||
|
}
|
||
|
return data
|
||
|
|
||
|
ReportHDMedical.register()
|