From a7faddcfcd3860901b4ab0abcfd1f067be3d1e40 Mon Sep 17 00:00:00 2001 From: "watcha.h@almacom.co.th" Date: Thu, 15 Jan 2015 23:18:06 +0700 Subject: [PATCH] report visit --- .../actions/clinic_report_visit.xml | 8 ++ netforce_clinic/layouts/clinic_menu.xml | 1 + .../layouts/clinic_report_visit.xml | 7 ++ netforce_clinic/models/__init__.py | 1 + netforce_clinic/models/report_visit.py | 114 ++++++++++++++++++ netforce_clinic/reports/report_visit.xlsx | Bin 0 -> 5206 bytes netforce_clinic/templates/report_visit.hbs | 41 +++++++ netforce_clinic/todo.txt | 1 - 8 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 netforce_clinic/actions/clinic_report_visit.xml create mode 100644 netforce_clinic/layouts/clinic_report_visit.xml create mode 100644 netforce_clinic/models/report_visit.py create mode 100644 netforce_clinic/reports/report_visit.xlsx create mode 100644 netforce_clinic/templates/report_visit.hbs diff --git a/netforce_clinic/actions/clinic_report_visit.xml b/netforce_clinic/actions/clinic_report_visit.xml new file mode 100644 index 0000000..de52702 --- /dev/null +++ b/netforce_clinic/actions/clinic_report_visit.xml @@ -0,0 +1,8 @@ + + Report Visit + report + clinic.report.visit + report_visit + report_visit + clinic_menu + diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 2d3b9e0..ff172e4 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -49,6 +49,7 @@ + diff --git a/netforce_clinic/layouts/clinic_report_visit.xml b/netforce_clinic/layouts/clinic_report_visit.xml new file mode 100644 index 0000000..fe0b2e7 --- /dev/null +++ b/netforce_clinic/layouts/clinic_report_visit.xml @@ -0,0 +1,7 @@ +
+ + + + + + diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py index 1cbd276..db1214a 100644 --- a/netforce_clinic/models/__init__.py +++ b/netforce_clinic/models/__init__.py @@ -59,6 +59,7 @@ from . import schedule_copy from . import load_nurse from . import load_nurse_line from . import report_clinic +from . import report_visit from . import report_hd_case_summary from . import report_medical_summary from . import report_recent_patient diff --git a/netforce_clinic/models/report_visit.py b/netforce_clinic/models/report_visit.py new file mode 100644 index 0000000..9ee2155 --- /dev/null +++ b/netforce_clinic/models/report_visit.py @@ -0,0 +1,114 @@ +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 ReportVisit(Model): + _name="clinic.report.visit" + _string="Report Visit" + _transient=True + + _fields={ + "date": fields.Date("Month"), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), + "patient_id": fields.Many2One("clinic.patient","Patient"), + "doctor_id": fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']]), + } + + 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("-") + 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) + patient_id=None + doctor_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 + patient_id=obj.patient_id.id + doctor_id=obj.doctor_id.id + # new patient of this month + dom=[] + dom.append(['visit_date','>=',time_start]) + dom.append(['visit_date','<=',time_stop]) + if patient_id: + dom.append(['patient_id','=',patient_id]) + if doctor_id: + dom.appen(['doctor_id','=',doctor_id]) + + records=get_model('clinic.visit').search_browse(dom) + lines=[] + no=1 + for record in records: + lines.append({ + 'no': no, + 'vid': record.id, + 'cid': record.cycle_id.id, + 'cname': record.cycle_id.name or "", + 'pid': record.patient_id.id or '', + 'pname': record.patient_id.name or '', + 'tname': record.patient_id.type_id.name or '', + 'tid': record.patient_id.type_id.id or '', + 'did': record.doctor_id.id, + 'dname': record.doctor_id.name or "", + 'date': record.visit_date or '', + 'note': record.note 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 + +ReportVisit.register() diff --git a/netforce_clinic/reports/report_visit.xlsx b/netforce_clinic/reports/report_visit.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..879078ac38b1779e26966bc64e306efcab30328b GIT binary patch literal 5206 zcmaJ_1yodP*QP^K=@MxWWEeW-!oX0{DIGI3GcZF+HzFZDgrYEXHwF!Yz#t(d0#Z^U zAs{I6f%m^xf4}eEXV#iCXRWjMIq$P)Kksw4js`9sH5L&O5teuu0F3nuNG^U`A)u~E zfZ*kKMe-YUTp(ric3|v7f1gGgB}iRM%y719UKW%Oo^q zuG?v1DZOZ2!2B#4G7IsKaI>(&J%_9v#*`e+InI5LH;Vomkx^Z;36Azzw!{HTjVv1H zJ-qdm7Yq=2c~$$3lD^>+My(gF0H0%jEh63tvziYv9*>$0>f%ssUb4@k5s&1lRwF9U zkW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2ssmk?t6gQb|;G6u1(u`o?kC=RSk%7d)LinMBTQ%G^N{rcfMho@nN}78j9L3DRgYk zq^Y!fY*Da{wr;)H+!aUX)w6_~y1n!;G^YiqsCWmPIaff=`{o|4u`us!F-_mV?vc9l zHhVLwcbTnl1$SwfvG3!RrIw8+*Y+5ma@|E6LYi2^y2~T3JZ&&luGFr4bPOJ7LZg`x z#f_nYk_vtEYJo2zTl`!tU&60wo$XA{Zk=rCs_1c^woW$s>tYp%usVP$#29IcS z&-^!@n6jaIV`QPyNHVLJ6l=XOJcnDMb|ZY7hX-shQ%QeZg0Z$fft-8_P6nhf^F1R* zAwO%4c1H?`OQO4Mz}JnGZ#*6b{R{c1)*ns2`=l@&c)_;ug{{@mz{a7*`Z)snbp~=d z0{Z{>Wgzr>;IAWs%Mr;>FkIZ~p9dzt=lRudUk((0LgYf1F7o`(@xt#}e)Vpb-ux#7 z34dhyFQ@){hF^`srN{dTUgE!><1feed+@I^dg`GX&xBuH&{2uzN&|K>5PcW1J zx9a{L{cAH_iqTJqT`b~n&HhW8eh>fkpK;l7KaqIxEdQhbbTse@E-xa!_{d+>2m9LP G*?$1{r?T<@ literal 0 HcmV?d00001 diff --git a/netforce_clinic/templates/report_visit.hbs b/netforce_clinic/templates/report_visit.hbs new file mode 100644 index 0000000..0063263 --- /dev/null +++ b/netforce_clinic/templates/report_visit.hbs @@ -0,0 +1,41 @@ +
+ +
+ + + + + + + + + + + + {{#each lines }} + + + + + + + + + + {{/each}} + + + +
#วันที่รอบผู้ป่วยสิทธ์แพทย์หมายเหตุ
{{no}}{{date}}{{cname}}{{pname}}{{tname}}{{dname}}{{note}}
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index 1e667e3..397125f 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -12,7 +12,6 @@ report: - doctor detail (for accounting) - patient visit - sharing setting - filter by branch - patient -> ok