xxxx
parent
e84623a1d7
commit
bf7301fa76
|
@ -1,36 +1,26 @@
|
||||||
<form model="clinic.gen.visit">
|
<form model="clinic.gen.visit">
|
||||||
<group form_layout="stacked">
|
<group form_layout="stacked">
|
||||||
<field name="date_from" span="2"/>
|
<field name="date_from" span="2"/>
|
||||||
<field name="time_start" span="2"/>
|
|
||||||
<field name="date_to" span="2"/>
|
<field name="date_to" span="2"/>
|
||||||
<field name="time_stop" span="2"/>
|
<separator string="Please Select > 1. Days > 2. Patients"/>
|
||||||
<field name="cycle_id" onchange="onchange_cycle" span="2"/>
|
|
||||||
<field name="patient_categ_id" span="2"/>
|
|
||||||
<field name="patient_type_id" span="2"/>
|
|
||||||
<field name="doctor_id" span="2"/>
|
|
||||||
<field name="department_id" span="2"/>
|
|
||||||
<field name="nurse_categ_id" span="2"/>
|
|
||||||
<separator string="Select Days"/>
|
|
||||||
<field name="monday" span="2"/>
|
|
||||||
<field name="tuesday" span="2"/>
|
|
||||||
<field name="wednesday" span="2"/>
|
|
||||||
<field name="thursday" span="2"/>
|
|
||||||
<field name="friday" span="2"/>
|
|
||||||
<field name="sathurday" span="2"/>
|
|
||||||
<field name="sunday" span="2"/>
|
|
||||||
<separator string="Manual"/>
|
|
||||||
<tabs>
|
<tabs>
|
||||||
<tab string="Patients">
|
<tab string="Days">
|
||||||
<field name="patient_lines" nolabel="1">
|
<field name="time_lines" noadd="1" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="patient_id"/>
|
<field name="day"/>
|
||||||
|
<field name="cycle_id" onchange="onchange_cycle_line"/>
|
||||||
|
<field name="time_start"/>
|
||||||
|
<field name="time_stop"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Nurses">
|
<tab string="Patients">
|
||||||
<field name="nurse_lines" nolabel="1">
|
<field name="department_id" span="3"/>
|
||||||
|
<field name="patient_categ_id" span="4"/>
|
||||||
|
<field name="patient_type_id" span="4"/>
|
||||||
|
<field name="patient_lines" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="nurse_id"/>
|
<field name="patient_id"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
|
|
|
@ -40,6 +40,7 @@ from . import cycle_monthly
|
||||||
from . import cycle_monthly_line
|
from . import cycle_monthly_line
|
||||||
from . import gen_visit
|
from . import gen_visit
|
||||||
from . import gen_visit_line
|
from . import gen_visit_line
|
||||||
|
from . import gen_visit_time
|
||||||
from . import fin_setting
|
from . import fin_setting
|
||||||
from . import payment
|
from . import payment
|
||||||
from . import account_payment
|
from . import account_payment
|
||||||
|
|
|
@ -2,6 +2,7 @@ from datetime import datetime, timedelta
|
||||||
|
|
||||||
from netforce.access import get_active_user
|
from netforce.access import get_active_user
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
|
from netforce.utils import get_data_path
|
||||||
|
|
||||||
FMT_DATE="%Y-%m-%d"
|
FMT_DATE="%Y-%m-%d"
|
||||||
FMT_DATETIME="%Y-%m-%d %H:%M:%S"
|
FMT_DATETIME="%Y-%m-%d %H:%M:%S"
|
||||||
|
@ -13,24 +14,12 @@ class GenVisit(Model):
|
||||||
_fields={
|
_fields={
|
||||||
'date_from': fields.Date("From", required=True),
|
'date_from': fields.Date("From", required=True),
|
||||||
'date_to': fields.Date("To", required=True),
|
'date_to': fields.Date("To", required=True),
|
||||||
'time_start': fields.Char("Time Start"),
|
|
||||||
'time_stop': fields.Char("Time Stop"),
|
|
||||||
'cycle_id': fields.Many2One("clinic.cycle","Cycle", required=True),
|
|
||||||
'patient_lines': fields.One2Many("clinic.gen.visit.line","gen_id","Patient Lines"),
|
'patient_lines': fields.One2Many("clinic.gen.visit.line","gen_id","Patient Lines"),
|
||||||
'nurse_lines': fields.One2Many("clinic.gen.visit.line","gen_id","Nurse Lines"),
|
|
||||||
'monday': fields.Boolean("Monday"),
|
|
||||||
'tuesday': fields.Boolean("Tuesdays"),
|
|
||||||
'wednesday': fields.Boolean("Wednesdays"),
|
|
||||||
'thursday': fields.Boolean("Thursdays"),
|
|
||||||
'friday': fields.Boolean("Fridays"),
|
|
||||||
'sathurday': fields.Boolean("Sathurday"),
|
|
||||||
'sunday': fields.Boolean("Sunday"),
|
|
||||||
'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']]),
|
|
||||||
'department_id': fields.Many2One("clinic.department","Department"),
|
|
||||||
#"patient_type": fields.Selection([("s","Social Security"),("u","UC."),("others","Others")],"Patient Type"),
|
|
||||||
'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type"),
|
'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type"),
|
||||||
'patient_categ_id': fields.Many2One("clinic.patient.categ", "Patient Category"),
|
'patient_categ_id': fields.Many2One("clinic.patient.categ", "Patient Category"),
|
||||||
'nurse_categ_id': fields.Many2One("clinic.staff.categ", "Nurse Category", domain=[['type','=','nurse']]),
|
'time_lines': fields.One2Many("clinic.gen.visit.time","gen_id","Time Lines"),
|
||||||
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
|
'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,69 +28,28 @@ class GenVisit(Model):
|
||||||
if not ids:
|
if not ids:
|
||||||
ids=[context.get("refer_id")]
|
ids=[context.get("refer_id")]
|
||||||
lines=[]
|
lines=[]
|
||||||
# XXX [None]
|
|
||||||
if any(ids):
|
if any(ids):
|
||||||
lines=[{'patient_id': id} for id in ids]
|
lines=[{'patient_id': id} for id in ids if type(id)==type(1)]
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
def _get_nurse(self,context={}):
|
def _get_time_lines(self,context={}):
|
||||||
user_id=get_active_user()
|
return [
|
||||||
print("user_id ",user_id)
|
{'day': 'mon',},
|
||||||
nurse_ids=get_model("clinic.nurse").search([['user_id','=',user_id]])
|
{'day': 'tue',},
|
||||||
if nurse_ids:
|
{'day': 'wed',},
|
||||||
return nurse_ids[0]
|
{'day': 'thu',},
|
||||||
return None
|
{'day': 'fri',},
|
||||||
|
{'day': 'sat',},
|
||||||
def _get_cycle(self,context={}):
|
{'day': 'sun',},
|
||||||
cycle_ids=get_model('clinic.cycle').search([],order="sequence")
|
]
|
||||||
if cycle_ids:
|
|
||||||
cycle_id=cycle_ids[0]
|
|
||||||
return cycle_id or None
|
|
||||||
|
|
||||||
def _get_start(self,context={}):
|
|
||||||
cycle_ids=get_model('clinic.cycle').search([],order="sequence")
|
|
||||||
time_start="00:00"
|
|
||||||
if cycle_ids:
|
|
||||||
cycle_id=cycle_ids[0]
|
|
||||||
cycle=get_model('clinic.cycle').browse(cycle_id)
|
|
||||||
time_start=cycle.time_start
|
|
||||||
return time_start
|
|
||||||
|
|
||||||
def _get_stop(self,context={}):
|
|
||||||
cycle_ids=get_model('clinic.cycle').search([],order="sequence")
|
|
||||||
time_stop="00:00"
|
|
||||||
if cycle_ids:
|
|
||||||
cycle_id=cycle_ids[0]
|
|
||||||
cycle=get_model('clinic.cycle').browse(cycle_id)
|
|
||||||
time_stop=cycle.time_stop
|
|
||||||
return time_stop
|
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
'patient_lines': _get_patient_lines,
|
|
||||||
'date_from': lambda *a: datetime.now().strftime(FMT_DATE),
|
'date_from': lambda *a: datetime.now().strftime(FMT_DATE),
|
||||||
'date_to': lambda *a: (datetime.now()+timedelta(days=7)).strftime(FMT_DATE),
|
'date_to': lambda *a: (datetime.now()+timedelta(days=7)).strftime(FMT_DATE),
|
||||||
'time_start': _get_start,
|
'patient_lines': _get_patient_lines,
|
||||||
'time_stop': _get_stop,
|
'time_lines': _get_time_lines,
|
||||||
'nurse_id': _get_nurse,
|
|
||||||
'duration': 2,
|
|
||||||
'cycle_id': _get_cycle,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def default_get(self,field_names=None,context=None,**kw):
|
|
||||||
vals=super().default_get(field_names,context,**kw)
|
|
||||||
wd=datetime.now().weekday()
|
|
||||||
wds={
|
|
||||||
0: 'monday',
|
|
||||||
1: 'tuesday',
|
|
||||||
2: 'wednesday',
|
|
||||||
3: 'thursday',
|
|
||||||
4: 'friday',
|
|
||||||
5: 'sathurday',
|
|
||||||
6: 'sunday',
|
|
||||||
}
|
|
||||||
vals[wds[wd]]=True
|
|
||||||
return vals
|
|
||||||
|
|
||||||
def onchange_cycle(self,context={}):
|
def onchange_cycle(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
cycle_id=data['cycle_id']
|
cycle_id=data['cycle_id']
|
||||||
|
@ -114,18 +62,37 @@ class GenVisit(Model):
|
||||||
def gen_visit(self,ids,context):
|
def gen_visit(self,ids,context):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
visit_obj=get_model('clinic.visit')
|
visit_obj=get_model('clinic.visit')
|
||||||
days=[
|
days={}
|
||||||
obj.monday and 1 or 0,
|
for tline in obj.time_lines:
|
||||||
obj.tuesday and 2 or 0,
|
if tline.day and tline.cycle_id and tline.time_start and tline.time_stop:
|
||||||
obj.wednesday and 3 or 0,
|
day=tline.day
|
||||||
obj.thursday and 4 or 0,
|
cycle_id=tline.cycle_id.id
|
||||||
obj.friday and 5 or 0,
|
time_start=tline.time_start
|
||||||
obj.sathurday and 6 or 0,
|
time_stop=tline.time_stop
|
||||||
obj.sunday and 7 or 0,
|
d=0
|
||||||
]
|
if day=='mon':
|
||||||
days=[day for day in days if day]
|
d=1
|
||||||
|
elif day=='tue':
|
||||||
|
d=2
|
||||||
|
elif day=='wed':
|
||||||
|
d=3
|
||||||
|
elif day=='thu':
|
||||||
|
d=4
|
||||||
|
elif day=='fri':
|
||||||
|
d=5
|
||||||
|
elif day=='sat':
|
||||||
|
d=6
|
||||||
|
elif day=='sun':
|
||||||
|
d=7
|
||||||
|
days.update({
|
||||||
|
d:{
|
||||||
|
'cycle_id': cycle_id,
|
||||||
|
'time_start': time_start,
|
||||||
|
'time_stop': time_stop,
|
||||||
|
}})
|
||||||
if not days:
|
if not days:
|
||||||
raise Exception("Please select Day")
|
raise Exception("Please select Days")
|
||||||
|
|
||||||
visit_vals=[]
|
visit_vals=[]
|
||||||
date_from=datetime.strptime(obj.date_from,FMT_DATE)
|
date_from=datetime.strptime(obj.date_from,FMT_DATE)
|
||||||
date_to=datetime.strptime(obj.date_to,FMT_DATE)
|
date_to=datetime.strptime(obj.date_to,FMT_DATE)
|
||||||
|
@ -144,33 +111,12 @@ class GenVisit(Model):
|
||||||
else:
|
else:
|
||||||
raise Exception("Please select some patient or patient type")
|
raise Exception("Please select some patient or patient type")
|
||||||
|
|
||||||
nurse_vals=[]
|
day_choices=days.keys()
|
||||||
for nurse_line in obj.nurse_lines:
|
|
||||||
nurse=nurse_line.nurse_id
|
|
||||||
# None
|
|
||||||
if nurse:
|
|
||||||
nurse_vals.append({
|
|
||||||
'id': nurse.id,
|
|
||||||
'level_id': nurse.level_id.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
if not nurse_vals and obj.nurse_categ_id:
|
|
||||||
for nurse in get_model("clinic.staff").search_browse([['type','=','nurse'],['categ_id','=',obj.nurse_categ_id.id]]):
|
|
||||||
nurse_vals.append({
|
|
||||||
'id': nurse.id,
|
|
||||||
'level_id': nurse.level_id.id,
|
|
||||||
})
|
|
||||||
|
|
||||||
schedules={}
|
|
||||||
cycle=obj.cycle_id
|
|
||||||
cstart='%s:00'%cycle.time_start
|
|
||||||
cstop='%s:00'%cycle.time_stop
|
|
||||||
|
|
||||||
for patient_id in patients:
|
for patient_id in patients:
|
||||||
patient=get_model("clinic.patient").browse(patient_id)
|
patient=get_model("clinic.patient").browse(patient_id)
|
||||||
ntoday=1
|
ntoday=1
|
||||||
day_total=(date_to-date_from).days+ntoday
|
day_total=(date_to-date_from).days+ntoday
|
||||||
for weekday in days:
|
for weekday in day_choices:
|
||||||
wd=date_from.weekday()
|
wd=date_from.weekday()
|
||||||
start_date=date_from
|
start_date=date_from
|
||||||
while wd != weekday-1:
|
while wd != weekday-1:
|
||||||
|
@ -181,6 +127,8 @@ class GenVisit(Model):
|
||||||
continue
|
continue
|
||||||
count=0
|
count=0
|
||||||
tmp=start_date
|
tmp=start_date
|
||||||
|
cstart=days[weekday]['time_start']
|
||||||
|
cstop=days[weekday]['time_stop']
|
||||||
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),cstart)
|
ttime_start="%s %s" % (tmp.strftime(FMT_DATE),cstart)
|
||||||
|
@ -189,7 +137,7 @@ class GenVisit(Model):
|
||||||
'patient_id': patient_id,
|
'patient_id': patient_id,
|
||||||
'doctor_id': obj.doctor_id.id or patient.doctor_id.id,
|
'doctor_id': obj.doctor_id.id or patient.doctor_id.id,
|
||||||
'department_id': obj.department_id.id,
|
'department_id': obj.department_id.id,
|
||||||
'cycle_id': cycle.id,
|
'cycle_id': days[weekday]['cycle_id'],
|
||||||
'time_start': ttime_start,
|
'time_start': ttime_start,
|
||||||
'time_stop': ttime_stop,
|
'time_stop': ttime_stop,
|
||||||
'state': 'pending',
|
'state': 'pending',
|
||||||
|
@ -201,18 +149,10 @@ class GenVisit(Model):
|
||||||
dom.append(['time_start','>=','%s %s'%(tmp.strftime(FMT_DATE)[0:10],' 00:00:00')])
|
dom.append(['time_start','>=','%s %s'%(tmp.strftime(FMT_DATE)[0:10],' 00:00:00')])
|
||||||
dom.append(['time_stop','<=','%s %s'%(tmp.strftime(FMT_DATE)[0:10],' 23:59:59')])
|
dom.append(['time_stop','<=','%s %s'%(tmp.strftime(FMT_DATE)[0:10],' 23:59:59')])
|
||||||
dom.append(['patient_id', '=', patient_id])
|
dom.append(['patient_id', '=', patient_id])
|
||||||
dom.append(['cycle_id', '=', obj.cycle_id.id]) #XXX
|
dom.append(['cycle_id', '=', days[weekday]['cycle_id']])
|
||||||
dom.append(['state','=','pending'])
|
dom.append(['state','=','pending'])
|
||||||
vids=visit_obj.search(dom)
|
vids=visit_obj.search(dom)
|
||||||
visit_obj.delete(vids)
|
visit_obj.delete(vids)
|
||||||
key='%s/%s'%(vals['cycle_id'], vals['time_start'])
|
|
||||||
if not schedules.get(key):
|
|
||||||
schedules[key]={
|
|
||||||
'cycle_id': obj.cycle_id.id,
|
|
||||||
'time_start': ttime_start,
|
|
||||||
'time_stop': ttime_stop,
|
|
||||||
'state':'pending',
|
|
||||||
}
|
|
||||||
start_date=tmp
|
start_date=tmp
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
staff_ids=get_model("clinic.staff").search([['type','=','type'],['user_id','=',user_id]])
|
staff_ids=get_model("clinic.staff").search([['type','=','type'],['user_id','=',user_id]])
|
||||||
|
@ -222,40 +162,6 @@ class GenVisit(Model):
|
||||||
for vals in visit_vals:
|
for vals in visit_vals:
|
||||||
vals['nurse_id']=confirm_id
|
vals['nurse_id']=confirm_id
|
||||||
visit_obj.create(vals)
|
visit_obj.create(vals)
|
||||||
|
|
||||||
print("create schedule")
|
|
||||||
print("="*50)
|
|
||||||
for k, v in schedules.items():
|
|
||||||
cycle_id,time_start=k.split("/")
|
|
||||||
schedule_date=time_start[0:10]
|
|
||||||
dom=[]
|
|
||||||
dom.append(['date','=',schedule_date])
|
|
||||||
schedules=get_model("clinic.schedule").search_browse(dom)
|
|
||||||
if schedules:
|
|
||||||
schedule=schedules[0]
|
|
||||||
if schedule.state=='draft':
|
|
||||||
for line in schedule.lines:
|
|
||||||
line.delete()
|
|
||||||
else:
|
|
||||||
vals={
|
|
||||||
'date': time_start[0:10],
|
|
||||||
'time_start': time_start,
|
|
||||||
'time_stop': time_start,
|
|
||||||
}
|
|
||||||
schedule_id=get_model("clinic.schedule").create(vals)
|
|
||||||
schedule=get_model("clinic.schedule").browse(schedule_id)
|
|
||||||
|
|
||||||
lines=[]
|
|
||||||
for nv in nurse_vals:
|
|
||||||
nurse_id=nv['id']
|
|
||||||
lines.append(('create',{
|
|
||||||
'nurse_id': nurse_id,
|
|
||||||
'cycle_id': cycle_id,
|
|
||||||
}))
|
|
||||||
schedule.write({'lines': lines})
|
|
||||||
|
|
||||||
print("="*50)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': 'clinic_visit',
|
'name': 'clinic_visit',
|
||||||
|
@ -266,21 +172,43 @@ class GenVisit(Model):
|
||||||
|
|
||||||
def clear_visit(self,ids,context={}):
|
def clear_visit(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
days=[
|
days={}
|
||||||
obj.monday and 1 or 0,
|
for tline in obj.time_lines:
|
||||||
obj.tuesday and 2 or 0,
|
if tline.day and tline.cycle_id and tline.time_start and tline.time_stop:
|
||||||
obj.wednesday and 3 or 0,
|
day=tline.day
|
||||||
obj.thursday and 4 or 0,
|
cycle_id=tline.cycle_id.id
|
||||||
obj.friday and 5 or 0,
|
time_start=tline.time_start
|
||||||
]
|
time_stop=tline.time_stop
|
||||||
days=[day for day in days if day]
|
d=0
|
||||||
|
if day=='mon':
|
||||||
|
d=1
|
||||||
|
elif day=='tue':
|
||||||
|
d=2
|
||||||
|
elif day=='wed':
|
||||||
|
d=3
|
||||||
|
elif day=='thu':
|
||||||
|
d=4
|
||||||
|
elif day=='fri':
|
||||||
|
d=5
|
||||||
|
elif day=='sat':
|
||||||
|
d=6
|
||||||
|
elif day=='sun':
|
||||||
|
d=7
|
||||||
|
days.update({
|
||||||
|
d:{
|
||||||
|
'cycle_id': cycle_id,
|
||||||
|
'time_start': time_start,
|
||||||
|
'time_stop': time_stop,
|
||||||
|
}})
|
||||||
|
if not days:
|
||||||
|
raise Exception("Please select Days")
|
||||||
|
|
||||||
visit_ids=[]
|
visit_ids=[]
|
||||||
date_from=datetime.strptime(obj.date_from,FMT_DATE)
|
date_from=datetime.strptime(obj.date_from,FMT_DATE)
|
||||||
date_to=datetime.strptime(obj.date_to,FMT_DATE)
|
date_to=datetime.strptime(obj.date_to,FMT_DATE)
|
||||||
# FIXME add more 1 week for make sure
|
# FIXME add more 1 week for make sure
|
||||||
date_to2=(date_to+timedelta(days=7)).strftime(FMT_DATETIME)
|
date_to2=(date_to+timedelta(days=7)).strftime(FMT_DATETIME)
|
||||||
visit_obj=get_model("clinic.visit")
|
visit_obj=get_model("clinic.visit")
|
||||||
schedule_obj=get_model("clinic.schedule")
|
|
||||||
|
|
||||||
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:
|
||||||
|
@ -288,7 +216,6 @@ class GenVisit(Model):
|
||||||
elif not patients and obj.patient_categ_id:
|
elif not patients and obj.patient_categ_id:
|
||||||
patients=get_model("clinic.patient").search([['categ_id','=',obj.patient_categ_id.id]])
|
patients=get_model("clinic.patient").search([['categ_id','=',obj.patient_categ_id.id]])
|
||||||
elif patients:
|
elif patients:
|
||||||
# continue to create with critiria
|
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
dom=[]
|
dom=[]
|
||||||
|
@ -297,15 +224,6 @@ class GenVisit(Model):
|
||||||
dom.append(['state','=','pending'])
|
dom.append(['state','=','pending'])
|
||||||
vids=visit_obj.search(dom)
|
vids=visit_obj.search(dom)
|
||||||
visit_obj.delete(vids)
|
visit_obj.delete(vids)
|
||||||
schedule_obj=get_model("clinic.schedule")
|
|
||||||
dom[-1][2]='draft' #XXX
|
|
||||||
schedules=schedule_obj.search_browse(dom)
|
|
||||||
schedule_ids=[]
|
|
||||||
for sch in schedules:
|
|
||||||
for line in sch.lines:
|
|
||||||
if obj.cycle_id.id==line.cycle_id.id:
|
|
||||||
schedule_ids.append(sch.id)
|
|
||||||
schedule_obj.delete(schedule_ids)
|
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': 'clinic_gen_visit_form',
|
'name': 'clinic_gen_visit_form',
|
||||||
|
@ -314,18 +232,18 @@ class GenVisit(Model):
|
||||||
'flash': 'Clear %s visits'%len(vids),
|
'flash': 'Clear %s visits'%len(vids),
|
||||||
}
|
}
|
||||||
|
|
||||||
if days:
|
day_choices=days.keys()
|
||||||
|
if day_choices:
|
||||||
for patient_id in patients:
|
for patient_id in patients:
|
||||||
# loop days in weekend
|
# loop days in weekend
|
||||||
ntoday=1
|
ntoday=1
|
||||||
day_total=(date_to-date_from).days+ntoday
|
day_total=(date_to-date_from).days+ntoday
|
||||||
for weekday in days:
|
for weekday in day_choices:
|
||||||
wd=date_from.weekday()
|
wd=date_from.weekday()
|
||||||
start_date=date_from
|
start_date=date_from
|
||||||
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 scop
|
#XXX should gen only in scop
|
||||||
if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
|
if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
|
||||||
continue
|
continue
|
||||||
|
@ -339,13 +257,16 @@ class GenVisit(Model):
|
||||||
dom.append(['time_start','>=','%s'%time_start])
|
dom.append(['time_start','>=','%s'%time_start])
|
||||||
dom.append(['time_stop','<=','%s'%time_stop])
|
dom.append(['time_stop','<=','%s'%time_stop])
|
||||||
dom.append(['patient_id','=','%s'%patient_id])
|
dom.append(['patient_id','=','%s'%patient_id])
|
||||||
|
dom.append(['cycle_id','=','%s'%days[weekday]['cycle_id']])
|
||||||
dom.append(['state','=','pending'])
|
dom.append(['state','=','pending'])
|
||||||
count+=7
|
count+=7
|
||||||
vids=visit_obj.search(dom)
|
vids=visit_obj.search(dom)
|
||||||
|
print('x dom ', vids)
|
||||||
if vids:
|
if vids:
|
||||||
visit_ids.append(vids[0])
|
visit_ids.append(vids[0])
|
||||||
start_date=tmp
|
start_date=tmp
|
||||||
else:
|
else:
|
||||||
|
# discard
|
||||||
time_start=obj.date_from
|
time_start=obj.date_from
|
||||||
time_stop=obj.date_to
|
time_stop=obj.date_to
|
||||||
for patient_id in patients:
|
for patient_id in patients:
|
||||||
|
@ -354,17 +275,13 @@ class GenVisit(Model):
|
||||||
dom.append(['time_stop','<=','%s'%time_stop])
|
dom.append(['time_stop','<=','%s'%time_stop])
|
||||||
dom.append(['patient_id','=','%s'%patient_id])
|
dom.append(['patient_id','=','%s'%patient_id])
|
||||||
dom.append(['state','=','pending'])
|
dom.append(['state','=','pending'])
|
||||||
|
print('dom ', dom)
|
||||||
vids=visit_obj.search(dom)
|
vids=visit_obj.search(dom)
|
||||||
if vids:
|
if vids:
|
||||||
visit_ids.append(vids[0])
|
visit_ids.append(vids[0])
|
||||||
if visit_ids:
|
if visit_ids:
|
||||||
get_model("clinic.visit").delete(visit_ids)
|
get_model("clinic.visit").delete(visit_ids)
|
||||||
dom=[]
|
|
||||||
dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
|
|
||||||
dom.append(['time_stop','<=','%s %s'%(date_to2[0:10],' 23:59:59')])
|
|
||||||
dom.append(['cycle_id','=',obj.cycle_id.id])
|
|
||||||
schedule_ids=schedule_obj.search(dom)
|
|
||||||
schedule_obj.delete(schedule_ids)
|
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
'name': 'clinic_visit',
|
'name': 'clinic_visit',
|
||||||
|
@ -373,5 +290,16 @@ class GenVisit(Model):
|
||||||
'flash': 'Clear %s visits'%len(visit_ids),
|
'flash': 'Clear %s visits'%len(visit_ids),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def onchange_cycle_line(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
path=context['path']
|
||||||
|
line=get_data_path(data,path,parent=True)
|
||||||
|
cycle_id=line['cycle_id']
|
||||||
|
if cycle_id:
|
||||||
|
cycle=get_model('clinic.cycle').browse(cycle_id)
|
||||||
|
line['time_start']=cycle.time_start
|
||||||
|
line['time_stop']=cycle.time_stop
|
||||||
|
return data
|
||||||
|
|
||||||
GenVisit.register()
|
GenVisit.register()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
from netforce.model import Model, fields, get_model
|
||||||
|
|
||||||
|
class GenVisitTime(Model):
|
||||||
|
_name="clinic.gen.visit.time"
|
||||||
|
_transient=True
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
'gen_id': fields.Many2One("clinic.gen.visit","gen_id","Gen Visit"),
|
||||||
|
'day': fields.Selection([('mon', 'Monday'), ('tue','Tuesday'), ('wed','Wedsday'),('thu','Thursday'),('fri','Friday'),('sat','Satherday'),('sun','Sunday')], 'Days'),
|
||||||
|
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
|
||||||
|
'time_start': fields.Char("Time Start"),
|
||||||
|
'time_stop': fields.Char("Time Stop"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GenVisitTime.register()
|
||||||
|
|
|
@ -990,6 +990,7 @@ class HDCase(Model):
|
||||||
for line in vals['lines']:
|
for line in vals['lines']:
|
||||||
mode=line[0]
|
mode=line[0]
|
||||||
amt=0
|
amt=0
|
||||||
|
rmb='no'
|
||||||
if mode=='create':
|
if mode=='create':
|
||||||
line_vals=line[1]
|
line_vals=line[1]
|
||||||
amt=line_vals.get("amount",0)
|
amt=line_vals.get("amount",0)
|
||||||
|
@ -1003,11 +1004,11 @@ class HDCase(Model):
|
||||||
line['uom_id']=prod.uom_id.id
|
line['uom_id']=prod.uom_id.id
|
||||||
continue
|
continue
|
||||||
line_id=line[1][0]
|
line_id=line[1][0]
|
||||||
line_vals=line[1]
|
line_vals=line[2]
|
||||||
|
rmb=line_vals.get("reimbursable","no")
|
||||||
line=get_model('clinic.hd.case.line').browse(line_id)
|
line=get_model('clinic.hd.case.line').browse(line_id)
|
||||||
amt=line.amount or 0
|
amt=line.amount or 0
|
||||||
total_amt+=amt
|
total_amt+=amt
|
||||||
rmb=line_vals.get("reimbursable","no")
|
|
||||||
if rmb=='no':
|
if rmb=='no':
|
||||||
due_amt+=amt
|
due_amt+=amt
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue