diff --git a/netforce_clinic/layouts/clinic_department_form.xml b/netforce_clinic/layouts/clinic_department_form.xml index 5b2b9d7..4556095 100644 --- a/netforce_clinic/layouts/clinic_department_form.xml +++ b/netforce_clinic/layouts/clinic_department_form.xml @@ -3,6 +3,6 @@ + - diff --git a/netforce_clinic/layouts/clinic_department_list.xml b/netforce_clinic/layouts/clinic_department_list.xml index d32d65c..14dc8d9 100644 --- a/netforce_clinic/layouts/clinic_department_list.xml +++ b/netforce_clinic/layouts/clinic_department_list.xml @@ -1,5 +1,6 @@ + diff --git a/netforce_clinic/layouts/clinic_patient_list.xml b/netforce_clinic/layouts/clinic_patient_list.xml index 6787f2a..1b93e97 100644 --- a/netforce_clinic/layouts/clinic_patient_list.xml +++ b/netforce_clinic/layouts/clinic_patient_list.xml @@ -8,7 +8,8 @@ - + + diff --git a/netforce_clinic/layouts/clinic_setting.xml b/netforce_clinic/layouts/clinic_setting.xml index 9e16a2d..907be90 100644 --- a/netforce_clinic/layouts/clinic_setting.xml +++ b/netforce_clinic/layouts/clinic_setting.xml @@ -25,21 +25,10 @@ - - --> diff --git a/netforce_clinic/layouts/clinic_staff_form.xml b/netforce_clinic/layouts/clinic_staff_form.xml index e06150f..f38ae19 100644 --- a/netforce_clinic/layouts/clinic_staff_form.xml +++ b/netforce_clinic/layouts/clinic_staff_form.xml @@ -8,9 +8,9 @@ - + diff --git a/netforce_clinic/layouts/clinic_staff_rotate_form.xml b/netforce_clinic/layouts/clinic_staff_rotate_form.xml index 88bfad6..d2a64ac 100644 --- a/netforce_clinic/layouts/clinic_staff_rotate_form.xml +++ b/netforce_clinic/layouts/clinic_staff_rotate_form.xml @@ -1,5 +1,5 @@
- + diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 79edc8c..87b126f 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -5,13 +5,12 @@ from netforce.access import get_active_company, get_active_user, set_active_user from . import utils - class Patient(Model): _name="clinic.patient" _string="Patient" _audit_log=True _multi_company=True - _key=['number'] + _key=['number','branch_id'] def _get_age(self,ids,context): res={} diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index ee6ae7c..6bb6c33 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -89,12 +89,34 @@ class ClinicSetting(Model): return True def run_script(self,ids,context={}): - for inv in get_model("account.invoice").search_browse([]): - inv.write({ - 'due_date': '2%s'%(inv.due_date[1:]), - 'date': '2%s'%(inv.due_date[1:]), - }) - print("Done") + dts={} + for pt in get_model('clinic.patient').search_browse([]): + doctor=pt.doctor_id + if not dts.get(doctor.id): + dts[doctor.id]=[] + dts[doctor.id].append(pt.id) + x=0 + y=0 + c=1 + for doctor_id, pt_ids in dts.items(): + st=set() + b_ids=[pt.branch_id.id for pt in get_model('clinic.patient').browse(pt_ids)] + for b_id in b_ids: + st.update({b_id}) + if len(st)>1: + if doctor_id: + doctor=get_model('clinic.staff').browse(doctor_id) + doctor.write({ + 'branch_id': 5, + }) + print('%s %s'%(doctor_id, st)) + # update doctor to ratchawat branch + x+=1 + else: + y+=1 + c+=1 + print("RD ", x) + print("Other", y) def reset_last_import(self,ids,context={}): res=get_model("clinic.report.payment.matching").search_read([],['date'],order="date desc") diff --git a/netforce_clinic/models/staff.py b/netforce_clinic/models/staff.py index a116fc9..c541ab2 100644 --- a/netforce_clinic/models/staff.py +++ b/netforce_clinic/models/staff.py @@ -8,7 +8,7 @@ class Staff(Model): _string="Staff" _audit_log=True _multi_company=True - _key=["number","name"] + _key=["name","branch_id"] def _get_age(self,ids,context={}): res={} @@ -135,6 +135,11 @@ class Staff(Model): return num get_model("sequence").increment_number(seq_id,context=context) + def _get_branch(self,context={}): + b_ids=get_model('clinic.branch').search([]) + if b_ids: + return b_ids[0] + _defaults={ 'active': True, "state": "temporary", @@ -142,6 +147,7 @@ class Staff(Model): "date": lambda *a: time.strftime("%Y-%m-%d"), "number": _get_number, "company_id": lambda *a: get_active_company(), + 'branch_id': _get_branch, } _order="date desc,number desc" @@ -190,10 +196,9 @@ class Staff(Model): vals=[] for obj in self.browse(ids): level=obj.level_id - lname="" + name=obj.name or "" if level: - lname=level.name - name="%s (%s)"%(obj.name,lname) + name+=" (%s)"%(level.name or "") vals.append((obj.id,name)) return vals @@ -205,7 +210,12 @@ class Staff(Model): dom=[["name","ilike","%"+name+"%"]] level_ids=get_model('clinic.staff.level').search(dom) - ids2=[x['id'] for x in self.search_read([domain],['level_id']) if x['level_id'][0] in level_ids] + ids2=[] + for x in self.search_read([domain],['level_id']): + if x['level_id']: + level_id=x['level_id'][0] + if level_id in level_ids: + ids2.append(x['id']) ids=list(set(ids1+ids2)) return self.name_get(ids,context=context) diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index 102de9d..d2728fc 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -1,18 +1,18 @@ sharing setting - filter by branch - patient -> ok - - staff -> ok - - nurse ยังไม่มีรายชื่อสาขาที่เขาเลือก - - doctor ยังไม่ match ก้ับคนไข้ + - staff -> not yet + - nurse ยังไม่มีรายชื่อสาขาที่เขาเลือก -> ok + - doctor ยังไม่ match ก้ับคนไข้ **** - visit -> ok - hd case -> ok - cycle item -> ok - department -> ok - sickbed -> ok - - schedule -> + - schedule -> ok - dialyser - - add popup to new dialyser + - add popup to new dialyser -> not yet **** - running number user: