reset cycle item nurse
parent
a90e0daee9
commit
24d1bf3338
|
@ -5,6 +5,6 @@
|
||||||
<!--<field name="domain">[["order_id.state","in",["confirmed","done"]]]</field>-->
|
<!--<field name="domain">[["order_id.state","in",["confirmed","done"]]]</field>-->
|
||||||
<field name="group_fields">visit_date</field>
|
<field name="group_fields">visit_date</field>
|
||||||
<field name="group_select">visit_date,cycle_id</field>
|
<field name="group_select">visit_date,cycle_id</field>
|
||||||
<field name="view_xml">clinic_visit_dialy</field>
|
<!--<field name="view_xml">clinic_visit_dialy</field>-->
|
||||||
<field name="menu">clinic_menu</field>
|
<field name="menu">clinic_menu</field>
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -12,12 +12,14 @@
|
||||||
<field name="nurses" nolabel="1">
|
<field name="nurses" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="nurse_id"/>
|
<field name="nurse_id"/>
|
||||||
<field name="categ_id"/>
|
<field name="level_id"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
|
<button string="Validate" type="success" method="validate" icon="ok" states="draft" />
|
||||||
|
<button string="To Draft" type="default" method="to_draft" icon="repeat" states="done" />
|
||||||
</foot>
|
</foot>
|
||||||
<related>
|
<related>
|
||||||
<field name="visits"/>
|
<field name="visits"/>
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]],"#bcbbb9":[["state","=","cancelled"]]}'>
|
|
||||||
<field name="number"/>
|
|
||||||
<field name="visit_date"/>
|
|
||||||
<field name="cycle_id"/>
|
|
||||||
<field name="patient_id"/>
|
|
||||||
<field name="doctor_id"/>
|
|
||||||
<field name="department_id"/>
|
|
||||||
<field name="state"/>
|
|
||||||
</list>
|
|
|
@ -28,7 +28,7 @@
|
||||||
</tabs>
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Confirm" type="success" method="confirm" states="draft" />
|
<button string="Confirm" type="success" method="confirm" states="draft" />
|
||||||
<button string="Cancel" type="danger" method="cancel" states="draft" />
|
<button string="Discard" type="danger" method="cancel" states="draft" />
|
||||||
<button string="To Draft" type="default" icon="repeat" method="to_draft" states="confirmed,cancelled" />
|
<button string="To Draft" type="default" icon="repeat" method="to_draft" states="confirmed,cancelled" />
|
||||||
</foot>
|
</foot>
|
||||||
<related>
|
<related>
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]],"#bcbbb9":[["state","=","cancelled"]]}'>
|
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]],"#dbdbdb":[["state","=","cancelled"]]}'>
|
||||||
<search>
|
|
||||||
<field name="number"/>
|
|
||||||
<field name="time_start"/>
|
|
||||||
<field name="time_stop"/>
|
|
||||||
<field name="cycle_id"/>
|
|
||||||
<field name="patient_id"/>
|
|
||||||
<field name="doctor_id"/>
|
|
||||||
</search>
|
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="time_start"/>
|
<field name="visit_date"/>
|
||||||
<field name="time_stop"/>
|
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="patient_id"/>
|
<field name="patient_id"/>
|
||||||
<field name="doctor_id"/>
|
<field name="doctor_id"/>
|
||||||
|
<field name="department_id"/>
|
||||||
|
<field name="nurse_id"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -51,5 +51,17 @@ class CycleItem(Model):
|
||||||
cycle=obj.cycle_id
|
cycle=obj.cycle_id
|
||||||
vals['sequence']='%s-%s'%(obj.date,cycle.sequence) #date-sequence
|
vals['sequence']='%s-%s'%(obj.date,cycle.sequence) #date-sequence
|
||||||
super().write(ids,vals,**kw)
|
super().write(ids,vals,**kw)
|
||||||
|
|
||||||
|
def validate(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
obj.write({
|
||||||
|
'state': 'done',
|
||||||
|
})
|
||||||
|
|
||||||
|
def to_draft(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
obj.write({
|
||||||
|
'state': 'draft',
|
||||||
|
})
|
||||||
|
|
||||||
CycleItem.register()
|
CycleItem.register()
|
||||||
|
|
|
@ -7,7 +7,7 @@ class CycleItemNurse(Model):
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
|
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
|
||||||
'categ_id': fields.Many2One("clinic.personal.categ", "Category",),
|
'level_id': fields.Many2One("clinic.personal.level", "Level",),
|
||||||
'nurse_id': fields.Many2One("clinic.personal",'Nurse',domain=[['type','=','nurse']]),
|
'nurse_id': fields.Many2One("clinic.personal",'Nurse',domain=[['type','=','nurse']]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,14 +128,21 @@ class GenVisit(Model):
|
||||||
else:
|
else:
|
||||||
raise Exception("Please select some patient or patient type")
|
raise Exception("Please select some patient or patient type")
|
||||||
|
|
||||||
nurse_ids=[]
|
nurse_vals=[]
|
||||||
for nurse_line in obj.nurse_lines:
|
for nurse_line in obj.nurse_lines:
|
||||||
nurse_id=nurse_line.nurse_id.id
|
nurse=nurse_line.nurse_id
|
||||||
# None
|
# None
|
||||||
if nurse_id:
|
if nurse:
|
||||||
nurse_ids.append(nurse_id)
|
nurse_vals.append({
|
||||||
if not nurse_ids:
|
'id': nurse.id,
|
||||||
nurse_ids=get_model("clinic.personal").search([['type','=','nurse'],['categ_id','=',obj.nurse_categ_id.id]])
|
'level_id': nurse.level_id.id,
|
||||||
|
})
|
||||||
|
if not nurse_vals:
|
||||||
|
for nurse in get_model("clinic.personal").search_browse([['type','=','nurse'],['categ_id','=',obj.nurse_categ_id.id]]):
|
||||||
|
nurse_vals.append({
|
||||||
|
'id': nurse.id,
|
||||||
|
'level_id': nurse.level_id.id,
|
||||||
|
})
|
||||||
schedules={}
|
schedules={}
|
||||||
for patient_id in patients:
|
for patient_id in patients:
|
||||||
patient=get_model("clinic.patient").browse(patient_id)
|
patient=get_model("clinic.patient").browse(patient_id)
|
||||||
|
@ -188,7 +195,7 @@ class GenVisit(Model):
|
||||||
start_date=tmp
|
start_date=tmp
|
||||||
|
|
||||||
for vals in visit_vals:
|
for vals in visit_vals:
|
||||||
vals['nurse_ids']=nurse_ids
|
vals['nurse_vals']=nurse_vals # XXX
|
||||||
visit_obj.create(vals)
|
visit_obj.create(vals)
|
||||||
dom=[]
|
dom=[]
|
||||||
dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
|
dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
|
||||||
|
@ -197,6 +204,7 @@ class GenVisit(Model):
|
||||||
schedule_obj=get_model("clinic.schedule")
|
schedule_obj=get_model("clinic.schedule")
|
||||||
schedule_ids=schedule_obj.search(dom)
|
schedule_ids=schedule_obj.search(dom)
|
||||||
schedule_obj.delete(schedule_ids)
|
schedule_obj.delete(schedule_ids)
|
||||||
|
nurse_ids=[nurse['id'] for nurse in nurse_vals]
|
||||||
for key, vals in schedules.items():
|
for key, vals in schedules.items():
|
||||||
vals['nurses']=[('add', nurse_ids)]
|
vals['nurses']=[('add', nurse_ids)]
|
||||||
schedule_obj.create(vals)
|
schedule_obj.create(vals)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class Visit(Model):
|
||||||
"comments": fields.One2Many("message","related_id","Comments"),
|
"comments": fields.One2Many("message","related_id","Comments"),
|
||||||
'visit_date': fields.Date('Visit Date'),
|
'visit_date': fields.Date('Visit Date'),
|
||||||
'print_date': fields.Date('Print Date',function="_get_print_date"),
|
'print_date': fields.Date('Print Date',function="_get_print_date"),
|
||||||
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item", on_delete="cascade"), #XXX on_delete="cascade" -> rm visit from cycle item
|
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item
|
||||||
'sequence': fields.Char("Sequence"),
|
'sequence': fields.Char("Sequence"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,18 +297,34 @@ class Visit(Model):
|
||||||
item_ids=item_obj.search(dom)
|
item_ids=item_obj.search(dom)
|
||||||
item_id=None
|
item_id=None
|
||||||
# XXX
|
# XXX
|
||||||
nurse_ids=[]
|
nurse_vals=[]
|
||||||
if 'nurse_ids' in vals.keys():
|
if 'nurse_vals' in vals.keys():
|
||||||
nurse_ids=vals['nurse_ids']
|
nurse_vals=vals['nurse_vals']
|
||||||
del vals['nurse_ids']
|
del vals['nurse_vals']
|
||||||
if not item_ids:
|
if not item_ids:
|
||||||
item_id=item_obj.create({
|
item_vals={
|
||||||
'cycle_id': cycle_id,
|
'cycle_id': cycle_id,
|
||||||
'date': date,
|
'date': date,
|
||||||
'nurses': [('create',{'nurse_id': nurse_id}) for nurse_id in nurse_ids]
|
'nurses': [],
|
||||||
})
|
}
|
||||||
|
for nurse_val in nurse_vals:
|
||||||
|
item_vals['nurses'].append(('create',{
|
||||||
|
'nurse_id': nurse_val['id'],
|
||||||
|
'level_id': nurse_val['level_id'],
|
||||||
|
}))
|
||||||
|
item_id=item_obj.create(item_vals)
|
||||||
else:
|
else:
|
||||||
item_id=item_ids[0]
|
item_id=item_ids[0]
|
||||||
|
item_nurse_obj=get_model("clinic.cycle.item.nurse")
|
||||||
|
item_nurse_ids=item_nurse_obj.search([['cycle_item_id','=',item_id]])
|
||||||
|
item_nurse_obj.delete(item_nurse_ids)
|
||||||
|
for nurse_val in nurse_vals:
|
||||||
|
item_nurse_obj.create({
|
||||||
|
'cycle_item_id': item_id,
|
||||||
|
'nurse_id': nurse_val['id'],
|
||||||
|
'level_id': nurse_val['level_id'],
|
||||||
|
})
|
||||||
|
|
||||||
vals['cycle_item_id']=item_id
|
vals['cycle_item_id']=item_id
|
||||||
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle.sequence) #date-sequence
|
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle.sequence) #date-sequence
|
||||||
vals['visit_date']=vals['time_start'][0:10]
|
vals['visit_date']=vals['time_start'][0:10]
|
||||||
|
|
|
@ -11,6 +11,7 @@ flow:
|
||||||
======
|
======
|
||||||
missing:
|
missing:
|
||||||
- search calendar
|
- search calendar
|
||||||
|
- can not move schedule in calendar
|
||||||
- color calendar
|
- color calendar
|
||||||
- can not move calendar's schedule
|
- can not move calendar's schedule
|
||||||
- order's visit report dialy
|
- order's visit report dialy
|
||||||
|
|
Loading…
Reference in New Issue