conv_bal
watcha.h 2014-11-14 08:58:12 +07:00
parent f84e2337e4
commit a732066d11
19 changed files with 426 additions and 79 deletions

View File

@ -0,0 +1,6 @@
<action>
<field name="string">List Nurse</field>
<field name="view_cls">form_popup</field>
<field name="model">clinic.schedule.load.nurse</field>
<field name="target">_popup</field>
</action>

View File

@ -2,7 +2,7 @@
<field name="string">Schedules</field>
<field name="view_cls">multi_view</field>
<field name="model">clinic.schedule</field>
<field name="modes">calendar,list,page,form</field>
<field name="modes">list,page,form,calendar</field>
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]]]</field>
<field name="menu">clinic_menu</field>
</action>

View File

@ -108,7 +108,6 @@
<foot>
<button string="Start" type="success" icon="arrow-right" method="do_treatment" states="draft"/>
<button string="Done" type="success" icon="ok" method="done" states="in_progress"/>
<!--<button string="Complete" type="success" icon="ok" method="complete" states="in_progress"/>-->
<button string="Discontinue" type="danger" icon="remove" action="clinic_hd_case_distcont" states="in_progress"/>
<button string="Undo" type="default" icon="repeat" method="undo" states="completed"/>
<button string="Pay" type="success" icon="ok" action="clinic_payment" states="waiting_payment" />

View File

@ -0,0 +1,15 @@
<form model="clinic.schedule.load.nurse">
<group form_layout="stacked">
<field name="categ_id" span="6" onchange="onchange_categ"/>
<field name="schedule_id" invisible="1"/> <!-- need to push -->
<field name="lines" nolabel="1">
<list>
<field name="nurse_id"/>
<field name="cycle_id"/>
</list>
</field>
</group>
<foot>
<button string="OK" type="success" method="copy2schedule"/>
</foot>
</form>

View File

@ -15,11 +15,11 @@
<field name="nick_name"/>
<field name="identification"/>
<field name="expiry_card"/>
<field name="birthday"/>
<field name="gender"/>
<field name="birthday"/>
<field name="nation_id"/>
<field name="department_id"/>
<field name="categ_id" domain="[['type','=',type]]"/>
<field name="nation_id"/>
<field name="state"/>
</group>
<group span="6" columns="1">
@ -39,17 +39,7 @@
<field name="prof_license_date" attrs='{"invisible":[["type","in",["personal"]]]}'/>
<field name="level_id" domain="[['type','=',type]]"/>
<field name="prof_license_expiry" attrs='{"invisible":[["type","in",["personal"]]]}'/>
<field name="moves" nolabel="1">
<list>
<field name="level_id" domain="[['type','=',parent.type]]"/>
<field name="from_company_id"/>
<field name="to_company_id"/>
<field name="hire_date"/>
<field name="resign_date"/>
<field name="wage"/>
<field name="note"/>
</list>
</field>
<field name="cycle_id"/>
</tab>
<tab string="Note">
<field name="note" nolabel="1"/>
@ -57,6 +47,30 @@
</tabs>
<related>
<field name="documents"/>
<field name="cycles" nolabel="1">
<list>
<field name="cycle_id"/>
<field name="name"/>
<field name="date"/>
</list>
<form>
<field name="cycle_id"/>
<field name="name"/>
<field name="date"/>
</form>
</field>
<field name="moves" nolabel="1">
<list>
<field name="level_id" domain="[['type','=',parent.type]]"/>
<field name="from_company_id"/>
<field name="to_company_id"/>
<field name="hire_date"/>
<field name="resign_date"/>
<!--<field name="wage"/>-->
<field name="note"/>
</list>
</field>
<field name="patients" attrs='{"invisible":[["type","in",["nurse","other"]]]}'/>
<field name="nurse_visits" attrs='{"invisible":[["type","in",["doctor","personal"]]]}'/>
<field name="doctor_visits" attrs='{"invisible":[["type","in",["nurse","personal"]]]}'/>

View File

@ -1,4 +1,4 @@
<calendar model="clinic.schedule" start_field="time_start" end_field="time_stop">
<field name="name"/>
<field name="cycle_id"/>
<field name="state"/>
</calendar>

