report hd

conv_bal
watcha.h 2014-10-14 14:07:37 +07:00
parent 6f437ceba7
commit 86dc6b5fa3
6 changed files with 87 additions and 93 deletions

View File

@ -1,4 +1,5 @@
<form model="clinic.cycle"> <form model="clinic.cycle">
<field name="name"/> <field name="name"/>
<field name="duration"/> <field name="duration"/>
<field name="sequence"/>
</form> </form>

View File

@ -1,4 +1,5 @@
<list model="clinic.cycle"> <list model="clinic.cycle">
<field name="name"/> <field name="name"/>
<field name="duration"/> <field name="duration"/>
<field name="sequence"/>
</list> </list>

View File

@ -7,10 +7,12 @@ class Cycle(Model):
_fields={ _fields={
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
'duration': fields.Integer("Duration (hrs)"), 'duration': fields.Integer("Duration (hrs)"),
'sequence': fields.Integer("Sequence"),
} }
_defaults={ _defaults={
'duration': 1, 'duration': 1,
'sequence': 1,
} }

View File

@ -19,8 +19,6 @@ class HDReport(Model):
_order="cycle_id desc" _order="cycle_id desc"
def get_report_data(self,ids,context={}): def get_report_data(self,ids,context={}):
obj=self.browse(ids)[0]
lines=[]
PATIENT_TYPE={ PATIENT_TYPE={
"mg":"Medical Government", "mg":"Medical Government",
"sc":"Social Security", "sc":"Social Security",
@ -28,33 +26,79 @@ class HDReport(Model):
"personal": "Personal", "personal": "Personal",
"others": "Others", "others": "Others",
} }
date=time.strftime("%Y-%m-%d")
dom=[] dom=[]
dom.append([ dom.append(['state','=','completed'])
'state','=','completed', if ids:
]) obj=self.browse(ids)[0]
if obj.cycle_id: if obj.date:
dom.append([ date=obj.date
'cycle_id','=',obj.cycle_id.id, if obj.cycle_id:
]) dom.append([
'cycle_id','=',obj.cycle_id.id,
if obj.date: ])
dom.append(['time_start', ">=", obj.date+" 00:00:00"]) dom.append(['time_start', ">=", date+" 00:00:00"])
dom.append(['time_stop', "<=", obj.date+" 23:59:59"]) dom.append(['time_stop', "<=", date+" 23:59:59"])
print("dom ", dom) print("dom ", dom)
for hd_case in get_model("clinic.hd.case").search_browse(dom): lines=[]
cycles=[]
index=0
no_patient=0
for hd_case in get_model("clinic.hd.case").search_browse(dom,order="cycle_id.sequence"):
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)
lines.append({ cycle_name=hd_case.cycle_id.name or ""
'cycle' : hd_case.cycle_id.name, show_cycle=False
if not cycle_name in cycles:
cycles.append(cycle_name)
show_cycle=True
if index > 1:
vals={
'color': 'success',
'show_cycle': False,
'cycle' : "",
'patient': "",
'no_patient': no_patient,
'patient_type' : "",
'doctor' : "",
'total' : "",
'rc_no' : "",
'nurse' : "",
}
lines.append(vals)
no_patient=1
else:
no_patient+=1
index+=1
vals={
'show_cycle': show_cycle,
'cycle' : cycle_name,
'patient': hd_case.patient_id.name, 'patient': hd_case.patient_id.name,
'patient_type' : patient_type, 'patient_type' : patient_type,
'no_patient': 0,
'doctor' : hd_case.doctor_id.name, 'doctor' : hd_case.doctor_id.name,
'total' : hd_case.fee, 'total' : hd_case.fee,
'rc_no' : hd_case.number, 'rc_no' : hd_case.number,
'nurse' : hd_case.nurse_id.name, 'nurse' : hd_case.nurse_id.name,
}) }
lines.append(vals)
# XXX
if lines:
vals={
'color': 'success',
'show_cycle': False,
'cycle' : "",
'patient': "",
'no_patient': no_patient,
'patient_type' : "",
'doctor' : "",
'total' : "",
'rc_no' : "",
'nurse' : "",
}
lines.append(vals)
data={ data={
'lines': lines, 'lines': lines,
} }

View File

@ -1,63 +0,0 @@
<center>
<h2>
HD Case Report
</h2>
</center>
<table class="table table-striped">
<thead class="scroll-header">
<tr>
<th>
Cycle
</th>
<th>
Patient
</th>
<th>
Doctor
</th>
<th>
HD Fee
</th>
<th>
RC.No
</th>
<th>
Nurse
</th>
</tr>
</thead>
<tbody>
{{#each lines context=context}}
<tr>
<td colspan="10" style="font-weight:bold">
{{cycle}}
</td>
</tr>
<tr>
<td>
</td>
<td>
{{patient}}
</td>
<td>
{{doctor}}
</td>
<td>
{{total}}
</td>
<td>
{{rc_no}}
</td>
<td>
{{nurse}}
</td>
</tr>
{{/each}}
</tbody>
<tfoot>
<tr style="font-weight:bold">
</tr>
</tfoot>
</table>

View File

@ -15,6 +15,9 @@
<th> <th>
Doctor Doctor
</th> </th>
<th>
Patient Type
</th>
<th> <th>
HD Fee HD Fee
</th> </th>
@ -28,21 +31,27 @@
</thead> </thead>
<tbody> <tbody>
{{#each lines context=context}} {{#each lines context=context}}
<tr> {{#if show_cycle}}
<td colspan="10" style="font-weight:bold"> <tr>
{{cycle}} <td colspan="10" style="font-weight:bold">
</td> {{cycle}}
</tr> </td>
<tr> </tr>
<td> {{/if}}
<tr class="{{color}}">
</td> {{#if no_patient}}
<td> <td>Total</td>
{{patient}} <td>{{no_patient}}</td>
</td> {{else}}
<td></td>
<td>{{patient}}</td>
{{/if}}
<td> <td>
{{doctor}} {{doctor}}
</td> </td>
<td>
{{patient_type}}
</td>
<td> <td>
{{total}} {{total}}
</td> </td>