From 0c9ef4b33ed6e5e89cd86ad5ba14c08d4da17c94 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Fri, 12 Jun 2015 10:35:33 +0700 Subject: [PATCH] add report cycle setting --- .../actions/clinic_report_cycle_setting.xml | 8 + netforce_clinic/layouts/clinic_menu.xml | 1 + .../layouts/clinic_report_cycle_setting.xml | 5 + netforce_clinic/models/__init__.py | 1 + .../models/report_cycle_setting.py | 154 ++++++++++++++++++ .../reports/report_cycle_setting.xlsx | Bin 0 -> 6735 bytes .../templates/report_cycle_setting.hbs | 41 +++++ netforce_clinic/todo.txt | 15 +- 8 files changed, 212 insertions(+), 13 deletions(-) create mode 100644 netforce_clinic/actions/clinic_report_cycle_setting.xml create mode 100644 netforce_clinic/layouts/clinic_report_cycle_setting.xml create mode 100644 netforce_clinic/models/report_cycle_setting.py create mode 100644 netforce_clinic/reports/report_cycle_setting.xlsx create mode 100644 netforce_clinic/templates/report_cycle_setting.hbs diff --git a/netforce_clinic/actions/clinic_report_cycle_setting.xml b/netforce_clinic/actions/clinic_report_cycle_setting.xml new file mode 100644 index 0000000..e205637 --- /dev/null +++ b/netforce_clinic/actions/clinic_report_cycle_setting.xml @@ -0,0 +1,8 @@ + + Report Cycle Setting + report + clinic.report.cycle.setting + report_cycle_setting + report_cycle_setting + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 42b66db..6f37415 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -45,6 +45,7 @@ + diff --git a/netforce_clinic/layouts/clinic_report_cycle_setting.xml b/netforce_clinic/layouts/clinic_report_cycle_setting.xml new file mode 100644 index 0000000..d5d2505 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_cycle_setting.xml @@ -0,0 +1,5 @@ +
+ + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 2b18ad9..4e65f51 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -136,5 +136,6 @@ from . import num2word from . import province from . import change_visit from . import share_location +from . import report_cycle_setting #from . import district #from . import subdistrict diff --git a/netforce_clinic/models/report_cycle_setting.py b/netforce_clinic/models/report_cycle_setting.py new file mode 100644 index 0000000..b9e1e99 --- /dev/null +++ b/netforce_clinic/models/report_cycle_setting.py @@ -0,0 +1,154 @@ +from netforce.model import Model, fields, get_model + +class ReportCycleSetting(Model): + _name="clinic.report.cycle.setting" + _transient=True + + _fields={ + 'department_id': fields.Many2One("clinic.department","Department"), + 'branch_id': fields.Many2One("clinic.branch","Branch"), + 'cycle_id': fields.Many2One("clinic.cycle","Cycle"), + } + + 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'] + + def default_get(self,field_names=None,context={},**kw): + defaults=context.get("defaults",{}) + branch_id=defaults.get('branch_id') + if branch_id: + branch_id=int(branch_id) + else: + branch_id=self._get_branch(context=context) + + department_id=defaults.get('department_id') + if department_id: + department_id=int(department_id) + else: + department_id=self._get_department(context=context) + res={ + 'branch_id': branch_id, + 'department_id': department_id, + } + print('report.cycle.item.setting', res) + return res + + def get_report_data(self,ids,context={}): + defaults=self.default_get(context=context) + department_id=defaults.get('department_id',None) + branch_id=defaults.get('branch_id',None) + cycle_id=defaults.get('cycle_id',None) + if ids: + obj=self.browse(ids)[0] + department_id=obj.department_id.id + branch_id=obj.branch_id.id + cycle_id=obj.cycle_id.id + pts={} + dom=[] + dom.append(['patient_id.state','=','admit']) + if department_id: + dom.append(['department_id','=',department_id]) + if cycle_id: + dom.append(['cycle_id','=',cycle_id]) + pcs=get_model("clinic.patient.cycle").search_browse(dom) + if not pcs: + # Create patient cycle with that department + for pt in get_model("clinic.patient").search_browse([['department_id','=',department_id]]): + if pt.walkin=='yes': + continue + for pc in pt.cycles: + vals={ + 'patient_id': pt.id, + 'department_id': pt.department_id.id, + 'cycle_id': pc.cycle_id.id, + 'day': pc.day, + } + res=get_model("clinic.patient.cycle").search([[ + ['patient_id','=',pt.id], + ['day','=',pc.day], + ['cycle_id','=',pc.cycle_id.id], + ['department_id','=', pt.department_id.id], + ]]) + if not res: + pcycle_id=get_model("clinic.patient.cycle").create(vals) + print("create ", pcycle_id) + else: + print("exist ", res) + pcs=get_model("clinic.patient.cycle").search_browse(dom) + if not pcs: + raise Exception("Please go to menu 'Patients -> Patient Cycles' and import data for %s"%(department_id)) + for pc in pcs: + patient=pc.patient_id + dpt=pc.department_id + branch=dpt.branch_id + if not branch: + continue + if branch_id and branch_id!=branch.id: + continue + key=(patient.id,dpt.id) + if not pts.get(key): + pts[key]={ + 'patient_name': patient.name, + 'department_name': dpt.name, + 'mon_cycle_id': None, + 'tue_cycle_id': None, + 'wed_cycle_id': None, + 'thu_cycle_id': None, + 'fri_cycle_id': None, + 'sat_cycle_id': None, + 'sun_cycle_id': None, + } + cycle=pc.cycle_id + day=pc.day or '' + if day=='mon': + pts[key]['mon_cycle_id']=cycle.name + elif day=='tue': + pts[key]['tue_cycle_id']=cycle.name + elif day=='wed': + pts[key]['wed_cycle_id']=cycle.name + elif day=='thu': + pts[key]['thu_cycle_id']=cycle.name + elif day=='fri': + pts[key]['fri_cycle_id']=cycle.name + elif day=='sat': + pts[key]['sat_cycle_id']=cycle.name + else: + pts[key]['sun_cycle_id']=cycle.name + + lines=[] + no=1 + for k, vals in pts.items(): + pt_id, dpt_id=k + if pt_id: + vals['patient_id']=pt_id + if not dpt_id: + pt=get_model("clinic.patient").browse(pt_id) + dpt_id=pt.department_id.id + if dpt_id: + vals['department_id']=dpt_id + vals['no']=no + lines.append(vals) + no+=1 + + data={ + 'lines': lines, + 'department_id': department_id, + } + return data + + def onchange_branch(self,context={}): + data=context['data'] + data['department_id']=None + return data + +ReportCycleSetting.register() diff --git a/netforce_clinic/reports/report_cycle_setting.xlsx b/netforce_clinic/reports/report_cycle_setting.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..2a18e2acef84046bc48775dd2bb1835f3bf82b6b GIT binary patch literal 6735 zcmeI1XH-+$w#R{hfDs8Dq)QE<3LFVV4AMIoLzgb0L+D^Ah9=UxAV^VZN)ZTxbfhbw zNJj)iQ<@+hgqNK2&eiKX=ZrVrhxh5uJyP}unfv})lJbu+3M)f%-1K@m+y1&Zw+$z0OH;bRP90?Kr{O^PT z;jgfBx7A0vdw7Xidw7WYySn5Iy>TLupeLI}KfFjyEM~ zDC3%Bq1VAhAGz_Jfoe~r#;YqS-2&xi_TR(5 z%$1RHA#z#s+li_51q`n0jaek`O$>j#6=4k93ea41tQt=wYZ`PkxShWL@c`y;%Gw>s zq1>NBoV6R-h-;YWbhpnNUJHyZdS-2PeixM~$-~zy+WloiYJ!@eGfB&Y3>dF5%RdI- z1-#DwE@FQqr=L5@*~Z=7nV|LWiQ1IXrrRNYE^;F%rpGS}%Sw^|DLe{ZVMqADVi#t6%A5yww&Gw3%c5enO_?(SY7MDHab9Tm8%rBv`oN0uS zoPC%Mi?&K~V}n#mL<)c>jM=0euHmZ>cM+}3BxbB0-%Sh!JADxs+F!4J1lW3x4$wK$(+k2zZzjz8rOq~M zN|0AKN@zpLs~aR?dmjU;i{~fQiuDLWp}@w%b9fmP0sj<` z^nVEDg|tT5+gDs}mchzyRM-5l3w!_-aIogYuh(n^5G?!X((q^AF zG{5v_95Fd&(HcP$6Q-qK@&c2Fzv*iH>+cH?^B>b9th^V}-rn0w?Dr4J-wV+V9e38t zpr$<|ko^36CnHTe%3jSdZX+GyZd&0Y;=sc6YSVV}fyjB&st|Of`I_1^N6Z(lB+2>g zx$Mh@tGGSQYJp1Ke3Q-3ybI^F;|=c*$AkoopJ3--2UtHELRxh`Y}-s&v3xE$sb)mt zuS(SQ%>Og``xOoIn@W7sq|V~=;2}i&@Mtcrks0XH%~J16TEk_JX#2i0&NY1(V>YH2 ziei18eKyt|CXAc|qm4=@H+>j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~}YM34~bb6Tg0Y~|&(?T{j05mVVjf2phTXrwpOeBcddj2=0R zq+y-Il;emtHo5l@y}EHTH4po8J*y08f}!kDVjT;CSnAV2NNgV!hl-m$s;-(BJF8~i z>nbBdnk%(Crx)zOgNyrim{Co-2n%q~=I-5y|KP9x?n~k8j>=*+!4Brz=us>R&3&Nk zF5t`g#=*j%gIqp)z`=I)%+8a1rGaV{Q8L(ptudUN$?*Lod5p+K^2&GxR9%}bwD)eV zf7K?#Z{?B~tF85e-689&A(Wm@6&O*f!Ig|Gx)W?4c~{8L0j2CIsls=Vf&xrW5jI$m zWk4cky15{Ye-3KZRSPR>1rT$r$Qem=l0l%0A6q)#wkTa|1!g^RWOVG-st5rP)*8-e z*HVF}N~-?|OX%=xZFbGw&D-A1+Y%n&Vee%@*k-*+eXG?W4(j^2XO!BgneBQfx@HP9 zTX_D#AZ^Ojg-QN7(Sfy=J;Tc|8gtKLF)F@2bjwD(bN>O>xtfa0WJ5>-+;tI9)KukW zaW`r~Cm6g~ZBRc=mKW>Hexo2>!dye6AyU_14j|KP60i!NH!|yq{6= zkVxpg_PS55D_=TMgucsc1jaYdqonm*T`$R^g_5?KRw#Vbi2?d>TISo`^bHM-i7|aw zK#pfvqGd|#7;rm`mzAl+4Kz@JKmdZ|{e;0*{h9!NY8Ogo5w`A84r`g?A!kEQjcM%B z+h%{4+(viWoy%RXtx6g0)F<@3R957WCL^^kJ`+9NM!w;WdNdlu-g_dW=$YKe s56_=s{8`3-9sF~Y5-PzD`^xZ_bwOW?49`o5h=BN`A0IVtOoX%l0=uAJ=l}o! literal 0 HcmV?d00001 diff --git a/netforce_clinic/templates/report_cycle_setting.hbs b/netforce_clinic/templates/report_cycle_setting.hbs new file mode 100644 index 0000000..b7b58ae --- /dev/null +++ b/netforce_clinic/templates/report_cycle_setting.hbs @@ -0,0 +1,41 @@ + + + + + + {{#unless department_id}} + + {{/unless}} + + + + + + + + + + {{#each lines }} + + + + {{#unless ../department_id}} + + {{/unless}} + + + + + + + + + {{/each}} + + + +
#PatientDepartmentMondayTuesdayWednesdayThursdayFridaySaturdaySunday
{{no}} + {{view "link" string=patient_name action="clinic_patient" action_options="mode=form" active_id=patient_id}} + {{department_name}}{{mon_cycle_id}}{{tue_cycle_id}}{{wed_cycle_id}}{{thu_cycle_id}}{{fri_cycle_id}}{{sat_cycle_id}}{{sun_cycle_id}}
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index 3ab75b6..610a64a 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,13 +1,2 @@ -> script: - - merge - - staff -> ok - - patient - -> explain nurse - กรณีแก้ไขรายชื่อหมอให้ดูรายชื่อแพทย์ให้ดี - -> note: - แก้ไขยาก หากมาเจอข้อผิดพลาดบางครั้ง - -> report K. boy - total qty of report_labor_cost_staff is not the same report_labor_cost +- show log for each model that use _log=True +- create report patient cycle setting -> link to patient to change cycle setting