count use time

conv_bal
watcha.h 2014-10-03 14:27:57 +07:00
parent a68e0f5743
commit c4fda2bb58
7 changed files with 104 additions and 18 deletions

View File

@ -2,7 +2,7 @@
<field name="string">Dialyzer</field>
<field name="view_cls">multi_view</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="menu">clinic_menu</field>
</action>

View File

@ -32,7 +32,7 @@
</list>
</field>
</tab>
<tab string="Healthy Information">
<tab string="Healthy History">
<field name="wh_start"/>
<field name="wh_stop"/>
<field name="bp_start"/>

View File

@ -21,7 +21,7 @@ class Dialyzer(Model):
"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),
"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"),
"company_id": fields.Many2One("company","Company"),
'product_id': fields.Many2One("product", "Product",required=True),

View File

@ -197,6 +197,8 @@ class HDcase(Model):
}
vals['lines'].append(('create',line))
inv_id=get_model("account.invoice").create(vals,context)
# create picking
obj.make_pickings()
if obj.fee:
vals={
"type": "out",
@ -225,6 +227,64 @@ class HDcase(Model):
vals['lines'].append(('create',line))
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={}):
obj=self.browse(ids[0])
for inv in obj.invoices:

View File

@ -8,10 +8,10 @@ class HdcaseDialyzer(Model):
"description": fields.Char("Description",search=True),
"use_time":fields.Integer("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),
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Member Type",required=True),
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",required=True,search=True),
"ultrafittration": fields.Float("Ultrafittration Kg.",required=True,search=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"),
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)"),
"ultrafittration": fields.Float("Ultrafittration Kg."),
"state":fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status"),
}

View File

@ -55,7 +55,7 @@ class Visit(Model):
'nurse_id': _get_nurse,
'time_use': 1,
}
_order="date,cycle"
_order="number desc"
def get_dialyzer(self):
return
@ -107,19 +107,31 @@ class Visit(Model):
break
# find dialyser
for dlz in get_model("clinic.dialyzer").search_browse([['patient_id','=',obj.patient_id.id],['state','=','active']]):
vals['dialyzers'].append({
"dialzer_id": dlz.id,
for dlz in get_model("clinic.dialyzer").search_browse([['patient_id','=',obj.patient_id.id],['state','=','active']],order="id desc"):
use_time=dlz.use_time or 0
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,
"use_time": dlz.use_time,
"use_time": use_time,
"max_use_time": dlz.max_use_time,
"member_type": dlz.member_type,
"dialyzer_type": dlz.dialyzer_type,
"bid_flow_rate": dlz.bid_flow_rate,
"ultrafittration": dlz.ultrafittration,
})
hd_case_id=hd_case_id=hd_case_obj.create(vals)
}))
if not vals['dialyzers']:
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"})
return {
'next': {
@ -141,11 +153,16 @@ class Visit(Model):
def onchange_patient(self,context={}):
data=context['data']
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:
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['department_id']=visit.department_id.id
cycle=int(visit.cycle)+1
data['cycle']=str(cycle)
if cycle>4:
data['cycle']='1'
else:
data['doctor_id']=None
data['department_id']=None
@ -159,6 +176,14 @@ class Visit(Model):
'nurse_id': obj.nurse_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_obj=self.browse(new_id)
return {

View File

@ -11,4 +11,5 @@ question?
- how cycle running?
- treatment
- 1 cycle take how long ?
issue:
hd case should link only 1 dialyzer -> should not copy 2 time