View File

@ -3,19 +3,35 @@
<field name="state"/>
<button string="Options" dropdown="1">
<item string="Copy" method="copy"/>
<item string="Copy Nurses To Cycle Item" method="copy_nurses"/>
<item string="View Cycle Item" method="view_cycle_item"/>
<item string="Copy To Cycle Item" method="copy2cycle_item"/>
<item string="Copy Nurses To Schedule" action="clinic_load_nurses"/>
</button>
</head>
<group form_layout="stacked">
<field name="time_start" span="3"/>
<field name="time_stop" span="3"/>
<field name="cycle_id" span="3"/>
<newline/>
<field name="nurses" span="8"/>
</group>
<tabs>
<tab string="General">
<group form_layout="stacked">
<field name="date" span="3" onchange="onchange_date"/>
<field name="lines" nolabel="1">
<list>
<field name="cycle_id"/>
<field name="nurse_id"/>
</list>
</field>
</group>
</tab>
<tab string="Planing">
<group form_layout="stacked">
<field name="time_start" span="3"/>
<field name="time_stop" span="3"/>
</group>
</tab>
<tab string="Confirmation">
<field name="user_id"/>
</tab>
</tabs>
<foot>
<button string="Confirm" type="success" method="confirm" states="draft" />
<button string="Confirm" type="success" icon="ok" method="confirm" states="draft" />
<button string="Clear List" type="danger" icon="remove" method="clear" states="draft" />
<button string="To Draft" type="default" icon="repeat" method="to_draft" states="confirmed" />
</foot>
</form>

View File

@ -1,6 +1,4 @@
<list model="clinic.schedule">
<field name="name"/>
<field name="time_start"/>
<field name="time_stop"/>
<field name="date"/>
<field name="state"/>
</list>

View File

@ -48,4 +48,8 @@ from . import personal
from . import personal_categ
from . import personal_level
from . import personal_move
from . import personal_cycle
from . import schedule
from . import schedule_line
from . import load_nurse
from . import load_nurse_line

View File

@ -197,17 +197,17 @@ class GenVisit(Model):
for vals in visit_vals:
vals['nurse_vals']=nurse_vals # XXX
visit_obj.create(vals)
dom=[]
dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
dom.append(['time_stop','<=','%s %s'%(start_date.strftime(FMT_DATE)[0:10],' 23:59:59')])
dom.append(['cycle_id','=',obj.cycle_id.id])
schedule_obj=get_model("clinic.schedule")
schedule_ids=schedule_obj.search(dom)
schedule_obj.delete(schedule_ids)
nurse_ids=[nurse['id'] for nurse in nurse_vals]
for key, vals in schedules.items():
vals['nurses']=[('add', nurse_ids)]
schedule_obj.create(vals)
#dom=[]
#dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
#dom.append(['time_stop','<=','%s %s'%(start_date.strftime(FMT_DATE)[0:10],' 23:59:59')])
#dom.append(['cycle_id','=',obj.cycle_id.id])
#schedule_obj=get_model("clinic.schedule")
#schedule_ids=schedule_obj.search(dom)
#schedule_obj.delete(schedule_ids)
#nurse_ids=[nurse['id'] for nurse in nurse_vals]
#for key, vals in schedules.items():
#vals['nurses']=[('add', nurse_ids)]
#schedule_obj.create(vals)
return {
'next': {

View File

@ -11,6 +11,7 @@ class HDCaseDiscont(Model):
def _get_hd_case_id(self,context={}):
hd_case_id=context.get("refer_id")
print("hd case deault")
if not hd_case_id:
return None
return int(hd_case_id)

View File

@ -0,0 +1,80 @@
from netforce.model import Model, fields, get_model
class LoadNurse(Model):
_name="clinic.schedule.load.nurse"
_transient=True
_fields={
"schedule_id": fields.Many2One("clinic.schedule","Schedule",required=True,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'),
}
def _get_schedule_id(self,context={}):
schedule_id=context.get("refer_id")
if not schedule_id:
return None
return int(schedule_id)
def _get_lines(self,context={}):
cycle_ids=get_model("clinic.cycle").search([])
cycle_id=None
if cycle_ids:
cycle_id=cycle_ids[0]
lines=[]
print("cycle_id ", cycle_id)
for nurse in get_model("clinic.personal").search_browse([['type','=','nurse']]):
in_cycle_id=None
if nurse.cycle_id.id:
in_cycle_id=nurse.cycle_id.id
lines.append({
'nurse_id': nurse.id,
'cycle_id': in_cycle_id and in_cycle_id or cycle_id,
})
return lines
_defaults={
'schedule_id': _get_schedule_id,
'lines': _get_lines,
}
def copy2schedule(self,ids,context):
obj=self.browse(ids)[0]
schedule=get_model("clinic.schedule").browse(obj.schedule_id.id)
vals={
'lines': [],
}
cycles=set()
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,
'nurse_id': nurse.id,
}))
for line in schedule.lines:
if line.cycle_id.id in list(cycles):
line.delete()
schedule.write(vals)
return {
'next': {
'name': 'clinic_schedule',
'mode': 'form',
'active_id': schedule.id,
},
'flash': 'Copy nurse to schedule succesfully'
}
def onchange_categ(self,context={}):
data=context['data']
return data
LoadNurse.register()

