demo
parent
a732066d11
commit
d0395e9fcf
|
@ -1,11 +1,7 @@
|
||||||
<action>
|
<action>
|
||||||
<field name="string">Cycle Dialy</field>
|
<field name="string">Cycle Dialy</field>
|
||||||
<field name="view_cls">report_view</field>
|
<field name="view_cls">multi_view</field>
|
||||||
<field name="model">clinic.cycle.item</field>
|
<field name="model">clinic.cycle.dialy</field>
|
||||||
<!--<field name="domain">[["order_id.state","in",["confirmed","done"]]]</field>-->
|
<field name="modes">list,form</field>
|
||||||
<field name="group_fields">date</field>
|
|
||||||
<field name="group_select">cycle_id</field>
|
|
||||||
<!--<field name="group_select">partner_id,product_id,user_id,order_id</field>-->
|
|
||||||
<!--<field name="sum_fields">amount</field>-->
|
|
||||||
<field name="menu">clinic_menu</field>
|
<field name="menu">clinic_menu</field>
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Cycle Dialy</field>
|
||||||
|
<field name="view_cls">report_view</field>
|
||||||
|
<field name="model">clinic.cycle.item</field>
|
||||||
|
<!--<field name="domain">[["order_id.state","in",["confirmed","done"]]]</field>-->
|
||||||
|
<field name="group_fields">date</field>
|
||||||
|
<field name="group_select">cycle_id</field>
|
||||||
|
<!--<field name="group_select">partner_id,product_id,user_id,order_id</field>-->
|
||||||
|
<!--<field name="sum_fields">amount</field>-->
|
||||||
|
<field name="menu">clinic_menu</field>
|
||||||
|
</action>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Copy Schedule</field>
|
||||||
|
<field name="view_cls">form_popup</field>
|
||||||
|
<field name="model">clinic.schedule.copy</field>
|
||||||
|
<field name="target">_popup</field>
|
||||||
|
</action>
|
|
@ -1,10 +1,8 @@
|
||||||
<action>
|
<action>
|
||||||
<field name="string">Visit Dialy</field>
|
<field name="string">Visit Dialy</field>
|
||||||
<field name="view_cls">report_view</field>
|
<field name="view_cls">report</field>
|
||||||
<field name="model">clinic.visit</field>
|
<field name="model">clinic.visit.dialy</field>
|
||||||
<!--<field name="domain">[["order_id.state","in",["confirmed","done"]]]</field>-->
|
<field name="report_template">visit_dialy</field>
|
||||||
<field name="group_fields">visit_date</field>
|
<field name="report_template_xls">visit_dialy</field>
|
||||||
<field name="group_select">visit_date,cycle_id</field>
|
|
||||||
<!--<field name="view_xml">clinic_visit_dialy</field>-->
|
|
||||||
<field name="menu">clinic_menu</field>
|
<field name="menu">clinic_menu</field>
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<field name="view_cls">list_view</field>
|
<field name="view_cls">list_view</field>
|
||||||
<field name="model">clinic.visit</field>
|
<field name="model">clinic.visit</field>
|
||||||
<field name="domain">[["state","not in",["confirmed"]]]</field>
|
<field name="domain">[["state","not in",["confirmed"]]]</field>
|
||||||
|
<!-- need to filter by datenow-->
|
||||||
<field name="view_xml">clinic_visit_widget</field>
|
<field name="view_xml">clinic_visit_widget</field>
|
||||||
<field name="limit">10</field>
|
<field name="limit">10</field>
|
||||||
</action>
|
</action>
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<form model="clinic.cycle.dialy">
|
||||||
|
<head>
|
||||||
|
<button string="Options" dropdown="1">
|
||||||
|
</button>
|
||||||
|
</head>
|
||||||
|
<field name="date"/>
|
||||||
|
<related>
|
||||||
|
<field name="cycle_items">
|
||||||
|
<list colors='{"#cfc":[["state","=","done"]]}'>
|
||||||
|
<field name="cycle_id"/>
|
||||||
|
<field name="date"/>
|
||||||
|
<field name="state"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</related>
|
||||||
|
</form>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<list model="clinic.cycle.dialy">
|
||||||
|
<field name="name"/>
|
||||||
|
</list>
|
|
@ -16,6 +16,9 @@
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
|
<tab string="Other Info">
|
||||||
|
<field name="cycle_dialy_id" domain="[['date','=',date]]"/>
|
||||||
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Validate" type="success" method="validate" icon="ok" states="draft" />
|
<button string="Validate" type="success" method="validate" icon="ok" states="draft" />
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<item string="Schedules" action="clinic_schedule"/>
|
<item string="Schedules" action="clinic_schedule"/>
|
||||||
<item string="Visits">
|
<item string="Visits">
|
||||||
<item string="Visits" action="clinic_visit"/>
|
<item string="Visits" action="clinic_visit"/>
|
||||||
<!--<item string="Visit Dialy" action="clinic_visit_dialy"/>-->
|
<item string="Visit Dialy" action="clinic_visit_dialy"/>
|
||||||
<item string="Generate Visit" action="clinic_gen_visit_form"/>
|
<item string="Generate Visit" action="clinic_gen_visit_form"/>
|
||||||
</item>
|
</item>
|
||||||
<item string="HD Cases" action="clinic_hd_case"/>
|
<item string="HD Cases" action="clinic_hd_case"/>
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<form model="clinic.schedule.copy">
|
||||||
|
<group form_layout="stacked">
|
||||||
|
<field name="date_from"/>
|
||||||
|
<field name="date_to"/>
|
||||||
|
<field name="mon"/>
|
||||||
|
<field name="tue"/>
|
||||||
|
<field name="wed"/>
|
||||||
|
<field name="thu"/>
|
||||||
|
<field name="fri"/>
|
||||||
|
<field name="sat"/>
|
||||||
|
<field name="sun"/>
|
||||||
|
<field name="schedule_id" invisible="2"/> <!-- need to push -->
|
||||||
|
</group>
|
||||||
|
<foot>
|
||||||
|
<button string="Copy" type="success" method="copy2schedule"/>
|
||||||
|
</foot>
|
||||||
|
</form>
|
|
@ -3,7 +3,7 @@
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<button string="Options" dropdown="1">
|
<button string="Options" dropdown="1">
|
||||||
<item string="Copy" method="copy"/>
|
<item string="Copy" method="copy"/>
|
||||||
<item string="Copy To Cycle Item" method="copy2cycle_item"/>
|
<item string="Copy From" action="clinic_schedule_copy"/>
|
||||||
<item string="Copy Nurses To Schedule" action="clinic_load_nurses"/>
|
<item string="Copy Nurses To Schedule" action="clinic_load_nurses"/>
|
||||||
</button>
|
</button>
|
||||||
</head>
|
</head>
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Planing">
|
<tab string="Planning">
|
||||||
<group form_layout="stacked">
|
<group form_layout="stacked">
|
||||||
<field name="time_start" span="3"/>
|
<field name="time_start" span="3"/>
|
||||||
<field name="time_stop" span="3"/>
|
<field name="time_stop" span="3"/>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<list model="clinic.schedule">
|
<list model="clinic.schedule">
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
|
<field name="user_id"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -4,5 +4,6 @@
|
||||||
<field name="number"/>
|
<field name="number"/>
|
||||||
<field name="doctor_id"/>
|
<field name="doctor_id"/>
|
||||||
<field name="nurse_id"/>
|
<field name="nurse_id"/>
|
||||||
<field name="state"/>
|
<field name="cycle_color"/>
|
||||||
|
<!--<field name="state"/>-->
|
||||||
</calendar>
|
</calendar>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<form model="clinic.visit.dialy">
|
||||||
|
<field name="date" span="2"/>
|
||||||
|
</form>
|
|
@ -25,6 +25,9 @@
|
||||||
<tab string="Validation">
|
<tab string="Validation">
|
||||||
<field name="nurse_id"/>
|
<field name="nurse_id"/>
|
||||||
</tab>
|
</tab>
|
||||||
|
<tab string="Note">
|
||||||
|
<field name="note" nolabel="1"/>
|
||||||
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Confirm" type="success" method="confirm" states="draft" />
|
<button string="Confirm" type="success" method="confirm" states="draft" />
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
<!--<list model="clinic.visit" colors='{"#cfc":[["cycle_color","=","red"]]}'>-->
|
||||||
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]]}'>
|
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]]}'>
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="visit_date"/>
|
<field name="visit_date"/>
|
||||||
<field name="patient_id"/>
|
<field name="patient_id"/>
|
||||||
<field name="doctor_id"/>
|
<field name="doctor_id"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
|
<!--<field name="cycle_color" invisible="1"/>-->
|
||||||
</list>
|
</list>
|
||||||
|
|
|
@ -30,6 +30,7 @@ from . import cycle_item
|
||||||
from . import cycle_item_nurse
|
from . import cycle_item_nurse
|
||||||
from . import cycle_item_doctor
|
from . import cycle_item_doctor
|
||||||
from . import cycle_item_line
|
from . import cycle_item_line
|
||||||
|
from . import cycle_dialy
|
||||||
from . import gen_visit
|
from . import gen_visit
|
||||||
from . import gen_visit_line
|
from . import gen_visit_line
|
||||||
from . import report_clinic
|
from . import report_clinic
|
||||||
|
@ -51,5 +52,6 @@ from . import personal_move
|
||||||
from . import personal_cycle
|
from . import personal_cycle
|
||||||
from . import schedule
|
from . import schedule
|
||||||
from . import schedule_line
|
from . import schedule_line
|
||||||
|
from . import schedule_copy
|
||||||
from . import load_nurse
|
from . import load_nurse
|
||||||
from . import load_nurse_line
|
from . import load_nurse_line
|
||||||
|
|
|
@ -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()
|
|
@ -18,16 +18,16 @@ class CycleItem(Model):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'name': fields.Char("Name", function="_get_all",function_multi=True), # need to field related in journal
|
'name': fields.Char("Name", function="_get_all",function_multi=True),
|
||||||
'company_id': fields.Many2One("company", "Company"),
|
|
||||||
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
|
||||||
'date': fields.Date("Date",search=True),
|
'date': fields.Date("Date",search=True),
|
||||||
"state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
|
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
||||||
'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
|
'cycle_dialy_id': fields.Many2One("clinic.cycle.dialy", "Cycle Dialy",search=True),
|
||||||
'visits': fields.One2Many("clinic.visit","cycle_item_id", "Visits"),
|
'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'),
|
'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"), # for sort item
|
||||||
'sequence': fields.Char("Sequence"),
|
'company_id': fields.Many2One("company", "Company"),
|
||||||
|
"state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
@ -41,9 +41,26 @@ class CycleItem(Model):
|
||||||
("cycle_item_uniq","unique (cycle_id,date,company_id)","Cycle item should be unique"),
|
("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):
|
def create(self, vals,**kw):
|
||||||
date=vals['date']
|
date=vals['date']
|
||||||
cycle_id=vals['cycle_id']
|
cycle_id=vals['cycle_id']
|
||||||
|
vals['cycle_dialy_id']=self.get_cycle_diary(date)
|
||||||
|
|
||||||
cycle=get_model("clinic.cycle").browse(cycle_id)
|
cycle=get_model("clinic.cycle").browse(cycle_id)
|
||||||
vals['sequence']='%s-%s'%(date,cycle.sequence) #date-sequence
|
vals['sequence']='%s-%s'%(date,cycle.sequence) #date-sequence
|
||||||
obj_id=super().create(vals,**kw)
|
obj_id=super().create(vals,**kw)
|
||||||
|
@ -52,6 +69,8 @@ class CycleItem(Model):
|
||||||
def write(self,ids,vals,**kw):
|
def write(self,ids,vals,**kw):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
cycle=obj.cycle_id
|
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
|
vals['sequence']='%s-%s'%(obj.date,cycle.sequence) #date-sequence
|
||||||
super().write(ids,vals,**kw)
|
super().write(ids,vals,**kw)
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ class GenVisit(Model):
|
||||||
res[obj.id]=duration.days
|
res[obj.id]=duration.days
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
'date_from': fields.DateTime("From", required=True),
|
'date_from': fields.DateTime("From", required=True),
|
||||||
'date_to': fields.DateTime("To", required=True),
|
'date_to': fields.DateTime("To", required=True),
|
||||||
|
|
|
@ -5,7 +5,7 @@ class LoadNurse(Model):
|
||||||
_transient=True
|
_transient=True
|
||||||
|
|
||||||
_fields={
|
_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']]),
|
'categ_id': fields.Many2One("clinic.personal.categ","Category", domain=[['type','=','nurse']]),
|
||||||
"lines": fields.One2Many("clinic.schedule.load.nurse.line",'load_id', 'Lines'),
|
"lines": fields.One2Many("clinic.schedule.load.nurse.line",'load_id', 'Lines'),
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,13 @@ class LoadNurse(Model):
|
||||||
|
|
||||||
def copy2schedule(self,ids,context):
|
def copy2schedule(self,ids,context):
|
||||||
obj=self.browse(ids)[0]
|
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)
|
schedule=get_model("clinic.schedule").browse(obj.schedule_id.id)
|
||||||
vals={
|
vals={
|
||||||
'lines': [],
|
'lines': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
cycles=set()
|
cycles=set()
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
nurse=line.nurse_id
|
nurse=line.nurse_id
|
||||||
|
@ -75,6 +77,5 @@ class LoadNurse(Model):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LoadNurse.register()
|
LoadNurse.register()
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Schedule(Model):
|
||||||
def _get_name(self,ids,context={}):
|
def _get_name(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
res[obj.id]='Schedule - %s'%(obj.date)
|
res[obj.id]='%s'%(obj.date)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_item(self,ids,context={}):
|
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"),
|
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item", function="_get_item"),
|
||||||
"time_start": fields.DateTime("Time Start",required=True),
|
"time_start": fields.DateTime("Time Start",required=True),
|
||||||
"time_stop": fields.DateTime("Time Stop",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"),
|
'lines': fields.One2Many("clinic.schedule.line","schedule_id","Lines"),
|
||||||
'company_id': fields.Many2One("company","Company"),
|
'company_id': fields.Many2One("company","Company"),
|
||||||
'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State'),
|
'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State',search=True),
|
||||||
'user_id': fields.Many2One("base.user","User"),
|
'user_id': fields.Many2One("base.user","Confirm By"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
@ -45,6 +45,8 @@ class Schedule(Model):
|
||||||
'state': 'draft',
|
'state': 'draft',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_order="date desc"
|
||||||
|
|
||||||
_sql_constraints=[
|
_sql_constraints=[
|
||||||
('schedule_uniq','unique (date,company_id)','Date should be unique'),
|
('schedule_uniq','unique (date,company_id)','Date should be unique'),
|
||||||
]
|
]
|
||||||
|
@ -64,6 +66,10 @@ class Schedule(Model):
|
||||||
|
|
||||||
def copy(self,ids,context={}):
|
def copy(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
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={
|
vals={
|
||||||
'lines': [],
|
'lines': [],
|
||||||
}
|
}
|
||||||
|
@ -73,7 +79,6 @@ class Schedule(Model):
|
||||||
'cycle_id': line.cycle_id.id
|
'cycle_id': line.cycle_id.id
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
|
|
||||||
new_id=get_model("clinic.schedule").create(vals)
|
new_id=get_model("clinic.schedule").create(vals)
|
||||||
new_obj=get_model("clinic.schedule").browse(new_id)
|
new_obj=get_model("clinic.schedule").browse(new_id)
|
||||||
return {
|
return {
|
||||||
|
@ -94,7 +99,7 @@ class Schedule(Model):
|
||||||
'nurse_id': nurse.id,
|
'nurse_id': nurse.id,
|
||||||
'level_id': nurse.level_id.id,
|
'level_id': nurse.level_id.id,
|
||||||
}))
|
}))
|
||||||
|
print('xx')
|
||||||
for nurse in obj.cycle_item_id.nurses:
|
for nurse in obj.cycle_item_id.nurses:
|
||||||
nurse.delete()
|
nurse.delete()
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -19,6 +19,13 @@ class Visit(Model):
|
||||||
res[obj.id]=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
res[obj.id]=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
return res
|
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={
|
_fields={
|
||||||
"number": fields.Char("Number",required=True,search=True),
|
"number": fields.Char("Number",required=True,search=True),
|
||||||
"time_start": fields.DateTime("Time Start",required=True),
|
"time_start": fields.DateTime("Time Start",required=True),
|
||||||
|
@ -31,12 +38,14 @@ class Visit(Model):
|
||||||
"company_id": fields.Many2One("company","Company"),
|
"company_id": fields.Many2One("company","Company"),
|
||||||
'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True),
|
'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True),
|
||||||
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
"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),
|
"state": fields.Selection([["draft","Draft"],["confirmed","Confirmed"],["cancelled","Cancelled"]],"Status",required=True),
|
||||||
"comments": fields.One2Many("message","related_id","Comments"),
|
"comments": fields.One2Many("message","related_id","Comments"),
|
||||||
'visit_date': fields.Date('Visit Date'),
|
'visit_date': fields.Date('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"), #XXX on_delete="cascade" -> rm visit from cycle item
|
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), #XXX on_delete="cascade" -> rm visit from cycle item
|
||||||
'sequence': fields.Char("Sequence"),
|
'sequence': fields.Char("Sequence"),
|
||||||
|
'note': fields.Text('Note'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
|
@ -296,7 +305,7 @@ class Visit(Model):
|
||||||
item_obj=get_model('clinic.cycle.item')
|
item_obj=get_model('clinic.cycle.item')
|
||||||
item_ids=item_obj.search(dom)
|
item_ids=item_obj.search(dom)
|
||||||
item_id=None
|
item_id=None
|
||||||
# XXX
|
|
||||||
nurse_vals=[]
|
nurse_vals=[]
|
||||||
if 'nurse_vals' in vals.keys():
|
if 'nurse_vals' in vals.keys():
|
||||||
nurse_vals=vals['nurse_vals']
|
nurse_vals=vals['nurse_vals']
|
||||||
|
@ -326,6 +335,7 @@ class Visit(Model):
|
||||||
})
|
})
|
||||||
|
|
||||||
vals['cycle_item_id']=item_id
|
vals['cycle_item_id']=item_id
|
||||||
|
|
||||||
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle.sequence) #date-sequence
|
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle.sequence) #date-sequence
|
||||||
vals['visit_date']=vals['time_start'][0:10]
|
vals['visit_date']=vals['time_start'][0:10]
|
||||||
obj_id=super().create(vals,**kw)
|
obj_id=super().create(vals,**kw)
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
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):
|
class VisitDialy(Model):
|
||||||
_name="clinic.visit.dialy"
|
_name="clinic.visit.dialy"
|
||||||
|
@ -6,7 +14,61 @@ class VisitDialy(Model):
|
||||||
_transient=True
|
_transient=True
|
||||||
|
|
||||||
_fields={
|
_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()
|
VisitDialy.register()
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,33 @@
|
||||||
|
<center>
|
||||||
|
<h2>ตารางการรักษาผู้ป่วย</h2>
|
||||||
|
<h3>
|
||||||
|
{{parent_company_name}} {{company_name}}<br/>
|
||||||
|
</h3>
|
||||||
|
<h4>
|
||||||
|
ประจำวันที่ {{date}}
|
||||||
|
</h4>
|
||||||
|
</center>
|
||||||
|
<table class="table table-hover">
|
||||||
|
<thead>
|
||||||
|
<th>รอบ</th>
|
||||||
|
<th>Ref.</th>
|
||||||
|
<th>ผู้ป่วย</th>
|
||||||
|
<th>นพ.</th>
|
||||||
|
<th>HD Case</th>
|
||||||
|
<th>หมายเหตุ</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each lines }}
|
||||||
|
<tr style="background-color: {{success_color}}">
|
||||||
|
<td style="background-color: {{cycle_color}}">{{cycle_name}}</td>
|
||||||
|
<td><a href="/ui#name=clinic_visit&active_id={{visit_id}}&mode=form">{{number}}</a></td>
|
||||||
|
<td>{{patient_name}}</td>
|
||||||
|
<td>{{doctor_name}}</td>
|
||||||
|
<td><a href="/ui#name=clinic_hd_case&active_id={{hd_case_id}}&mode=form">{{hd_case_number}}</a></td>
|
||||||
|
<td>{{note}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
|
@ -1,7 +1,7 @@
|
||||||
cycle dialy
|
cycle dialy
|
||||||
cycle_id, date,
|
-list of cycle items
|
||||||
-list of cycle items
|
- report all compute all cost
|
||||||
-list
|
|
||||||
visit dialy
|
visit dialy
|
||||||
list of visits
|
list of visits
|
||||||
schedule planing for nurses / personal
|
schedule planing for nurses / personal
|
||||||
|
|
Loading…
Reference in New Issue