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 100644 index 0000000..8a209fd Binary files /dev/null and b/netforce_clinic/reports/report_hdcase_summary.xlsx differ 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}} +
+