From fe76ddc2930c369d275ce7677115fb3c97d6a7cd 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 -> 5069 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..e6297d847c09b16a66bbad5449ba7d5f50f83a45 GIT binary patch literal 5069 zcmaJ_2Q*x3*VYZ9cS6)CNf<^C5y2>t=)LzoBZxML=tPZ@(R=TrGl(`sH&H^AghZkf zEuwtp-v55_XWcJ*)|zu>&Dr}s@AK~c?4tG%8;1%5003b0@Hoq3ToIzndsA0yCpUgR z^moO}QDtlavaoHx$T*m11GSvhYee{1nxbC-eCXUVksPfvA{=#x*++DgIY=$vmcHw8+GlwQ!K`Hj&KRk8 z>6u7;GAp>=9A-6d1q*gIHpRZM`g#~%a=2i(@H1K`>?rtEb;&w7%yY#A3oJhVNjEp{ z&Jj15AJj&!Ix45Boz3vL)rsHp2kbF`d&;n8Df~%Blh*4fc*j%8<}lX`Y0A~$%5yjI zCIC40yzS+qZ-aJ|o#R|~(imzF@c}lafsIR-+rEp1arygy0mE?lgqIWl-`IFUT^%i; zP)9y5XQ#h$ihtzT4ZIe*eMSvF>Q%zGj1ogc$yA*kWA>?k8tV~xIaPn*&&Oy;XuUC( zFgE?YUGZQ|D0(ftNA?hZ8x&=2lrsUeO8f?| zzl-VfS#-tSHO?PUeq1s=&=Rz%&Of-Pgi6O8rq--5#IA$fQfqbVx~R6CCMGe>gJl8x zi3x^Xnd3p@8nG5jxA+C|_nm)ymijEs#x%qJwkjw~L&TF{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{>GmvK4YRK@K@pg! zs87;5Wlf$g2faL!dF)Wu?Byzq;mXKFp6s_STK5LB>l|PydMQr9WaA%0eOT))047EpHcVH)Axmh{Q*# ze|5P(skJMMhx;&D-$C#>Vt^4(z^uDd#m*G(&D}4Ui<}gF!<}b)ICZExwwGtr-|8>c zzh{Um_e_FQS;jv{E$B6t_MkrTbf*@gXD7<%N7;yU|!F {{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