diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml index 34a71a4..db9d926 100644 --- a/netforce_clinic/layouts/clinic_menu.xml +++ b/netforce_clinic/layouts/clinic_menu.xml @@ -1,7 +1,7 @@ - + diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml index d303815..419249c 100644 --- a/netforce_clinic/layouts/clinic_patient_form.xml +++ b/netforce_clinic/layouts/clinic_patient_form.xml @@ -9,16 +9,16 @@ + + - + + - - - diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py index 1188daf..fa17834 100644 --- a/netforce_clinic/models/patient.py +++ b/netforce_clinic/models/patient.py @@ -39,7 +39,32 @@ class Patient(Model): res[obj.id]=hn return res - def _get_name_check(self,ids,context={}): + def _get_name(self,ids,context={}): + res={} + for obj in self.browse(ids): + name='' + title=obj.title_id + if title: + title_name=title.name or "" + title_name=title_name.replace(" ","") + if title_name.lower()!='notitle': + name+=obj.title_id.name or "" + if obj.first_name: + name+=obj.first_name or "" + name+=" " + if obj.last_name: + name+=obj.last_name or "" + if not obj.active: + name+='not_use' + elif context.get('active'): + name+='not_use' + res[obj.id]={ + 'name': name, + 'name_check': name.replace(" ",""), # remove all space for make sure + } + return res + + def _get_name_old(self,ids,context={}): # remove all space for make sure res={} for obj in self.browse(ids): @@ -48,7 +73,9 @@ class Patient(Model): name+='not_use' elif context.get('active'): name+='not_use' - res[obj.id]=name + res[obj.id]={ + 'name_check': name, + } return res _fields={ @@ -59,8 +86,8 @@ class Patient(Model): 'title_id': fields.Many2One("clinic.name.title","Title"), "first_name": fields.Char("First Name"), "last_name": fields.Char("Last Name"), - "name": fields.Char("Name",search=True), - "name_check": fields.Char("Name",function="_get_name_check",store=True), # prevent duplicate + "name": fields.Char("Name",function="_get_name",function_multi=True,store=True,search=True), + "name_check": fields.Char("Name",function="_get_name",function_multi=True,store=True), # prevent duplicate 'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True), "reg_date": fields.Date("Reg. Date",required=False,search=True), "birthday": fields.Date("Birthday",required=False,search=True), @@ -169,7 +196,7 @@ class Patient(Model): _order="resign_date desc,number desc" def create(self, vals,**kw): - obj_id=super(Patient,self).create(vals,**kw) + obj_id=super().create(vals,**kw) self.function_store([obj_id]) obj=self.browse(obj_id) partner_id=obj.partner_id @@ -211,6 +238,8 @@ class Patient(Model): address_ids=[addr.id for addr in obj.partner_id.addresses] get_model("partner").delete(partner_ids) get_model("address").delete(address_ids) + vids=get_model("clinic.visit").search([['patient_id','in',ids],['state','in',['draft','pending']]]) + get_model('clinic.visit').delete(vids) super().delete(ids) def write(self,ids,vals,**kw): @@ -244,6 +273,7 @@ class Patient(Model): 'doctor_id': vals['doctor_id'], } update_visit_pending(obj,visit_vals) + # get name partner_id=obj.partner_id if not partner_id: for partner in get_model("partner").search_browse([['name', '=', obj.name]]): @@ -280,8 +310,13 @@ class Patient(Model): visit_ids=get_model('clinic.visit').search([['patient_id','=',obj.id],['state','in',('draft','pending')]]) get_model('clinic.visit').delete(visit_ids) print('remove visit auto %s'%visit_ids) - self.function_store(ids,context=ctx) super().write(ids,vals,**kw) + self.function_store(ids,context=ctx) + for obj in self.browse(ids): + print(obj.name or "") + obj.partner_id.write({ + 'last_name': obj.name, + }) def name_get(self,ids,context={}): vals=[] diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py index 7f9119e..1759467 100644 --- a/netforce_clinic/models/setting.py +++ b/netforce_clinic/models/setting.py @@ -110,6 +110,132 @@ class ClinicSetting(Model): if user_id !=1: print("Only admin!!") return + titles=dict([(t.name, t.id) for t in get_model("clinic.name.title").search_browse([])]) + title_id=None + gtile_id=title_id + for name, tid in titles.items(): + if name=='No Title': + gtitle_id=tid + for model_name in ('clinic.staff', 'clinic.patient'): + for st in get_model(model_name).search_browse([]): + name=st.name + vals={} + if 'นายแพทย์' in name: + name=name.replace("นายแพทย์","") + tname='นายแพทย์' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'male', + }) + elif 'นพ.' in name: + name=name.replace("นพ.","") + tname='นพ.' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'male', + }) + elif 'นาย' in name: + name=name.replace("นาย","") + tname='นาย' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'male', + }) + elif 'พันตำรวจเอก' in name: + name=name.replace("พันตำรวจเอก","") + tname='พันตำรวจเอก' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'male', + }) + elif 'นางสาว' in name: + name=name.replace("นางสาว","") + tname='นางสาว' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'female', + }) + elif 'นาง' in name: + name=name.replace("นาง","") + tname='นาง' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'female', + }) + elif 'น.ส.' in name: + name=name.replace("น.ส.","") + tname='น.ส.' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'female', + }) + elif 'พญ..' in name: + name=name.replace("พญ..","") + tname='พญ..' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'female', + }) + elif 'แพทย์หญิง' in name: + name=name.replace("แพทย์หญิง","") + tname='แพทย์หญิง' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'female', + }) + elif 'ร้อยเอกหญิง' in name: + name=name.replace("ร้อยเอกหญิง","") + tname='ร้อยเอกหญิง' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'female', + }) + elif 'พันตรีหญิง' in name: + name=name.replace("พันตรีหญิง","") + tname='พันตรีหญิง' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'female', + }) + elif 'พันตำรวจโทหญิง' in name: + name=name.replace("พันตำรวจโทหญิง","") + tname='พันตำรวจโทหญิง' + title_id=titles.get(tname) + vals.update({ + 'title_id': title_id, + 'gender': 'female', + }) + else: + vals.update({ + 'first_name': name, #XXX + 'title_id': gtitle_id, + #'gender': 'male', + }) + names=name.split() + names=[n for n in names if n] # skip space + if len(names)==2: + vals.update({ + 'first_name':names[0], + 'last_name': names[1], + }) + else: + print(name) + st.write(vals) + if not st.gender: + st.write({ + 'gender': 'male', + }) print("Done!") def reset_last_import(self,ids,context={}): diff --git a/netforce_clinic/models/staff.py b/netforce_clinic/models/staff.py index bd0f22d..1e61c40 100644 --- a/netforce_clinic/models/staff.py +++ b/netforce_clinic/models/staff.py @@ -71,11 +71,29 @@ class Staff(Model): res[obj.id]=hids return res - def _get_name_check(self,ids,context={}): - # remove all space for make sure + def _get_name(self,ids,context={}): res={} for obj in self.browse(ids): - res[obj.id]=(obj.name or "").replace(" ","") + name='' + title=obj.title_id + if title: + title_name=title.name or "" + title_name=title_name.replace(" ","") + if title_name.lower()!='notitle': + name+=obj.title_id.name or "" + if obj.first_name: + name+=obj.first_name or "" + name+=" " + if obj.last_name: + name+=obj.last_name or "" + if not obj.active: + name+='not_use' + elif context.get('active'): + name+='not_use' + res[obj.id]={ + 'name': name, + 'name_check': name.replace(" ",""), # remove all space for make sure + } return res _fields={ @@ -84,8 +102,8 @@ class Staff(Model): "title_id": fields.Many2One("clinic.name.title","Title"), "first_name": fields.Char("First Name"), "last_name": fields.Char("Last Name"), - "name": fields.Char("Name",required=True,search=True), - "name_check": fields.Char("Name",function="_get_name_check",store=True), + "name": fields.Char("Name",function="_get_name",function_multi=True,store=True,required=True,search=True), + "name_check": fields.Char("Name",function="_get_name",function_multi=True,store=True), "name_eng": fields.Char("Eng Name",search=True), "nick_name": fields.Char("Nick Name",search=True), "identification" : fields.Char("Identification Card"), @@ -133,7 +151,6 @@ class Staff(Model): 'branch_id': fields.Many2One("clinic.branch","Branch", search=True), "partner_id": fields.Many2One("partner","Contact"), 'departments': fields.Many2Many("clinic.department","Departments"), - 'test': fields.Boolean("Test",search=True), } def _get_number(self,context={}): @@ -256,8 +273,8 @@ class Staff(Model): address_id=None if not partner_id: vals['partner_id'],address_id=self.create_contact(name) - self.function_store(ids) super().write(ids,vals,**kw) + self.function_store(ids) if address_id: addr=get_model('address').browse(address_id) addr.write({ diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt index 2d48bb7..cf10cd9 100644 --- a/netforce_clinic/todo.txt +++ b/netforce_clinic/todo.txt @@ -10,3 +10,34 @@ todo: matching payment > ok create contact from staff -> ok script to clear invoice -> ok + +requirement: + +1.1 Profile STAFF ยังไม่สามารถ กำหนดให้ 1คน มี profile ได้หลาย Department (ตามเมล์ date: Mon, Feb 23, 2015 at 3:15 PM ที่คุณพอลลี่แจ้งมา อยู่ระหว่างกำลังแก้ไข) + +1.2 HD Cases ยังพบ bug ในส่วน Expense EPO ที่เบิกได้ตามสิทธิ์ของผู้ป่วย เลือก Product แล้วราคาไม่แสดง + -> config on product price list and retest it again + +1.3 HD Cases ในส่วน Expense ที่ถูกต้อง เมื่อเลือก Product แล้ว Product นั้นต้องสัมพันธ์กับสถานะ Reimbursable (เช่น Category: EPO Product: [61006-SSO] EPIAO-SSO Reimbursable ต้องเป็น Yes ถ้า EPO ขาย สถานะ Reimbursable เป็น No) + ->ok + +1.4 RC เป็น PDF + ชื่อพยาบาล วันที่ (ตรงลายเซ็นคุณผดา ต้องการให้สามารถใส่ไฟล์แก้ไขได้เอง) + +1.5 HD Case Summary สร้าง filter กรองตามชั้น + -> ok + + + +2. Accounting issues + +2.1 HD Cases Matching + +2.2 Statement Matching + +2.3 ค่าตอบแทนแพทย์ และพยาบาล (ตามที่ คุณบอย แจ้งเมื่อวันที่ 19 ก.พ. 58) + +2.4 Bank Reconciliation + +2.5 Fixed Asset + +