From 4440a5a31247cc048ac0f11e093ce4f48a6c734a Mon Sep 17 00:00:00 2001 From: "watcha.h" Date: Tue, 25 Nov 2014 12:24:51 +0700 Subject: [PATCH] xxxx --- .../layouts/clinic_visit_dialy.xml | 3 +- netforce_clinic/models/hd_case.py | 2 + netforce_clinic/models/hd_case_dialy.py | 12 +++- netforce_clinic/models/setting.py | 1 - netforce_clinic/models/visit.py | 31 +++++----- netforce_clinic/models/visit_dialy.py | 58 ++++++++++++++----- netforce_clinic/templates/visit_dialy.hbs | 6 +- netforce_clinic/todo.txt | 3 + 8 files changed, 81 insertions(+), 35 deletions(-) diff --git a/netforce_clinic/layouts/clinic_visit_dialy.xml b/netforce_clinic/layouts/clinic_visit_dialy.xml index 3a275c4..2505e6f 100644 --- a/netforce_clinic/layouts/clinic_visit_dialy.xml +++ b/netforce_clinic/layouts/clinic_visit_dialy.xml @@ -1,3 +1,4 @@
- + + diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py index b317a90..8638ec0 100644 --- a/netforce_clinic/models/hd_case.py +++ b/netforce_clinic/models/hd_case.py @@ -76,6 +76,8 @@ class HDCase(Model): "total_doctor": fields.Integer("Total Doctor",function="get_personal",function_multi=True), "total_nurse": fields.Integer("Total Nurse",function="get_personal",function_multi=True), 'doctor_id': fields.Many2One("clinic.personal","Doctor",domain=[['type','=','doctor']],function="get_personal",function_multi=True), + # XXX + #"payment_term": fields.Selection([("fee_prod","Invoice Fee & Product"),("x","In Progress"),("completed","Completed"),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("in_completed","In completed")],"Status",required=True), } def _get_number(self,context={}): diff --git a/netforce_clinic/models/hd_case_dialy.py b/netforce_clinic/models/hd_case_dialy.py index f0de7f2..8aea3d0 100644 --- a/netforce_clinic/models/hd_case_dialy.py +++ b/netforce_clinic/models/hd_case_dialy.py @@ -37,6 +37,7 @@ class HDCaseDialy(Model): dom.append(['time_start','>=','%s 00:00:00'%date]) dom.append(['time_stop','<=','%s 23:59:59'%date]) lines=[] + for obj in get_model("clinic.hd.case").search_browse(dom): patient_type=utils.PATIENT_TYPE[obj.patient_id.type] dlz_number="" @@ -61,19 +62,26 @@ class HDCaseDialy(Model): 'dlz_id': dlz_id, 'success_color': obj.state=='completed' and '#99ff99' or '', 'note': obj.note or "", + 'last': False, } lines.append(line) - # XXX + year=int(year)+543 date_str='%s %s %s'%(day,month_str,year) - slines=[] no=1 + slines=[] + cycles=[] for line in sorted(lines,key=lambda x: (x['cycle_sequence'],x['hd_case_number'])): line['no']=no slines.append(line) no+=1 + # find all nurse for each cycle + items=get_model("clinic.cycle.item").search_browse([['date','=',date]]) + for item in sorted(items,key=lambda x: x.cycle_id.sequence): + pass + data={ 'lines': slines, 'date': date_str, diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 1d3301a..646dabe 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -23,7 +23,6 @@ class ClinicSetting(Model): "company_id": lambda *a: get_active_company(), } - def read_excel(self,fpath=None): data={} if fpath: diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py index 8db9a95..8054846 100644 --- a/netforce_clinic/models/visit.py +++ b/netforce_clinic/models/visit.py @@ -135,7 +135,7 @@ class Visit(Model): 'type': 'fee', 'product_id': product.id, 'description': product.name or "", - 'qty': 1, + 'qty': 2, 'price': product.sale_price or 0.0, 'amount': product.sale_price or 0.0, 'uom_id': product.uom_id.id, @@ -192,7 +192,7 @@ class Visit(Model): dom=[] dom.append(['date','=',date]) dom.append(['cycle_id','=',cycle.id]) - dom.append(['state','=','draft']) + #dom.append(['state','=','draft']) item_obj=get_model('clinic.cycle.item') item_ids=item_obj.search(dom) @@ -218,21 +218,22 @@ class Visit(Model): # clear old nurse in cycle item item_id=item_ids[0] item=item_obj.browse(item_id) - for nurse in item.nurses: - nurse.delete() + if item.state!='draft': + for nurse in item.nurses: + nurse.delete() item=item_obj.browse(item_id) - schedule=get_schedule(date) - if schedule: - for line in schedule.lines: - if line.cycle_id.id==cycle.id: - nurse=line.nurse_id - item_vals['nurses'].append(('create',{ - 'nurse_id': nurse.id, - 'level_id': nurse.level_id.id, - })) - - item.write(item_vals) + if item.state!='draft': + schedule=get_schedule(date) + if schedule: + for line in schedule.lines: + if line.cycle_id.id==cycle.id: + nurse=line.nurse_id + item_vals['nurses'].append(('create',{ + 'nurse_id': nurse.id, + 'level_id': nurse.level_id.id, + })) + item.write(item_vals) obj.write({ 'cycle_item_id': item_id, diff --git a/netforce_clinic/models/visit_dialy.py b/netforce_clinic/models/visit_dialy.py index 19be82b..9cadf6b 100644 --- a/netforce_clinic/models/visit_dialy.py +++ b/netforce_clinic/models/visit_dialy.py @@ -1,7 +1,6 @@ import time -import urllib.parse as urllib -from datetime import datetime +from datetime import datetime, timedelta from calendar import monthrange from netforce.model import Model, fields, get_model from netforce.access import get_active_company @@ -14,29 +13,50 @@ class VisitDialy(Model): _transient=True _fields={ - "date": fields.Date("Date", required=True), + "date_from": fields.Date("From", required=True), + "date_to": fields.Date("To", required=True), } _defaults={ - 'date': lambda *a: time.strftime("%Y-%m-%d"), + 'date_from': lambda *a: time.strftime("%Y-%m-%d"), + 'date_to': lambda *a: (datetime.now()+timedelta(days=7)).strftime("%Y-%m-%d"), } 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") + date_from=datetime.now().strftime("%Y-%m-%d") + date_to=(datetime.now()+timedelta(days=7)).strftime("%Y-%m-%d") + if ids: obj=self.browse(ids)[0] - date=obj.date - month=int(date[5:7]) - day=date[8:10] - year=date[0:4] + date_from=obj.date_from + date_to=obj.date_to + + time_start='%s 00:00:00'%(date_from) + time_stop='%s 23:59:59'%(date_to) + + month=int(date_from[5:7]) + year=date_from[0:4] + day=date_from[8:10] month_str=utils.MONTHS['th_TH'][month] dom=[] - dom.append(['time_start','>=','%s 00:00:00'%date]) - dom.append(['time_stop','<=','%s 23:59:59'%date]) + dom.append(['time_start','>=','%s'%time_start]) + dom.append(['time_stop','<=','%s'%time_stop]) lines=[] + + empty_line={ + 'number': '', + 'visit_id': None, + 'cycle_name': '', + 'cycle_color': '', + 'patient_name': '', + 'doctor_name': '', + 'hd_case_number': '', + 'hd_case_id': None, + 'success_color': '', + } for obj in get_model("clinic.visit").search_browse(dom): hd_case_id=None hd_case_number='' @@ -47,11 +67,12 @@ class VisitDialy(Model): number=obj.number if number=='/': number='รอการรรักษา' + cycle=obj.cycle_id line={ 'number': number, 'visit_id': obj.id, - 'cycle_name': obj.cycle_id.name, - 'cycle_color': obj.cycle_id.color, + 'cycle_name': cycle.name, + 'cycle_color': cycle.color, 'patient_name': obj.patient_id.name, 'doctor_name': obj.doctor_id.name, 'hd_case_number': hd_case_number, @@ -59,16 +80,23 @@ class VisitDialy(Model): 'success_color': obj.state=='confirmed' and '#99ff99' or '' } lines.append(line) - # XXX + year=int(year)+543 date_str='%s %s %s'%(day,month_str,year) + has_duration=False + if date_from != date_to: + has_duration=True + data={ 'lines': lines, - #'date': date, 'date': date_str, 'company_name': company.name, 'company_parent_name': company.parent_id.name, + 'has_duration': has_duration, + 'date_from': date_from, + 'date_to': date_to, } + return data VisitDialy.register() diff --git a/netforce_clinic/templates/visit_dialy.hbs b/netforce_clinic/templates/visit_dialy.hbs index 89dba43..8c110f5 100644 --- a/netforce_clinic/templates/visit_dialy.hbs +++ b/netforce_clinic/templates/visit_dialy.hbs @@ -4,7 +4,11 @@ {{parent_company_name}} {{company_name}}

- ประจำวันที่ {{date}} + {{#if has_duration}} + ระหว่างวันที่ {{date_from}} ถึง {{date_to}} + {{else}} + ประจำวันที่ {{date}} + {{/if}}

diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index d939a19..0635820 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -3,6 +3,9 @@ - auto complete hd after time out - create payment for each type of patient - invoice + - reports + - visitl dialy + - summary total for each cycle - define rule to get - fee product - invoice