visit
parent
14ae8fb35f
commit
16fdf098e0
|
@ -3,5 +3,6 @@
|
||||||
<field name="view_cls">multi_view</field>
|
<field name="view_cls">multi_view</field>
|
||||||
<field name="model">clinic.cycle.item</field>
|
<field name="model">clinic.cycle.item</field>
|
||||||
<field name="modes">list,form</field>
|
<field name="modes">list,form</field>
|
||||||
|
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Done",[["state","=","done"]]]]</field>
|
||||||
<field name="menu">clinic_menu</field>
|
<field name="menu">clinic_menu</field>
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<action>
|
||||||
|
<field name="view_cls">list_view</field>
|
||||||
|
<field name="model">clinic.visit</field>
|
||||||
|
<field name="domain">[["state","not in",["confirmed"]]]</field>
|
||||||
|
<field name="view_xml">clinic_visit_widget</field>
|
||||||
|
<field name="limit">10</field>
|
||||||
|
</action>
|
|
@ -1,11 +1,11 @@
|
||||||
<board>
|
<board>
|
||||||
<!--<hpanel>-->
|
|
||||||
<!--<widget action="clinic_visit_cal_widget" string="Visits Calendar" span="12"/>-->
|
|
||||||
<!--</hpanel>-->
|
|
||||||
<vpanel>
|
<vpanel>
|
||||||
<widget action="clinic_cycle_widget" string="Average Cycle" span="12"/>
|
<widget action="clinic_visit_widget" string="Current Visit" span="12"/>
|
||||||
</vpanel>
|
</vpanel>
|
||||||
<vpanel>
|
<vpanel>
|
||||||
<widget action="clinic_recent_patient_widget" string="Recent Patient" span="12"/>
|
<widget action="clinic_recent_patient_widget" string="Recent Patient" span="12"/>
|
||||||
</vpanel>
|
</vpanel>
|
||||||
|
<vpanel>
|
||||||
|
<widget action="clinic_cycle_widget" string="Average Cycle" span="12"/>
|
||||||
|
</vpanel>
|
||||||
</board>
|
</board>
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
<group form_layout="stacked">
|
<group form_layout="stacked">
|
||||||
<field name="date_from" onchange="onchange_time" span="3"/>
|
<field name="date_from" onchange="onchange_time" span="3"/>
|
||||||
<field name="date_to" onchange="onchange_dateto" span="3"/>
|
<field name="date_to" onchange="onchange_dateto" span="3"/>
|
||||||
<field name="duration" span="3"/>
|
<!--<field name="duration" span="3"/>-->
|
||||||
<field name="cycle_id" onchange="onchange_time" span="3"/>
|
<field name="cycle_id" onchange="onchange_time" span="3"/>
|
||||||
|
<field name="patient_categ_id" span="3"/>
|
||||||
<field name="doctor_id" span="3"/>
|
<field name="doctor_id" span="3"/>
|
||||||
<field name="department_id" span="3"/>
|
<field name="department_id" span="3"/>
|
||||||
<field name="patient_type" span="3"/>
|
<field name="patient_type" span="3"/>
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
<field name="hn"/>
|
<field name="hn"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="reg_date"/>
|
<field name="reg_date"/>
|
||||||
|
<field name="categ_id"/>
|
||||||
<field name="type"/>
|
<field name="type"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
</tabs>
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Confirm" type="success" method="confirm" states="draft" />
|
<button string="Confirm" type="success" method="confirm" states="draft" />
|
||||||
<button string="To Draft" type="default" icon="refresh" method="to_draft" states="confirmed" />
|
<button string="Cancel" type="danger" method="cancel" states="draft" />
|
||||||
|
<button string="To Draft" type="default" icon="repeat" method="to_draft" states="confirmed,cancelled" />
|
||||||
</foot>
|
</foot>
|
||||||
<related>
|
<related>
|
||||||
<field name="hd_cases" readonly="1"/>
|
<field name="hd_cases" readonly="1"/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<list model="clinic.visit">
|
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]],"#bcbbb9":[["state","=","cancelled"]]}'>
|
||||||
<search>
|
<search>
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="time_start"/>
|
<field name="time_start"/>
|
||||||
|
@ -6,7 +6,6 @@
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="patient_id"/>
|
<field name="patient_id"/>
|
||||||
<field name="doctor_id"/>
|
<field name="doctor_id"/>
|
||||||
<field name="nurse_id"/>
|
|
||||||
</search>
|
</search>
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="time_start"/>
|
<field name="time_start"/>
|
||||||
|
@ -14,6 +13,5 @@
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="patient_id"/>
|
<field name="patient_id"/>
|
||||||
<field name="doctor_id"/>
|
<field name="doctor_id"/>
|
||||||
<field name="nurse_id"/>
|
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]]}'>
|
||||||
|
<field name="cycle_id"/>
|
||||||
|
<field name="visit_date"/>
|
||||||
|
<field name="patient_id"/>
|
||||||
|
<field name="doctor_id"/>
|
||||||
|
<field name="state"/>
|
||||||
|
</list>
|
|
@ -33,4 +33,6 @@ class CycleItem(Model):
|
||||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_order="date asc"
|
||||||
|
|
||||||
CycleItem.register()
|
CycleItem.register()
|
||||||
|
|
|
@ -37,6 +37,7 @@ class GenVisit(Model):
|
||||||
'department_id': fields.Many2One("clinic.department","Department"),
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
'duration': fields.Integer("Duration (hrs)", function="_get_duration"),
|
'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_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']]),
|
'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]
|
patients=[p.patient_id.id for p in obj.patient_lines if p.patient_id]
|
||||||
if not patients and obj.patient_type:
|
if not patients and obj.patient_type:
|
||||||
patients=get_model("clinic.patient").search([['type','=',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:
|
elif patients:
|
||||||
# continue to generate with condition
|
# continue to generate with condition
|
||||||
pass
|
pass
|
||||||
|
@ -132,11 +139,11 @@ class GenVisit(Model):
|
||||||
while wd != weekday-1:
|
while wd != weekday-1:
|
||||||
start_date+=timedelta(days=1)
|
start_date+=timedelta(days=1)
|
||||||
wd=start_date.weekday()
|
wd=start_date.weekday()
|
||||||
|
|
||||||
#XXX should gen only in scope
|
#XXX should gen only in scope
|
||||||
if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
|
if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
|
||||||
continue
|
continue
|
||||||
count=0
|
count=0
|
||||||
|
tmp=start_date
|
||||||
while count < day_total:
|
while count < day_total:
|
||||||
tmp=start_date+timedelta(days=count)
|
tmp=start_date+timedelta(days=count)
|
||||||
ttime_start="%s %s" % (tmp.strftime(FMT_DATE),date_from.strftime(FMT_DATETIME)[11:])
|
ttime_start="%s %s" % (tmp.strftime(FMT_DATE),date_from.strftime(FMT_DATETIME)[11:])
|
||||||
|
@ -144,7 +151,6 @@ class GenVisit(Model):
|
||||||
vals={
|
vals={
|
||||||
'patient_id': patient_id,
|
'patient_id': patient_id,
|
||||||
'doctor_id': obj.doctor_id.id,
|
'doctor_id': obj.doctor_id.id,
|
||||||
'nurse_id': obj.nurse_id.id,
|
|
||||||
'department_id': obj.department_id.id,
|
'department_id': obj.department_id.id,
|
||||||
'cycle_id': obj.cycle_id.id,
|
'cycle_id': obj.cycle_id.id,
|
||||||
'time_start': ttime_start,
|
'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]
|
patients=[p.patient_id.id for p in obj.patient_lines if p.patient_id]
|
||||||
if not patients and obj.patient_type:
|
if not patients and obj.patient_type:
|
||||||
patients=get_model("clinic.patient").search([['type','=',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:
|
elif patients:
|
||||||
# continue to create with critiria
|
# continue to create with critiria
|
||||||
pass
|
pass
|
||||||
|
@ -263,6 +271,7 @@ class GenVisit(Model):
|
||||||
if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
|
if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
|
||||||
continue
|
continue
|
||||||
count=0
|
count=0
|
||||||
|
tmp=start_date
|
||||||
while count < day_total:
|
while count < day_total:
|
||||||
tmp=start_date+timedelta(days=count)
|
tmp=start_date+timedelta(days=count)
|
||||||
time_start="%s 00:00:00" % (tmp.strftime(FMT_DATE))
|
time_start="%s 00:00:00" % (tmp.strftime(FMT_DATE))
|
||||||
|
|
|
@ -235,7 +235,7 @@ class Patient(Model):
|
||||||
def name_get(self,ids,context={}):
|
def name_get(self,ids,context={}):
|
||||||
vals=[]
|
vals=[]
|
||||||
for obj in self.browse(ids):
|
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))
|
vals.append((obj.id,name))
|
||||||
return vals
|
return vals
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Schedule(Model):
|
||||||
res={}
|
res={}
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
total_nurse=len(obj.nurses)
|
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
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
|
|
|
@ -42,6 +42,7 @@ class Visit(Model):
|
||||||
'visit_date': fields.Date('Visit Date',function="_get_visit_date"),
|
'visit_date': fields.Date('Visit Date',function="_get_visit_date"),
|
||||||
'print_date': fields.Date('Print Date',function="_get_print_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
|
'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={}):
|
def _get_number(self,context={}):
|
||||||
|
@ -83,13 +84,13 @@ class Visit(Model):
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
"state": "draft",
|
"state": "draft",
|
||||||
#'time_start': _get_time_start,
|
'time_start': _get_time_start,
|
||||||
#'time_stop': _get_time_stop,
|
'time_stop': _get_time_stop,
|
||||||
"number": "/",
|
"number": "/",
|
||||||
"company_id": lambda *a: get_active_company(),
|
"company_id": lambda *a: get_active_company(),
|
||||||
'nurse_id': _get_nurse,
|
'nurse_id': _get_nurse,
|
||||||
}
|
}
|
||||||
_order="id desc"
|
_order="sequence"
|
||||||
|
|
||||||
def confirm(self,ids,context={}):
|
def confirm(self,ids,context={}):
|
||||||
obj=self.browse(ids[0])
|
obj=self.browse(ids[0])
|
||||||
|
@ -299,9 +300,23 @@ class Visit(Model):
|
||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
item_id=item_ids[0]
|
item_id=item_ids[0]
|
||||||
print("item_id ",item_id)
|
|
||||||
vals['cycle_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)
|
obj_id=super().create(vals,**kw)
|
||||||
return obj_id
|
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()
|
Visit.register()
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
dashboard
|
||||||
|
: hd summary report -> click and go direct
|
||||||
cycle item:
|
cycle item:
|
||||||
cycle_id
|
cycle_id
|
||||||
list's nurse
|
list's nurse
|
||||||
|
@ -11,6 +13,7 @@ formalar
|
||||||
|
|
||||||
order
|
order
|
||||||
- visit
|
- visit
|
||||||
|
- date, cycle (1, 2, 3), state
|
||||||
- by datenow, cycle sequence, state
|
- by datenow, cycle sequence, state
|
||||||
- solution: maybe make some dashboard to that
|
- solution: maybe make some dashboard to that
|
||||||
- like a table treatment in 1 day
|
- like a table treatment in 1 day
|
||||||
|
|
Loading…
Reference in New Issue