report claim/no claim

conv_bal
watcha.h 2015-03-18 23:30:26 +07:00
parent 5ccbb9ab60
commit d35fa2e11d
6 changed files with 168 additions and 51 deletions

View File

@ -1,5 +1,5 @@
<action>
<field name="string">HD Case Report Summary</field>
<field name="string">Report Claim/No Claim</field>
<field name="view_cls">report</field>
<field name="model">clinic.report.account.hd.case.summary</field>
<field name="report_template">report_account_hd_case_summary</field>

View File

@ -7,7 +7,7 @@
<item string="HD Cases Matching" action="clinic_matching_hdcase_acc"/>
<divider/>
<header string="REPORTS"/>
<item string="HD Case Summary" action="clinic_report_account_hd_case_summary"/>
<item string="Report Claim/No Claim" action="clinic_report_account_hd_case_summary"/>
<item string="Labor Cost Summary" action="clinic_report_labor_cost_summary"/>
<item string="Labor Cost Detail" action="clinic_report_labor_cost_detail"/>
<item string="Labor Cost Sub Detail" action="clinic_report_labor_cost_sub_detail"/>

View File

@ -92,6 +92,8 @@ class HDCase(Model):
dlz_name=','.join([dlz for dlz in dlz_name])
names=[]
fee=0
lab=0
misc=0
#sign=1
#if obj.state=='waiting_payment':
#sign=-1
@ -112,9 +114,15 @@ class HDCase(Model):
names.append(name)
elif categ.code=='FEE':
fee+=amt*sign
elif categ.code=="LAB":
lab+=amt
else:
misc+=amt
res[obj.id]={
'epo': ','.join([n for n in names]),
'fee': fee,
'lab': lab,
'misc': misc,
'dlz_id': dlz_id,
'dlz_name': dlz_name,
'dlz_use': dlz_use,
@ -127,6 +135,8 @@ class HDCase(Model):
"number": fields.Char("Number",required=True,search=True),
"epo": fields.Char("EPO",function="_get_expense",function_multi=True),
"fee": fields.Float("Fee",function="_get_expense",function_multi=True),
"lab": fields.Float("Fee",function="_get_expense",function_multi=True),
"misc": fields.Float("Fee",function="_get_expense",function_multi=True),
"dlz_name": fields.Float("DZ",function="_get_expense",function_multi=True),
"dlz_use": fields.Float("DZ Use",function="_get_expense",function_multi=True),
"dlz_max": fields.Float("DZ Max",function="_get_expense",function_multi=True),

View File

@ -17,7 +17,7 @@ class ReportAccountHDCaseSummary(Model):
'branch_id': fields.Many2One("clinic.branch","Branch"),
'department_id': fields.Many2One("clinic.department","Departments"),
'ptype_id': fields.Many2One("clinic.patient.type","Patient Type"),
'reimbursable': fields.Selection([['yes','Yes'],['no','No']],'Reimbursable'),
'reimbursable': fields.Selection([['yes','Yes'],['no','No']],'Claim'),
}
def default_get(self,field_names=None,context={},**kw):
@ -27,6 +27,10 @@ class ReportAccountHDCaseSummary(Model):
weekday, total_day=monthrange(int(year), int(month))
date_from=defaults.get('date_from','%s-%s-01'%(year,month))
date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
#XXX
date_from=defaults.get('date',date)
date_to=defaults.get('date',date)
branch_id=defaults.get('branch_id',None)
print('defaults ', defaults)
if branch_id:
@ -40,6 +44,7 @@ class ReportAccountHDCaseSummary(Model):
'date_to': date_to,
'branch_id': branch_id,
'department_id': department_id,
'reimbursable': 'yes',
}
return res
@ -81,6 +86,7 @@ class ReportAccountHDCaseSummary(Model):
dom.append(['state','in',['completed','waiting_payment','paid']])
print('dom ', dom)
lines=[]
cycles={}
for hdcase in get_model("clinic.hd.case").search_browse(dom):
items={}
mdc_name=(hdcase.epo or "").split("-")
@ -99,28 +105,43 @@ class ReportAccountHDCaseSummary(Model):
for pm in hdcase.payments:
pm_number+=pm.number or ""
inv_number=""
inv_ref=""
for inv in hdcase.invoices:
inv_number+=inv.number or ""
inv_ref+=inv.ref or ""
patient=hdcase.patient_id
ptype=hdcase.patient_type_id
cycle=hdcase.cycle_id
cycle_item=hdcase.cycle_item_id
if cycle.id not in cycles.keys():
cycles[cycle.id]=[]
for line in cycle_item.lines:
nurse=line.nurse_id
cycles[cycle.id].append(nurse.name)
vals={
'hdcase_id': hdcase.id,
'number': hdcase.number or "",
'date': hdcase.date,
'hct': hdcase.hct or 0,
'epo_name': hdcase.epo or 0,
'ptype': ptype.name or "",
'ptype_color': ptype.color or "default",
'dname': hdcase.doctor_id.name or "",
'cycle': cycle.name or "",
'cid': cycle.id,
'pname': patient.name,
'hn': patient.hn_no,
'idcard': patient.card_no or "",
'cseq': cycle.sequence or 0,
'cycle_item_id': cycle_item.id,
'pm_number': pm_number,
'inv_number': inv_number,
'pm_number': pm_number and pm_number or "-",
'inv_number': inv_number and inv_number or "-",
'mdc_name': mdc_name,
'dlz_name': hdcase.dlz_name,
'dlz_id': hdcase.dlz_id.id,
'lab': hdcase.lab,
'misc': hdcase.misc,
'inv_ref': inv_ref and inv_ref or "-",
}
for code, item in items.items():
vals.update({
@ -135,9 +156,13 @@ class ReportAccountHDCaseSummary(Model):
total_fee=0
total_srv=0
total_epo=0
total_lab=0
total_misc=0
slines=[]
no=1
ptypes={}
index=0
old=[]
for line in sorted(lines, key=lambda x: (x['date'],x['cseq'])):
ptype=line['ptype'] or ""
if ptype not in ptypes.keys():
@ -149,7 +174,20 @@ class ReportAccountHDCaseSummary(Model):
total_fee+=line.get('fee',0)
total_srv+=line.get('srv',0)
total_epo+=line.get('epo',0)
total_lab+=line.get('lab',0)
total_misc+=line.get('misc',0)
line['no']=no
cid=line['cid']
if not cid in old:
old.append(cid)
index=0
else:
index+=1
cres=cycles[cid]
line['nurse']=''
if index < len(cres):
line['nurse']=cres[index]
slines.append(line)
no+=1
types=[]
@ -174,10 +212,19 @@ class ReportAccountHDCaseSummary(Model):
'total_fee': total_fee,
'total_srv': total_srv,
'total_epo': total_epo,
'total_lab': total_lab,
'total_misc': total_misc,
'total_qty': total_qty,
'types': types,
'reimbursable': reimbursable,
}
if not reimbursable:
data['title']=''
elif reimbursable=='yes':
data['title']='Report - Claim'
else:
data['title']='Report - No Claim'
print('>>', data['reimbursable'])
return data
def onchange_date(self,context={}):

View File

@ -1,6 +1,6 @@
<center>
<h2>
HD Case Summary
{{title}}
</h2>
<h3>
{{company_name}}<br/>
@ -12,7 +12,11 @@
<table class="table">
<thead class="scroll-header">
<tr>
<th colspan="13" style="text-align:center">
{{#ifeq reimbursable "no"}}
<th colspan="16" style="text-align:center">
{{else}}
<th colspan="14" style="text-align:center">
{{/ifeq}}
{{#each types}}
<span class="label label-{{color}}">{{name}}: {{qty}}</span>
{{/each}}
@ -20,53 +24,108 @@
</th>
</tr>
<tr>
<th>#</th>
<th>วันที่</th>
<th>รอบ</th>
<th>HD Case</th>
<th>ชื่อ-นามสกุล</th>
{{#ifeq reimbursable "no"}}
<th>Date</th>
<th>Cycle#</th>
<th>HD Case#</th>
<th>Name</th>
<th>HN</th>
<th>ID Card</th>
<th>สิทธิ์</th>
<th>Receipt#</th>
<th>Invoice#</th>
<th>EPO</th>
<th>ค่าฟอก</th>
<th>ค่ายา</th>
<th>ค่าฉีดยา</th>
<th>HCT</th>
<th>ยา</th>
{{#ifeq reimbursable "no"}}
<th>Rc.</th>
<th>Inv.</th>
{{/ifeq}}
<th>Lab</th>
<th>Misc.</th>
<th>Dlz</th>
<th>Ref.Inv#</th>
{{else}}
<th>Date</th>
<th>Cycle#</th>
<th>HD Case#</th>
<th>Name</th>
<th>HN</th>
<th>ID Card</th>
<th>สิทธิ์</th>
<th>HCT%</th>
<th>EPO</th>
<th>ค่าฟอก</th>
<th>ค่ายา</th>
<th>ค่าบริการฉีดยา</th>
<th>แพทย์</th>
<th>พยาบาล</th>
{{/ifeq}}
</tr>
</thead>
<tbody>
{{#each lines}}
<tr>
<td>{{no}}</td>
<td style="width:8%">{{date}}</td>
{{#ifeq ../reimbursable "no"}}
<td style="width:10%">{{date}}</td>
<td style="width:6%">{{cycle}}</td>
<td style="width:9%">
{{view "link" string=number action="clinic_hd_case" action_options="mode=form" active_id=hdcase_id}}
</td>
<td style="width:20%">{{pname}}</td>
<td style="width:20%">{{hn}}</td>
<td style="width:20%">{{idcard}}</td>
<td>{{ptype}}</td>
<td>{{pm_number}}</td>
<td>{{inv_number}}</td>
<td>{{epo_name}}</td>
<td>{{currency fee zero=""}}</td>
<td>{{currency epo zero=""}}</td>
<td>{{currency lab zero=""}}</td>
<td>{{currency misc zero=""}}</td>
<td>{{dlz_name}}</td>
<td>{{inv_ref}}</td>
{{else}}
<td style="width:10%">{{date}}</td>
<td style="width:6%">{{cycle}}</td>
<td style="width:9%">
{{view "link" string=number action="clinic_hd_case" action_options="mode=form" active_id=hdcase_id}}
</td>
<td style="width:20%">{{pname}}</td>
<td style="width:20%">{{hn}}</td>
<td style="width:20%">{{idcard}}</td>
<td>{{ptype}}</td>
<td>{{hct}}</td>
<td>{{epo_name}}</td>
<td>{{currency fee zero=""}}</td>
<td>{{currency epo zero=""}}</td>
<td>{{currency srv zero=""}}</td>
<td>{{hct}}</td>
<td>{{mdc_name}}</td>
{{#ifeq ../reimbursable "no"}}
<td>{{pm_number}}</td>
<td>{{inv_number}}</td>
{{/ifeq}}
<td>{{dname}}</td>
<td>
{{view "link" string="View" action="clinic_cycle_item" action_options="mode=form" active_id=cycle_item_id}}
</td>
{{/ifeq}}
</tr>
{{/each}}
</tbody>
<tfoot>
{{#ifeq reimbursable "no"}}
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>{{currency total_fee zero=""}}</th>
<th>{{currency total_epo zero=""}}</th>
<th>{{currency total_lab zero=""}}</th>
<th>{{currency total_misc zero=""}}</th>
<th></th>
<th></th>
{{else}}
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
@ -78,6 +137,7 @@
<th>{{currency total_srv zero=""}}</th>
<th></th>
<th></th>
{{/ifeq}}
</tfoot>
</table>