xxx
parent
f8ebf4c30c
commit
04ef418988
|
@ -1,6 +1,6 @@
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from netforce.access import get_active_user
|
from netforce.access import get_active_user, set_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
|
from netforce.utils import get_data_path
|
||||||
|
|
||||||
|
@ -57,11 +57,18 @@ class GenVisit(Model):
|
||||||
cycle=get_model('clinic.cycle').browse(cycle_id)
|
cycle=get_model('clinic.cycle').browse(cycle_id)
|
||||||
data['time_start']=cycle.time_start
|
data['time_start']=cycle.time_start
|
||||||
data['time_stop']=cycle.time_stop
|
data['time_stop']=cycle.time_stop
|
||||||
|
else:
|
||||||
|
data['time_start']=''
|
||||||
|
data['time_stop']=''
|
||||||
return data
|
return data
|
||||||
|
|
||||||
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')
|
||||||
|
b_ids=get_model('clinic.branch').search([])
|
||||||
|
branch_id=None
|
||||||
|
if b_ids:
|
||||||
|
branch_id=b_ids[0]
|
||||||
days={}
|
days={}
|
||||||
for tline in obj.time_lines:
|
for tline in obj.time_lines:
|
||||||
if tline.day and tline.cycle_id and tline.time_start and tline.time_stop:
|
if tline.day and tline.cycle_id and tline.time_start and tline.time_stop:
|
||||||
|
@ -131,15 +138,18 @@ class GenVisit(Model):
|
||||||
cstop=days[weekday]['time_stop']
|
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)
|
visit_date="%s"%(tmp.strftime(FMT_DATE))
|
||||||
ttime_stop="%s %s" % (tmp.strftime(FMT_DATE),cstop)
|
ttime_start="%s %s" % (visit_date,cstart)
|
||||||
|
ttime_stop="%s %s" % (visit_date,cstop)
|
||||||
vals={
|
vals={
|
||||||
'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': patient.department_id.id,
|
||||||
|
'branch_id': branch_id,
|
||||||
'cycle_id': days[weekday]['cycle_id'],
|
'cycle_id': days[weekday]['cycle_id'],
|
||||||
'time_start': ttime_start,
|
'time_start': ttime_start,
|
||||||
'time_stop': ttime_stop,
|
'time_stop': ttime_stop,
|
||||||
|
'visit_date': visit_date,
|
||||||
'state': 'pending',
|
'state': 'pending',
|
||||||
}
|
}
|
||||||
visit_vals.append(vals)
|
visit_vals.append(vals)
|
||||||
|
@ -160,6 +170,7 @@ class GenVisit(Model):
|
||||||
if staff_ids:
|
if staff_ids:
|
||||||
confirm_id=staff_ids[0]
|
confirm_id=staff_ids[0]
|
||||||
for vals in visit_vals:
|
for vals in visit_vals:
|
||||||
|
print("vals ", vals)
|
||||||
vals['nurse_id']=confirm_id
|
vals['nurse_id']=confirm_id
|
||||||
visit_obj.create(vals)
|
visit_obj.create(vals)
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -27,7 +27,6 @@ class Visit(Model):
|
||||||
res[obj.id]={
|
res[obj.id]={
|
||||||
'cycle_color': color,
|
'cycle_color': color,
|
||||||
'sequence': '%s-%s'%(obj.time_start[0:10],cycle.sequence), #date-sequence
|
'sequence': '%s-%s'%(obj.time_start[0:10],cycle.sequence), #date-sequence
|
||||||
#'visit_date': obj.time_start[0:10]
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -101,13 +100,16 @@ class Visit(Model):
|
||||||
|
|
||||||
_order="sequence"
|
_order="sequence"
|
||||||
|
|
||||||
def new_dlz(self,patient_id):
|
def new_dlz(self,patient_id,department_id):
|
||||||
if not patient_id:
|
if not patient_id:
|
||||||
raise Exception("No Patient to creat Dialyzer")
|
raise Exception("No Patient to creat Dialyzer")
|
||||||
|
if not department_id:
|
||||||
|
raise Exception("No Department to creat Dialyzer")
|
||||||
dlz_vals=get_model("clinic.dialyzer").default_get()
|
dlz_vals=get_model("clinic.dialyzer").default_get()
|
||||||
dlz_vals['product_id']=dlz_vals['product_id'][0]
|
dlz_vals['product_id']=dlz_vals['product_id'][0]
|
||||||
dlz_vals['company_id']=dlz_vals['company_id'][0]
|
dlz_vals['company_id']=dlz_vals['company_id'][0]
|
||||||
dlz_vals['patient_id']=patient_id
|
dlz_vals['patient_id']=patient_id
|
||||||
|
dlz_vals['department_id']=department_id
|
||||||
dlz_id=get_model('clinic.dialyzer').create(dlz_vals)
|
dlz_id=get_model('clinic.dialyzer').create(dlz_vals)
|
||||||
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
||||||
dialyzer.confirm()
|
dialyzer.confirm()
|
||||||
|
@ -118,7 +120,7 @@ class Visit(Model):
|
||||||
patient=obj.patient_id
|
patient=obj.patient_id
|
||||||
dialyzers=get_model("clinic.dialyzer").search_browse([['patient_id','=',patient.id],['state','=','active']])
|
dialyzers=get_model("clinic.dialyzer").search_browse([['patient_id','=',patient.id],['state','=','active']])
|
||||||
if not dialyzers:
|
if not dialyzers:
|
||||||
dlz_id=self.new_dlz(patient.id)
|
dlz_id=self.new_dlz(patient.id, obj.department_id.id)
|
||||||
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
||||||
else:
|
else:
|
||||||
dialyzer=dialyzers[-1]
|
dialyzer=dialyzers[-1]
|
||||||
|
@ -129,7 +131,7 @@ class Visit(Model):
|
||||||
'state': 'expire',
|
'state': 'expire',
|
||||||
})
|
})
|
||||||
# get new dialyzer
|
# get new dialyzer
|
||||||
dlz_id=self.new_dlz(patient.id)
|
dlz_id=self.new_dlz(patient.id, obj.department_id.id)
|
||||||
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
||||||
use_time+=1
|
use_time+=1
|
||||||
vals={
|
vals={
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sharing setting
|
sharing setting
|
||||||
- filter by branch
|
- filter by branch
|
||||||
- patient -> ok
|
- patient -> ok
|
||||||
|
@ -10,7 +14,7 @@ sharing setting
|
||||||
- department -> ok
|
- department -> ok
|
||||||
- sickbed -> ok
|
- sickbed -> ok
|
||||||
- schedule -> ok
|
- schedule -> ok
|
||||||
- dialyser
|
- dialyser -> ok
|
||||||
|
|
||||||
- add popup to new dialyser -> not yet ****
|
- add popup to new dialyser -> not yet ****
|
||||||
- running number
|
- running number
|
||||||
|
|
Loading…
Reference in New Issue