copy nurse
parent
f184eb6799
commit
0a3357826a
|
@ -1,16 +1,17 @@
|
|||
<form model="clinic.cycle.item.copy" title="Load Nurses">
|
||||
<form model="clinic.cycle.item.copy" title="Copy Nurses">
|
||||
<group form_layout="stacked">
|
||||
<field name="choice" onchange="onchange_choice" span="4"/>
|
||||
<field name="item_copy_id" onchange="onchange_item" span="4"/>
|
||||
<field name="schd_copy_id" onchange="onchange_schd" span="4"/>
|
||||
<field name="item_copy_id" onchange="onchange_item" attrs='{"required":[["choice","=","item"]]}' span="4"/>
|
||||
<field name="schd_copy_id" onchange="onchange_item" attrs='{"required":[["choice","=","schd"]]}' span="4"/>
|
||||
<field name="cycle_item_id" span="2" invisible="1"/>
|
||||
</group>
|
||||
<field name="lines" nolabel="1">
|
||||
<list noadd="1">
|
||||
<field name="nurse_id"/>
|
||||
<field name="department_id"/>
|
||||
</list>
|
||||
</field>
|
||||
<foot>
|
||||
<button string="Load" type="success" method="load"/>
|
||||
<button string="OK" type="success" method="load"/>
|
||||
</foot>
|
||||
</form>
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<!--<item string="Load Nurses" method="load_nurse_from_schedule" states='draft'/>-->
|
||||
<item string="Load Nurses" method="cycle_item_copy" states='draft'/>
|
||||
<item string="Load HDCase" method="update_hdcase" states="draft" />
|
||||
<item string="Copy Nurses" method="cycle_item_copy" states='draft'/>
|
||||
<item string="Recheck HD Case" method="update_hdcase" states="draft" />
|
||||
<item string="View Schedule" method="view_schedule"/>
|
||||
<item string="To Draft" method="to_draft" states="validated" />
|
||||
</button>
|
||||
|
@ -22,6 +22,7 @@
|
|||
<list>
|
||||
<field name="nurse_id" domain='[["type","=","nurse"]]' onchange="onchange_nurse"/>
|
||||
<field name="level_id"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
</field>
|
||||
</tab>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<button string="Options" dropdown="1">
|
||||
<item string="Copy" action="clinic_schedule_copy"/>
|
||||
<item string="Get Nurse" action="clinic_load_nurses" states="draft"/>
|
||||
<item string="Reset Item" method="clear" confirm="Are you sure to remove all item?" states="draft"/>
|
||||
<item string="Reset Nurse" method="clear" confirm="Are you sure to remove all item?" states="draft"/>
|
||||
<item string="To Draft" method="to_draft" states="confirmed"/>
|
||||
</button>
|
||||
</head>
|
||||
|
@ -12,12 +12,12 @@
|
|||
<tab string="General">
|
||||
<group form_layout="stacked">
|
||||
<field name="date" span="3" onchange="onchange_date"/>
|
||||
<field name="department_id" span="3"/>
|
||||
<field name="branch_id" span="3"/>
|
||||
<field name="branch_id" span="3" onchange="onchange_branch"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
|
||||
<field name="lines" nolabel="1">
|
||||
<list>
|
||||
<field name="cycle_id"/>
|
||||
<field name="nurse_id" onchange="onchange_nurse"/>
|
||||
<field name="nurse_id" onchange="onchange_nurse" domain='[["department_id","=",parent.department_id]]'/>
|
||||
<field name="level_id"/>
|
||||
<field name="note"/>
|
||||
<field name="cycle_item_id" readonly="1"/>
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<form model="clinic.visit.board">
|
||||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="date_from" onchange="onchange_datefrom" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="cycle_id" span="2"/>
|
||||
<field name="patient_id" span="2"/>
|
||||
<field name="doctor_id" span="2"/>
|
||||
<field name="department_id" span="2"/>
|
||||
<field name="branch_id" span="2"/>
|
||||
<field name="branch_id" onchange="onchange_branch" span="2"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||
<button string='Confirm Visits' method="confirm" type="success" icon="arrow-right"/>
|
||||
<separator string="Note: Please Click 'Run Report' Before Confirm Visits"/>
|
||||
</form>
|
||||
|
|
|
@ -23,16 +23,87 @@ class CycleItemCopy(Model):
|
|||
'choice': 'item',
|
||||
}
|
||||
|
||||
def update_line(self,context={}):
|
||||
data=context['data']
|
||||
lines=[]
|
||||
if data['choice']=='item':
|
||||
item=get_model("clinic.cycle.item").browse(data['item_copy_id'])
|
||||
for line in item.lines:
|
||||
nr=line.nurse_id
|
||||
dpt=nr.department_id
|
||||
lines.append({
|
||||
'nurse_id':nr.id,
|
||||
'department_id': dpt.id,
|
||||
})
|
||||
elif data['choice']=='schd':
|
||||
item=get_model("clinic.cycle.item").browse(data['cycle_item_id'])
|
||||
schd=get_model("clinic.schedule").browse(data['schd_copy_id'])
|
||||
cycle=item.cycle_id
|
||||
for line in schd.lines:
|
||||
nr=line.nurse_id
|
||||
dpt=nr.department_id
|
||||
if cycle.id==line.cycle_id.id:
|
||||
lines.append({
|
||||
'nurse_id':nr.id,
|
||||
'department_id': dpt.id,
|
||||
})
|
||||
else:
|
||||
pass
|
||||
return lines
|
||||
|
||||
def onchange_choice(self,context={}):
|
||||
data=context['data']
|
||||
if data['choice']:
|
||||
data['lines']=self.update_line(context=context)
|
||||
return data
|
||||
|
||||
def onchange_item(self,context={}):
|
||||
data=context['data']
|
||||
data['lines']=self.update_line(context=context)
|
||||
return data
|
||||
|
||||
def onchange_schd(self,context={}):
|
||||
data=context['data']
|
||||
return data
|
||||
def load(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
item=obj.cycle_item_id
|
||||
for line in item.lines:
|
||||
line.delete()
|
||||
lines=[]
|
||||
if obj.choice=='item':
|
||||
for line in obj.item_copy_id.lines:
|
||||
nr=line.nurse_id
|
||||
lines.append(('create', {
|
||||
'nurse_id': nr.id,
|
||||
'level_id': nr.level_id.id,
|
||||
'state': nr.state,
|
||||
}))
|
||||
elif obj.choice=='schd':
|
||||
for line in obj.schd_copy_id.lines:
|
||||
nr=line.nurse_id
|
||||
cycle=line.cycle_id
|
||||
if item.cycle_id.id==cycle.id:
|
||||
lines.append(('create', {
|
||||
'nurse_id': nr.id,
|
||||
'level_id': nr.level_id.id,
|
||||
'state': nr.state,
|
||||
}))
|
||||
else:
|
||||
for line in obj.lines:
|
||||
nr=line.nurse_id
|
||||
lines.append(('create', {
|
||||
'nurse_id': nr.id,
|
||||
'level_id': nr.level_id.id,
|
||||
'state': nr.state,
|
||||
}))
|
||||
item.write({
|
||||
'lines': lines,
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_item',
|
||||
'mode': 'form',
|
||||
'active_id': item.id,
|
||||
},
|
||||
'flash': 'Load Nurse Complete!',
|
||||
}
|
||||
|
||||
CycleItemCopy.register()
|
||||
|
|
|
@ -7,6 +7,7 @@ class CycleItemCopyLine(Model):
|
|||
_fields={
|
||||
"item_copy_id": fields.Many2One("clinic.cycle.item.copy","Copy Item",required=True,on_delete="cascade"),
|
||||
'nurse_id': fields.Many2One("clinic.staff","Nurse",domain=[['type','=','nurse']]),
|
||||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ class CycleItemLine(Model):
|
|||
'level_id': fields.Many2One("clinic.staff.level", "Level",),
|
||||
'nurse_id': fields.Many2One("clinic.staff",'Nurse',domain=[['type','=','nurse']]),
|
||||
'department_id': fields.Many2One("clinic.department","Department"),
|
||||
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
|
||||
}
|
||||
|
||||
CycleItemLine.register()
|
||||
|
|
|
@ -7,38 +7,20 @@ from netforce.utils import get_data_path
|
|||
class Schedule(Model):
|
||||
_name="clinic.schedule"
|
||||
_string="Schedule"
|
||||
_field_name="date"
|
||||
_name_field="name"
|
||||
_key=['name']
|
||||
|
||||
def _get_name(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
st="\n" # XXX
|
||||
count=0
|
||||
for line in obj.lines:
|
||||
nurse=line.nurse_id
|
||||
level=line.level_id
|
||||
cycle=line.cycle_id
|
||||
st+='#%s %s %s\n'%(cycle.sequence,nurse.name,level.name or "")
|
||||
count+=1
|
||||
res[obj.id]='%s'%(st if count else 'No nurse')
|
||||
return res
|
||||
|
||||
def _get_item(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
cycle_id=None
|
||||
if obj.cycle_id:
|
||||
cycle_id=obj.cycle_id.id
|
||||
item_ids=get_model("clinic.cycle.item").search([['cycle_id','=',cycle_id],['date','=',obj.time_start[0:10]]])
|
||||
item_id=None
|
||||
if item_ids:
|
||||
item_id=item_ids[0]
|
||||
res[obj.id]=item_id
|
||||
count=len(obj.lines)
|
||||
dpt=obj.department_id
|
||||
name='%s %s'%(obj.date, dpt.name or '')
|
||||
res[obj.id]='%s'%(name if count else 'Waiting planing')
|
||||
return res
|
||||
|
||||
_fields={
|
||||
'name': fields.Char("Name", function="_get_name"),
|
||||
'name': fields.Char("Name", function="_get_name",store=True),
|
||||
"time_start": fields.DateTime("Time Start",required=True),
|
||||
"time_stop": fields.DateTime("Time Stop",required=True),
|
||||
'date': fields.Date("Date",required=True,search=True),
|
||||
|
@ -245,5 +227,18 @@ class Schedule(Model):
|
|||
line['level_id']=nurse.level_id.id
|
||||
return data
|
||||
|
||||
def create(self,vals,**kw):
|
||||
id=super().create(vals,**kw)
|
||||
self.function_store([id])
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
super().write(ids,vals,**kw)
|
||||
self.function_store(ids)
|
||||
|
||||
def onchange_branch(self,context={}):
|
||||
data=context['data']
|
||||
data['department_id']=None
|
||||
return data
|
||||
|
||||
Schedule.register()
|
||||
|
||||
|
|
|
@ -91,56 +91,12 @@ class ClinicSetting(Model):
|
|||
return True
|
||||
|
||||
def run_script(self,ids,context={}):
|
||||
db=get_connection()
|
||||
db.execute("""
|
||||
update clinic_branch set active=True;
|
||||
update clinic_department set active=True;
|
||||
""")
|
||||
print("Done!")
|
||||
return
|
||||
|
||||
obj=self.browse(ids)[0]
|
||||
################ update sickbed #############
|
||||
#sickbed: update department
|
||||
for sb in get_model('clinic.sickbed').search_browse([]):
|
||||
hdcs=sorted(sb.hd_cases, key=lambda a: a.id)
|
||||
if hdcs:
|
||||
hdc=hdcs[0]
|
||||
#patient=hdc.patient_id
|
||||
sb.write({
|
||||
'department_id': hdc.department_id.id,
|
||||
for item in get_model("clinic.cycle.item").search_browse([]):
|
||||
for line in item.lines:
|
||||
nr=line.nurse_id
|
||||
line.write({
|
||||
'state': nr.state,
|
||||
})
|
||||
#print("Done!")
|
||||
#return
|
||||
|
||||
#############################################
|
||||
|
||||
############### cycle item
|
||||
for lc in get_model('clinic.labor.cost').search_browse([]):
|
||||
lc.delete()
|
||||
|
||||
db=get_connection()
|
||||
res=db.query("""
|
||||
select cycle_item_id, nurse_id, level_id from clinic_cycle_item_nurse
|
||||
""")
|
||||
for rs in res:
|
||||
item_id=rs['cycle_item_id']
|
||||
nid=rs['nurse_id']
|
||||
lid=rs['level_id']
|
||||
if item_id:
|
||||
item=get_model('clinic.cycle.item').browse(item_id)
|
||||
item.write({
|
||||
'lines': [('create',{'nurse_id': nid, 'level_id': lid})],
|
||||
})
|
||||
print('update ', item.name)
|
||||
item.validate()
|
||||
if item.department_id:
|
||||
print("update department for nurse", nid)
|
||||
get_model("clinic.staff").browse(nid).write({
|
||||
'department_id': item.department_id.id,
|
||||
})
|
||||
#return
|
||||
#############################################
|
||||
print("Done!")
|
||||
|
||||
def reset_last_import(self,ids,context={}):
|
||||
|
|
|
@ -218,6 +218,10 @@ class Visit(Model):
|
|||
def get_schedule(date):
|
||||
dom=[]
|
||||
dom.append(['date','=',date])
|
||||
if branch:
|
||||
dom.append(['branch_id','=',branch.id])
|
||||
if department:
|
||||
dom.append(['department_id','=',department.id])
|
||||
schedule=None
|
||||
schedules=get_model("clinic.schedule").search_browse(dom)
|
||||
if schedules:
|
||||
|
@ -239,14 +243,10 @@ class Visit(Model):
|
|||
# clear old nurse in cycle item
|
||||
item_id=item_ids[0]
|
||||
item=item_obj.browse(item_id)
|
||||
if item.state!='draft':
|
||||
# reset nurse
|
||||
for nurse in item.lines:
|
||||
nurse.delete()
|
||||
|
||||
# copy nurse from schedule
|
||||
# copy nurse from schedule(only draft)
|
||||
item=item_obj.browse(item_id)
|
||||
if item.state!='draft':
|
||||
if not item.lines and item.state=='draft':
|
||||
schedule=get_schedule(date)
|
||||
if schedule:
|
||||
for line in schedule.lines:
|
||||
|
@ -255,9 +255,32 @@ class Visit(Model):
|
|||
item_vals['lines'].append(('create',{
|
||||
'nurse_id': nurse.id,
|
||||
'level_id': nurse.level_id.id,
|
||||
'state': nurse.state,
|
||||
}))
|
||||
item.write(item_vals)
|
||||
|
||||
# copy nurse from previous cycle item
|
||||
if not item.lines:
|
||||
dom=[
|
||||
['branch_id','=',branch.id],
|
||||
['department_id','=',department.id],
|
||||
]
|
||||
for item2 in get_model("clinic.cycle.item").search_browse([]):
|
||||
lines=[]
|
||||
for line in item2.lines:
|
||||
nr=line.nurse_id
|
||||
lines.append(('create', {
|
||||
'nurse_id': nr.id,
|
||||
'level_id': nr.level_id.id,
|
||||
'state': nr.state,
|
||||
}))
|
||||
if lines:
|
||||
print("copy nurse from %s to %s"%(item2.name, item.name))
|
||||
item.write({
|
||||
'lines': lines,
|
||||
})
|
||||
break
|
||||
|
||||
obj.write({
|
||||
'cycle_item_id': item_id,
|
||||
})
|
||||
|
|
|
@ -319,6 +319,16 @@ class VisitBoard(Model):
|
|||
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||
return data
|
||||
|
||||
def onchange_datefrom(self,context={}):
|
||||
data=context['data']
|
||||
data['date_to']=data['date_from']
|
||||
return data
|
||||
|
||||
def onchange_branch(self,context={}):
|
||||
data=context['data']
|
||||
data['department_id']=None
|
||||
return data
|
||||
|
||||
def confirm(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
return {
|
||||
|
|
|
@ -5,7 +5,7 @@ todo:
|
|||
- popup messagging -> Ask DJ
|
||||
- modify message of log -> Ask DJ
|
||||
- show image of staff
|
||||
- copy old nurse from previous cycle item
|
||||
- copy old nurse from previous cycle item -> fixing
|
||||
- multi confirm on visit board **** -> ok
|
||||
=======
|
||||
generate visit ใหม่ -> ok
|
||||
|
|
Loading…
Reference in New Issue