From e204d4c1351560ea7af2f4643bc1d7f49f49c740 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Thu, 30 Jul 2015 19:10:49 +0700 Subject: [PATCH] improve cycle item --- netforce_clinic/models/report_cycle_item.py | 22 ++++++ .../templates/report_cycle_item.hbs | 77 ++++++++++++------- 2 files changed, 70 insertions(+), 29 deletions(-) diff --git a/netforce_clinic/models/report_cycle_item.py b/netforce_clinic/models/report_cycle_item.py index b108c00..06d9685 100644 --- a/netforce_clinic/models/report_cycle_item.py +++ b/netforce_clinic/models/report_cycle_item.py @@ -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 diff --git a/netforce_clinic/templates/report_cycle_item.hbs b/netforce_clinic/templates/report_cycle_item.hbs index bf041bd..26d0de7 100644 --- a/netforce_clinic/templates/report_cycle_item.hbs +++ b/netforce_clinic/templates/report_cycle_item.hbs @@ -44,40 +44,59 @@ {{nfirst_name}} {{else}} {{#ifeq sub "show"}} - รวม + ผู้ป่วย | ยาฉีด + + {{no}} + + {{#each epo_items}} + {{name}} : {{qty}}     + {{/each}} + {{else}} + + {{no}} + {{hdcase_number}} + {{pname}} + {{dname}} + {{tname}} + {{mdc_name}} + {{hct}} + {{dlz_name}} + {{dlz_use}} + {{nfirst_name}} {{/ifeq}} - - {{no}} - {{hdcase_number}} - {{pname}} - {{dname}} - {{tname}} - {{mdc_name}} - {{hct}} - {{dlz_name}} - {{dlz_use}} - {{nfirst_name}} {{/if}} {{/each}} - - - รวมผู้ป่วยทั้งหมด - - {{total_pt}} - -

- {{#each ptype_lines}} - {{name}} : {{qty}}     + + ผู้ป่วยทั้งหมด + + {{total_pt}} + +

+ {{#each ptype_lines}} + {{name}} : {{qty}}     + {{/each}} +

+

+ {{#each vscl_lines}} + {{description}} = {{qty}}     + {{/each}} +

+ + + + ยาฉีดทั้งหมด + + {{total_epo}} + +

+ {{#each total_epo_items}} + {{name}} = {{qty}}     {{/each}} -

-

- {{#each vscl_lines}} - {{description}} = {{qty}}     - {{/each}} -

- - +

+ + +