clinic/netforce_clinic/models/report_hd.py

42 lines
1.1 KiB
Python

import time
from netforce.model import Model, fields, get_model
class HDReport(Model):
_name="clinic.hd.report"
_string="HD Report"
_transient=True
_fields={
"date": fields.Date("Date"),
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
}
_defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"),
}
_order="cycle_id desc"
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,
})
data={
'cycle_id': hd_case_ids.cycle or "Empty Cyle",
'lines': lines,
}
return data
HDReport.register()