diff --git a/netforce_clinic/actions/clinic_report_account_hd_case_summary.xml b/netforce_clinic/actions/clinic_report_account_hd_case_summary.xml index c1e7d3a..e220d99 100644 --- a/netforce_clinic/actions/clinic_report_account_hd_case_summary.xml +++ b/netforce_clinic/actions/clinic_report_account_hd_case_summary.xml @@ -1,5 +1,5 @@ - HD Case Report Summary + Report Claim/No Claim report clinic.report.account.hd.case.summary report_account_hd_case_summary diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml index 5f789c0..92d7df7 100644 --- a/netforce_clinic/layouts/clinic_account_menu.xml +++ b/netforce_clinic/layouts/clinic_account_menu.xml @@ -7,7 +7,7 @@
- + diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index ea0977e..e5508b9 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -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), diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py index 46cd7ed..c613528 100644 --- a/netforce_clinic/models/report_account_hd_case_summary.py +++ b/netforce_clinic/models/report_account_hd_case_summary.py @@ -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={}): diff --git a/netforce_clinic/reports/report_account_hd_case_summary.xlsx b/netforce_clinic/reports/report_account_hd_case_summary.xlsx index 5e34291..4080997 100644 Binary files a/netforce_clinic/reports/report_account_hd_case_summary.xlsx and b/netforce_clinic/reports/report_account_hd_case_summary.xlsx differ diff --git a/netforce_clinic/templates/report_account_hd_case_summary.hbs b/netforce_clinic/templates/report_account_hd_case_summary.hbs index 94d590f..f3f8b21 100644 --- a/netforce_clinic/templates/report_account_hd_case_summary.hbs +++ b/netforce_clinic/templates/report_account_hd_case_summary.hbs @@ -1,6 +1,6 @@

- HD Case Summary + {{title}}

{{company_name}}
@@ -12,7 +12,11 @@ - - - - - - - - - - - - {{#ifeq reimbursable "no"}} - - + + + + + + + + + + + + + + + + + {{else}} + + + + + + + + + + + + + + {{/ifeq}} - - {{#each lines}} - - - - - - - - - - - {{#ifeq ../reimbursable "no"}} + + + + + + + + + + + + + + + {{else}} + + + + + + + + + + + + + + {{/ifeq}} - - {{/each}} - - - - - - - - - - - + {{#ifeq reimbursable "no"}} + + + + + + + + + + + + + + + + + {{else}} + + + + + + + + + + + + + + + {{/ifeq}}
+ {{#ifeq reimbursable "no"}} + + {{else}} + + {{/ifeq}} {{#each types}} {{name}}: {{qty}} {{/each}} @@ -20,64 +24,120 @@
#วันที่รอบHD Caseชื่อ-นามสกุลสิทธิ์ค่าฟอกค่ายาค่าฉีดยาHCTยาRc.Inv.DateCycle#HD Case#NameHNID Cardสิทธิ์Receipt#Invoice#EPOค่าฟอกค่ายาLabMisc.DlzRef.Inv#DateCycle#HD Case#NameHNID Cardสิทธิ์HCT%EPOค่าฟอกค่ายาค่าบริการฉีดยาแพทย์พยาบาลแพทย์พยาบาล
{{no}}{{date}}{{cycle}} - {{view "link" string=number action="clinic_hd_case" action_options="mode=form" active_id=hdcase_id}} - {{pname}}{{ptype}}{{currency fee zero=""}}{{currency epo zero=""}}{{currency srv zero=""}}{{hct}}{{mdc_name}}{{date}}{{cycle}} + {{view "link" string=number action="clinic_hd_case" action_options="mode=form" active_id=hdcase_id}} + {{pname}}{{hn}}{{idcard}}{{ptype}} {{pm_number}} {{inv_number}}{{epo_name}}{{currency fee zero=""}}{{currency epo zero=""}}{{currency lab zero=""}}{{currency misc zero=""}}{{dlz_name}}{{inv_ref}}{{date}}{{cycle}} + {{view "link" string=number action="clinic_hd_case" action_options="mode=form" active_id=hdcase_id}} + {{pname}}{{hn}}{{idcard}}{{ptype}}{{hct}}{{epo_name}}{{currency fee zero=""}}{{currency epo zero=""}}{{currency srv zero=""}}{{dname}} + {{view "link" string="View" action="clinic_cycle_item" action_options="mode=form" active_id=cycle_item_id}} + {{dname}} - {{view "link" string="View" action="clinic_cycle_item" action_options="mode=form" active_id=cycle_item_id}} -
{{currency total_fee zero=""}}{{currency total_epo zero=""}}{{currency total_srv zero=""}}{{currency total_fee zero=""}}{{currency total_epo zero=""}}{{currency total_lab zero=""}}{{currency total_misc zero=""}}{{currency total_fee zero=""}}{{currency total_epo zero=""}}{{currency total_srv zero=""}}