conv_bal
watcha.h 2014-11-26 08:39:49 +07:00
parent 754999a0db
commit e642ed021a
5 changed files with 51 additions and 16 deletions

View File

@ -1,4 +1,5 @@
<form model="clinic.patient.categ"> <form model="clinic.patient.categ">
<field name="name"/> <field name="name"/>
<field name="parent_id"/> <field name="parent_id"/>
<field name="note"/>
</form> </form>

View File

@ -39,8 +39,6 @@
<field name="height"/> <field name="height"/>
<field name="phone"/> <field name="phone"/>
</group> </group>
<separator string="Address Information"/>
<field name="addresses" view="form_list"/>
</tab> </tab>
<tab string="Health Information"> <tab string="Health Information">
<field name="smoke"/> <field name="smoke"/>
@ -93,10 +91,11 @@
</tab> </tab>
</tabs> </tabs>
<related> <related>
<field name="documents"/> <field name="addresses"/>
<field name="visits"/> <field name="visits"/>
<field name="hd_cases"/> <field name="hd_cases"/>
<field name="dialyzers"/> <field name="dialyzers"/>
<field name="documents"/>
<field name="comments"/> <field name="comments"/>
</related> </related>
</form> </form>

View File

@ -27,8 +27,8 @@ class Patient(Model):
return res # -> {1: 30, 2: 45,.....} return res # -> {1: 30, 2: 45,.....}
_fields={ _fields={
"type": fields.Selection([("sc","Social Security"),("uc","UC"),("others","Others")],"Patient Type",required=True), "type": fields.Selection([("sc","Social Security"),("uc","UC"),("others","Others")],"Type",required=True),
"number": fields.Char("Patient No.",required=True,search=True), "number": fields.Char("Number",required=True,search=True),
"hn": fields.Char("REF/HN",search=True), "hn": fields.Char("REF/HN",search=True),
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
"reg_date": fields.Date("Register Date",required=False,search=True), "reg_date": fields.Date("Register Date",required=False,search=True),
@ -42,8 +42,8 @@ class Patient(Model):
"weight": fields.Float("Weight (cm)"), "weight": fields.Float("Weight (cm)"),
"height": fields.Float("Height (Kg)"), "height": fields.Float("Height (Kg)"),
"card_type": fields.Selection([("identification","Identification"),("passport","Passport")],"Card Type"), "card_type": fields.Selection([("identification","Identification"),("passport","Passport")],"Card Type"),
'card_no' : fields.Char("Card No."), 'card_no' : fields.Char("Card Number"),
'card_exp' : fields.Date("Card Expiry"), 'card_exp' : fields.Date("Card Expire"),
"app_no": fields.Char("Application No."), "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"), "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"), "addresses": fields.One2Many("address","patient_id","Addresses"),
@ -97,18 +97,16 @@ class Patient(Model):
return num return num
get_model("sequence").increment_number(seq_id,context=context) get_model("sequence").increment_number(seq_id,context=context)
def _get_cause_line(self,context={}): def _get_cause_line(self,context={}):
cause_ids=get_model("clinic.cause.chronic").search([]) cause_ids=get_model("clinic.cause.chronic").search([])
return cause_ids return cause_ids
_defaults={ _defaults={
"number": _get_number,
"type": "sc", "type": "sc",
"reg_date": lambda *a: time.strftime("%Y-%m-%d"), "reg_date": lambda *a: time.strftime("%Y-%m-%d"),
"number": _get_number,
"company_id": lambda *a: get_active_company(), "company_id": lambda *a: get_active_company(),
#'cause_lines': _get_cause_line, 'card_type': 'identification',
"active" : True, "active" : True,
} }
_order="resign_date desc,number desc" _order="resign_date desc,number desc"
@ -215,7 +213,6 @@ class Patient(Model):
}) })
vals['partner_id']=partner_id vals['partner_id']=partner_id
# XXX
if not isinstance(partner_id,int): if not isinstance(partner_id,int):
partner_id=partner_id.id partner_id=partner_id.id
if obj.addresses: if obj.addresses:
@ -225,7 +222,6 @@ class Patient(Model):
}) })
else: else:
if vals.get("addresses"): if vals.get("addresses"):
# in case no address in patient
addr_vals=vals.get("addresses")[0][1] addr_vals=vals.get("addresses")[0][1]
addr_id=get_model("address").create(addr_vals) addr_id=get_model("address").create(addr_vals)
get_model("address").browse(addr_id).write({ get_model("address").browse(addr_id).write({
@ -234,6 +230,11 @@ class Patient(Model):
}) })
del vals['addresses'] del vals['addresses']
print("create address for %s"%obj.name) 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) super().write(ids,vals,**kw)
def name_get(self,ids,context={}): def name_get(self,ids,context={}):

View File

@ -7,6 +7,7 @@ class PatientCateg(Model):
_fields={ _fields={
"name": fields.Char("Name",required=True,search=True), "name": fields.Char("Name",required=True,search=True),
"parent_id": fields.Many2One('clinic.patient.categ',"Parent"), "parent_id": fields.Many2One('clinic.patient.categ',"Parent"),
'note': fields.Text("Note"),
} }
PatientCateg.register() PatientCateg.register()

View File

@ -125,12 +125,45 @@ class Staff(Model):
} }
_order="date desc,number desc" _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") emp_obj=get_model("hr.employee")
last_name=vals['name'].split(" ")[-1]
emp_ids=emp_obj.search([['last_name','=',last_name]]) 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) new_id=super().create(vals,**kw)
return new_id 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() Staff.register()