report detail

conv_bal
watcha.h 2014-11-05 00:18:58 +07:00
parent b892f55408
commit c8f37e0414
4 changed files with 27 additions and 211 deletions

View File

@ -1,11 +1,10 @@
<form model="clinic.report.hd.case.detail"> <form model="clinic.report.hd.case.detail">
<group> <group>
<field name="patient_id" span="3"/>
<field name="doctor_id" span="3"/>
<field name="nurse_id" span="3"/>
<newline/>
<field name="date_from" span="3"/> <field name="date_from" span="3"/>
<field name="date_to" span="3"/> <field name="date_to" span="3"/>
<field name="cycle_id" span="3"/> <field name="cycle_id" span="3"/>
<newline/>
<field name="patient_id" span="3"/>
<field name="doctor_id" span="3"/>
</group> </group>
</form> </form>

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 . import utils
class ReportHDCaseDetail(Model): class ReportHDCaseDetail(Model):
_name="clinic.report.hd.case.detail" _name="clinic.report.hd.case.detail"
@ -40,14 +40,7 @@ class ReportHDCaseDetail(Model):
if defaults.get("date_to"): if defaults.get("date_to"):
date_to=defaults['date_to'] date_to=defaults['date_to']
PATIENT_TYPE={ obj_doctor_id=None
"mg":"Medical Government",
"sc":"Social Security",
"nhso":"NHSO (30฿)",
"personal": "Personal",
"others": "Others",
}
dom=[] dom=[]
dom.append(['state','=','completed']) dom.append(['state','=','completed'])
if ids: if ids:
@ -64,18 +57,8 @@ class ReportHDCaseDetail(Model):
dom.append([ dom.append([
'patient_id','=',obj.patient_id.id, 'patient_id','=',obj.patient_id.id,
]) ])
if obj.nurse_id:
dom.append([
'nurse_id','=',obj.nurse_id.id,
])
if obj.doctor_id: if obj.doctor_id:
dom.append([ obj_doctor_id=obj.doctor_id
'doctor_id','=',obj.doctor_id.id,
])
"""if obj.patient_id:
dom.append([
'type','=',obj.patient_id.type,
])"""
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"])
@ -84,14 +67,22 @@ class ReportHDCaseDetail(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"):
dialyzer_number=hd_case.dlz_id.number or ""
for total in get_model("clinic.hd.case.line").search_browse([]): dialyzer_id=hd_case.dlz_id.id or ""
total_fee=total.price or ""
dialyzer_number=hd_case.dlz_id.id or ""
patient_type=hd_case.patient_id.type patient_type=hd_case.patient_id.type
patient_type=PATIENT_TYPE.get(patient_type) patient_type=utils.PATIENT_TYPE.get(patient_type)
cycle_name=hd_case.cycle_id.name or "" cycle_name=hd_case.cycle_id.name or ""
total_fee=hd_case.fee_amount or 0.0
doctors=[p for p in hd_case.personals if p.type=='doctor' and p.priop=='owner']
doctor_id=None
if doctors:
doctor_id=doctors[0].personal_id
# XXX
if obj_doctor_id:
if not obj_doctor_id.id==doctor_id.id:
continue
show_cycle=False show_cycle=False
if not cycle_name in cycles: if not cycle_name in cycles:
cycles.append(cycle_name) cycles.append(cycle_name)
@ -121,14 +112,13 @@ class ReportHDCaseDetail(Model):
'patient_name': hd_case.patient_id.name, 'patient_name': hd_case.patient_id.name,
'patient_type' : patient_type, 'patient_type' : patient_type,
'no_patient': 0, 'no_patient': 0,
'doctor_id': hd_case.doctor_id.id, 'doctor_id': doctor_id.id,
'doctor_name' : hd_case.doctor_id.name, 'doctor_name' : doctor_id.name,
'total' : total_fee, 'total' : total_fee,
'hd_case_id' : hd_case.id, 'hd_case_id' : hd_case.id,
'rc_no' : hd_case.number, 'rc_no' : hd_case.number,
'dialyzer_number' : dialyzer_number, 'dialyzer_number' : dialyzer_number,
'nurse_id': hd_case.nurse_id.id, 'dialyzer_id' : dialyzer_id,
'nurse_name' : hd_case.nurse_id.name,
} }
lines.append(vals) lines.append(vals)

View File

