From b7d1fc74f22b697e9bd45888ec6c48b09777788b Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 10 Mar 2015 13:51:16 +0700 Subject: [PATCH] improvement --- .../clinic_report_account_hd_case_summary.xml | 8 + .../layouts/clinic_account_menu.xml | 1 + .../layouts/clinic_cycle_item_form.xml | 4 +- .../clinic_report_account_hd_case_summary.xml | 9 + netforce_clinic/models/__init__.py | 1 + netforce_clinic/models/cycle_item.py | 12 +- netforce_clinic/models/labor_cost.py | 2 +- .../models/report_account_hd_case_summary.py | 278 ++++++++++++++++++ .../report_account_hd_case_summary.xlsx | Bin 0 -> 4785 bytes .../report_account_hd_case_summary.hbs | 44 +++ 10 files changed, 350 insertions(+), 9 deletions(-) create mode 100644 netforce_clinic/actions/clinic_report_account_hd_case_summary.xml create mode 100644 netforce_clinic/layouts/clinic_report_account_hd_case_summary.xml create mode 100644 netforce_clinic/models/report_account_hd_case_summary.py create mode 100644 netforce_clinic/reports/report_account_hd_case_summary.xlsx create mode 100644 netforce_clinic/templates/report_account_hd_case_summary.hbs diff --git a/netforce_clinic/actions/clinic_report_account_hd_case_summary.xml b/netforce_clinic/actions/clinic_report_account_hd_case_summary.xml new file mode 100644 index 0000000..e28ceed --- /dev/null +++ b/netforce_clinic/actions/clinic_report_account_hd_case_summary.xml @@ -0,0 +1,8 @@ + + HD Case Report Summary + report + clinic.report.account.hd.case.summary + report_account_hd_case_summary + report_account_hd_case_summary + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml index 9030a1a..5f789c0 100644 --- a/netforce_clinic/layouts/clinic_account_menu.xml +++ b/netforce_clinic/layouts/clinic_account_menu.xml @@ -7,6 +7,7 @@
+ diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml index 1d5e393..f8e2a9b 100644 --- a/netforce_clinic/layouts/clinic_cycle_item_form.xml +++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml @@ -20,8 +20,8 @@ - - + + diff --git a/netforce_clinic/layouts/clinic_report_account_hd_case_summary.xml b/netforce_clinic/layouts/clinic_report_account_hd_case_summary.xml new file mode 100644 index 0000000..b81e50e --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_account_hd_case_summary.xml @@ -0,0 +1,9 @@ +
+ + + + + + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 2d3a25a..cbeb309 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -66,6 +66,7 @@ from . import report_clinic from . import report_visit from . import report_cycle_item from . import report_hd_case_summary +from . import report_account_hd_case_summary from . import report_hd_case_detail from . import report_medical_summary from . import report_recent_patient diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py index c612d16..99bfd00 100644 --- a/netforce_clinic/models/cycle_item.py +++ b/netforce_clinic/models/cycle_item.py @@ -146,12 +146,12 @@ class CycleItem(Model): def onchange_nurse(self,context={}): data=context["data"] - path=context["path"] - line=get_data_path(data,path,parent=True) - nurse_id=line['nurse_id'] - nurse=get_model('clinic.staff').browse(nurse_id) - line['level_id']=nurse.level_id.id - line['categ_id']=nurse.categ_id.id + #path=context["path"] + #line=get_data_path(data,path,parent=True) + #nurse_id=line['nurse_id'] + #nurse=get_model('clinic.staff').browse(nurse_id) + #line['level_id']=nurse.level_id.id + #line['categ_id']=nurse.categ_id.id return data def view_schedule(self,ids,context={}): diff --git a/netforce_clinic/models/labor_cost.py b/netforce_clinic/models/labor_cost.py index e2e5538..a3d7571 100644 --- a/netforce_clinic/models/labor_cost.py +++ b/netforce_clinic/models/labor_cost.py @@ -136,8 +136,8 @@ class LaborCost(Model): item=obj.cycle_item_id for line in item.lines: - level=line.level_id nurse=line.nurse_id + level=line.level_id or nurse.level_id if not level: raise Exception("Please specify level for %s"%nurse.name) levels[level.id]['total']+=1 diff --git a/netforce_clinic/models/report_account_hd_case_summary.py b/netforce_clinic/models/report_account_hd_case_summary.py new file mode 100644 index 0000000..d5468e2 --- /dev/null +++ b/netforce_clinic/models/report_account_hd_case_summary.py @@ -0,0 +1,278 @@ +import time +import urllib.parse as urllib + +from datetime import datetime +from calendar import monthrange +from netforce.model import Model, fields, get_model +from netforce.access import get_active_company + +from . import utils + +class ReportAccountHDCaseSummary(Model): + _name="clinic.report.account.hd.case.summary" + _string="HD Case Report Summary" + _transient=True + + _fields={ + "date": fields.Date("Month", required=True), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), + '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'), + } + + def _get_date_from(self,context={}): + year,month=time.strftime("%Y-%m").split("-") + return '%s-%s-01'%(year,month) + + def _get_date_to(self,context={}): + year,month,day=time.strftime("%Y-%m-%d").split("-") + weekday, total_day=monthrange(int(year), int(month)) + return "%s-%s-%s"%(year,month,total_day) + + _defaults={ + 'date': lambda *a: time.strftime("%Y-%m-%d"), + 'date_from': _get_date_from, + 'date_to': _get_date_to, + } + + def get_report_data(self,ids,context={}): + company_id=get_active_company() + company=get_model("company").browse(company_id) + + date=datetime.now().strftime("%Y-%m-%d") + year=int(date[0:4]) + crr_month=int(date[5:7]) + weekday, crr_total_day=monthrange(year, crr_month) + branch_id=None + department_id=None + time_start='%s-%s-01 00:00:00'%(year,str(crr_month).zfill(2)) + time_stop='%s-%s-%s 23:59:59'%(year,str(crr_month).zfill(2),crr_total_day) + if ids: + obj=self.browse(ids)[0] + branch_id=obj.branch_id.id + department_id=obj.department_id.id + date=obj.date + crr_month=int(date[5:7]) #XXX + time_start='%s 00:00:00'%obj.date_from + time_stop='%s 23:59:59'%obj.date_to + year=int(date[0:4]) + + prev_year=year + next_year=year + prev_month=crr_month-1 + next_month=crr_month+1 + if crr_month==1: + prev_month=12 + prev_year-=1 + if crr_month==12: + next_month=1 + next_year+=1 + + month_str=utils.MONTHS['th_TH'][crr_month] + next_month_str=utils.MONTHS['th_TH'][next_month] + prev_month_str=utils.MONTHS['th_TH'][prev_month] + + def encode_url(dom): + dom='%s'%dom + dom=urllib.quote(dom.encode('utf-8')) + return dom + + def replace_quote(dom=""): + return dom.replace("'","\"") + + count=1 + # number of hd case of this month + dom=[] + dom.append(["time_start",">=",time_start]) + dom.append(["time_stop","<=",time_stop]) + dom.append(["state","in",["completed","waiting_payment","paid"]]) + dom.append(['patient_id.walkin','=','no']) + if branch_id: + dom.append(['branch_id','=',branch_id]) + if department_id: + dom.append(['department_id','=',department_id]) + crr_total=len(get_model("clinic.hd.case").search(dom)) + items={} + items['topic%s'%count]={ + 'month': month_str, + 'qty': crr_total or 0, + 'action': 'clinic_hd_case', + 'action_options': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%dom), + } + count+=1 + + # number of patient from previous + dom=[] + weekday, prev_total_day=monthrange(prev_year, prev_month) + time_stop='%s-%s-%s'%(prev_year,str(prev_month).zfill(2),prev_total_day) + dom.append(['reg_date','<=',time_stop]) + if branch_id: + dom.append(['branch_id','=',branch_id]) + if department_id: + dom.append(['department_id','=',department_id]) + npatient=len(get_model("clinic.patient").search(dom)) + dom=replace_quote('%s'%dom) + items['topic%s'%count]={ + 'month': prev_month_str, + 'qty': npatient or 0, + 'action': 'clinic_patient', + 'action_options': 'mode=list&search_domain=%s'%dom, + } + count+=1 + + # new patient of this month + dom=[] + weekday, crr_total_day=monthrange(prev_year, crr_month) + time_start='%s-%s-01'%(year,str(crr_month).zfill(2)) + time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day) + dom.append(['reg_date','>=',time_start]) + dom.append(['reg_date','<=',time_stop]) + if branch_id: + dom.append(['branch_id','=',branch_id]) + if department_id: + dom.append(['department_id','=',department_id]) + new_patients=get_model('clinic.patient').search_browse(dom) + dom=replace_quote('%s'%dom) + items['topic%s'%count]={ + 'month': month_str, + 'qty': len(new_patients) or 0, + 'action': 'clinic_patient', + 'action_options': 'mode=list&search_domain=%s'%dom, + } + count+=1 + + # number for patient who resign for this month + dom=[] + time_start='%s-%s-01'%(year,str(crr_month).zfill(2)) + time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day) + dom.append(['resign_date','>=',time_start]) + dom.append(['resign_date','<=',time_stop]) + if branch_id: + dom.append(['branch_id','=',branch_id]) + if department_id: + dom.append(['department_id','=',department_id]) + resign_patients_qty=0 + resign_patients=[] + for pt in get_model('clinic.patient').search_browse(dom): + resign_patients_qty+=1 + resign_patients.append(pt.name) + + del dom[-1] + dom=replace_quote('%s'%dom) + items['topic%s'%count]={ + 'month': month_str, + 'qty': resign_patients_qty, + 'action': 'clinic_patient', + 'action_options': 'mode=list&search_domain=%s&tab_no=2'%dom, + } + count+=1 + # all patient who are in hospital on select month + dom=[] + weekday, crr_total_day=monthrange(year, crr_month) + time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day) + dom.append(['reg_date','<=',time_stop]) + if branch_id: + dom.append(['branch_id','=',branch_id]) + if department_id: + dom.append(['department_id','=',department_id]) + total_patient=get_model('clinic.patient').search_browse(dom) + dom=replace_quote('%s'%dom) + total_patient_qty=len(total_patient) or 0 + items['topic%s'%count]={ + 'month': next_month_str, + 'qty': total_patient_qty-resign_patients_qty, + 'action': 'clinic_patient', + 'action_options': 'mode=list&search_domain=%s'%dom, + } + count+=1 + + topics=utils.TOPICS + for ptype in get_model("clinic.patient.type").search_read([[]],['name']): + tkey='topic%s'%count + topics.update({ + tkey:{ + 'name': ptype['name'], + 'unit': 'คน', + } + }) + + + dom=[] + time_start='%s-%s-01'%(year,str(crr_month).zfill(2)) + time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day) + dom.append(['reg_date','<=',time_stop]) + dom.append(['type_id','=',ptype['id']]) + dom.append(['name','not in', resign_patients]) + npatients_qty=0 + for pt in get_model("clinic.patient").search(dom): + npatients_qty+=1 + dom=replace_quote('%s'%dom) + items[tkey]={ + 'month': '', + 'qty': npatients_qty, + 'action': 'clinic_patient', + 'action_options': 'mode=list&search_domain=%s'%dom, + } + count+=1 + + lines=[] + index=1 + for item in items: + topic='topic%s'%index + name=utils.TOPICS[topic]['name'] + unit=utils.TOPICS[topic]['unit'] + line=items[topic] + line['topic']=name + line['unit']=unit + lines.append(line) + index+=1 + + context['defaults']={ + 'date': date, + 'branch_id': branch_id, + 'department_id': department_id, + } + + medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context) + year=year+543 + sub_name='' + if department_id: + dpt=get_model("clinic.department").browse(department_id) + sub_name="(%s)" % dpt.name or "" + elif branch_id: + branch=get_model("clinic.branch").browse(branch_id) + sub_name="(%s)" % branch.name or "" + data={ + 'branch_id': branch_id, + 'department_id': department_id, + 'date': date, + 'month': month_str, + 'year': year, + 'lines': lines, + 'recent_patients': get_model("clinic.report.recent.patient").get_report_data(ids=[],context=context)['lines'], + 'resign_patients': get_model("clinic.report.discontinue.patient").get_report_data(ids=[],context=context)['lines'], + 'medicals': medicals['lines'], + 'titles': medicals['titles'], + 'company_name': '%s %s'% (company.name or "", sub_name), + 'parent_company_name': company.parent_id.name or "", + } + return data + + def onchange_date(self,context={}): + data=context['data'] + date=data['date'] + year,month,day=date.split("-") + weekday, total_day=monthrange(int(year), int(month)) + data['date_from']="%s-%s-01"%(year,month) + data['date_to']="%s-%s-%s"%(year,month,total_day) + return data + + def onchange_branch(self,context={}): + data=context['data'] + data['department_id']=None + return data + +ReportAccountHDCaseSummary.register() diff --git a/netforce_clinic/reports/report_account_hd_case_summary.xlsx b/netforce_clinic/reports/report_account_hd_case_summary.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..6eee4d5b5c85111a1f462635f8d303a1aab6e4e7 GIT binary patch literal 4785 zcmaJ_1z1#D*QUFrOOOV2W+(@wkr!J=nQrv1IXeT;1@<>QdUG94+;D> zd_y_&1D*9=^b@scRp+NBA~A6%%zmg`s)Kblw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2=VEDi-mCtC7*?0Ce*S0Y`n#8l#n^cn`3ti|KfU}{QTe-v zi<$qtX#0g);=jl7R|)sK@kJRuFAjbIN&4sO|1K4NH@zq{=Q{ff-W30>y1!drTukR; v^a}~tar~{>e@WBt<`*O5e8v638rA +

+ HD Case Summary +

+

+ {{company_name}}
+

+

+ From {{date_from}} To {{date_to}} +

+ + + + + + + + + + + + + + + + + {{#each lines}} + + + + + + + + + + + + + + {{/each}} + +
#วันที่รอบHD Caseชื่อ-นามสกุลสิทธิ์ค่าฟอกค่ายาค่าฉีดยาแพทย์พยาบาล
{{no}}{{date}}{{cycle}}{{hd_case}}{{pname}}{{ptype}}{{fee}}{{epo}}{{srv}}{{dname}}{{nnames}}
+