diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml index aa70254..6c7d2ae 100644 --- a/netforce_clinic/layouts/clinic_patient_form.xml +++ b/netforce_clinic/layouts/clinic_patient_form.xml @@ -15,7 +15,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_report_labor_cost_daily.xml b/netforce_clinic/layouts/clinic_report_labor_cost_daily.xml index 6647b90..0971e59 100644 --- a/netforce_clinic/layouts/clinic_report_labor_cost_daily.xml +++ b/netforce_clinic/layouts/clinic_report_labor_cost_daily.xml @@ -2,5 +2,6 @@ - + + diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 5a2958d..f047da4 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -351,7 +351,7 @@ class Patient(Model): datenow=time.strftime("%Y-%m-%d") vdom=[ ['patient_id','in',ids], - ['visit_date','>',datenow], + ['visit_date','>=',datenow], ['state','=','pending'], ['manual','=',False], ] @@ -564,4 +564,14 @@ class Patient(Model): return data + def onchange_walkin(self,context={}): + data=context['data'] + if data['walkin']=='yes': + res=get_model('clinic.staff').search([['number','=','walkin'],['type','=','doctor']]) + if res: + data['doctor_id']=res[0] + else: + data['doctor_id']=None + return data + Patient.register() diff --git a/netforce_clinic/models/report_labor_cost_daily.py b/netforce_clinic/models/report_labor_cost_daily.py index adc7a4f..4e101e6 100644 --- a/netforce_clinic/models/report_labor_cost_daily.py +++ b/netforce_clinic/models/report_labor_cost_daily.py @@ -13,6 +13,7 @@ class ReportLaborCostDaily(Model): "staff_type": fields.Selection([["doctor","Doctor"],["nurse","Nurse"],["staff","Staff"]],"Type"), 'staff_id': fields.Many2One("clinic.staff","Staff"), 'department_id': fields.Many2One("clinic.department",'Department'), + 'branch_id': fields.Many2One("clinic.branch","Branch"), } def default_get(self,field_names=None,context={},**kw): @@ -21,11 +22,13 @@ class ReportLaborCostDaily(Model): staff_type=defaults.get("staff_type","doctor") staff_id=int(defaults.get('staff_id', "0")) department_id=int(defaults.get('department_id', "0")) + branch_id=int(defaults.get('branch_id', "0")) res={ 'date': date, 'staff_type': staff_type, 'staff_id': staff_id and staff_id or None, 'department_id': department_id and department_id or None, + 'branch_id': branch_id and branch_id or None, } print("res ", res) return res @@ -37,6 +40,7 @@ class ReportLaborCostDaily(Model): date=defaults.get("date") staff_id=defaults.get("staff_id") staff_type=defaults.get("staff_type") + branch_id=defaults.get("branch_id") dpt_id=defaults.get("department_id") dom=[] if ids: @@ -44,6 +48,7 @@ class ReportLaborCostDaily(Model): date=obj.date staff_id=obj.staff_id.id staff_type=obj.staff_type + branch_id=obj.branch_id.id dpt_id=obj.department_id.id dom.append(['date','>=',date]) dom.append(['date','<=',date]) @@ -55,6 +60,8 @@ class ReportLaborCostDaily(Model): dom.append(['staff_id','=',staff_id]) if staff_type: dom.append(['type','=',staff_type]) + if branch_id: + dom.append(['labor_cost_id.cycle_item_id.branch_id','=',branch_id]) if dpt_id: dom.append(['labor_cost_id.cycle_item_id.department_id','=',dpt_id]) print('dom ', dom) diff --git a/netforce_clinic/models/report_labor_cost_detail.py b/netforce_clinic/models/report_labor_cost_detail.py index 8c549f2..58acb1c 100644 --- a/netforce_clinic/models/report_labor_cost_detail.py +++ b/netforce_clinic/models/report_labor_cost_detail.py @@ -128,9 +128,10 @@ class ReportLaborCostDetail(Model): qty=0 if staff.type=='doctor': for hdcase in citem.hd_cases: - doctor_id=hdcase.doctor_id.id - if staff.id==doctor_id: - qty+=1 + if hdcase.state in ('waiting_payment','paid'): + doctor_id=hdcase.doctor_id.id + if staff.id==doctor_id: + qty+=1 elif staff.type=='nurse': qty=citem.pt_total or 0 # qty of patient else: @@ -141,6 +142,7 @@ class ReportLaborCostDetail(Model): 'staff_id': staff.id, 'staff_name': staff.name or "", 'staff_type': staff.type, + 'department_id': department_id, dpt.name: { 'amt': 0, 'qty': 0, @@ -153,6 +155,7 @@ class ReportLaborCostDetail(Model): 'staff_id': staff.id, 'staff_name': staff.name or '', 'staff_type': staff.type, + 'department_id': department_id, dpt.name: { 'amt': 0, 'qty': 0, @@ -199,7 +202,8 @@ class ReportLaborCostDetail(Model): 'date': kdate, 'staff_type': vals.get("staff_type"), 'staff_id': vals.get("staff_id"), - 'labor_cost_id': vals.get("labor_cost_id") + 'labor_cost_id': vals.get("labor_cost_id"), + 'department_id': vals.get('department_id'), } total_qty, total_amt=0, 0 lvals['sub_lines']=[] @@ -229,6 +233,8 @@ class ReportLaborCostDetail(Model): # summary as footer dpt_lines=[{'qty': 0, 'amt': 0} for dpt in dpts] for line in lines: + line['branch_id']=branch_id + line['department_id']=department_id i=0 for sub_line in line['sub_lines']: dpt_lines[i]['qty']+=sub_line['qty'] or 0 @@ -271,7 +277,8 @@ class ReportLaborCostDetail(Model): 'dpt_lines': dpt_lines, 'show_all': show_count <=1 and True or False, } - print('.... ', data['show_name']) + print('department_id ', department_id) + print('branch_id ', branch_id) return data def onchange_date(self,context={}): diff --git a/netforce_clinic/models/report_labor_cost_summary.py b/netforce_clinic/models/report_labor_cost_summary.py index f51030e..79343b5 100644 --- a/netforce_clinic/models/report_labor_cost_summary.py +++ b/netforce_clinic/models/report_labor_cost_summary.py @@ -142,8 +142,9 @@ class ReportLaborCostSummary(Model): if staff.level_id: level=get_model("clinic.staff.level").browse(staff.level_id.id) level_name=level.name or "" - if not staffs.get(staff.name): - staffs[staff.name]={ + staff_name='%s %s'%(staff.first_name, staff.last_name) + if not staffs.get(staff_name): + staffs[staff_name]={ 'number': staff.number or '', 'first_name': staff.first_name or "", 'staff_id': staff.id, @@ -156,14 +157,14 @@ class ReportLaborCostSummary(Model): 'qty': qty, }, } - if not staffs[staff.name].get(dpt.name): - staffs[staff.name].update({ + if not staffs[staff_name].get(dpt.name): + staffs[staff_name].update({ dpt.name: { 'amt': 0, 'qty': qty, }}) - staffs[staff.name][dpt.name]['amt']+=amt - staffs[staff.name][dpt.name]['qty']+=qty + staffs[staff_name][dpt.name]['amt']+=amt + staffs[staff_name][dpt.name]['qty']+=qty if not citems.get(citem.id): qty=0 @@ -252,7 +253,13 @@ class ReportLaborCostSummary(Model): # run no nlines=[] no=1 - for line in sorted(lines, key=lambda x: (x['staff_name'],x['first_name'])): + sort_key='staff_name' + if staff_type=='nurse' and categ_id: + categ=get_model('clinic.staff.categ').browse(categ_id) + if categ.name in ("FT","HP"): + sort_key='number' + + for line in sorted(lines, key=lambda x: (x[sort_key])): line['no']=no nlines.append(line) no+=1 diff --git a/netforce_clinic/templates/report_labor_cost_detail.hbs b/netforce_clinic/templates/report_labor_cost_detail.hbs index 3f6ac8e..9ad3efe 100644 --- a/netforce_clinic/templates/report_labor_cost_detail.hbs +++ b/netforce_clinic/templates/report_labor_cost_detail.hbs @@ -79,7 +79,15 @@ {{/each}} - {{currency total_qty zero=""}} + {{#if ../../department_id}} + {{currency total_qty zero=""}} + {{else}} + {{#if ../../branch_id}} + {{currency total_qty zero=""}} + {{else}} + {{currency total_qty zero=""}} + {{/if}} + {{/if}} {{currency total_amt zero=""}} diff --git a/netforce_clinic/templates/report_labor_cost_summary.hbs b/netforce_clinic/templates/report_labor_cost_summary.hbs index 13b5365..0399f71 100644 --- a/netforce_clinic/templates/report_labor_cost_summary.hbs +++ b/netforce_clinic/templates/report_labor_cost_summary.hbs @@ -19,8 +19,8 @@ # - รหัส {{#ifeq staff_type "nurse"}} + รหัส ชื่อ-สกุล ตำแหน่ง หมวดหมู่ @@ -38,8 +38,8 @@ {{#each lines }} {{no}} - {{number}} {{#ifeq ../staff_type "nurse"}} + {{number}} {{view "link" string=staff_name action="clinic_staff" action_options="mode=form" active_id=staff_id}}