View File

@ -0,0 +1,15 @@
from netforce.model import Model, fields
class LoadNurseLine(Model):
_name="clinic.schedule.load.nurse.line"
_transient=True
_fields={
"load_id": fields.Many2One("clinic.schedule.load.nurse","Load Nurse",required=True,on_delete="cascade"),
'nurse_id': fields.Many2One("clinic.personal","Nurse",domain=[['type','=','nurse']]),
'cycle_id': fields.Many2One("clinic.cycle", "Cycle"),
}
LoadNurseLine.register()

View File

@ -29,6 +29,16 @@ class Personal(Model):
res[obj.id]=level_id
return res
def _get_cycle(self,ids,context={}):
res={}
for obj in self.browse(ids):
cycle_id=None
for line in obj.cycles:
cycle=line.cycle_id
cycle_id=cycle.id
res[obj.id]=cycle_id
return res
_fields={
"number": fields.Char("Ref.",required=True,search=True),
"name": fields.Char("Name",required=True,search=True),
@ -68,7 +78,9 @@ class Personal(Model):
'hire_date': fields.Date("Hire Date"),
'resign_date': fields.Date("Resign Date"),
"documents": fields.One2Many("document","related_id","Documents"),
"moves": fields.One2Many("clinic.personal.move","personal_id","Moves"),
"moves": fields.One2Many("clinic.personal.move","personal_id","Personal Moves"),
"cycles": fields.One2Many("clinic.personal.cycle","personal_id","Working Cycles"),
'cycle_id': fields.Many2One('clinic.cycle','Recent Cycle',function="_get_cycle"),
}
def _get_number(self,context={}):

View File

@ -0,0 +1,23 @@
import time
from netforce.model import Model, fields
from netforce.access import get_active_company
class PersonalCycle(Model):
_name="clinic.personal.cycle"
_string="Personal Cycle"
_fields={
"name": fields.Char("Description",search=True),
'personal_id': fields.Many2One("clinic.personal","Personal",required=True),
'cycle_id': fields.Many2One("clinic.cycle","Cycle",required=True),
'date': fields.DateTime("Date"),
'company_id': fields.Many2One("company","Company"),
}
_defaults={
"company_id": lambda *a: get_active_company(),
'date': lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
}
PersonalCycle.register()

View File

