diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml
index 9f855a3..4f812d6 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_form.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml
@@ -3,6 +3,7 @@
@@ -43,12 +44,12 @@
-
-
-
+
+
+
diff --git a/netforce_clinic/layouts/clinic_cycle_item_list.xml b/netforce_clinic/layouts/clinic_cycle_item_list.xml
index beca47f..01a154d 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_list.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_list.xml
@@ -2,5 +2,6 @@
+
diff --git a/netforce_clinic/layouts/clinic_schedule_form.xml b/netforce_clinic/layouts/clinic_schedule_form.xml
index 1498090..4ab583c 100644
--- a/netforce_clinic/layouts/clinic_schedule_form.xml
+++ b/netforce_clinic/layouts/clinic_schedule_form.xml
@@ -3,10 +3,10 @@
@@ -16,8 +16,9 @@
-
+
+
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index cd5c94c..b48998c 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -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()
diff --git a/netforce_clinic/models/hd_case_dialy.py b/netforce_clinic/models/hd_case_dialy.py
index 238b017..1df7d0f 100644
--- a/netforce_clinic/models/hd_case_dialy.py
+++ b/netforce_clinic/models/hd_case_dialy.py
@@ -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,
diff --git a/netforce_clinic/models/load_nurse.py b/netforce_clinic/models/load_nurse.py
index 3540120..da3f93e 100644
--- a/netforce_clinic/models/load_nurse.py
+++ b/netforce_clinic/models/load_nurse.py
@@ -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 {
diff --git a/netforce_clinic/models/schedule.py b/netforce_clinic/models/schedule.py
index 41a0d36..6478de1 100644
--- a/netforce_clinic/models/schedule.py
+++ b/netforce_clinic/models/schedule.py
@@ -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()
diff --git a/netforce_clinic/models/schedule_line.py b/netforce_clinic/models/schedule_line.py
index 7ae8650..baa7859 100644
--- a/netforce_clinic/models/schedule_line.py
+++ b/netforce_clinic/models/schedule_line.py
@@ -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"),
}
diff --git a/netforce_clinic/templates/hd_case_dialy.hbs b/netforce_clinic/templates/hd_case_dialy.hbs
index 53d7223..9550cb6 100644
--- a/netforce_clinic/templates/hd_case_dialy.hbs
+++ b/netforce_clinic/templates/hd_case_dialy.hbs
@@ -30,7 +30,7 @@
{{patient_name}} |
{{doctor_name}} |
{{patient_type}} |
- {{fee_amount}} |
+ {{currency fee_amount}} |
- |
{{hd_case_number}} |
{{dlz_number}} |