From b1cbccd312059488d5df532b10f1d42e72b18477 Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Thu, 23 Nov 2017 11:25:06 +0700 Subject: [PATCH] revise hdcase summary using patient.move data --- .../actions/clinic_patient_move.xml | 11 ++ .../actions/report_hdcase_summary.xml | 9 ++ netforce_clinic/layouts/clinic_menu.xml | 1 + .../layouts/clinic_patient_form.xml | 1 + .../layouts/clinic_patient_move_form.xml | 7 + .../layouts/clinic_patient_move_list.xml | 7 + .../layouts/report_hdcase_summary.xml | 8 + netforce_clinic/models/__init__.py | 4 + netforce_clinic/models/patient.py | 3 + netforce_clinic/models/patient_move.py | 18 ++- .../models/report_hdcase_summary.py | 101 ++++++++++++ .../reports/report_hdcase_summary.xlsx | Bin 0 -> 6630 bytes .../templates/report_hdcase_summary.hbs | 152 ++++++++++++++++++ 13 files changed, 315 insertions(+), 7 deletions(-) create mode 100644 netforce_clinic/actions/clinic_patient_move.xml create mode 100644 netforce_clinic/actions/report_hdcase_summary.xml create mode 100644 netforce_clinic/layouts/clinic_patient_move_form.xml create mode 100644 netforce_clinic/layouts/clinic_patient_move_list.xml create mode 100644 netforce_clinic/layouts/report_hdcase_summary.xml create mode 100644 netforce_clinic/models/report_hdcase_summary.py create mode 100644 netforce_clinic/reports/report_hdcase_summary.xlsx create mode 100644 netforce_clinic/templates/report_hdcase_summary.hbs diff --git a/netforce_clinic/actions/clinic_patient_move.xml b/netforce_clinic/actions/clinic_patient_move.xml new file mode 100644 index 0000000..6f1d35a --- /dev/null +++ b/netforce_clinic/actions/clinic_patient_move.xml @@ -0,0 +1,11 @@ + + Patient Moves + multi_view + clinic.patient.move + [ + ["All",[[]]], + ["In",[["type","=","in"]]], + ["Out",[["type","=","out"]]]] + + clinic_menu + diff --git a/netforce_clinic/actions/report_hdcase_summary.xml b/netforce_clinic/actions/report_hdcase_summary.xml new file mode 100644 index 0000000..79b0a27 --- /dev/null +++ b/netforce_clinic/actions/report_hdcase_summary.xml @@ -0,0 +1,9 @@ + + HD Case Summary (Revise) + report + report.hdcase.summary + report_hdcase_summary + report_hdcase_summary + 1 + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 875bc87..ac18b10 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -42,6 +42,7 @@ + diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml index 8a6a94d..d660fff 100644 --- a/netforce_clinic/layouts/clinic_patient_form.xml +++ b/netforce_clinic/layouts/clinic_patient_form.xml @@ -133,6 +133,7 @@ + diff --git a/netforce_clinic/layouts/clinic_patient_move_form.xml b/netforce_clinic/layouts/clinic_patient_move_form.xml new file mode 100644 index 0000000..7290868 --- /dev/null +++ b/netforce_clinic/layouts/clinic_patient_move_form.xml @@ -0,0 +1,7 @@ +
+ + + + + + diff --git a/netforce_clinic/layouts/clinic_patient_move_list.xml b/netforce_clinic/layouts/clinic_patient_move_list.xml new file mode 100644 index 0000000..0c64ed1 --- /dev/null +++ b/netforce_clinic/layouts/clinic_patient_move_list.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/netforce_clinic/layouts/report_hdcase_summary.xml b/netforce_clinic/layouts/report_hdcase_summary.xml new file mode 100644 index 0000000..1f4c704 --- /dev/null +++ b/netforce_clinic/layouts/report_hdcase_summary.xml @@ -0,0 +1,8 @@ +
+ + + + + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 9a690ab..b916ed5 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -149,3 +149,7 @@ from . import create_invoice_payment from . import report_stock_card from . import report_receipt_summary from . import report_wizard_labor_cost + +#revise +from . import patient_move +from . import report_hdcase_summary diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 239b348..58bb9eb 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -178,6 +178,7 @@ class Patient(Model): 'location': fields.Char("Share Department"), #to filter 'cw_time': fields.DateTime("Cycle Updated"), 'cw_uid': fields.Many2One("base.user"," Cycle Edit"), + "moves": fields.One2Many("clinic.patient.move","patient_id","Moves"), } def _get_number(self,context={}): @@ -327,6 +328,8 @@ class Patient(Model): obj.write({ 'partner_id': partner_id, }) + + #TODO create patient.move return obj_id def delete(self,ids,context={}): diff --git a/netforce_clinic/models/patient_move.py b/netforce_clinic/models/patient_move.py index 992c736..4d94992 100644 --- a/netforce_clinic/models/patient_move.py +++ b/netforce_clinic/models/patient_move.py @@ -1,17 +1,21 @@ import time -from netforce.model import Model, fields +from netforce.model import Model, fields, get_model class PatientMove(Model): - _name="clinic.patient.move" + _name='clinic.patient.move' + _fields={ - 'patient_id': fields.Many2One('clinic.patient','Patient'), - 'date': fields.DateTime("Date"), - 'location_id': fields.Many2One("clinic.department","Department"), + 'patient_id': fields.Many2One("clinic.patient", "Patient", required=True, on_delete="cascade"), + "date": fields.DateTime("Date"), + "patient_name": fields.Char("Patient Name"), + "patient_type": fields.Char("Patient Type"), #ปกส. .... + "type": fields.Selection([['in','In'],['out','Out']], 'Type', required=True), } - + + _defaults={ 'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"), } -PatientMove() +PatientMove.register() diff --git a/netforce_clinic/models/report_hdcase_summary.py b/netforce_clinic/models/report_hdcase_summary.py new file mode 100644 index 0000000..9167607 --- /dev/null +++ b/netforce_clinic/models/report_hdcase_summary.py @@ -0,0 +1,101 @@ +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, get_active_user + +from . import utils + +class ReportHDCaseSummary(Model): + _name="report.hdcase.summary" + _string="Report HDCase 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"), + 'hdcase_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"HDCase Type"), + } + + 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) + + def _get_branch(self,context={}): + res=get_model('select.company').get_select() + if res: + return res['branch_id'] + + def _get_department(self,context={}): + res=get_model('select.company').get_select() + if res: + if res.get("department_ids"): + return res['department_ids'][0] + else: + return res['department_id'] + + _defaults={ + 'date': lambda *a: time.strftime("%Y-%m-%d"), + 'date_from': _get_date_from, + 'date_to': _get_date_to, + 'branch_id': _get_branch, + 'department_id': _get_department, + 'hdcase_type': 'completed', + } + + 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) + defaults=self.default_get(context=context) + date_from=defaults.get('date_from',date) + date_to=defaults.get('date_to',date) + branch_id=defaults.get("branch_id",None) + department_id=defaults.get("department_id",None) + hdcase_type=defaults.get('hdcase_type','completed') + #TODO get data from clinic.patient.move + #DO SOME STAFF + data={} + 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 + + def run_report(self,ids,context={}): + return { + 'next': { + 'name': 'clinic_print_hd_case_summary', + 'refer_id': ids[0], + 'action_options': 'convert=pdf', + } + } + + def export_pdf(self,ids,context={}): + raise Exception("TODO") + return + +ReportHDCaseSummary.register() diff --git a/netforce_clinic/reports/report_hdcase_summary.xlsx b/netforce_clinic/reports/report_hdcase_summary.xlsx new file mode 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mbmQ;%_e=FD}zm?Kh0; zP!I-LOS33;k?`e|TpTyYcz?F@BY`Yf;q(WoF}oZzfUoT%tGVt%Uk_@z&DujMB%3h1 zgRL>=7L<6?-=~)(9?$a0fF=WM`6kq|)_FlK6Ss~EBi~nNtutSZB`c!M+Lx%CogTGQ zcy|{U7n@@i`UxIt-v*Ci0&CEPjrxj$Q*J20stLaD;(W&kxSQ7Gl(RJK;%6KcrciII zKEJ1!0t~twiAtdAZfi?Dlg$v=N|6wc?$m8;-?8UE3~ZpjNK@Ws%kE1ROkZvYRobTS zb}He5UC~m8TQH6We=|fQd%Wbi?gI;oJ_S4}E{VP{3DIqlBmbBmPS7M%Z%e~vei$=b z^bLEKrEd-m8R<+rPzNOLcty-4v4cPZi}H?Z)Y)BPapQRbHxv5o?wo?W5`#~Dy4d3}A)i=F}g&T;VW z9mhx-?CNRb>S?Cq=Vs$!@^Fl7NmWd}@UU(ccM))!#EYa^sAPc!{EA-$ch79i#pYs5#Ua+<)S%d5B;OXmTo3puMQ&)hw z^^fq>9Z}KxmD5Nn^re zcQg&{GkxR6idOt=dT!JbvoKO<&gJ@LZldERCG0oyQq!z3>KRrD2)Ir}6#YL$i5E~? zfm&MRht5c%4S zH*mfwt@q$6#W0qtXCLoD^w#{vF5Y|5_3tBALm3_cAMO{D|D8!cAo>5c-vIre9e)S4 z56JqLk=#%9C&2!*_wU^B0p|WPv3tt!pWgpQyMK279o9U+#b366?^yo}HU2rm?@;3b z>in{Lq<@a^e-O`~O_&$j~JkNiMy+6DD z9#Ibo_m{2Rhta_ A_5c6? literal 0 HcmV?d00001 diff --git a/netforce_clinic/templates/report_hdcase_summary.hbs b/netforce_clinic/templates/report_hdcase_summary.hbs new file mode 100644 index 0000000..017ee66 --- /dev/null +++ b/netforce_clinic/templates/report_hdcase_summary.hbs @@ -0,0 +1,152 @@ +
+

