diff --git a/netforce_clinic/actions/clinic_report_nurse_fee_detail.xml b/netforce_clinic/actions/clinic_report_nurse_fee_detail.xml new file mode 100644 index 0000000..aa1611b --- /dev/null +++ b/netforce_clinic/actions/clinic_report_nurse_fee_detail.xml @@ -0,0 +1,8 @@ + + Report Nurse Fee Detail + report + clinic.report.nurse.fee.detail + report_nurse_fee_detail + report_nurse_fee_detail + clinic_menu + diff --git a/netforce_clinic/actions/clinic_report_nurse_fee_sum.xml b/netforce_clinic/actions/clinic_report_nurse_fee_sum.xml new file mode 100644 index 0000000..ec363ee --- /dev/null +++ b/netforce_clinic/actions/clinic_report_nurse_fee_sum.xml @@ -0,0 +1,8 @@ + + Report Nurse Fee Summary + report + clinic.report.nurse.fee.sum + report_nurse_fee_sum + report_nurse_fee_sum + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 7f25e33..6045a04 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -49,9 +49,9 @@
- - - + + + diff --git a/netforce_clinic/layouts/clinic_report_nurse_fee_detail.xml b/netforce_clinic/layouts/clinic_report_nurse_fee_detail.xml new file mode 100644 index 0000000..ee97439 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_nurse_fee_detail.xml @@ -0,0 +1,6 @@ +
+ + + + + diff --git a/netforce_clinic/layouts/clinic_report_nurse_fee_sum.xml b/netforce_clinic/layouts/clinic_report_nurse_fee_sum.xml new file mode 100644 index 0000000..6d752a7 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_nurse_fee_sum.xml @@ -0,0 +1,5 @@ +
+ + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 5cf384f..c1a071b 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -36,11 +36,6 @@ from . import cycle_dialy from . import cycle_dialy_line from . import gen_visit from . import gen_visit_line -from . import report_clinic -from . import report_hd_case_summary -from . import report_medical_summary -from . import report_recent_patient -from . import report_discontinue_patient from . import fin_setting from . import import_data_mg from . import import_data_nhso @@ -58,3 +53,10 @@ from . import schedule_line from . import schedule_copy from . import load_nurse from . import load_nurse_line +from . import report_clinic +from . import report_hd_case_summary +from . import report_medical_summary +from . import report_recent_patient +from . import report_discontinue_patient +from . import report_nurse_fee_sum +from . import report_nurse_fee_detail diff --git a/netforce_clinic/models/cycle_dialy_line.py b/netforce_clinic/models/cycle_dialy_line.py index 5ce20e4..cfa803c 100644 --- a/netforce_clinic/models/cycle_dialy_line.py +++ b/netforce_clinic/models/cycle_dialy_line.py @@ -15,6 +15,7 @@ class CycleDialyLine(Model): 'amount': fields.Float("Amount"), 'company_id': fields.Many2One("company","Company"), "type": fields.Selection([("doctor","Doctor"),('nurse','Nurse'),("personal","Personal")],"Type",required=True), + 'date': fields.Date("Date"), } _defaults={ diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py index 43dc67d..022d23c 100644 --- a/netforce_clinic/models/cycle_item.py +++ b/netforce_clinic/models/cycle_item.py @@ -208,6 +208,7 @@ class CycleItem(Model): line={ 'cycle_id': cycle_id, 'personal_id': personal_id, + 'date': obj.date, } line.update(vals) lines.append(('create',line)) diff --git a/netforce_clinic/models/report_nurse_fee_detail.py b/netforce_clinic/models/report_nurse_fee_detail.py new file mode 100644 index 0000000..0c9f1ed --- /dev/null +++ b/netforce_clinic/models/report_nurse_fee_detail.py @@ -0,0 +1,126 @@ +import time +from calendar import monthrange + +from netforce.model import Model,fields,get_model +from netforce.access import get_active_company + +from . import utils + +class ReportNurseFeeDetail(Model): + _name="clinic.report.nurse.fee.detail" + _string="Report Nurse Fee Summary" + _transient=True + + _fields={ + "date": fields.Date("Month"), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), + 'personal_id': fields.Many2One("clinic.personal","Personal"), + } + + 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) + year, month=time.strftime("%Y-%m").split("-") + weekday, total_day=monthrange(int(year), int(month)) + time_start='%s-%s-01'%(year,str(month).zfill(2)) + time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day) + + defaults=context.get('defaults') + if defaults: + year,month,day=defaults['date'].split("-") + time_start='%s-%s-01'%(year,str(month).zfill(2)) + time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day) + personal_id=None + if ids: + obj=self.browse(ids)[0] + month=obj.date_from.split("-")[1] + time_start=obj.date_from + time_stop=obj.date_to + personal_id=obj.personal_id.id + # new patient of this month + dom=[] + dom.append(['date','>=',time_start]) + dom.append(['date','<=',time_stop]) + personal_name='' + if personal_id: + personal=get_model("clinic.personal").browse(personal_id) + personal_name=personal.name + dom.append(['personal_id','=',personal.id]) + records=get_model('clinic.cycle.dialy.line').search_browse(dom) + # group by date + all_vals={} + for record in records: + #date='' + #if record.date: + #date=record.date[8:10] + date=record.date + personal_id=record.personal_id.id + key=(date,personal_id) + if key not in all_vals.keys(): + all_vals[key]={ + 'qty': 0, + 'amount': 0, + } + all_vals[key]['qty']+=record.qty or 0 + all_vals[key]['amount']+=record.amount or 0 + + lines=[] + total_amount=0.0 + total_qty=0.0 + for key,vals in all_vals.items(): + date,personal_id=key + qty=vals['qty'] or 0 + amount=vals['amount'] or 0 + lines.append({ + 'date': date, + 'qty': qty, + 'amount': amount or 0.0, + }) + total_qty+=qty + total_amount+=amount + + month_str=utils.MONTHS['th_TH'][int(month)] + start=int(time_start[8:10]) + stop=int(time_stop[8:10]) + diff=stop-start + data={ + 'company_name': company.name or "", + 'parent_company_name': company.parent_id.name or "", + 'personal_name': personal_name, + 'lines': lines, + 'total_qty': total_qty, + 'total_amount': total_amount, + 'month': month_str, + 'from': time_start, + 'to': time_stop, + 'is_duration': diff+1 < total_day, + 'year': year, + } + 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 + +ReportNurseFeeDetail.register() diff --git a/netforce_clinic/models/report_nurse_fee_sum.py b/netforce_clinic/models/report_nurse_fee_sum.py new file mode 100644 index 0000000..6bc2f33 --- /dev/null +++ b/netforce_clinic/models/report_nurse_fee_sum.py @@ -0,0 +1,96 @@ +import time +from calendar import monthrange + +from netforce.model import Model,fields,get_model +from netforce.access import get_active_company + +from . import utils + +class ReportNurseFeeSum(Model): + _name="clinic.report.nurse.fee.sum" + _string="Report Nurse Fee Summary" + _transient=True + + _fields={ + "date": fields.Date("Month"), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), + } + + 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) + year, month=time.strftime("%Y-%m").split("-") + weekday, total_day=monthrange(int(year), int(month)) + time_start='%s-%s-01'%(year,str(month).zfill(2)) + time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day) + + defaults=context.get('defaults') + if defaults: + year,month,day=defaults['date'].split("-") + time_start='%s-%s-01'%(year,str(month).zfill(2)) + time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day) + if ids: + obj=self.browse(ids)[0] + month=obj.date_from.split("-")[1] + time_start=obj.date_from + time_stop=obj.date_to + # new patient of this month + dom=[] + dom.append(['resign_date','>=',time_start]) + dom.append(['resign_date','<=',time_stop]) + dom.append(['active','=',False]) + records=get_model('clinic.patient').search_browse(dom) + lines=[] + no=1 + for record in records: + lines.append({ + 'no': no, + 'name': record.name or '', + 'pid': record.id, + 'note': record.note or '', + 'resign_date': record.resign_date or '', + }) + no+=1 + + month_str=utils.MONTHS['th_TH'][int(month)] + start=int(time_start[8:10]) + stop=int(time_stop[8:10]) + diff=stop-start + data={ + 'company_name': company.name or "", + 'parent_company_name': company.parent_id.name or "", + 'lines': lines, + 'month': month_str, + 'from': time_start, + 'to': time_stop, + 'is_duration': diff+1 < total_day, + 'year': year, + } + 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 + +ReportNurseFeeSum.register() diff --git a/netforce_clinic/reports/report_nurse_fee_detail.xlsx b/netforce_clinic/reports/report_nurse_fee_detail.xlsx new file mode 100644 index 0000000..74f749f Binary files /dev/null and b/netforce_clinic/reports/report_nurse_fee_detail.xlsx differ diff --git a/netforce_clinic/reports/report_nurse_fee_sum.xlsx b/netforce_clinic/reports/report_nurse_fee_sum.xlsx new file mode 100644 index 0000000..74f749f Binary files /dev/null and b/netforce_clinic/reports/report_nurse_fee_sum.xlsx differ diff --git a/netforce_clinic/templates/report_nurse_fee_detail.hbs b/netforce_clinic/templates/report_nurse_fee_detail.hbs new file mode 100644 index 0000000..4f4d0d1 --- /dev/null +++ b/netforce_clinic/templates/report_nurse_fee_detail.hbs @@ -0,0 +1,41 @@ +
+