@ -1,18 +1,17 @@
from datetime import datetime, timedelta
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
from netforce.access import get_active_company, get_active_user
class Schedule(Model):
_name="clinic.schedule"
_string="Schedule"
#_field_name="cycle_id"
_field_name="date"
def _get_name(self,ids,context={}):
res={}
for obj in self.browse(ids):
total_nurse=len(obj.nurses)
res[obj.id]='%s, Nurse: %s'%(obj.cycle_id.name or "", total_nurse)
res[obj.id]='Schedule - %s'%(obj.date)
return res
def _get_item(self,ids,context={}):
@ -26,23 +25,30 @@ class Schedule(Model):
return res
_fields={
"name": fields.Char("Name",function="_get_name"),
'cycle_id': fields.Many2One("clinic.cycle","Cycle",required=True),
'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),
'lines': fields.One2Many("clinic.schedule.line","schedule_id","Lines"),
'company_id': fields.Many2One("company","Company"),
'nurses': fields.Many2Many('clinic.personal','Nurses'), # XXX domain
'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State'),
'user_id': fields.Many2One("base.user","User"),
}
_defaults={
'user_id': lambda *a: get_active_user(),
"company_id": lambda *a: get_active_company(),
'date': lambda *a: datetime.now().strftime("%Y-%m-%d"),
'time_start': lambda *a: datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
'time_stop': lambda *a: (datetime.now()+timedelta(seconds=3600)).strftime("%Y-%m-%d %H:%M:%S"),
'state': 'draft',
}
_sql_constraints=[
('schedule_uniq','unique (date,company_id)','Date should be unique'),
]
def confirm(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({
@ -58,27 +64,32 @@ class Schedule(Model):
def copy(self,ids,context={}):
obj=self.browse(ids)[0]
nurse_ids=[nurse.id for nurse in obj.nurses]
vals={
'cycle_id': obj.cycle_id.id,
'time_start': obj.time_start,
'time_stop': obj.time_stop,
'nurses': [('add', nurse_ids)],
'lines': [],
}
obj_id=get_model("clinic.schedule").create(vals)
for line in obj.lines:
vals['lines'].append(('create', {
'nurse_id': line.nurse_id.id,
'cycle_id': line.cycle_id.id
}
))
new_id=get_model("clinic.schedule").create(vals)
new_obj=get_model("clinic.schedule").browse(new_id)
return {
'next': {
'name': 'clinic_schedule',
'mode': 'form',
'active_id': obj_id,
'active_id': new_id,
},
'flash': 'Copy schedule successfully',
'flash': 'Copy schedule from %s to %s successfully'%(obj.date,new_obj.date)
}
def copy_nurses(self,ids,context={}):
def copy2cycle_item(self,ids,context={}):
obj=self.browse(ids)[0]
nurses=[]
for nurse in obj.nurses:
for line in obj.lines:
nurse=line.nurse_id
nurses.append(('create',{
'nurse_id': nurse.id,
'level_id': nurse.level_id.id,
@ -99,32 +110,40 @@ class Schedule(Model):
'flash': 'Copy nurses to cycle item successfully',
}
def view_cycle_item(self,ids,context={}):
obj=self.browse(ids)[0]
item_id=obj.cycle_item_id.id
msg=''
if not item_id:
# XXX
item_id=get_model("clinic.cycle.item").create({
'cycle_id': obj.cycle_id.id,
'date': obj.time_start[0:10],
def onchange_date(self,context={}):
data=context['data']
date=data['date']
time_start=data['time_start'][11:]
data['time_start']='%s %s'%(date,time_start)
time_stop=data['time_stop'][11:]
data['time_stop']='%s %s'%(date,time_stop)
return data
def load_all_nurse(self,ids,context={}):
nurses=get_model("clinic.personal").search_browse([['type','=','nurse']])
vals={
'lines': [],
}
for nurse in nurses:
vals['lines'].append({
'cycle_id': nurse.id,
'nurse_id': nurse.id,
})
#raise Exception("No found cycle item")
item_nurse_obj=get_model("clinic.cycle.item.nurse")
for nurse in obj.nurses:
item_nurse_obj.create({
'cycle_item_id': item_id,
'nurse_id': nurse.id,
'level_id': nurse.level_id.id,
})
msg='Create Cycle Item successfully'
obj=self.browse(ids)[0]
obj.write(vals)
def clear(self,ids,context={}):
obj=self.browse(ids)[0]
for line in obj.lines:
line.delete()
return {
'next': {
'name': 'clinic_cycle_item',
'name': 'clinic_schedule',
'mode': 'form',
'active_id': item_id,
'active_id': obj.id,
},
'flash': msg,
'flash': 'List of nurse has been cleared.',
}
Schedule.register()

View File

@ -0,0 +1,130 @@
from datetime import datetime, timedelta
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
class Schedule(Model):
_name="clinic.schedule"
_string="Schedule"
#_field_name="cycle_id"
def _get_name(self,ids,context={}):
res={}
for obj in self.browse(ids):
nurse_list=','.join(nurse.name for nurse in obj.nurses)
res[obj.id]='%s, Nurse: %s'%(obj.cycle_id.name or "", nurse_list)
return res
def _get_item(self,ids,context={}):
res={}
for obj in self.browse(ids):
item_ids=get_model("clinic.cycle.item").search([['cycle_id','=',obj.cycle_id.id],['date','=',obj.time_start[0:10]]])
item_id=None
if item_ids:
item_id=item_ids[0]
res[obj.id]=item_id
return res
_fields={
"name": fields.Char("Name",function="_get_name"),
'cycle_id': fields.Many2One("clinic.cycle","Cycle",required=True),
'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),
'company_id': fields.Many2One("company","Company"),
'nurses': fields.Many2Many('clinic.personal','Nurses'), # XXX domain
'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State'),
}
_defaults={
"company_id": lambda *a: get_active_company(),
'time_start': lambda *a: datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
'time_stop': lambda *a: (datetime.now()+timedelta(seconds=3600)).strftime("%Y-%m-%d %H:%M:%S"),
'state': 'draft',
}
def confirm(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({
'state': 'confirmed',
})
def to_draft(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({
'state': 'draft',
})
def copy(self,ids,context={}):
obj=self.browse(ids)[0]
nurse_ids=[nurse.id for nurse in obj.nurses]
vals={
'cycle_id': obj.cycle_id.id,
'time_start': obj.time_start,
'time_stop': obj.time_stop,
'nurses': [('add', nurse_ids)],
}
obj_id=get_model("clinic.schedule").create(vals)
return {
'next': {
'name': 'clinic_schedule',
'mode': 'form',
'active_id': obj_id,
},
'flash': 'Copy schedule successfully',
}
def copy_nurses(self,ids,context={}):
obj=self.browse(ids)[0]
nurses=[]
for nurse in obj.nurses:
nurses.append(('create',{
'nurse_id': nurse.id,
'level_id': nurse.level_id.id,
}))
for nurse in obj.cycle_item_id.nurses:
nurse.delete()
obj.cycle_item_id.write({
'nurses': nurses,
})
return {
'next': {
'name': 'clinic_cycle_item',
'mode': 'form',
'active_id': obj.cycle_item_id.id,
},
'flash': 'Copy nurses to cycle item successfully',
}
def view_cycle_item(self,ids,context={}):
obj=self.browse(ids)[0]
item_id=obj.cycle_item_id.id
msg=''
if not item_id:
# XXX
item_id=get_model("clinic.cycle.item").create({
'cycle_id': obj.cycle_id.id,
'date': obj.time_start[0:10],
})
#raise Exception("No found cycle item")
item_nurse_obj=get_model("clinic.cycle.item.nurse")
for nurse in obj.nurses:
item_nurse_obj.create({
'cycle_item_id': item_id,
'nurse_id': nurse.id,
'level_id': nurse.level_id.id,
})
msg='Create Cycle Item successfully'
return {
'next': {
'name': 'clinic_cycle_item',
'mode': 'form',
'active_id': item_id,
},
'flash': msg,
}
Schedule.register()

View File

@ -0,0 +1,13 @@
from netforce.model import Model, fields
class ScheduleLine(Model):
_name="clinic.schedule.line"
_string="Schedule Line"
_fields={
'schedule_id': fields.Many2One("clinic.schedule","Schedule"),
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
"nurse_id": fields.Many2One("clinic.personal","Nurse",domain=[['type','=','nurse']]),
}
ScheduleLine.register()

View File

@ -4,5 +4,7 @@ cycle dialy
-list
visit dialy
list of visits
schedule planing for nurses / personal
import payment
- error report