diff --git a/netforce_clinic/models/gen_visit.py b/netforce_clinic/models/gen_visit.py index da8d78f..8dc5fff 100644 --- a/netforce_clinic/models/gen_visit.py +++ b/netforce_clinic/models/gen_visit.py @@ -1,6 +1,6 @@ from datetime import datetime, timedelta -from netforce.access import get_active_user +from netforce.access import get_active_user, set_active_user from netforce.model import Model, fields, get_model from netforce.utils import get_data_path @@ -57,11 +57,18 @@ class GenVisit(Model): cycle=get_model('clinic.cycle').browse(cycle_id) data['time_start']=cycle.time_start data['time_stop']=cycle.time_stop + else: + data['time_start']='' + data['time_stop']='' return data def gen_visit(self,ids,context): obj=self.browse(ids)[0] visit_obj=get_model('clinic.visit') + b_ids=get_model('clinic.branch').search([]) + branch_id=None + if b_ids: + branch_id=b_ids[0] days={} for tline in obj.time_lines: if tline.day and tline.cycle_id and tline.time_start and tline.time_stop: @@ -131,15 +138,18 @@ class GenVisit(Model): cstop=days[weekday]['time_stop'] while count < day_total: tmp=start_date+timedelta(days=count) - ttime_start="%s %s" % (tmp.strftime(FMT_DATE),cstart) - ttime_stop="%s %s" % (tmp.strftime(FMT_DATE),cstop) + visit_date="%s"%(tmp.strftime(FMT_DATE)) + ttime_start="%s %s" % (visit_date,cstart) + ttime_stop="%s %s" % (visit_date,cstop) vals={ 'patient_id': patient_id, 'doctor_id': obj.doctor_id.id or patient.doctor_id.id, - 'department_id': obj.department_id.id, + 'department_id': patient.department_id.id, + 'branch_id': branch_id, 'cycle_id': days[weekday]['cycle_id'], 'time_start': ttime_start, 'time_stop': ttime_stop, + 'visit_date': visit_date, 'state': 'pending', } visit_vals.append(vals) @@ -160,6 +170,7 @@ class GenVisit(Model): if staff_ids: confirm_id=staff_ids[0] for vals in visit_vals: + print("vals ", vals) vals['nurse_id']=confirm_id visit_obj.create(vals) return { diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py index 222e9ed..03cf565 100644 --- a/netforce_clinic/models/visit.py +++ b/netforce_clinic/models/visit.py @@ -27,7 +27,6 @@ class Visit(Model): res[obj.id]={ 'cycle_color': color, 'sequence': '%s-%s'%(obj.time_start[0:10],cycle.sequence), #date-sequence - #'visit_date': obj.time_start[0:10] } return res @@ -101,13 +100,16 @@ class Visit(Model): _order="sequence" - def new_dlz(self,patient_id): + def new_dlz(self,patient_id,department_id): if not patient_id: raise Exception("No Patient to creat Dialyzer") + if not department_id: + raise Exception("No Department to creat Dialyzer") dlz_vals=get_model("clinic.dialyzer").default_get() dlz_vals['product_id']=dlz_vals['product_id'][0] dlz_vals['company_id']=dlz_vals['company_id'][0] dlz_vals['patient_id']=patient_id + dlz_vals['department_id']=department_id dlz_id=get_model('clinic.dialyzer').create(dlz_vals) dialyzer=get_model("clinic.dialyzer").browse(dlz_id) dialyzer.confirm() @@ -118,7 +120,7 @@ class Visit(Model): patient=obj.patient_id dialyzers=get_model("clinic.dialyzer").search_browse([['patient_id','=',patient.id],['state','=','active']]) if not dialyzers: - dlz_id=self.new_dlz(patient.id) + dlz_id=self.new_dlz(patient.id, obj.department_id.id) dialyzer=get_model("clinic.dialyzer").browse(dlz_id) else: dialyzer=dialyzers[-1] @@ -129,7 +131,7 @@ class Visit(Model): 'state': 'expire', }) # get new dialyzer - dlz_id=self.new_dlz(patient.id) + dlz_id=self.new_dlz(patient.id, obj.department_id.id) dialyzer=get_model("clinic.dialyzer").browse(dlz_id) use_time+=1 vals={ diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index d2728fc..9b323a1 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,3 +1,7 @@ + + + + sharing setting - filter by branch - patient -> ok @@ -10,7 +14,7 @@ sharing setting - department -> ok - sickbed -> ok - schedule -> ok - - dialyser + - dialyser -> ok - add popup to new dialyser -> not yet **** - running number