ผลตอบแทนดูแลผู้ป่วย

+

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

+

+ {{personal_name}} +

+

+ {{#if is_duration}} + ระหว่างวันที่ {{from}} ถึง {{to}} + {{else}} + ประจำเดือน {{month}} {{year}} + {{/if}} +

+
+{{#if lines}} + + + + + + + + {{#each lines}} + + + + + + {{/each}} + + + + + + +
วันที่จำนวนคนไข้จำนวนเงิน
{{date}}{{qty}}{{currency amount}}
TOTAL{{total_qty}}{{currency total_amount}}
+{{else}} + No items to display. +{{/if}} diff --git a/netforce_clinic/templates/report_nurse_fee_sum.hbs b/netforce_clinic/templates/report_nurse_fee_sum.hbs new file mode 100644 index 0000000..4d5f9c3 --- /dev/null +++ b/netforce_clinic/templates/report_nurse_fee_sum.hbs @@ -0,0 +1,39 @@ +
+

สรุปค่าธรรมเนียมพยาบาล

+

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

+

+ {{#if is_duration}} + ระหว่างวันที่ {{from}} ถึง {{to}} + {{else}} + ประจำเดือน {{month}} {{year}} + {{/if}} +

+
+{{#if lines}} + + + + + + + + + {{#each lines}} + + + + + + + {{/each}} + + + +
#วันที่ชื่อหมายเหตุ
{{no}}{{resign_date}} + {{view "link" string=name action="clinic_patient" action_options="mode=form" active_id=pid}} + {{note}}
+{{else}} + No items to display. +{{/if}} diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index e070d3b..96933f2 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,4 +1,7 @@ ======= + - define rule to get + - fee product + - invoice - add picture of patient to visit/hd case dialy - cycle dialy - lines