diff --git a/netforce_clinic/actions/clinic_cycle_dialy.xml b/netforce_clinic/actions/clinic_cycle_dialy.xml
index 5df7a10..2271659 100644
--- a/netforce_clinic/actions/clinic_cycle_dialy.xml
+++ b/netforce_clinic/actions/clinic_cycle_dialy.xml
@@ -1,11 +1,7 @@
Cycle Dialy
- report_view
- clinic.cycle.item
-
- date
- cycle_id
-
-
+ multi_view
+ clinic.cycle.dialy
+ list,form
clinic_menu
diff --git a/netforce_clinic/actions/clinic_cycle_dialy.xml.old b/netforce_clinic/actions/clinic_cycle_dialy.xml.old
new file mode 100644
index 0000000..5df7a10
--- /dev/null
+++ b/netforce_clinic/actions/clinic_cycle_dialy.xml.old
@@ -0,0 +1,11 @@
+
+ Cycle Dialy
+ report_view
+ clinic.cycle.item
+
+ date
+ cycle_id
+
+
+ clinic_menu
+
diff --git a/netforce_clinic/actions/clinic_schedule_copy.xml b/netforce_clinic/actions/clinic_schedule_copy.xml
new file mode 100644
index 0000000..db43ab9
--- /dev/null
+++ b/netforce_clinic/actions/clinic_schedule_copy.xml
@@ -0,0 +1,6 @@
+
+ Copy Schedule
+ form_popup
+ clinic.schedule.copy
+ _popup
+
diff --git a/netforce_clinic/actions/clinic_visit_dialy.xml b/netforce_clinic/actions/clinic_visit_dialy.xml
index b49b346..dfbc3c2 100644
--- a/netforce_clinic/actions/clinic_visit_dialy.xml
+++ b/netforce_clinic/actions/clinic_visit_dialy.xml
@@ -1,10 +1,8 @@
-
+
Visit Dialy
- report_view
- clinic.visit
-
- visit_date
- visit_date,cycle_id
-
- clinic_menu
-
+ report
+ clinic.visit.dialy
+ visit_dialy
+ visit_dialy
+ clinic_menu
+
diff --git a/netforce_clinic/actions/clinic_visit_widget.xml b/netforce_clinic/actions/clinic_visit_widget.xml
index 9b8637a..0b9159d 100644
--- a/netforce_clinic/actions/clinic_visit_widget.xml
+++ b/netforce_clinic/actions/clinic_visit_widget.xml
@@ -2,6 +2,7 @@
list_view
clinic.visit
[["state","not in",["confirmed"]]]
+
clinic_visit_widget
10
diff --git a/netforce_clinic/layouts/clinic_cycle_dialy_form.xml b/netforce_clinic/layouts/clinic_cycle_dialy_form.xml
new file mode 100644
index 0000000..5215aee
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_cycle_dialy_form.xml
@@ -0,0 +1,16 @@
+
diff --git a/netforce_clinic/layouts/clinic_cycle_dialy_list.xml b/netforce_clinic/layouts/clinic_cycle_dialy_list.xml
new file mode 100644
index 0000000..6792cf3
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_cycle_dialy_list.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml
index d8aa5d3..431cd7b 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_form.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml
@@ -16,6 +16,9 @@
+
+
+
diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml
index 17be872..face1da 100644
--- a/netforce_clinic/layouts/clinic_menu.xml
+++ b/netforce_clinic/layouts/clinic_menu.xml
@@ -32,7 +32,7 @@
-
-
+
diff --git a/netforce_clinic/layouts/clinic_schedule_copy_form.xml b/netforce_clinic/layouts/clinic_schedule_copy_form.xml
new file mode 100644
index 0000000..0152c54
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_schedule_copy_form.xml
@@ -0,0 +1,17 @@
+
diff --git a/netforce_clinic/layouts/clinic_schedule_form.xml b/netforce_clinic/layouts/clinic_schedule_form.xml
index 2a78182..64f3950 100644
--- a/netforce_clinic/layouts/clinic_schedule_form.xml
+++ b/netforce_clinic/layouts/clinic_schedule_form.xml
@@ -3,7 +3,7 @@
@@ -19,7 +19,7 @@
-
+
diff --git a/netforce_clinic/layouts/clinic_schedule_list.xml b/netforce_clinic/layouts/clinic_schedule_list.xml
index 565d306..34cb5de 100644
--- a/netforce_clinic/layouts/clinic_schedule_list.xml
+++ b/netforce_clinic/layouts/clinic_schedule_list.xml
@@ -1,4 +1,5 @@
+
diff --git a/netforce_clinic/layouts/clinic_visit_calendar.xml b/netforce_clinic/layouts/clinic_visit_calendar.xml
index f5515a7..11d8e9f 100644
--- a/netforce_clinic/layouts/clinic_visit_calendar.xml
+++ b/netforce_clinic/layouts/clinic_visit_calendar.xml
@@ -4,5 +4,6 @@
-
+
+
diff --git a/netforce_clinic/layouts/clinic_visit_dialy.xml b/netforce_clinic/layouts/clinic_visit_dialy.xml
new file mode 100644
index 0000000..3a275c4
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_visit_dialy.xml
@@ -0,0 +1,3 @@
+
diff --git a/netforce_clinic/layouts/clinic_visit_form.xml b/netforce_clinic/layouts/clinic_visit_form.xml
index 44c2815..f667683 100644
--- a/netforce_clinic/layouts/clinic_visit_form.xml
+++ b/netforce_clinic/layouts/clinic_visit_form.xml
@@ -25,6 +25,9 @@
+
+
+
diff --git a/netforce_clinic/layouts/clinic_visit_widget.xml b/netforce_clinic/layouts/clinic_visit_widget.xml
index 93ccb50..5c83e75 100644
--- a/netforce_clinic/layouts/clinic_visit_widget.xml
+++ b/netforce_clinic/layouts/clinic_visit_widget.xml
@@ -1,7 +1,9 @@
+
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 89d6e5a..d1e9d79 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -30,6 +30,7 @@ from . import cycle_item
from . import cycle_item_nurse
from . import cycle_item_doctor
from . import cycle_item_line
+from . import cycle_dialy
from . import gen_visit
from . import gen_visit_line
from . import report_clinic
@@ -51,5 +52,6 @@ from . import personal_move
from . import personal_cycle
from . import schedule
from . import schedule_line
+from . import schedule_copy
from . import load_nurse
from . import load_nurse_line
diff --git a/netforce_clinic/models/cycle_dialy.py b/netforce_clinic/models/cycle_dialy.py
new file mode 100644
index 0000000..a402bbf
--- /dev/null
+++ b/netforce_clinic/models/cycle_dialy.py
@@ -0,0 +1,27 @@
+import time
+
+from netforce.model import Model, fields
+from netforce.access import get_active_company
+
+class CycleDialy(Model):
+ _name="clinic.cycle.dialy"
+ _string="Cycle Diay"
+
+ _fields={
+ "name": fields.Char("Name"),
+ 'date': fields.Date("Date", required=True, search=True),
+ 'cycle_items': fields.One2Many("clinic.cycle.item","cycle_dialy_id", "Cycle Items"),
+ 'company_id': fields.Many2One("company","Company"),
+ }
+
+ _defaults={
+ 'company_id': lambda *a: get_active_company(),
+ 'date': lambda *a: time.strftime("%Y-%m-%d"),
+ 'name': lambda *a: time.strftime("%Y-%m-%d"),
+ }
+
+ def write(self,ids,vals,**kw):
+ vals['name']=vals['date']
+ super().write(ids,vals,**kw)
+
+CycleDialy.register()
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index 976d762..7cea13b 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -18,16 +18,16 @@ class CycleItem(Model):
return res
_fields={
- 'name': fields.Char("Name", function="_get_all",function_multi=True), # need to field related in journal
- 'company_id': fields.Many2One("company", "Company"),
- 'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
+ 'name': fields.Char("Name", function="_get_all",function_multi=True),
'date': fields.Date("Date",search=True),
- "state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
- 'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
+ 'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
+ 'cycle_dialy_id': fields.Many2One("clinic.cycle.dialy", "Cycle Dialy",search=True),
'visits': fields.One2Many("clinic.visit","cycle_item_id", "Visits"),
+ 'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
'nurses': fields.One2Many("clinic.cycle.item.nurse",'cycle_item_id','Nurses'),
- 'doctors': fields.One2Many("clinic.cycle.item.doctor",'cycle_item_id','Doctors'),
- 'sequence': fields.Char("Sequence"),
+ 'sequence': fields.Char("Sequence"), # for sort item
+ 'company_id': fields.Many2One("company", "Company"),
+ "state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
}
_defaults={
@@ -40,10 +40,27 @@ class CycleItem(Model):
_sql_constraints=[
("cycle_item_uniq","unique (cycle_id,date,company_id)","Cycle item should be unique"),
]
-
+
+ def get_cycle_diary(self,date):
+ dom=[]
+ print("get ", date)
+ dom.append(['date','=',date])
+ cd_ids=get_model('clinic.cycle.dialy').search(dom)
+ cd_id=None
+ if cd_ids:
+ cd_id=cd_ids[0]
+ else:
+ cd_id=get_model('clinic.cycle.dialy').create({
+ 'date':date,
+ 'name':date,
+ })
+ return cd_id
+
def create(self, vals,**kw):
date=vals['date']
cycle_id=vals['cycle_id']
+ vals['cycle_dialy_id']=self.get_cycle_diary(date)
+
cycle=get_model("clinic.cycle").browse(cycle_id)
vals['sequence']='%s-%s'%(date,cycle.sequence) #date-sequence
obj_id=super().create(vals,**kw)
@@ -52,6 +69,8 @@ class CycleItem(Model):
def write(self,ids,vals,**kw):
obj=self.browse(ids)[0]
cycle=obj.cycle_id
+ date=vals.get('date') and vals.get('date') or obj.date
+ vals['cycle_dialy_id']=self.get_cycle_diary(date)
vals['sequence']='%s-%s'%(obj.date,cycle.sequence) #date-sequence
super().write(ids,vals,**kw)
diff --git a/netforce_clinic/models/gen_visit.py b/netforce_clinic/models/gen_visit.py
index d0597ae..72c8d90 100644
--- a/netforce_clinic/models/gen_visit.py
+++ b/netforce_clinic/models/gen_visit.py
@@ -17,7 +17,6 @@ class GenVisit(Model):
duration=datetime.strptime(obj.date_to,FMT_DATETIME)-datetime.strptime(obj.date_from,FMT_DATETIME)
res[obj.id]=duration.days
return res
-
_fields={
'date_from': fields.DateTime("From", required=True),
diff --git a/netforce_clinic/models/load_nurse.py b/netforce_clinic/models/load_nurse.py
index 99062c9..44f825d 100644
--- a/netforce_clinic/models/load_nurse.py
+++ b/netforce_clinic/models/load_nurse.py
@@ -5,7 +5,7 @@ class LoadNurse(Model):
_transient=True
_fields={
- "schedule_id": fields.Many2One("clinic.schedule","Schedule",required=True,on_delete="cascade"),
+ "schedule_id": fields.Many2One("clinic.schedule","Schedule",on_delete="cascade"),
'categ_id': fields.Many2One("clinic.personal.categ","Category", domain=[['type','=','nurse']]),
"lines": fields.One2Many("clinic.schedule.load.nurse.line",'load_id', 'Lines'),
}
@@ -41,11 +41,13 @@ class LoadNurse(Model):
def copy2schedule(self,ids,context):
obj=self.browse(ids)[0]
+ if not obj.schedule_id:
+ raise Exception("Please save schedule before copy")
+
schedule=get_model("clinic.schedule").browse(obj.schedule_id.id)
vals={
'lines': [],
}
-
cycles=set()
for line in obj.lines:
nurse=line.nurse_id
@@ -75,6 +77,5 @@ class LoadNurse(Model):
return data
-
LoadNurse.register()
diff --git a/netforce_clinic/models/schedule.py b/netforce_clinic/models/schedule.py
index 21f9c43..fd7212f 100644
--- a/netforce_clinic/models/schedule.py
+++ b/netforce_clinic/models/schedule.py
@@ -11,7 +11,7 @@ class Schedule(Model):
def _get_name(self,ids,context={}):
res={}
for obj in self.browse(ids):
- res[obj.id]='Schedule - %s'%(obj.date)
+ res[obj.id]='%s'%(obj.date)
return res
def _get_item(self,ids,context={}):
@@ -29,11 +29,11 @@ class Schedule(Model):
'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),
+ 'date': fields.Date("Date",required=True,search=True),
'lines': fields.One2Many("clinic.schedule.line","schedule_id","Lines"),
'company_id': fields.Many2One("company","Company"),
- 'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State'),
- 'user_id': fields.Many2One("base.user","User"),
+ 'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State',search=True),
+ 'user_id': fields.Many2One("base.user","Confirm By"),
}
_defaults={
@@ -45,6 +45,8 @@ class Schedule(Model):
'state': 'draft',
}
+ _order="date desc"
+
_sql_constraints=[
('schedule_uniq','unique (date,company_id)','Date should be unique'),
]
@@ -64,6 +66,10 @@ class Schedule(Model):
def copy(self,ids,context={}):
obj=self.browse(ids)[0]
+ datenow=datetime.now().strftime("%Y-%m-%d")
+ old_ids=get_model('clinic.schedule').search([['date','=',datenow]])
+ if old_ids:
+ raise Exception("This schedule is already create!")
vals={
'lines': [],
}
@@ -73,7 +79,6 @@ class Schedule(Model):
'cycle_id': line.cycle_id.id
}
))
-
new_id=get_model("clinic.schedule").create(vals)
new_obj=get_model("clinic.schedule").browse(new_id)
return {
@@ -94,7 +99,7 @@ class Schedule(Model):
'nurse_id': nurse.id,
'level_id': nurse.level_id.id,
}))
-
+ print('xx')
for nurse in obj.cycle_item_id.nurses:
nurse.delete()
diff --git a/netforce_clinic/models/schedule_copy.py b/netforce_clinic/models/schedule_copy.py
new file mode 100644
index 0000000..c527a6b
--- /dev/null
+++ b/netforce_clinic/models/schedule_copy.py
@@ -0,0 +1,153 @@
+from datetime import datetime, timedelta
+from netforce.model import Model, fields, get_model
+
+FMT_DATE="%Y-%m-%d"
+FMT_DATETIME="%Y-%m-%d %H:%M:%S"
+
+class ScheduleCopy(Model):
+ _name="clinic.schedule.copy"
+ _transient=True
+
+ _fields={
+ "schedule_id": fields.Many2One("clinic.schedule","Schedule",on_delete="cascade"),
+ 'date_from': fields.Date("From", required=True),
+ 'date_to': fields.Date("To", required=True),
+ 'mon': fields.Boolean("Monday"),
+ 'tue': fields.Boolean("Tuesdays"),
+ 'wed': fields.Boolean("Wednesdays"),
+ 'thu': fields.Boolean("Thursdays"),
+ 'fri': fields.Boolean("Fridays"),
+ 'sat': fields.Boolean("Saturday"),
+ 'sun': fields.Boolean("Sunday"),
+ }
+
+ def _get_schedule_id(self,context={}):
+ schedule_id=context.get("refer_id")
+ if not schedule_id:
+ return None
+ return int(schedule_id)
+
+ def _get_date_from(self,context={}):
+ date_from=datetime.now().strftime("%Y-%m-%d")
+ schedule_id=context.get("refer_id")
+ if schedule_id:
+ schedule=get_model("clinic.schedule").browse(int(schedule_id))
+ date_from=datetime.strptime(schedule.date,FMT_DATE)
+ date_from=(date_from+timedelta(days=1)).strftime("%Y-%m-%d")
+ return date_from
+
+ def _get_date_to(self,context={}):
+ date_to=(datetime.now()+timedelta(days=8)).strftime("%Y-%m-%d")
+ schedule_id=context.get("refer_id")
+ if schedule_id:
+ schedule=get_model("clinic.schedule").browse(int(schedule_id))
+ date_to=datetime.strptime(schedule.date,FMT_DATE)
+ date_to=(date_to+timedelta(days=8)).strftime("%Y-%m-%d")
+ return date_to
+
+ _defaults={
+ 'schedule_id': _get_schedule_id,
+ 'date_from': _get_date_from,
+ 'date_to': _get_date_to,
+ 'mon': True,
+ 'tue': True,
+ 'wed': True,
+ 'thu': True,
+ 'fri': True,
+ 'sat': True,
+ 'sun': True,
+ }
+
+ def copy2schedule(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ if not obj.schedule_id:
+ raise Exception("Please save schedule before copy")
+
+ schedule=get_model("clinic.schedule").browse(obj.schedule_id.id)
+ lines=[]
+ for line in schedule.lines:
+ lines.append(('create',{
+ 'nurse_id': line.nurse_id.id,
+ 'cycle_id': line.cycle_id.id,
+ }))
+ days=[
+ obj.mon and 1 or 0,
+ obj.tue and 2 or 0,
+ obj.wed and 3 or 0,
+ obj.thu and 4 or 0,
+ obj.fri and 5 or 0,
+ obj.sat and 6 or 0,
+ obj.sun and 7 or 0,
+ ]
+ days=[day for day in days if day]
+ ntoday=1
+ date_from=datetime.strptime(obj.date_from,FMT_DATE)
+ date_to=datetime.strptime(obj.date_to,FMT_DATE)
+ day_total=(date_to-date_from).days+ntoday
+ schedules=[]
+ schedule_date=obj.schedule_id.date
+ time_start=obj.schedule_id.time_start[11:]
+ time_stop=obj.schedule_id.time_stop[11:]
+ exist_date={}
+ for r in get_model("clinic.schedule").search_read([['date','>=',obj.date_from],['date','<=',(date_to+timedelta(days=8)).strftime(FMT_DATE)]],['date','state']):
+ exist_date.update({
+ r['date']:{
+ 'id': r['id'],
+ 'date': r['date'],
+ 'state': r['state']
+ }})
+ print('exist date')
+ print("="*50)
+ for k,v in exist_date.items():
+ print(k)
+ print("="*50)
+ for weekday in days:
+ wd=date_from.weekday()
+ start_date=date_from
+ while wd != weekday-1:
+ start_date+=timedelta(days=1)
+ wd=start_date.weekday()
+ #XXX should gen only in scope
+ if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
+ continue
+ count=0
+ tmp=start_date
+ while count < day_total:
+ tmp=start_date+timedelta(days=count)
+ date=tmp.strftime(FMT_DATE)
+ exist_vals=exist_date.get(date,{})
+ if exist_vals:
+ eid=exist_vals['id']
+ edate=exist_vals['date']
+ estate=exist_vals['state']
+ if edate==date and estate=='draft':
+ get_model("clinic.schedule").delete([eid])
+ print("delete ", exist_date)
+ count+=7 # looking for next week if dow is not exist
+ if date not in [v['date'] for k,v in exist_date.items()]+[schedule_date]:
+ schedules.append({
+ 'date': date,
+ 'lines': lines,
+ })
+
+ start_date=tmp
+
+
+ for sc in schedules:
+ date=sc['date']
+ sc['time_start']='%s %s'%(date,time_start)
+ sc['time_stop']='%s %s'%(date,time_stop)
+ sc_id=get_model("clinic.schedule").create(sc)
+ print('create', sc['date'])
+
+ return {
+ 'next': {
+ 'name': 'clinic_schedule',
+ 'mode': 'form',
+ 'active_id': obj.schedule_id.id,
+ },
+ 'flash': 'Copy successully',
+ }
+
+ScheduleCopy.register()
+
diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py
index e6f4684..a7fb332 100644
--- a/netforce_clinic/models/visit.py
+++ b/netforce_clinic/models/visit.py
@@ -18,6 +18,13 @@ class Visit(Model):
for obj in self.browse(ids):
res[obj.id]=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return res
+
+ def _get_color(self,ids,context={}):
+ res={}
+ for obj in self.browse(ids):
+ color=get_model("clinic.cycle").browse(obj.cycle_id.id).color
+ res[obj.id]=color
+ return res
_fields={
"number": fields.Char("Number",required=True,search=True),
@@ -31,12 +38,14 @@ class Visit(Model):
"company_id": fields.Many2One("company","Company"),
'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True),
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
+ 'cycle_color': fields.Char('Color',function="_get_color"),
"state": fields.Selection([["draft","Draft"],["confirmed","Confirmed"],["cancelled","Cancelled"]],"Status",required=True),
"comments": fields.One2Many("message","related_id","Comments"),
'visit_date': fields.Date('Visit Date'),
'print_date': fields.Date('Print Date',function="_get_print_date"),
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item
'sequence': fields.Char("Sequence"),
+ 'note': fields.Text('Note'),
}
def _get_number(self,context={}):
@@ -296,7 +305,7 @@ class Visit(Model):
item_obj=get_model('clinic.cycle.item')
item_ids=item_obj.search(dom)
item_id=None
- # XXX
+
nurse_vals=[]
if 'nurse_vals' in vals.keys():
nurse_vals=vals['nurse_vals']
@@ -326,6 +335,7 @@ class Visit(Model):
})
vals['cycle_item_id']=item_id
+
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle.sequence) #date-sequence
vals['visit_date']=vals['time_start'][0:10]
obj_id=super().create(vals,**kw)
diff --git a/netforce_clinic/models/visit_dialy.py b/netforce_clinic/models/visit_dialy.py
index abb3276..1007607 100644
--- a/netforce_clinic/models/visit_dialy.py
+++ b/netforce_clinic/models/visit_dialy.py
@@ -1,12 +1,74 @@
-from netforce.model import Model, fields
+import time
+import urllib.parse as urllib
+
+from datetime import datetime
+from calendar import monthrange
+from netforce.model import Model, fields, get_model
+from netforce.access import get_active_company
+
+from . import utils
class VisitDialy(Model):
_name="clinic.visit.dialy"
_string="Visit Dialy"
_transient=True
-
+
_fields={
- 'date': fields.Date('Date'),
+ "date": fields.Date("Month", required=True),
}
+ _defaults={
+ 'date': lambda *a: time.strftime("%Y-%m-%d"),
+ }
+
+ def get_report_data(self,ids,context={}):
+ company_id=get_active_company()
+ company=get_model("company").browse(company_id)
+
+ date=datetime.now().strftime("%Y-%m-%d")
+ if ids:
+ obj=self.browse(ids)[0]
+ date=obj.date
+ month=int(date[5:7])
+ day=date[8:10]
+ year=date[0:4]
+ month_str=utils.MONTHS['th_TH'][month]
+ dom=[]
+ dom.append(['time_start','>=','%s 00:00:00'%date])
+ dom.append(['time_stop','<=','%s 23:59:59'%date])
+ lines=[]
+ for obj in get_model("clinic.visit").search_browse(dom):
+ hd_case_id=None
+ hd_case_number=''
+ if obj.hd_cases:
+ hd_case=obj.hd_cases[0]
+ hd_case_id=hd_case.id,
+ hd_case_number=hd_case.number,
+ number=obj.number
+ if number=='/':
+ number='รอการรรักษา'
+ line={
+ 'number': number,
+ 'visit_id': obj.id,
+ 'cycle_name': obj.cycle_id.name,
+ 'cycle_color': obj.cycle_id.color,
+ 'patient_name': obj.patient_id.name,
+ 'doctor_name': obj.doctor_id.name,
+ 'hd_case_number': hd_case_number,
+ 'hd_case_id': hd_case_id,
+ 'success_color': obj.state=='confirmed' and '#99ff99' or ''
+ }
+ lines.append(line)
+ # XXX
+ year=int(year)+543
+ date_str='%s %s %s'%(day,month_str,year)
+ data={
+ 'lines': lines,
+ #'date': date,
+ 'date': date_str,
+ 'company_name': company.name,
+ 'company_parent_name': company.parent_id.name,
+ }
+ return data
+
VisitDialy.register()
diff --git a/netforce_clinic/reports/visit_dialy.xlsx b/netforce_clinic/reports/visit_dialy.xlsx
new file mode 100644
index 0000000..47b0b02
Binary files /dev/null and b/netforce_clinic/reports/visit_dialy.xlsx differ
diff --git a/netforce_clinic/templates/visit_dialy.hbs b/netforce_clinic/templates/visit_dialy.hbs
new file mode 100644
index 0000000..c7230b3
--- /dev/null
+++ b/netforce_clinic/templates/visit_dialy.hbs
@@ -0,0 +1,33 @@
+
+ ตารางการรักษาผู้ป่วย
+
+ {{parent_company_name}} {{company_name}}
+
+
+ ประจำวันที่ {{date}}
+
+
+
+
+ รอบ |
+ Ref. |
+ ผู้ป่วย |
+ นพ. |
+ HD Case |
+ หมายเหตุ |
+
+
+ {{#each lines }}
+
+ {{cycle_name}} |
+ {{number}} |
+ {{patient_name}} |
+ {{doctor_name}} |
+ {{hd_case_number}} |
+ {{note}} |
+
+ {{/each}}
+
+
+
+
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index 7c08c6d..8648700 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1,7 +1,7 @@
cycle dialy
- cycle_id, date,
- -list of cycle items
- -list
+ -list of cycle items
+ - report all compute all cost
+
visit dialy
list of visits
schedule planing for nurses / personal