improve cycle item

conv_bal
watcha.h@almacom.co.th 2015-07-30 19:10:49 +07:00
parent fdef5622f3
commit e204d4c135
2 changed files with 70 additions and 29 deletions

View File

@ -139,6 +139,13 @@ class ReportCycleItem(Model):
number=number.replace("HDC/","")
number=number.replace("HDC-","")
return number
total_epo=0
for line in hdcase.lines:
prod=line.product_id
if prod.categ_id.code=='EPO':
total_epo+=line.qty or 0
lines.append({
'dlz_drop': dlz_drop,
'cancel': cancel,
@ -170,6 +177,7 @@ class ReportCycleItem(Model):
'tid': ptype.id,
'dpt_id': dpt.id,
'dpt_name': dpt.name or "",
'total_epo': total_epo,
})
month_str=utils.MONTHS['th_TH'][int(month)]
company_name=company.name or ""
@ -190,6 +198,7 @@ class ReportCycleItem(Model):
sub_fee=0
sub_mdc=0
pt=0
total_epos={}
for line in sorted(lines,key=lambda x:(x['date'],x['cseq'])):
pt+=1
date=line['date'] or ''
@ -199,10 +208,14 @@ class ReportCycleItem(Model):
count=0
sub_fee=1
sub_mdc=0
epos={}
for x in lines:
if x['cseq']==line['cseq'] and x['date']==date:
sub_fee+=x['fee'] or 0
sub_mdc+=x['mdc'] or 0
if not epos.get(x['mdc_name']):
epos[x['mdc_name']]=0
epos[x['mdc_name']]+=x['total_epo'] or 0
count+=1
line['date_txt']=line['date']
line['cseq_txt']=line['cseq']
@ -227,6 +240,7 @@ class ReportCycleItem(Model):
line['nfirst_name']=cres[index]['first_name']
nlines.append(line)
if no==count:
epo_items=[{'name': k, 'qty': v} for k,v in epos.items() if k ]
nlines.append({
'sub': 'show',
'sub_txt': 'รวม',
@ -234,7 +248,13 @@ class ReportCycleItem(Model):
'no': count,
'fee': sub_fee,
'mdc': sub_mdc,
'epo_items': epo_items,
})
for epo_item in epo_items:
if not total_epos.get(epo_item['name']):
total_epos[epo_item['name']]=0
total_epos[epo_item['name']]+=epo_item['qty'] or 0
total_epo_items=[{'name': k, 'qty': v} for k,v in total_epos.items() if k ]
vscl_lines=[]
for k,v in vasculars.items():
vscl_lines.append({
@ -275,6 +295,8 @@ class ReportCycleItem(Model):
'total_fee': total_fee,
'total_mdc': total_mdc,
'total_pt': total_pt,
'total_epo': sum([x['qty'] for x in total_epo_items]),
'total_epo_items': total_epo_items,
}
return data

View File

@ -44,10 +44,16 @@
<td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">{{nfirst_name}}</a></td>
{{else}}
{{#ifeq sub "show"}}
<td>รวม</td>
<td>ผู้ป่วย | ยาฉีด</td>
<td></td>
<td style="text-align:center">{{no}}</td>
<td colspan="9">
{{#each epo_items}}
{{name}} : {{qty}} &nbsp;&nbsp;&nbsp;
{{/each}}
</td>
{{else}}
<td></td>
{{/ifeq}}
<td></td>
<td style="text-align:center">{{no}}</td>
<td style="width:6%"><a href="/ui#name=clinic_hd_case&active_id={{hdcase_id}}&mode=form">{{hdcase_number}}</a></td>
@ -59,15 +65,15 @@
<td><a href="/ui#name=clinic_dialyzer&active_id={{dlz_id}}&mode=form">{{dlz_name}}</a></td>
<td>{{dlz_use}}</td>
<td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">{{nfirst_name}}</a></td>
{{/ifeq}}
{{/if}}
</tr>
{{/each}}
</tbody>
<tfoot>
<th rowspan="2" class="active">รวมผู้ป่วยทั้งหมด</th>
<th rowspan="2" class="active"></th>
<tr>
<th class="active">ผู้ป่วยทั้งหมด</th>
<th class="active"></th>
<th class="active">{{total_pt}}</th>
<th colspan="8" class="active">
<th colspan="9" class="active">
<p>
{{#each ptype_lines}}
{{name}} : {{qty}} &nbsp;&nbsp;&nbsp;
@ -79,5 +85,18 @@
{{/each}}
</p>
</th>
</tfoot>
</tr>
<tr>
<th class="active">ยาฉีดทั้งหมด</th>
<th class="active"></th>
<th class="active">{{total_epo}}</th>
<th colspan="9" class="active">
<p>
{{#each total_epo_items}}
{{name}} = {{qty}} &nbsp;&nbsp;&nbsp;
{{/each}}
</p>
</th>
</tr>
</tbody>
</table>