diff --git a/netforce_clinic/layouts/clinic_patient_categ_form.xml b/netforce_clinic/layouts/clinic_patient_categ_form.xml
index 20b6d00..8addfe1 100644
--- a/netforce_clinic/layouts/clinic_patient_categ_form.xml
+++ b/netforce_clinic/layouts/clinic_patient_categ_form.xml
@@ -1,4 +1,5 @@
diff --git a/netforce_clinic/layouts/clinic_patient_form.xml b/netforce_clinic/layouts/clinic_patient_form.xml
index 6ba4096..7a91662 100644
--- a/netforce_clinic/layouts/clinic_patient_form.xml
+++ b/netforce_clinic/layouts/clinic_patient_form.xml
@@ -39,8 +39,6 @@
-
-
@@ -93,10 +91,11 @@
-
+
+
diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py
index 14cff3b..e0e90ee 100644
--- a/netforce_clinic/models/patient.py
+++ b/netforce_clinic/models/patient.py
@@ -27,8 +27,8 @@ class Patient(Model):
return res # -> {1: 30, 2: 45,.....}
_fields={
- "type": fields.Selection([("sc","Social Security"),("uc","UC"),("others","Others")],"Patient Type",required=True),
- "number": fields.Char("Patient No.",required=True,search=True),
+ "type": fields.Selection([("sc","Social Security"),("uc","UC"),("others","Others")],"Type",required=True),
+ "number": fields.Char("Number",required=True,search=True),
"hn": fields.Char("REF/HN",search=True),
"name": fields.Char("Name",required=True,search=True),
"reg_date": fields.Date("Register Date",required=False,search=True),
@@ -42,8 +42,8 @@ class Patient(Model):
"weight": fields.Float("Weight (cm)"),
"height": fields.Float("Height (Kg)"),
"card_type": fields.Selection([("identification","Identification"),("passport","Passport")],"Card Type"),
- 'card_no' : fields.Char("Card No."),
- 'card_exp' : fields.Date("Card Expiry"),
+ 'card_no' : fields.Char("Card Number"),
+ 'card_exp' : fields.Date("Card Expire"),
"app_no": fields.Char("Application No."),
"salary": fields.Selection([["20000","5,001-20,000"],["50000","20,001-50,000"],["100000","50,001-100,000"],["100001","100,000+"]], "Salary"),
"addresses": fields.One2Many("address","patient_id","Addresses"),
@@ -97,18 +97,16 @@ class Patient(Model):
return num
get_model("sequence").increment_number(seq_id,context=context)
-
def _get_cause_line(self,context={}):
cause_ids=get_model("clinic.cause.chronic").search([])
return cause_ids
-
_defaults={
+ "number": _get_number,
"type": "sc",
"reg_date": lambda *a: time.strftime("%Y-%m-%d"),
- "number": _get_number,
"company_id": lambda *a: get_active_company(),
- #'cause_lines': _get_cause_line,
+ 'card_type': 'identification',
"active" : True,
}
_order="resign_date desc,number desc"
@@ -215,7 +213,6 @@ class Patient(Model):
})
vals['partner_id']=partner_id
- # XXX
if not isinstance(partner_id,int):
partner_id=partner_id.id
if obj.addresses:
@@ -225,7 +222,6 @@ class Patient(Model):
})
else:
if vals.get("addresses"):
- # in case no address in patient
addr_vals=vals.get("addresses")[0][1]
addr_id=get_model("address").create(addr_vals)
get_model("address").browse(addr_id).write({
@@ -234,6 +230,11 @@ class Patient(Model):
})
del vals['addresses']
print("create address for %s"%obj.name)
+
+ if obj.rm_remain_visit:
+ visit_ids=get_model('clinic.visit').search([['patient_id','=',obj.id],['state','=','draft']])
+ get_model('clinic.visit').delete(visit_ids)
+ print('remove visit auto %s'%visit_ids)
super().write(ids,vals,**kw)
def name_get(self,ids,context={}):
diff --git a/netforce_clinic/models/patient_categ.py b/netforce_clinic/models/patient_categ.py
index c510647..9be243b 100644
--- a/netforce_clinic/models/patient_categ.py
+++ b/netforce_clinic/models/patient_categ.py
@@ -7,6 +7,7 @@ class PatientCateg(Model):
_fields={
"name": fields.Char("Name",required=True,search=True),
"parent_id": fields.Many2One('clinic.patient.categ',"Parent"),
+ 'note': fields.Text("Note"),
}
PatientCateg.register()
diff --git a/netforce_clinic/models/staff.py b/netforce_clinic/models/staff.py
index bb063bc..9334667 100644
--- a/netforce_clinic/models/staff.py
+++ b/netforce_clinic/models/staff.py
@@ -125,12 +125,45 @@ class Staff(Model):
}
_order="date desc,number desc"
- def create(self,vals,**kw):
+ def check_emp(self,name="", employee_id=None):
+ names=name.split(" ")
+ first_name=names[0]
+ last_name=names[-1]
+ if first_name==last_name:
+ first_name=""
+ vals={
+ 'first_name': first_name,
+ 'last_name': last_name,
+ }
emp_obj=get_model("hr.employee")
- last_name=vals['name'].split(" ")[-1]
emp_ids=emp_obj.search([['last_name','=',last_name]])
- # TODO create employee automatically
+ emp_id=None
+ if not emp_ids and not employee_id:
+ emp_id=emp_obj.create(vals)
+ elif employee_id:
+ emp_obj.browse(employee_id).write(vals)
+ emp_id=employee_id
+ else:
+ emp_id=emp_ids[0]
+ return emp_id
+
+ def create(self,vals,**kw):
+ name=vals['name']
+ employee_id=vals.get('employee_id')
+ emp_id=self.check_emp(name,employee_id)
+ if emp_id:
+ vals['employee_id']=emp_id
new_id=super().create(vals,**kw)
return new_id
+ def write(self,ids,vals,**kw):
+ obj=self.browse(ids)[0]
+ name=vals.get("name","")
+ if not name:
+ name=obj.name
+ emp_id=self.check_emp(name,obj.employee_id.id)
+ if emp_id:
+ vals['employee_id']=emp_id
+ super().write(ids,vals,**kw)
+
Staff.register()