[patient] update address
parent
fae65fe0fc
commit
d328ee0a81
|
@ -2,7 +2,7 @@
|
|||
<head>
|
||||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="Get Dialyzer" action="clinic_get_dlz"/>
|
||||
<item string="New Dialyzer" method="new_dialyzer"/>
|
||||
</button>
|
||||
</head>
|
||||
<group span="6" columns="1">
|
||||
|
|
|
@ -7,6 +7,7 @@ from . import graduation
|
|||
from . import morbidity
|
||||
from . import nation
|
||||
from . import nurse
|
||||
from . import address
|
||||
from . import patient
|
||||
from . import patient_cause_line
|
||||
from . import patient_comorbidity_line
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
from netforce.model import Model, fields
|
||||
|
||||
class Address(Model):
|
||||
_inherit="address"
|
||||
|
||||
_fields={
|
||||
"patient_id": fields.Many2One("clinic.patient","Patient"),
|
||||
}
|
||||
|
||||
Address.register()
|
|
@ -66,12 +66,13 @@ class Dialyzer(Model):
|
|||
_defaults={
|
||||
"state": "new",
|
||||
"date": lambda *a: time.strftime("%Y-%m-%d"),
|
||||
#"number": _get_number,
|
||||
'number': '/',
|
||||
"max_use_time": 10,
|
||||
"use_time": 0,
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
'product_id': _get_product,
|
||||
'dialyzer_type': 'low',
|
||||
'member_type': 'unsub',
|
||||
}
|
||||
_order="date desc,number desc"
|
||||
|
||||
|
|
|
@ -621,4 +621,36 @@ class HDCase(Model):
|
|||
|
||||
return data
|
||||
|
||||
def new_dialyzer(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
dlz_id=get_model('clinic.dialyzer').create({
|
||||
'patient_id': obj.patient_id.id,
|
||||
})
|
||||
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
||||
dialyzer.confirm()
|
||||
vals={
|
||||
'dlz_id': dlz_id,
|
||||
'dialyzers': [],
|
||||
}
|
||||
vals['dialyzers'].append(('create',{
|
||||
'dialyzer_id': dlz_id,
|
||||
'description': dialyzer.description or "",
|
||||
'use_time': 1,
|
||||
'max_use_time': dialyzer.max_use_time,
|
||||
'member_type': dialyzer.member_type,
|
||||
'dialyzer_type': dialyzer.dialyzer_type,
|
||||
'bid_flow_rate': dialyzer.bid_flow_rate,
|
||||
'ultrafittration': dialyzer.ultrafittration,
|
||||
'state': dialyzer.state,
|
||||
}))
|
||||
obj.write(vals)
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_hd_case',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': 'Create new dialyzer successfully',
|
||||
}
|
||||
|
||||
HDCase.register()
|
||||
|
|
|
@ -48,7 +48,7 @@ class Patient(Model):
|
|||
'card_exp' : fields.Date("Card Expiry"),
|
||||
"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","related_id","Addresses"),
|
||||
"addresses": fields.One2Many("address","patient_id","Addresses"),
|
||||
"gender": fields.Selection([("male","Male"),("female","Female")],"Gender",required=False),
|
||||
"marital_status": fields.Selection([("single","Single"),("marry","Marry"),("divorce","Divorce"),("separated","Saparated"),("widowed","Widowed")],"Marital Status",required=False),
|
||||
"nation_id": fields.Many2One("clinic.nation","Nationality"),
|
||||
|
@ -203,6 +203,26 @@ class Patient(Model):
|
|||
'type': 'person',
|
||||
})
|
||||
vals['partner_id']=partner_id
|
||||
|
||||
# XXX
|
||||
if not isinstance(partner_id,int):
|
||||
partner_id=partner_id.id
|
||||
if obj.addresses:
|
||||
addr=obj.addresses[0]
|
||||
get_model("address").browse(addr.id).write({
|
||||
'partner_id': partner_id,
|
||||
})
|
||||
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({
|
||||
'patient_id': obj.id,
|
||||
'partner_id': partner_id,
|
||||
})
|
||||
del vals['addresses']
|
||||
print("create address for %s"%obj.name)
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
def name_get(self,ids,context={}):
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
====
|
||||
question:
|
||||
- can filter field in related
|
||||
find dialyzer automatic after confirm visit
|
||||
====
|
||||
- import data
|
||||
|
|
Loading…
Reference in New Issue