clinic/netforce_clinic/models/report_hd.py

42 lines
1.1 KiB
Python
Raw Normal View History

2014-10-09 10:53:01 +00:00
import time
from netforce.model import Model, fields, get_model
2014-10-09 10:53:01 +00:00
class HDReport(Model):
_name="clinic.hd.report"
_string="HD Report"
_transient=True
_fields={
"date": fields.Date("Date"),
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
2014-10-09 10:53:01 +00:00
}
_defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"),
}
_order="cycle_id desc"
2014-10-09 10:53:01 +00:00
def get_report_data(self,ids,context={}):
lines=[]
hd_case_ids=get_model("clinic.dialyzer").search([["state","=","completed"]])
hd_cases=get_model("clinic.hd.case").search_browse([])
for hd_case_ids in hd_cases:
lines.append({
'cycle' : hd_case_ids.cycle_id.name,
'patient': hd_case_ids.patient_id.name,
'doctor' : hd_case_ids.doctor_id.name,
'total' : hd_case_ids.fee,
'rc_no' : hd_case_ids.number,
'nurse' : hd_case_ids.nurse_id.name,
})
2014-10-09 10:53:01 +00:00
data={
'cycle_id': hd_case_ids.cycle or "Empty Cyle",
'lines': lines,
2014-10-09 10:53:01 +00:00
}
return data
HDReport.register()