count use time
parent
a68e0f5743
commit
c4fda2bb58
|
@ -2,7 +2,7 @@
|
||||||
<field name="string">Dialyzer</field>
|
<field name="string">Dialyzer</field>
|
||||||
<field name="view_cls">multi_view</field>
|
<field name="view_cls">multi_view</field>
|
||||||
<field name="model">clinic.dialyzer</field>
|
<field name="model">clinic.dialyzer</field>
|
||||||
<field name="tabs">[["All",[]],["New",[["state","=","new"]]],["Active",[["state","=","active"]]],["Drop",[["state","=","drop"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
|
<field name="tabs">[["All",[]],["New",[["state","=","new"]]],["Active",[["state","=","active"]]],["Drop",[["state","=","drop"]]],["Expire",[["state","=","expire"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
|
||||||
<field name="modes">list,page,form</field>
|
<field name="modes">list,page,form</field>
|
||||||
<field name="menu">clinic_menu</field>
|
<field name="menu">clinic_menu</field>
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Healthy Information">
|
<tab string="Healthy History">
|
||||||
<field name="wh_start"/>
|
<field name="wh_start"/>
|
||||||
<field name="wh_stop"/>
|
<field name="wh_stop"/>
|
||||||
<field name="bp_start"/>
|
<field name="bp_start"/>
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Dialyzer(Model):
|
||||||
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
|
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
|
||||||
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",search=True),
|
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",search=True),
|
||||||
"ultrafittration": fields.Float("Ultrafittration Kg.",search=True),
|
"ultrafittration": fields.Float("Ultrafittration Kg.",search=True),
|
||||||
"state": fields.Selection([("new","New"),("active","Active"),("drop","Drop"),('cancelled','Cancelled')],"Status"),
|
"state": fields.Selection([("new","New"),("active","Active"),("drop","Drop"),("expire","Expire"),('cancelled','Cancelled')],"Status"),
|
||||||
"comments": fields.One2Many("message","related_id","Comments"),
|
"comments": fields.One2Many("message","related_id","Comments"),
|
||||||
"company_id": fields.Many2One("company","Company"),
|
"company_id": fields.Many2One("company","Company"),
|
||||||
'product_id': fields.Many2One("product", "Product",required=True),
|
'product_id': fields.Many2One("product", "Product",required=True),
|
||||||
|
|
|
@ -197,6 +197,8 @@ class HDcase(Model):
|
||||||
}
|
}
|
||||||
vals['lines'].append(('create',line))
|
vals['lines'].append(('create',line))
|
||||||
inv_id=get_model("account.invoice").create(vals,context)
|
inv_id=get_model("account.invoice").create(vals,context)
|
||||||
|
# create picking
|
||||||
|
obj.make_pickings()
|
||||||
if obj.fee:
|
if obj.fee:
|
||||||
vals={
|
vals={
|
||||||
"type": "out",
|
"type": "out",
|
||||||
|
@ -225,6 +227,64 @@ class HDcase(Model):
|
||||||
vals['lines'].append(('create',line))
|
vals['lines'].append(('create',line))
|
||||||
inv_id=get_model("account.invoice").create(vals,context)
|
inv_id=get_model("account.invoice").create(vals,context)
|
||||||
|
|
||||||
|
def make_pickings(self,ids,context={}):
|
||||||
|
obj=self.browse(ids[0])
|
||||||
|
# no picking
|
||||||
|
if not obj.lines:
|
||||||
|
return
|
||||||
|
|
||||||
|
partner=obj.patient_id.partner_id
|
||||||
|
if not partner:
|
||||||
|
raise Exception("Contact not for this patient")
|
||||||
|
ship_address_id=None
|
||||||
|
for address in partner.addresses:
|
||||||
|
if address.type=="shipping":
|
||||||
|
ship_address_id=address.id
|
||||||
|
break
|
||||||
|
if not ship_address_id:
|
||||||
|
raise Exception("contact %s dont'have address with type shipping"%partner.name)
|
||||||
|
pick_vals={
|
||||||
|
"type": "out",
|
||||||
|
"ref": obj.number,
|
||||||
|
"related_id": "clinic.hd.case,%s"%obj.id,
|
||||||
|
"partner_id": obj.patient_id.partner_id.id,
|
||||||
|
"ship_address_id": ship_address_id,
|
||||||
|
"state": "draft",
|
||||||
|
"lines": [],
|
||||||
|
}
|
||||||
|
res=get_model("stock.location").search([["type","=","customer"]])
|
||||||
|
if not res:
|
||||||
|
raise Exception("Customer location not found")
|
||||||
|
cust_loc_id=res[0]
|
||||||
|
|
||||||
|
|
||||||
|
for line in obj.lines:
|
||||||
|
prod=line.product_id
|
||||||
|
if prod.type != 'stock':
|
||||||
|
continue
|
||||||
|
wh_loc_id=prod.location_id.id
|
||||||
|
if not wh_loc_id:
|
||||||
|
res=get_model("stock.location").search([["type","=","internal"]])
|
||||||
|
if not res:
|
||||||
|
raise Exception("Warehouse not found")
|
||||||
|
wh_loc_id=res[0]
|
||||||
|
line_vals={
|
||||||
|
"product_id": prod.id,
|
||||||
|
"qty": 1,
|
||||||
|
"uom_id": prod.uom_id.id,
|
||||||
|
"location_from_id": wh_loc_id,
|
||||||
|
"location_to_id": cust_loc_id,
|
||||||
|
}
|
||||||
|
pick_vals["lines"].append(("create",line_vals))
|
||||||
|
if not pick_vals["lines"]:
|
||||||
|
return {
|
||||||
|
"flash": "Nothing left to deliver",
|
||||||
|
}
|
||||||
|
picking_obj=get_model("stock.picking")
|
||||||
|
pick_id=picking_obj.create(pick_vals,context={"pick_type": "out"})
|
||||||
|
pick=picking_obj.browse(pick_id)
|
||||||
|
pick.set_done([pick_id])
|
||||||
|
|
||||||
def post_invoices(self,ids,context={}):
|
def post_invoices(self,ids,context={}):
|
||||||
obj=self.browse(ids[0])
|
obj=self.browse(ids[0])
|
||||||
for inv in obj.invoices:
|
for inv in obj.invoices:
|
||||||
|
|
|
@ -8,10 +8,10 @@ class HdcaseDialyzer(Model):
|
||||||
"description": fields.Char("Description",search=True),
|
"description": fields.Char("Description",search=True),
|
||||||
"use_time":fields.Integer("Use time"),
|
"use_time":fields.Integer("Use time"),
|
||||||
"max_use_time":fields.Integer("Max use time"),
|
"max_use_time":fields.Integer("Max use time"),
|
||||||
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Member Type",required=True),
|
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Member Type"),
|
||||||
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Member Type",required=True),
|
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Member Type"),
|
||||||
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",required=True,search=True),
|
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)"),
|
||||||
"ultrafittration": fields.Float("Ultrafittration Kg.",required=True,search=True),
|
"ultrafittration": fields.Float("Ultrafittration Kg."),
|
||||||
"state":fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status"),
|
"state":fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Visit(Model):
|
||||||
'nurse_id': _get_nurse,
|
'nurse_id': _get_nurse,
|
||||||
'time_use': 1,
|
'time_use': 1,
|
||||||
}
|
}
|
||||||
_order="date,cycle"
|
_order="number desc"
|
||||||
|
|
||||||
def get_dialyzer(self):
|
def get_dialyzer(self):
|
||||||
return
|
return
|
||||||
|
@ -107,19 +107,31 @@ class Visit(Model):
|
||||||
break
|
break
|
||||||
|
|
||||||
# find dialyser
|
# find dialyser
|
||||||
for dlz in get_model("clinic.dialyzer").search_browse([['patient_id','=',obj.patient_id.id],['state','=','active']]):
|
for dlz in get_model("clinic.dialyzer").search_browse([['patient_id','=',obj.patient_id.id],['state','=','active']],order="id desc"):
|
||||||
vals['dialyzers'].append({
|
use_time=dlz.use_time or 0
|
||||||
"dialzer_id": dlz.id,
|
use_time+=1
|
||||||
|
# XXX update dialyzer
|
||||||
|
dlz.write({
|
||||||
|
'use_time': use_time,
|
||||||
|
})
|
||||||
|
if use_time > dlz.max_use_time:
|
||||||
|
dlz.write({
|
||||||
|
"state": "expire",
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
vals['dialyzers'].append(('create',{
|
||||||
|
"dialyzer_id": dlz.id,
|
||||||
"description": dlz.description,
|
"description": dlz.description,
|
||||||
"use_time": dlz.use_time,
|
"use_time": use_time,
|
||||||
"max_use_time": dlz.max_use_time,
|
"max_use_time": dlz.max_use_time,
|
||||||
"member_type": dlz.member_type,
|
"member_type": dlz.member_type,
|
||||||
"dialyzer_type": dlz.dialyzer_type,
|
"dialyzer_type": dlz.dialyzer_type,
|
||||||
"bid_flow_rate": dlz.bid_flow_rate,
|
"bid_flow_rate": dlz.bid_flow_rate,
|
||||||
"ultrafittration": dlz.ultrafittration,
|
"ultrafittration": dlz.ultrafittration,
|
||||||
})
|
}))
|
||||||
|
if not vals['dialyzers']:
|
||||||
hd_case_id=hd_case_id=hd_case_obj.create(vals)
|
raise Exception("%s don't have dialyzer for treatment" % obj.patient_id.name)
|
||||||
|
hd_case_id=hd_case_obj.create(vals)
|
||||||
obj.write({"state":"confirmed"})
|
obj.write({"state":"confirmed"})
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
|
@ -141,11 +153,16 @@ class Visit(Model):
|
||||||
def onchange_patient(self,context={}):
|
def onchange_patient(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
patient_id=data['patient_id']
|
patient_id=data['patient_id']
|
||||||
visits=self.search_browse([['patient_id','=',patient_id]])
|
visits=self.search_browse([['patient_id','=',patient_id]],order="number desc")
|
||||||
if visits:
|
if visits:
|
||||||
visit=visits[-1]
|
#print([(v.id, v.visit_date,v.cycle) for v in visits])
|
||||||
|
visit=visits[0]
|
||||||
data['doctor_id']=visit.doctor_id.id
|
data['doctor_id']=visit.doctor_id.id
|
||||||
data['department_id']=visit.department_id.id
|
data['department_id']=visit.department_id.id
|
||||||
|
cycle=int(visit.cycle)+1
|
||||||
|
data['cycle']=str(cycle)
|
||||||
|
if cycle>4:
|
||||||
|
data['cycle']='1'
|
||||||
else:
|
else:
|
||||||
data['doctor_id']=None
|
data['doctor_id']=None
|
||||||
data['department_id']=None
|
data['department_id']=None
|
||||||
|
@ -159,6 +176,14 @@ class Visit(Model):
|
||||||
'nurse_id': obj.nurse_id.id,
|
'nurse_id': obj.nurse_id.id,
|
||||||
'department_id': obj.department_id.id,
|
'department_id': obj.department_id.id,
|
||||||
}
|
}
|
||||||
|
# XXX update cycle
|
||||||
|
visits=self.search_browse([['patient_id','=',obj.patient_id.id]],order="number desc")
|
||||||
|
if visits:
|
||||||
|
visit=visits[0] # order desc already
|
||||||
|
cycle=int(visit.cycle)+1
|
||||||
|
vals['cycle']=str(cycle)
|
||||||
|
if cycle>4:
|
||||||
|
vals['cycle']='1'
|
||||||
new_id=self.create(vals,context=context)
|
new_id=self.create(vals,context=context)
|
||||||
new_obj=self.browse(new_id)
|
new_obj=self.browse(new_id)
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -11,4 +11,5 @@ question?
|
||||||
- how cycle running?
|
- how cycle running?
|
||||||
- treatment
|
- treatment
|
||||||
- 1 cycle take how long ?
|
- 1 cycle take how long ?
|
||||||
|
issue:
|
||||||
|
hd case should link only 1 dialyzer -> should not copy 2 time
|
||||||
|
|
Loading…
Reference in New Issue