Link Report to Data

conv_bal
chayut.s 2014-10-24 13:58:31 +07:00
parent 20f304274d
commit 3215e9b638
3 changed files with 49 additions and 20 deletions

View File

@ -1,7 +1,7 @@
import time import time
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
#from netforce.access import get_active_company
class ReportHDDetail(Model): class ReportHDDetail(Model):
_name="clinic.report.hd.detail" _name="clinic.report.hd.detail"
@ -15,6 +15,8 @@ class ReportHDDetail(Model):
"date_from": fields.Date("From"), "date_from": fields.Date("From"),
"date_to": fields.Date("To"), "date_to": fields.Date("To"),
"cycle_id": fields.Many2One("clinic.cycle","Cycle"), "cycle_id": fields.Many2One("clinic.cycle","Cycle"),
"type": fields.Selection([("mg","Medical Goverment"),("sc","Social Security"),("nhso","NHSO (30B)"),("personal","Personal"),("other","Other")],"Type"),
} }
_defaults={ _defaults={
@ -38,20 +40,14 @@ class ReportHDDetail(Model):
date_from=time.strftime("%Y-%m-%d") date_from=time.strftime("%Y-%m-%d")
date_to=time.strftime("%Y-%m-%d") date_to=time.strftime("%Y-%m-%d")
# print('date_from ',date_from)
defaults=context.get("defaults") defaults=context.get("defaults")
if defaults: if defaults:
if defaults.get("date_from"): if defaults.get("date_from"):
date_from=defaults['date_from'] date_from=defaults['date_from']
if defaults.get("date_to"): if defaults.get("date_to"):
date_to=defaults['date_to'] date_to=defaults['date_to']
# date_to=context['date_to']
# default => key => dataults
# date_from=context['date_from']
# print(context['date_from'])
#'2014-10-13'
# print('date_from ',date_from)
# print('date_to ',date_to)
PATIENT_TYPE={ PATIENT_TYPE={
"mg":"Medical Government", "mg":"Medical Government",
"sc":"Social Security", "sc":"Social Security",
@ -84,7 +80,11 @@ class ReportHDDetail(Model):
dom.append([ dom.append([
'doctor_id','=',obj.doctor_id.id, 'doctor_id','=',obj.doctor_id.id,
]) ])
if obj.type_id:
dom.append([
'type','=',obj.type_id.id,
])
dom.append(['time_start', ">=", date_from+" 00:00:00"]) dom.append(['time_start', ">=", date_from+" 00:00:00"])
dom.append(['time_stop',"<=", date_to+" 23:59:59"]) dom.append(['time_stop',"<=", date_to+" 23:59:59"])
lines=[] lines=[]
@ -92,10 +92,17 @@ class ReportHDDetail(Model):
index=0 index=0
no_patient=0 no_patient=0
for hd_case in get_model("clinic.hd.case").search_browse(dom,order="cycle_id.sequence"): for hd_case in get_model("clinic.hd.case").search_browse(dom,order="cycle_id.sequence"):
#print('='*50)
#for line in hd_case.line:
# dialyzer_id=line.dialyzer_id
# if dialyzer_id:
# dialyzer_number=line.number or ""
# print(dialyzer_number)
#print('='*50)
patient_type=hd_case.patient_id.type patient_type=hd_case.patient_id.type
patient_type=PATIENT_TYPE.get(patient_type) patient_type=PATIENT_TYPE.get(patient_type)
#dialyzer_name=hd_case.dialyzers.id #dialyzer=get_model("clinic.dialyzer").search_browse([])
#dialyzer_name=DIALYZER_NAME.get(dialyzer_name)
cycle_name=hd_case.cycle_id.name or "" cycle_name=hd_case.cycle_id.name or ""
show_cycle=False show_cycle=False
if not cycle_name in cycles: if not cycle_name in cycles:
@ -122,14 +129,18 @@ class ReportHDDetail(Model):
vals={ vals={
'show_cycle': show_cycle, 'show_cycle': show_cycle,
'cycle' : cycle_name, 'cycle' : cycle_name,
'patient': hd_case.patient_id.name, 'patient_id': hd_case.patient_id.id,
'patient_name': hd_case.patient_id.name,
'patient_type' : patient_type, 'patient_type' : patient_type,
'no_patient': 0, 'no_patient': 0,
'doctor' : hd_case.doctor_id.name, 'doctor_id': hd_case.doctor_id.id,
'doctor_name' : hd_case.doctor_id.name,
'total' : hd_case.total, 'total' : hd_case.total,
'hd_case_id' : hd_case.id,
'rc_no' : hd_case.number, 'rc_no' : hd_case.number,
'dialyzer_name' : 'DZ-xxx', 'dialyzer_number' : 'DZ-XXXX',
'nurse' : hd_case.nurse_id.name, 'nurse_id': hd_case.nurse_id.id,
'nurse_name' : hd_case.nurse_id.name,
} }
lines.append(vals) lines.append(vals)

View File

@ -46,22 +46,30 @@ class ReportHDMadical(Model):
weekday, total_day=monthrange(year, month) weekday, total_day=monthrange(year, month)
time_start='2014-%s-01 00:00:00'%(month) time_start='2014-%s-01 00:00:00'%(month)
time_stop='2014-%s-%s 23:59:59'%(month,total_day) time_stop='2014-%s-%s 23:59:59'%(month,total_day)
dom=[] dom=[]
dom.append(['state','=','completed']) dom.append(['state','=','completed'])
dom.append(['time_start','>=',time_start]) dom.append(['time_start','>=',time_start])
dom.append(['time_stop','<=',time_stop]) dom.append(['time_stop','<=',time_stop])
#hd_cases=get_model("clinic.hd.case.gm.line").search_browse(dom)
for product in get_model("clinic.hd.case.gm.line").search_browse([]):
product_id=product.product_id
print(product_id)
if product_id:
product_name=product.description or ""
product_id=product.product_id or ""
lines=[ lines=[
{ {
'madical' : 'H4', 'product_id' : 'MD-XXXX',
'madical' : product_name,
'sc': '437', 'sc': '437',
'uc': '', 'uc': '',
'buy' : '4', 'buy' : '4',
'total' : '441', 'total' : '441',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'H2', 'madical' : 'H2',
'sc': '', 'sc': '',
'uc': '', 'uc': '',
@ -69,6 +77,7 @@ class ReportHDMadical(Model):
'total' : '', 'total' : '',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Epr4', 'madical' : 'Epr4',
'sc': '216', 'sc': '216',
'uc': '', 'uc': '',
@ -76,6 +85,7 @@ class ReportHDMadical(Model):
'total' : '216', 'total' : '216',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Epr2', 'madical' : 'Epr2',
'sc': '', 'sc': '',
'uc': '', 'uc': '',
@ -83,6 +93,7 @@ class ReportHDMadical(Model):
'total' : '', 'total' : '',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Epk4', 'madical' : 'Epk4',
'sc': '70', 'sc': '70',
'uc': '', 'uc': '',
@ -90,6 +101,7 @@ class ReportHDMadical(Model):
'total' : '70', 'total' : '70',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Epk2', 'madical' : 'Epk2',
'sc': '', 'sc': '',
'uc': '', 'uc': '',
@ -97,6 +109,7 @@ class ReportHDMadical(Model):
'total' : '', 'total' : '',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Epg4', 'madical' : 'Epg4',
'sc': '98', 'sc': '98',
'uc': '', 'uc': '',
@ -104,6 +117,7 @@ class ReportHDMadical(Model):
'total' : '98', 'total' : '98',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Epg2', 'madical' : 'Epg2',
'sc': '', 'sc': '',
'uc': '', 'uc': '',
@ -111,6 +125,7 @@ class ReportHDMadical(Model):
'total' : '', 'total' : '',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Rng4', 'madical' : 'Rng4',
'sc': '34', 'sc': '34',
'uc': '', 'uc': '',
@ -118,6 +133,7 @@ class ReportHDMadical(Model):
'total' : '43', 'total' : '43',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Rng2', 'madical' : 'Rng2',
'sc': '', 'sc': '',
'uc': '', 'uc': '',
@ -125,6 +141,7 @@ class ReportHDMadical(Model):
'total' : '', 'total' : '',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Epi4', 'madical' : 'Epi4',
'sc': '264', 'sc': '264',
'uc': '', 'uc': '',
@ -132,6 +149,7 @@ class ReportHDMadical(Model):
'total' : '43', 'total' : '43',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Epi2', 'madical' : 'Epi2',
'sc': '', 'sc': '',
'uc': '', 'uc': '',
@ -139,6 +157,7 @@ class ReportHDMadical(Model):
'total' : '', 'total' : '',
}, },
{ {
'product_id' : 'MD-XXXX',
'madical' : 'Vnf', 'madical' : 'Vnf',
'sc': '', 'sc': '',
'uc': '', 'uc': '',

View File

@ -55,7 +55,6 @@ class ReportHDSummary(Model):
dom.append(['time_start','>=',time_start]) dom.append(['time_start','>=',time_start])
dom.append(['time_stop','<=',time_stop]) dom.append(['time_stop','<=',time_stop])
dom=[] dom=[]
dom.append(['type','=','mg']) dom.append(['type','=','mg'])
patients_mg=len(get_model("clinic.patient").search(dom)) patients_mg=len(get_model("clinic.patient").search(dom))