@ -1,173 +0,0 @@
import time
from netforce.model import Model, fields, get_model
class ReportHDCasePayment(Model):
_name="clinic.report.hd.case.payment"
_string="Hemodialysis Report Payment"
_transient=True
_fields={
"patient_id" : fields.Many2One("clinic.patient","Patient"),
"doctor_id" : fields.Many2One("clinic.personal","Doctor",domain=[['type','=','doctor']]),
"nurse_id" : fields.Many2One("clinic.personal","Nurse",domain=[['type','=','nurse']]),
"date_from": fields.Date("From"),
"date_to": fields.Date("To"),
"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={
'date_from': lambda *a: time.strftime("%Y-%m-%d"),
'date_to': lambda *a: time.strftime("%Y-%m-%d"),
}
_order="cycle_id desc"
def get_report_data(self,ids,context={}):
# company_id=get_active_company
# comp=get_model("company").browse(company_id)
# context=> dict
# inside context => keys => defaults => type => dict
# dict => key: value => '', 1, [], {}
# context['default'] => defaults(dict) => key => inside key => value => '2014-10-22'
for item in get_model("company").search_browse([]):
company_name=item.name
date_from=time.strftime("%Y-%m-%d")
date_to=time.strftime("%Y-%m-%d")
defaults=context.get("defaults")
if defaults:
if defaults.get("date_from"):
date_from=defaults['date_from']
if defaults.get("date_to"):
date_to=defaults['date_to']
PATIENT_TYPE={
"mg":"Medical Government",
"sc":"Social Security",
"nhso":"NHSO (30฿)",
"personal": "Personal",
"others": "Others",
}
dom=[]
dom.append(['state','=','completed'])
if ids:
obj=self.browse(ids)[0]
if obj.date_from:
date_from=obj.date_from
if obj.date_to:
date_to=obj.date_to
if obj.cycle_id:
dom.append([
'cycle_id','=',obj.cycle_id.id,
])
if obj.patient_id:
dom.append([
'patient_id','=',obj.patient_id.id,
])
if obj.nurse_id:
dom.append([
'nurse_id','=',obj.nurse_id.id,
])
if obj.doctor_id:
dom.append([
'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_stop',"<=", date_to+" 23:59:59"])
lines=[]
cycles=[]
index=0
no_patient=0
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=PATIENT_TYPE.get(patient_type)
#dialyzer=get_model("clinic.dialyzer").search_browse([])
cycle_name=hd_case.cycle_id.name or ""
show_cycle=False
if not cycle_name in cycles:
cycles.append(cycle_name)
show_cycle=True
vals={
'color': 'success',
'show_cycle': False,
'cycle' : "",
'patient': "",
'no_patient': no_patient,
'patient_type' : "",
'doctor' : "",
'total' : "",
'rc_no' : "",
'dialyzer_name' : "",
'nurse' : "",
}
lines.append(vals)
no_patient=1
else:
no_patient+=1
index+=1
vals={
'show_cycle': show_cycle,
'cycle' : cycle_name,
'patient_id': hd_case.patient_id.id,
'patient_name': hd_case.patient_id.name,
'patient_type' : patient_type,
'no_patient': 0,
'doctor_id': hd_case.doctor_id.id,
'doctor_name' : hd_case.doctor_id.name,
'total' : hd_case.total,
'hd_case_id' : hd_case.id,
'rc_no' : hd_case.number,
'dialyzer_number' : 'DZ-XXXX',
'nurse_id': hd_case.nurse_id.id,
'nurse_name' : 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' : "",
'dialyzer_name' : "",
'nurse' : "",
}
lines.append(vals)
#XXX
del lines[0]
data={
'lines': lines,
'same_date': date_from==date_to,
'date_from': date_from,
'date_to': date_to,
'company_name': company_name,
}
return data
ReportHDCasePayment.register()

View File

@ -13,7 +13,7 @@
<thead class="scroll-header"> <thead class="scroll-header">
<tr> <tr>
<th> <th>
รอบ รอบการรักษา
</th> </th>
<th> <th>
ผู้ป่วย ผู้ป่วย
@ -31,7 +31,7 @@
Dialyzer Dialyzer
</th> </th>
<th> <th>
หมอ แพทย์
</th> </th>
</tr> </tr>
</thead> </thead>
@ -59,8 +59,8 @@
{{total}} {{total}}
</td> </td>
<td><a style="text-decoration: underline" href="ui#name=clinic_hd_case&mode=page&active_id={{hd_case_id}}">{{rc_no}}</a></td> <td><a style="text-decoration: underline" href="ui#name=clinic_hd_case&mode=page&active_id={{hd_case_id}}">{{rc_no}}</a></td>
<td><a style="text-decoration: underline" href="ui#name=clinic_dialyzer&mode=page&active_id={{dialyzer_number}}">{{dialyzer_number}}</a></td> <td><a style="text-decoration: underline" href="ui#name=clinic_dialyzer&mode=page&active_id={{dialyzer_id}}">{{dialyzer_number}}</a></td>
<td><a style="text-decoration: underline" href="ui#name=clinic_doctor&mode=page&active_id={{doctor_id}}">{{doctor_name}}</a></td> <td><a style="text-decoration: underline" href="ui#name=clinic_personal&mode=page&active_id={{doctor_id}}">{{doctor_name}}</a></td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>