+ {{title}} +

+

+ {{parent_company_name}} {{company_name}}
+

+

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

+
+ + + + + + + + + + {{#each lines}} + + + + + {{#ifeq qty '0'}} + + {{else}} + + {{/ifeq}} + + + {{/each}} + +
{{topic}}{{month}}เท่ากับ + {{qty}} + {{unit}}
+ + + + + + + + + + + + + +
+
+ + รายชื่อผู้ป่วยรับใหม่ + +
+
+
+ + รายชื่อผู้ป่วยจำหน่าย + +
+
+ + + + + + + + {{#if recent_patients}} + {{#each recent_patients}} + + + + + + {{/each}} + {{else}} + + + + {{/if}} + + + +
#วันที่ชื่อ
{{no}}{{reg_date}} + {{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}} +
+ No items to display. +
+
+ + + + + + + + {{#if resign_patients}} + {{#each resign_patients}} + + + + + + {{/each}} + {{else}} + + + + {{/if}} + + + +
#วันที่ชื่อ
{{no}}{{resign_date}} + {{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}} +
+ No items to display. +
+
+ +
+ + รวมจำนวนยาที่ใช้ประจำเดือน + +
+
+ + + {{#each titles}} + + {{/each}} + + + {{#each medicals}} + + + {{#each sub_lines}} + + {{/each}} + + {{/each}} + + + +
{{name}}
+ {{prod_name}} + + {{qty}} +
+