schedule
parent
14164962ce
commit
d229e2eba2
|
@ -3,6 +3,7 @@
|
|||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="Compute Labor Cost" method="compute"/>
|
||||
<item string="View Schedule" method="view_schedule"/>
|
||||
</button>
|
||||
</head>
|
||||
|
||||
|
@ -43,12 +44,12 @@
|
|||
<field name="total" span="6" offset="6"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Other Info">
|
||||
<field name="cycle_dialy_id" domain="[['date','=',date]]"/>
|
||||
</tab>
|
||||
<tab string="Validation">
|
||||
<field name="user_id"/>
|
||||
</tab>
|
||||
<tab string="Other Info">
|
||||
<field name="cycle_dialy_id" domain="[['date','=',date]]"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
<button string="Validate" type="success" method="validate" icon="ok" states="draft" />
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
<!--<field name="name"/>-->
|
||||
<field name="cycle_id"/>
|
||||
<field name="date"/>
|
||||
<!--<field name="sequence"/>-->
|
||||
<field name="state"/>
|
||||
</list>
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="Copy" method="copy"/>
|
||||
<item string="Copy From" action="clinic_schedule_copy"/>
|
||||
<item string="Copy Nurses To Schedule" action="clinic_load_nurses"/>
|
||||
<item string="Copy Nurses To Cycle Item" method="copy2cycle_item"/>
|
||||
<item string="Clear List" method="clear" states="draft"/>
|
||||
<item string="Copy By Duration" action="clinic_schedule_copy"/>
|
||||
<item string="Load Nurse To Schedule" action="clinic_load_nurses"/>
|
||||
<item string="Load Nurses To Cycle Item" method="copy2cycle_item"/>
|
||||
<item string="Clear Nurses" method="clear" states="draft"/>
|
||||
</button>
|
||||
</head>
|
||||
<tabs>
|
||||
|
@ -16,8 +16,9 @@
|
|||
<field name="lines" nolabel="1">
|
||||
<list>
|
||||
<field name="cycle_id"/>
|
||||
<field name="nurse_id"/>
|
||||
<field name="nurse_id" onchange="onchange_nurse"/>
|
||||
<field name="level_id"/>
|
||||
<field name="cycle_item_id" readonly="1"/>
|
||||
</list>
|
||||
</field>
|
||||
</group>
|
||||
|
|
|
@ -74,7 +74,7 @@ class CycleItem(Model):
|
|||
'var_k': _get_vark,
|
||||
}
|
||||
|
||||
_order="sequence"
|
||||
_order="date desc"
|
||||
_sql_constraints=[
|
||||
("cycle_item_uniq","unique (cycle_id,date,company_id)","Cycle item should be unique"),
|
||||
]
|
||||
|
@ -336,5 +336,20 @@ class CycleItem(Model):
|
|||
nurse=get_model('clinic.personal').browse(nurse_id)
|
||||
line['level_id']=nurse.level_id.id
|
||||
return data
|
||||
|
||||
def view_schedule(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
date=obj.date
|
||||
schd_ids=get_model('clinic.schedule').search([['date','=',date]])
|
||||
schedule_id=None
|
||||
if schd_ids:
|
||||
schedule_id=schd_ids[0]
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_schedule',
|
||||
'mode': 'form',
|
||||
'active_id': schedule_id,
|
||||
}
|
||||
}
|
||||
|
||||
CycleItem.register()
|
||||
|
|
|
@ -37,7 +37,6 @@ class HDCaseDialy(Model):
|
|||
dom.append(['time_start','>=','%s 00:00:00'%date])
|
||||
dom.append(['time_stop','<=','%s 23:59:59'%date])
|
||||
lines=[]
|
||||
no=1
|
||||
for obj in get_model("clinic.hd.case").search_browse(dom):
|
||||
patient_type=utils.PATIENT_TYPE[obj.patient_id.type]
|
||||
dlz_number=""
|
||||
|
@ -48,7 +47,7 @@ class HDCaseDialy(Model):
|
|||
dlz_number=dlz.number
|
||||
line={
|
||||
'cycle_name': obj.cycle_id.name,
|
||||
'no': no,
|
||||
'cycle_sequence': obj.cycle_id.sequence,
|
||||
'hd_case_number': obj.number,
|
||||
'patient_name': obj.patient_id.name,
|
||||
'patient_type': patient_type,
|
||||
|
@ -62,12 +61,19 @@ class HDCaseDialy(Model):
|
|||
'note': obj.note or "",
|
||||
}
|
||||
lines.append(line)
|
||||
no+=1
|
||||
# XXX
|
||||
year=int(year)+543
|
||||
date_str='%s %s %s'%(day,month_str,year)
|
||||
|
||||
slines=[]
|
||||
no=1
|
||||
for line in sorted(lines,key=lambda x: (x['cycle_sequence'],x['hd_case_number'])):
|
||||
line['no']=no
|
||||
slines.append(line)
|
||||
no+=1
|
||||
|
||||
data={
|
||||
'lines': lines,
|
||||
'lines': slines,
|
||||
'date': date_str,
|
||||
'company_name': company.name,
|
||||
'company_parent_name': company.parent_id.name,
|
||||
|
|
|
@ -48,18 +48,28 @@ class LoadNurse(Model):
|
|||
'lines': [],
|
||||
}
|
||||
cycles=set()
|
||||
lines=[]
|
||||
for line in obj.lines:
|
||||
nurse=line.nurse_id
|
||||
cycle_id=line.cycle_id.id
|
||||
cycles.update({cycle_id})
|
||||
vals['lines'].append(('create',{
|
||||
'cycle_id': cycle_id,
|
||||
cycle=line.cycle_id
|
||||
cycles.update({(cycle.id,nurse.id)})
|
||||
lines.append({
|
||||
'cycle_id': cycle.id,
|
||||
'nurse_id': nurse.id,
|
||||
}))
|
||||
'cycle_seq': cycle.sequence,
|
||||
})
|
||||
|
||||
for line in schedule.lines:
|
||||
if line.cycle_id.id in list(cycles):
|
||||
line.delete()
|
||||
for cycle in cycles:
|
||||
cycle_id,nurse_id=cycle
|
||||
if line.cycle_id.id==cycle_id and line.nurse_id.id==nurse_id:
|
||||
line.delete()
|
||||
|
||||
for line in sorted(lines,key=lambda x: x['cycle_seq']):
|
||||
vals['lines'].append(('create',{
|
||||
'cycle_id': line['cycle_id'],
|
||||
'nurse_id': line['nurse_id'],
|
||||
}))
|
||||
|
||||
schedule.write(vals)
|
||||
return {
|
||||
|
|
|
@ -2,6 +2,7 @@ from datetime import datetime, timedelta
|
|||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company, get_active_user
|
||||
from netforce.utils import get_data_path
|
||||
|
||||
class Schedule(Model):
|
||||
_name="clinic.schedule"
|
||||
|
@ -35,7 +36,6 @@ class Schedule(Model):
|
|||
|
||||
_fields={
|
||||
'name': fields.Char("Name", function="_get_name"),
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item", function="_get_item"),
|
||||
"time_start": fields.DateTime("Time Start",required=True),
|
||||
"time_stop": fields.DateTime("Time Stop",required=True),
|
||||
'date': fields.Date("Date",required=True,search=True),
|
||||
|
@ -101,34 +101,45 @@ class Schedule(Model):
|
|||
|
||||
def copy2cycle_item(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
nurses=[]
|
||||
date=obj.date
|
||||
items={}
|
||||
cycles=set()
|
||||
for line in obj.lines:
|
||||
nurse=line.nurse_id
|
||||
nurses.append(('create',{
|
||||
'nurse_id': nurse.id,
|
||||
'level_id': nurse.level_id.id,
|
||||
}))
|
||||
if not obj.cycle_item_id:
|
||||
item_id=get_model("clinic.cycle.item").create({
|
||||
'date': obj.date,
|
||||
'cycle_id': obj.cycle_id.id,
|
||||
})
|
||||
obj.write({
|
||||
'cycle_item_id': item_id,
|
||||
})
|
||||
for nurse in obj.cycle_item_id.nurses:
|
||||
nurse.delete()
|
||||
cycle=line.cycle_id
|
||||
item_ids=get_model("clinic.cycle.item").search([['date','=',date],['cycle_id','=',cycle.id],['state','=','draft']])
|
||||
if item_ids:
|
||||
item_id=item_ids[0]
|
||||
if not items.get(item_id):
|
||||
items[item_id]=[]
|
||||
items[item_id].append(('create',{
|
||||
'nurse_id': nurse.id,
|
||||
'level_id': nurse.level_id.id,
|
||||
}))
|
||||
line.write({
|
||||
'cycle_item_id': item_id,
|
||||
})
|
||||
cycles.update({cycle.name})
|
||||
|
||||
obj.cycle_item_id.write({
|
||||
'nurses': nurses,
|
||||
})
|
||||
for item_id, nurses in items.items():
|
||||
item=get_model("clinic.cycle.item").browse(item_id)
|
||||
for nurse in item.nurses:
|
||||
nurse.delete()
|
||||
item.write({
|
||||
'nurses': nurses,
|
||||
})
|
||||
|
||||
msg='Load nurses to cycle item %s successfully'%(','.join(list(cycles)))
|
||||
# TODO create cycle item automatically
|
||||
if not items:
|
||||
msg='No cycle item to copy'
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_item',
|
||||
'name': 'clinic_schedule',
|
||||
'mode': 'form',
|
||||
'active_id': obj.cycle_item_id.id,
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': 'Copy nurses to cycle item successfully',
|
||||
'flash': msg,
|
||||
}
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
|
@ -166,5 +177,14 @@ class Schedule(Model):
|
|||
'flash': 'List of nurse has been cleared.',
|
||||
}
|
||||
|
||||
def onchange_nurse(self,context={}):
|
||||
data=context['data']
|
||||
path=context["path"]
|
||||
line=get_data_path(data,path,parent=True)
|
||||
nurse_id=line['nurse_id']
|
||||
nurse=get_model("clinic.personal").browse(nurse_id)
|
||||
line['level_id']=nurse.level_id.id
|
||||
return data
|
||||
|
||||
Schedule.register()
|
||||
|
||||
|
|
|
@ -9,9 +9,11 @@ class ScheduleLine(Model):
|
|||
for obj in self.browse(ids):
|
||||
res[obj.id]=obj.nurse_id.level_id.id
|
||||
return res
|
||||
|
||||
_fields={
|
||||
'schedule_id': fields.Many2One("clinic.schedule","Schedule"),
|
||||
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"),
|
||||
"nurse_id": fields.Many2One("clinic.personal","Nurse",domain=[['type','=','nurse']]),
|
||||
'level_id': fields.Many2One("clinic.personal.level","Level",function="_get_level"),
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<td><a href="/ui#name=clinic_patient&active_id={{patient_id}}&mode=form">{{patient_name}}</a></td>
|
||||
<td><a href="/ui#name=clinic_personal&active_id={{doctor_id}}&mode=form">{{doctor_name}}</a></td>
|
||||
<td>{{patient_type}}</td>
|
||||
<td>{{fee_amount}}</td>
|
||||
<td>{{currency fee_amount}}</td>
|
||||
<td>-</td>
|
||||
<td><a href="/ui#name=clinic_hd_case&active_id={{hd_case_id}}&mode=form">{{hd_case_number}}</a></td>
|
||||
<td><a href="/ui#name=clinic_hd_dialyzer&active_id={{dlz_id}}&mode=form">{{dlz_number}}</a></td>
|
||||
|
|
Loading…
Reference in New Issue