diff --git a/netforce_clinic/actions/clinic_cycle_item.xml b/netforce_clinic/actions/clinic_cycle_item.xml
index 09c4581..821c85b 100644
--- a/netforce_clinic/actions/clinic_cycle_item.xml
+++ b/netforce_clinic/actions/clinic_cycle_item.xml
@@ -3,5 +3,6 @@
multi_view
clinic.cycle.item
list,form
+ [["All",[]],["Draft",[["state","=","draft"]]],["Done",[["state","=","done"]]]]
clinic_menu
diff --git a/netforce_clinic/actions/clinic_visit_widget.xml b/netforce_clinic/actions/clinic_visit_widget.xml
new file mode 100644
index 0000000..9b8637a
--- /dev/null
+++ b/netforce_clinic/actions/clinic_visit_widget.xml
@@ -0,0 +1,7 @@
+
+ list_view
+ clinic.visit
+ [["state","not in",["confirmed"]]]
+ clinic_visit_widget
+ 10
+
diff --git a/netforce_clinic/layouts/clinic_board.xml b/netforce_clinic/layouts/clinic_board.xml
index 6e71737..1738390 100644
--- a/netforce_clinic/layouts/clinic_board.xml
+++ b/netforce_clinic/layouts/clinic_board.xml
@@ -1,11 +1,11 @@
-
-
-
-
+
+
+
+
diff --git a/netforce_clinic/layouts/clinic_gen_visit_form.xml b/netforce_clinic/layouts/clinic_gen_visit_form.xml
index ef455c7..1a8493e 100644
--- a/netforce_clinic/layouts/clinic_gen_visit_form.xml
+++ b/netforce_clinic/layouts/clinic_gen_visit_form.xml
@@ -2,8 +2,9 @@
-
+
+
diff --git a/netforce_clinic/layouts/clinic_patient_list.xml b/netforce_clinic/layouts/clinic_patient_list.xml
index bbf504a..776bce0 100644
--- a/netforce_clinic/layouts/clinic_patient_list.xml
+++ b/netforce_clinic/layouts/clinic_patient_list.xml
@@ -6,5 +6,6 @@
+
diff --git a/netforce_clinic/layouts/clinic_visit_form.xml b/netforce_clinic/layouts/clinic_visit_form.xml
index 8094dc5..abbba06 100644
--- a/netforce_clinic/layouts/clinic_visit_form.xml
+++ b/netforce_clinic/layouts/clinic_visit_form.xml
@@ -27,7 +27,8 @@
-
+
+
diff --git a/netforce_clinic/layouts/clinic_visit_list.xml b/netforce_clinic/layouts/clinic_visit_list.xml
index ba83845..35bdc29 100644
--- a/netforce_clinic/layouts/clinic_visit_list.xml
+++ b/netforce_clinic/layouts/clinic_visit_list.xml
@@ -1,4 +1,4 @@
-
+
@@ -6,7 +6,6 @@
-
@@ -14,6 +13,5 @@
-
diff --git a/netforce_clinic/layouts/clinic_visit_widget.xml b/netforce_clinic/layouts/clinic_visit_widget.xml
new file mode 100644
index 0000000..93ccb50
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_visit_widget.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index 32dcd7b..6c1d59f 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -33,4 +33,6 @@ class CycleItem(Model):
'date': lambda *a: time.strftime("%Y-%m-%d"),
}
+ _order="date asc"
+
CycleItem.register()
diff --git a/netforce_clinic/models/gen_visit.py b/netforce_clinic/models/gen_visit.py
index 60a7183..d3b5e43 100644
--- a/netforce_clinic/models/gen_visit.py
+++ b/netforce_clinic/models/gen_visit.py
@@ -37,6 +37,7 @@ class GenVisit(Model):
'department_id': fields.Many2One("clinic.department","Department"),
'duration': fields.Integer("Duration (hrs)", function="_get_duration"),
"patient_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Patient Type"),
+ 'patient_categ_id': fields.Many2One("clinic.patient.categ", "Patient Category"),
'nurse_categ_id': fields.Many2One("clinic.personal.categ", "Nurse Category", domain=[['type','=','nurse']]),
}
@@ -116,6 +117,12 @@ class GenVisit(Model):
patients=[p.patient_id.id for p in obj.patient_lines if p.patient_id]
if not patients and obj.patient_type:
patients=get_model("clinic.patient").search([['type','=',obj.patient_type]])
+ if not patients:
+ raise Exception("No patient for type %s"%obj.patient_type)
+ elif not patients and obj.patient_categ_id:
+ patients=get_model("clinic.patient").search([['categ_id','=',obj.patient_categ_id.id]])
+ if not patients:
+ raise Exception("No patient for category %s"%obj.patient_categ_id.name)
elif patients:
# continue to generate with condition
pass
@@ -132,11 +139,11 @@ class GenVisit(Model):
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)
ttime_start="%s %s" % (tmp.strftime(FMT_DATE),date_from.strftime(FMT_DATETIME)[11:])
@@ -144,7 +151,6 @@ class GenVisit(Model):
vals={
'patient_id': patient_id,
'doctor_id': obj.doctor_id.id,
- 'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
'cycle_id': obj.cycle_id.id,
'time_start': ttime_start,
@@ -225,6 +231,8 @@ class GenVisit(Model):
patients=[p.patient_id.id for p in obj.patient_lines if p.patient_id]
if not patients and obj.patient_type:
patients=get_model("clinic.patient").search([['type','=',obj.patient_type]])
+ elif not patients and obj.patient_categ_id:
+ patients=get_model("clinic.patient").search([['categ_id','=',obj.patient_categ_id.id]])
elif patients:
# continue to create with critiria
pass
@@ -263,6 +271,7 @@ class GenVisit(Model):
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)
time_start="%s 00:00:00" % (tmp.strftime(FMT_DATE))
diff --git a/netforce_clinic/models/patient.py b/netforce_clinic/models/patient.py
index d988e6e..2f0d650 100644
--- a/netforce_clinic/models/patient.py
+++ b/netforce_clinic/models/patient.py
@@ -235,7 +235,7 @@ class Patient(Model):
def name_get(self,ids,context={}):
vals=[]
for obj in self.browse(ids):
- name="%s [%s] %s"%(obj.name,obj.number,obj.hn or "")
+ name="%s %s %s"%(obj.number,obj.name, obj.hn)
vals.append((obj.id,name))
return vals
diff --git a/netforce_clinic/models/schedule.py b/netforce_clinic/models/schedule.py
index f2e254d..3689179 100644
--- a/netforce_clinic/models/schedule.py
+++ b/netforce_clinic/models/schedule.py
@@ -10,7 +10,7 @@ class Schedule(Model):
res={}
for obj in self.browse(ids):
total_nurse=len(obj.nurses)
- res[obj.id]='Cycle: %s, Nurse: %s'%(obj.cycle_id.name or "", total_nurse)
+ res[obj.id]='%s, Nurse: %s'%(obj.cycle_id.name or "", total_nurse)
return res
_fields={
@@ -26,7 +26,7 @@ class Schedule(Model):
_defaults={
"company_id": lambda *a: get_active_company(),
}
-
+
def confirm(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({
diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py
index 6a845b9..dd7651b 100644
--- a/netforce_clinic/models/visit.py
+++ b/netforce_clinic/models/visit.py
@@ -24,7 +24,7 @@ class Visit(Model):
for obj in self.browse(ids):
res[obj.id]=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return res
-
+
_fields={
"number": fields.Char("Number",required=True,search=True),
"time_start": fields.DateTime("Time Start",required=True),
@@ -42,6 +42,7 @@ class Visit(Model):
'visit_date': fields.Date('Visit Date',function="_get_visit_date"),
'print_date': fields.Date('Print Date',function="_get_print_date"),
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), # on_delete="cascade" -> rm visit from cycle item
+ 'sequence': fields.Char("Sequence"),
}
def _get_number(self,context={}):
@@ -83,13 +84,13 @@ class Visit(Model):
_defaults={
"state": "draft",
- #'time_start': _get_time_start,
- #'time_stop': _get_time_stop,
+ 'time_start': _get_time_start,
+ 'time_stop': _get_time_stop,
"number": "/",
"company_id": lambda *a: get_active_company(),
'nurse_id': _get_nurse,
}
- _order="id desc"
+ _order="sequence"
def confirm(self,ids,context={}):
obj=self.browse(ids[0])
@@ -299,9 +300,23 @@ class Visit(Model):
})
else:
item_id=item_ids[0]
- print("item_id ",item_id)
vals['cycle_item_id']=item_id
+ vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle_id)
obj_id=super().create(vals,**kw)
return obj_id
+
+ def cancel(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ obj.write({
+ 'state': 'cancelled',
+ })
+ return {
+ 'next': {
+ 'name': 'clinic_visit',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash': 'Visit\'s %s has been cancelled'%obj.patient_id.name
+ }
Visit.register()
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index 06ce71e..c2dcdb3 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1,3 +1,5 @@
+dashboard
+ : hd summary report -> click and go direct
cycle item:
cycle_id
list's nurse
@@ -11,6 +13,7 @@ formalar
order
- visit
+ - date, cycle (1, 2, 3), state
- by datenow, cycle sequence, state
- solution: maybe make some dashboard to that
- like a table treatment in 1 day