prevent to create name of staff & patient
parent
5867a9bcfb
commit
178c1adcb9
|
@ -50,7 +50,6 @@
|
||||||
<item string="Reporting" perm="clinic_report">
|
<item string="Reporting" perm="clinic_report">
|
||||||
<item string="Visit Summary" action="clinic_report_visit"/>
|
<item string="Visit Summary" action="clinic_report_visit"/>
|
||||||
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
||||||
<item string="HD Cases Matching" action="clinic_matching_hdcase" perm="clinic_matching_hdcase"/>
|
|
||||||
<item string="Medical Summary" action="clinic_report_medical_summary"/>
|
<item string="Medical Summary" action="clinic_report_medical_summary"/>
|
||||||
<item string="Recent Patient" action="clinic_report_recent_patient"/>
|
<item string="Recent Patient" action="clinic_report_recent_patient"/>
|
||||||
<item string="Discontinue Patient" action="clinic_report_discontinue_patient"/>
|
<item string="Discontinue Patient" action="clinic_report_discontinue_patient"/>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<field name="name_eng"/>
|
<field name="name_eng"/>
|
||||||
<field name="nick_name"/>
|
<field name="nick_name"/>
|
||||||
<field name="branch_id" required="1"/>
|
<field name="branch_id" required="1"/>
|
||||||
<field name="department_id" required="1"/>
|
<field name="department_id" domain='[["branch_id","=",branch_id]]' required="1"/>
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
<tabs>
|
<tabs>
|
||||||
<tab string="General">
|
<tab string="General">
|
||||||
|
@ -22,7 +22,6 @@
|
||||||
<field name="birthday"/>
|
<field name="birthday"/>
|
||||||
<field name="nation_id"/>
|
<field name="nation_id"/>
|
||||||
<field name="categ_id" domain="[['type','=',type]]"/>
|
<field name="categ_id" domain="[['type','=',type]]"/>
|
||||||
<!--<field name="state"/>-->
|
|
||||||
</group>
|
</group>
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
<field name="image"/>
|
<field name="image"/>
|
||||||
|
|
|
@ -10,7 +10,6 @@ class Patient(Model):
|
||||||
_string="Patient"
|
_string="Patient"
|
||||||
_audit_log=True
|
_audit_log=True
|
||||||
_multi_company=True
|
_multi_company=True
|
||||||
_key=['number','branch_id']
|
|
||||||
|
|
||||||
def _get_age(self,ids,context):
|
def _get_age(self,ids,context):
|
||||||
res={}
|
res={}
|
||||||
|
@ -40,6 +39,13 @@ class Patient(Model):
|
||||||
res[obj.id]=hn
|
res[obj.id]=hn
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _get_name_check(self,ids,context={}):
|
||||||
|
# remove all space for make sure
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
res[obj.id]=(obj.name or "").replace(" ","")
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True),
|
'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True),
|
||||||
"number": fields.Char("HN Number",required=True,search=True),
|
"number": fields.Char("HN Number",required=True,search=True),
|
||||||
|
@ -47,6 +53,7 @@ class Patient(Model):
|
||||||
"hn_no": fields.Char("HN",function="_get_hn_no",store=True),
|
"hn_no": fields.Char("HN",function="_get_hn_no",store=True),
|
||||||
"hn": fields.Char("REF/HN",search=False),
|
"hn": fields.Char("REF/HN",search=False),
|
||||||
"name": fields.Char("Name",required=True,search=True),
|
"name": fields.Char("Name",required=True,search=True),
|
||||||
|
"name_check": fields.Char("Name",function="_get_name_check",store=True), # prevent duplicate
|
||||||
"reg_date": fields.Date("Reg. Date",required=False,search=True),
|
"reg_date": fields.Date("Reg. Date",required=False,search=True),
|
||||||
"birthday": fields.Date("Birthday",required=False,search=True),
|
"birthday": fields.Date("Birthday",required=False,search=True),
|
||||||
"phone": fields.Char("Phone",required=False,search=True),
|
"phone": fields.Char("Phone",required=False,search=True),
|
||||||
|
@ -149,10 +156,13 @@ class Patient(Model):
|
||||||
'type_id': _get_type,
|
'type_id': _get_type,
|
||||||
"active" : True,
|
"active" : True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"),
|
||||||
_order="resign_date desc,number desc"
|
_order="resign_date desc,number desc"
|
||||||
|
|
||||||
def create(self, vals,**kw):
|
def create(self, vals,**kw):
|
||||||
obj_id=super(Patient,self).create(vals,**kw)
|
obj_id=super(Patient,self).create(vals,**kw)
|
||||||
|
self.function_store([obj_id])
|
||||||
obj=self.browse(obj_id)
|
obj=self.browse(obj_id)
|
||||||
partner_id=obj.partner_id
|
partner_id=obj.partner_id
|
||||||
if not partner_id:
|
if not partner_id:
|
||||||
|
@ -246,6 +256,7 @@ class Patient(Model):
|
||||||
visit_ids=get_model('clinic.visit').search([['patient_id','=',obj.id],['state','=','draft']])
|
visit_ids=get_model('clinic.visit').search([['patient_id','=',obj.id],['state','=','draft']])
|
||||||
get_model('clinic.visit').delete(visit_ids)
|
get_model('clinic.visit').delete(visit_ids)
|
||||||
print('remove visit auto %s'%visit_ids)
|
print('remove visit auto %s'%visit_ids)
|
||||||
|
self.function_store(ids)
|
||||||
super().write(ids,vals,**kw)
|
super().write(ids,vals,**kw)
|
||||||
|
|
||||||
def name_get(self,ids,context={}):
|
def name_get(self,ids,context={}):
|
||||||
|
|
|
@ -8,7 +8,6 @@ class Staff(Model):
|
||||||
_string="Staff"
|
_string="Staff"
|
||||||
_audit_log=True
|
_audit_log=True
|
||||||
_multi_company=True
|
_multi_company=True
|
||||||
_key=["name","branch_id"]
|
|
||||||
|
|
||||||
def _get_age(self,ids,context={}):
|
def _get_age(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
|
@ -69,10 +68,18 @@ class Staff(Model):
|
||||||
res[obj.id]=hids
|
res[obj.id]=hids
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _get_name_check(self,ids,context={}):
|
||||||
|
# remove all space for make sure
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
res[obj.id]=(obj.name or "").replace(" ","")
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'employee_id': fields.Many2One("hr.employee","Employee"),
|
'employee_id': fields.Many2One("hr.employee","Employee"),
|
||||||
"number": fields.Char("Number",required=True,search=True),
|
"number": fields.Char("Number",required=True,search=True),
|
||||||
"name": fields.Char("Name",required=True,search=True),
|
"name": fields.Char("Name",required=True,search=True),
|
||||||
|
"name_check": fields.Char("Name",function="_get_name_check",store=True),
|
||||||
"name_eng": fields.Char("Eng Name",search=True),
|
"name_eng": fields.Char("Eng Name",search=True),
|
||||||
"nick_name": fields.Char("Nick Name",search=True),
|
"nick_name": fields.Char("Nick Name",search=True),
|
||||||
"identification" : fields.Char("Identification Card"),
|
"identification" : fields.Char("Identification Card"),
|
||||||
|
@ -149,6 +156,10 @@ class Staff(Model):
|
||||||
"company_id": lambda *a: get_active_company(),
|
"company_id": lambda *a: get_active_company(),
|
||||||
'branch_id': _get_branch,
|
'branch_id': _get_branch,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#_key=["name_check","branch_id"] #not working
|
||||||
|
_sql_constraints=("clinic_staff_key_uniq","unique(name_check,branch_id)","name should be unique"),
|
||||||
|
|
||||||
_order="date desc,number desc"
|
_order="date desc,number desc"
|
||||||
|
|
||||||
def check_emp(self,name="", employee_id=None):
|
def check_emp(self,name="", employee_id=None):
|
||||||
|
@ -180,6 +191,7 @@ class Staff(Model):
|
||||||
if emp_id:
|
if emp_id:
|
||||||
vals['employee_id']=emp_id
|
vals['employee_id']=emp_id
|
||||||
new_id=super().create(vals,**kw)
|
new_id=super().create(vals,**kw)
|
||||||
|
self.function_store([new_id])
|
||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
def write(self,ids,vals,**kw):
|
def write(self,ids,vals,**kw):
|
||||||
|
@ -190,6 +202,7 @@ class Staff(Model):
|
||||||
emp_id=self.check_emp(name,obj.employee_id.id)
|
emp_id=self.check_emp(name,obj.employee_id.id)
|
||||||
if emp_id:
|
if emp_id:
|
||||||
vals['employee_id']=emp_id
|
vals['employee_id']=emp_id
|
||||||
|
self.function_store(ids)
|
||||||
super().write(ids,vals,**kw)
|
super().write(ids,vals,**kw)
|
||||||
|
|
||||||
def name_get(self,ids,context={}):
|
def name_get(self,ids,context={}):
|
||||||
|
@ -205,7 +218,7 @@ class Staff(Model):
|
||||||
vals.append((obj.id,name))
|
vals.append((obj.id,name))
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
def name_search(self,name,domain=None,context={},**kw):
|
def name_search(self,name,domain=None,condition=[],context={},**kw):
|
||||||
dom=[["name","ilike","%"+name+"%"]]
|
dom=[["name","ilike","%"+name+"%"]]
|
||||||
if domain:
|
if domain:
|
||||||
dom=[dom,domain]
|
dom=[dom,domain]
|
||||||
|
|
|
@ -295,14 +295,11 @@ class Visit(Model):
|
||||||
obj.write({
|
obj.write({
|
||||||
'cycle_item_id': item_id,
|
'cycle_item_id': item_id,
|
||||||
})
|
})
|
||||||
#XXX
|
|
||||||
set_active_user(user_id)
|
|
||||||
|
|
||||||
hd_case=hd_case_obj.browse(hd_case_id)
|
hd_case=hd_case_obj.browse(hd_case_id)
|
||||||
hd_case.write({
|
hd_case.write({
|
||||||
'cycle_item_id': item_id,
|
'cycle_item_id': item_id,
|
||||||
})
|
})
|
||||||
|
set_active_user(user_id)
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': 'clinic_hd_case',
|
'name': 'clinic_hd_case',
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
todo:
|
todo:
|
||||||
|
- checking douplicate name
|
||||||
- matching payment ***
|
- matching payment ***
|
||||||
- script generate hd case
|
- script generate hd case
|
||||||
- report doctor & nurse ***
|
- report doctor & nurse ***
|
||||||
|
|
Loading…
Reference in New Issue