From 33ce56fdd9a2aeed613ce6cfa2a8e76ee991edbc Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Tue, 24 Mar 2015 13:51:21 +0700 Subject: [PATCH] report detail --- .../actions/clinic_report_medical_detail.xml | 8 + .../layouts/clinic_account_menu.xml | 6 +- netforce_clinic/layouts/clinic_menu.xml | 2 +- .../layouts/clinic_report_medical_detail.xml | 14 ++ netforce_clinic/models/__init__.py | 1 + .../models/report_medical_detail.py | 162 ++++++++++++++++++ .../models/report_medical_summary.py | 23 ++- .../reports/report_medical_detail.xlsx | Bin 0 -> 5051 bytes .../templates/report_hd_case_summary.hbs | 4 +- .../templates/report_medical_detail.hbs | 43 +++++ .../templates/report_medical_summary.hbs | 4 +- netforce_clinic/todo.txt | 6 +- 12 files changed, 262 insertions(+), 11 deletions(-) create mode 100644 netforce_clinic/actions/clinic_report_medical_detail.xml create mode 100644 netforce_clinic/layouts/clinic_report_medical_detail.xml create mode 100644 netforce_clinic/models/report_medical_detail.py create mode 100644 netforce_clinic/reports/report_medical_detail.xlsx create mode 100644 netforce_clinic/templates/report_medical_detail.hbs diff --git a/netforce_clinic/actions/clinic_report_medical_detail.xml b/netforce_clinic/actions/clinic_report_medical_detail.xml new file mode 100644 index 0000000..34f0e3d --- /dev/null +++ b/netforce_clinic/actions/clinic_report_medical_detail.xml @@ -0,0 +1,8 @@ + + Report Medical Detail + report + clinic.report.medical.detail + report_medical_detail + report_medical_detail + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_account_menu.xml b/netforce_clinic/layouts/clinic_account_menu.xml index 2521b41..614404b 100644 --- a/netforce_clinic/layouts/clinic_account_menu.xml +++ b/netforce_clinic/layouts/clinic_account_menu.xml @@ -9,9 +9,9 @@
- - - + + +
diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 7db8d58..f588be3 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -20,7 +20,6 @@ - @@ -49,6 +48,7 @@ + diff --git a/netforce_clinic/layouts/clinic_report_medical_detail.xml b/netforce_clinic/layouts/clinic_report_medical_detail.xml new file mode 100644 index 0000000..3eb7701 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_medical_detail.xml @@ -0,0 +1,14 @@ +
+ + + + + + + + + + + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index a0f1251..c935e9b 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -70,6 +70,7 @@ 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_medical_detail from . import report_recent_patient from . import report_discontinue_patient from . import report_staff diff --git a/netforce_clinic/models/report_medical_detail.py b/netforce_clinic/models/report_medical_detail.py new file mode 100644 index 0000000..ca9070a --- /dev/null +++ b/netforce_clinic/models/report_medical_detail.py @@ -0,0 +1,162 @@ +import time +from calendar import monthrange + +from netforce.model import Model,fields,get_model +from netforce.access import get_active_company + +class ReportMedicalDetail(Model): + _name="clinic.report.medical.detail" + _string="Report Medical Detail" + _transient=True + + _fields={ + "date": fields.Date("Month", required=True), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), + "prod_categ_id": fields.Many2One("product.categ","Category",required=True), + "product_id": fields.Many2One("product","Product"), + 'types': fields.Many2Many("clinic.patient.type","Types"), + "branch_id": fields.Many2One("clinic.branch","Branch"), + "department_id": fields.Many2One("clinic.department","Department"), + } + + # in case link from another report + def default_get(self,field_names=None,context={},**kw): + defaults=context.get("defaults",{}) + date=defaults.get('date',time.strftime("%Y-%m-%d")) + year,month=time.strftime("%Y-%m").split("-") + 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)) + categ_id=defaults.get('categ_id',None) + if not categ_id: + categ_ids=get_model("product.categ").search([['code','=','EPO']]) + if categ_ids: + categ_id=categ_ids[0] + branch_id=defaults.get('branch_id',None) + select_dpt=get_model('select.company').get_select() + if not branch_id: + if select_dpt: + branch_id=select_dpt['branch_id'] + else: + branch_id=int(branch_id or "0") + department_id=defaults.get('department_id',None) + if not department_id: + if select_dpt.get('department_ids'): + department_id=select_dpt['department_ids'][0] + else: + department_id=select_dpt['department_id'] + else: + department_id=int(department_id or "0") + types=defaults.get('types',[]) + if types: + types=[int(t) for t in types.split(",") if t] + product_id=defaults.get("product_id",None) + if product_id: + product_id=int(product_id) + print('xx ',product_id) + res={ + 'date': date, + 'date_from': date_from, + 'date_to': date_to, + 'prod_categ_id': categ_id, + 'branch_id': branch_id, + 'department_id': department_id, + 'types': types, + 'product_id': product_id, + } + return res + + def get_report_data(self,ids,context={}): + year, month=time.strftime("%Y-%m").split("-") + weekday, total_day=monthrange(int(year), int(month)) + defaults=self.default_get(context=context) + time_start=defaults.get("date_from") + time_stop=defaults.get("date_to") + prod_categ_id=defaults.get("prod_categ_id") + branch_id=defaults.get("branch_id") + department_id=defaults.get("department_id") + product_id=defaults.get('product_id') + types=defaults.get('types') + if ids: + obj=self.browse(ids)[0] + prod_categ_id=obj.prod_categ_id.id + product_id=obj.product_id.id + types=obj.types + branch_id=obj.branch_id.id + department_id=obj.department_id.id + month=obj.date_from.split("-")[1] + time_start=obj.date_from + time_stop=obj.date_to + dom=[ + ['hd_case_id.date','>=',time_start], + ['hd_case_id.date','<=',time_stop], + ] + if branch_id: + dom.append(['hd_case_id.branch_id','=',branch_id]) + if department_id: + dom.append(['hd_case_id.department_id','=',department_id]) + if prod_categ_id: + dom.append(['product_categ_id','=',prod_categ_id]) + if product_id: + dom.append(['product_id','=',product_id]) + if types and ids: + dom.append(['hd_case_id.patient_type_id','in',[t.id for t in types]]) + elif types: + dom.append(['hd_case_id.patient_type_id','in',[t_id for t_id in types]]) + lines=[] + total_qty=0 + for line in get_model('clinic.hd.case.line').search_browse(dom): + hdcase=line.hd_case_id + patient=hdcase.patient_id + cycle=hdcase.cycle_id + department=hdcase.department_id + qty=line.qty or 0 + lines.append({ + 'date': hdcase.date or '', + 'tname': hdcase.patient_type_id.name or '', + 'pname': patient.name or '', + 'qty': qty, + 'cname': cycle.name, + 'cseq': cycle.sequence, + 'dpt_name': department.name, + 'hid': hdcase.id, + 'hname': hdcase.number, + }) + total_qty+=qty + 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 "" + company_id=get_active_company() + company=get_model("company").browse(company_id) + no=1 + for line in sorted(lines,key=lambda x: (x['date'],x['cseq'])): + line['no']=no + no+=1 + data={ + 'company_name': '%s %s' % (company.name or "", sub_name), + 'lines': lines, + 'year': year, + 'total_qty': total_qty, + } + 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 + +ReportMedicalDetail.register() diff --git a/netforce_clinic/models/report_medical_summary.py b/netforce_clinic/models/report_medical_summary.py index 545f16d..aaea893 100644 --- a/netforce_clinic/models/report_medical_summary.py +++ b/netforce_clinic/models/report_medical_summary.py @@ -2,7 +2,7 @@ import time from calendar import monthrange from netforce.model import Model,fields,get_model -from netforce.access import get_active_company, get_active_user +from netforce.access import get_active_company from . import utils class ReportMedicalSummary(Model): @@ -129,24 +129,43 @@ class ReportMedicalSummary(Model): count=1 total=0.0 sub_lines=[] + all_ptypes="" + prod_id=None for patient_type_id,type_name in sorted(patient_types.items(), key=lambda x: x[0]): + all_ptypes+="%s,"%patient_type_id qty=records[patient_type_id]['qty'] or 0 + prod_id=records[patient_type_id]['prod_id'] line={ 'prod_name': prod_name, 'prod_name_org': prod_name_org, - 'prod_id': records[patient_type_id]['prod_id'], + 'prod_id': prod_id, 'total': 0, } sub_lines.append({ 'qty': qty, + 'types': "%s"%patient_type_id, + 'time_start': time_start, + 'time_stop': time_stop, + 'product_id': prod_id, + 'product_categ_id': prod_categ_id, }) total+=qty count+=1 sub_lines.append({ 'qty': total, + 'types': all_ptypes, + 'time_start': time_start, + 'time_stop': time_stop, + 'product_id': prod_id, + 'product_categ_id': prod_categ_id, }) line['sub_lines']=sub_lines lines.append(line) + for line in lines: + st="" + for x in line['sub_lines']: + st+='%s'%(x['types']) + titles.append({'name':'รวม'}) company_id=get_active_company() diff --git a/netforce_clinic/reports/report_medical_detail.xlsx b/netforce_clinic/reports/report_medical_detail.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..776d9fa488a8f13c300d035259279993164ba9a3 GIT binary patch literal 5051 zcmaKw2Q-{(x5ss(6GU&5awNhSohTt%j82H&8NGL-L>IkxVS^%E*=dQ006+cDeNPUb;(H3-%Z@C9Na-X znD>h0aV1iN7j0s-6!lhE<%PTG zYk+*hMN6{Er(x(!$K+p7DJ*peA;7x)apMa5vG3wwp@083FqG&kES)XX-JD(AL1r#4 zJU)&Nc@v{{IA9w56<7ffuaQ4G2ACXOms%O-1>Vy!cT>0=N$0`-OHjdY-|x`Wc0vGxVl?;HJx~UWt4%0M{!?|##SxdaY6_W0!EpW#GC=I zh((z6-C{NWB<9fcZIflC{0^e}afbn`h-%jdRe2Ac26N5%yd4E;E?(r*d+2zT-Ul&t z+zLAE$TUn+ihzgbY~RS;4$YtzA-xYCkrzOz?f35t+XdM1c%I(Ij+)t$f9}$OTc<}e z@zyhA1BODj7z1_EEYmX%TY&a5+X1SB>o##e^3=NC&Wi}`vp0xCCh9T{@^_r*+S5YD zgkOO38>Tv#cdfGdx$Fas;%Am^YuGTDpVPJ+a-tD4{4xF*(U^T4K!4|^x3inQxwEr9 z2KC>0nxtai%}a{mEq~nmfY2gVq%~H$>iipapT^omk5KY#{f|H%CIe!t-HDWmxx+Ta zqt60ypQC#2lM<8{;e~hhdI4HP&cE!fGU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b;N#=c%)Hi@Y)5B1^!f!kd3f~@1 zXSP%nI$l|NQhSDgmE}AIEWF#FQa@-z94}=g+DRgf8nCbL7;%@#-QshZXWE&q_tBHw zXf&71(H?fh8hSme!JSRtotOHIX`7Z-GI%{Nt>0MgqPLz@snL$?;LRQ9XDFV>PkfbG z&2=QepeEb8rP)Hs$C~DLw2SK$N4w#NnZ+>9(1G!Pj`|#kB5YJXUyHuq_ypB$ zakdG|dH#cnKeS8(uqg^$z9DwkjuH=E6h&+f|Am?H2 zf%?hfoOQQvbL{IQhu*LRX%2oZ%!K`fZcfw9EP#fti!Lnc5NsS8tY34M%Yz2YoaO)8 zrK!vBj+ccvW)AVo7|?(9`&8n0@5}lUBi4TzA38Gr_5Me?|L%TSgkePJFU!LHlO+9p zoy$rDBiVjgEt(Zt+WtQQ_xlQ$3pPfv{4x~&&lUcoe))Zs%ZDANxc@RL^rm3$ {{prod_name}} {{#each sub_lines}} - {{qty}} + + {{qty}} + {{/each}} {{/each}} diff --git a/netforce_clinic/templates/report_medical_detail.hbs b/netforce_clinic/templates/report_medical_detail.hbs new file mode 100644 index 0000000..9771640 --- /dev/null +++ b/netforce_clinic/templates/report_medical_detail.hbs @@ -0,0 +1,43 @@ +
+

+ {{company_name}} +

+
+ + + + + + + + + + + + + + + {{#each lines}} + + + + + + + + + + + {{/each}} + + + + + + + + + +
#HDCase#DatePatientTypeCycleDepartmentQty
{{no}} + {{view "link" string=hname action="clinic_hd_case" action_options="mode=form" active_id=hid}} + {{date}}{{pname}}{{tname}}{{cname}}{{dpt_name}}{{qty}}
{{total_qty}}
diff --git a/netforce_clinic/templates/report_medical_summary.hbs b/netforce_clinic/templates/report_medical_summary.hbs index e10d1c8..b8ba80c 100644 --- a/netforce_clinic/templates/report_medical_summary.hbs +++ b/netforce_clinic/templates/report_medical_summary.hbs @@ -20,7 +20,9 @@ {{prod_name}} {{#each sub_lines}} - {{qty}} + + {{qty}} + {{/each}} {{/each}} diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index d28e542..fe63954 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,8 +1,8 @@ report cycle item - - remove minus from fee amount - - summary amount + - remove minus from fee amount -> ok + - summary amount -> ok report medical - see detail of amount (department, patient, cycle, hdcase#) report claim expense: - - add good issue columns + - add good issue columns -> ok