improve & fix bug
parent
882429f5d7
commit
4acb59ad24
|
@ -19,4 +19,5 @@ from . import clinic_setting
|
||||||
#from . import revise
|
#from . import revise
|
||||||
#from . import add_patient_moves #XXX do not run it again!!!
|
#from . import add_patient_moves #XXX do not run it again!!!
|
||||||
#from . import check_patient
|
#from . import check_patient
|
||||||
from . import update_patient_name
|
#from . import update_patient_name
|
||||||
|
from . import del_dbl_visit
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
import time
|
||||||
|
from netforce.migration import Migration
|
||||||
|
from netforce.model import Model, fields, get_model
|
||||||
|
|
||||||
|
|
||||||
|
class UpdatePatientName(Migration):
|
||||||
|
_name='del.dbl.visit'
|
||||||
|
_version="2.12.9"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
cond=[
|
||||||
|
['visit_date','>=','2018-03-06'],
|
||||||
|
['visit_date','<=', '2018-03-06'],
|
||||||
|
['department_id','=', 4],
|
||||||
|
['state','!=', 'confirmed'],
|
||||||
|
]
|
||||||
|
patients={}
|
||||||
|
add_count=0
|
||||||
|
del_count=0
|
||||||
|
for index, visit in enumerate(get_model("clinic.visit").search_browse(cond)):
|
||||||
|
patient_id=visit.patient_id.id
|
||||||
|
cycle_id=visit.cycle_id.id
|
||||||
|
key=(patient_id, cycle_id)
|
||||||
|
if key in patients.keys():
|
||||||
|
print("del ", visit.id)
|
||||||
|
try:
|
||||||
|
visit.delete()
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR ", e)
|
||||||
|
print("visit ", visit.id, visit.number)
|
||||||
|
del_count+=1
|
||||||
|
else:
|
||||||
|
print("add ", visit.id)
|
||||||
|
add_count+=1
|
||||||
|
patients.setdefault(key)
|
||||||
|
print('total ', add_count, del_count)
|
||||||
|
|
||||||
|
|
||||||
|
UpdatePatientName.register()
|
|
@ -13,18 +13,22 @@ class UpdatePatientName(Migration):
|
||||||
|
|
||||||
for f, model in [('date', 'clinic.hd.case'),('visit_date','clinic.visit')]:
|
for f, model in [('date', 'clinic.hd.case'),('visit_date','clinic.visit')]:
|
||||||
cond=[
|
cond=[
|
||||||
[f,'>=','%s-01-01'%(y)],
|
#[f,'>=','%s-01-01'%(y)],
|
||||||
|
[f,'>=','2014-01-01'],
|
||||||
[f,'<=',datenow],
|
[f,'<=',datenow],
|
||||||
['patient_name','=',None],
|
['patient_name','=',None],
|
||||||
]
|
]
|
||||||
print("update %s ... "%model)
|
print("update %s ... "%model)
|
||||||
|
context={
|
||||||
|
'migration': True,
|
||||||
|
}
|
||||||
objs=get_model(model).search_browse(cond)
|
objs=get_model(model).search_browse(cond)
|
||||||
for index, obj in enumerate(objs):
|
for index, obj in enumerate(objs):
|
||||||
patient=obj.patient_id
|
patient=obj.patient_id
|
||||||
vals={
|
vals={
|
||||||
'patient_name': patient.name_get()[-1][1]
|
'patient_name': patient.name_get()[-1][1]
|
||||||
}
|
}
|
||||||
obj.write(vals)
|
obj.write(vals,context=context)
|
||||||
#print("%s/%s"%(index+1, len(hdcases)))
|
#print("%s/%s"%(index+1, len(hdcases)))
|
||||||
|
|
||||||
UpdatePatientName.register()
|
UpdatePatientName.register()
|
||||||
|
|
|
@ -1109,7 +1109,7 @@ class HDCase(Model):
|
||||||
# update sickbed
|
# update sickbed
|
||||||
if obj.sickbed_id:
|
if obj.sickbed_id:
|
||||||
obj.sickbed_id.write({
|
obj.sickbed_id.write({
|
||||||
'available': False,
|
'available': True, #reset to available, => please recheck art
|
||||||
})
|
})
|
||||||
obj.recompute_labor_cost()
|
obj.recompute_labor_cost()
|
||||||
return {
|
return {
|
||||||
|
@ -1618,7 +1618,8 @@ class HDCase(Model):
|
||||||
})
|
})
|
||||||
sb=get_model("clinic.sickbed").browse(vals['sickbed_id'])
|
sb=get_model("clinic.sickbed").browse(vals['sickbed_id'])
|
||||||
sb.write({
|
sb.write({
|
||||||
'state': 'not_available',
|
'available': False,
|
||||||
|
'state': 'not_available', #XXX Check state.
|
||||||
})
|
})
|
||||||
set_active_user(user_id)
|
set_active_user(user_id)
|
||||||
if 'lines' in vals.keys():
|
if 'lines' in vals.keys():
|
||||||
|
|
|
@ -112,8 +112,8 @@ class Patient(Model):
|
||||||
"hn_no": fields.Char("HN",function="_get_hn_no",store=True),
|
"hn_no": fields.Char("HN",function="_get_hn_no",store=True),
|
||||||
"hn": fields.Char("REF/HN",search=False),
|
"hn": fields.Char("REF/HN",search=False),
|
||||||
'title_id': fields.Many2One("clinic.name.title","Title"),
|
'title_id': fields.Many2One("clinic.name.title","Title"),
|
||||||
"first_name": fields.Char("First Name"),
|
"first_name": fields.Char("First Name", search=True),
|
||||||
"last_name": fields.Char("Last Name"),
|
"last_name": fields.Char("Last Name", search=True),
|
||||||
"name": fields.Char("Name",function="_get_name",function_multi=True,store=True,search=True),
|
"name": fields.Char("Name",function="_get_name",function_multi=True,store=True,search=True),
|
||||||
"name_check": fields.Char("Name",function="_get_name",function_multi=True,store=True), # prevent duplicate
|
"name_check": fields.Char("Name",function="_get_name",function_multi=True,store=True), # prevent duplicate
|
||||||
'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True),
|
'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True),
|
||||||
|
@ -389,6 +389,7 @@ class Patient(Model):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
if obj.walkin=='no':
|
if obj.walkin=='no':
|
||||||
patient_move={
|
patient_move={
|
||||||
|
'date': obj.resign_date, #XXX
|
||||||
"patient_id": obj.id,
|
"patient_id": obj.id,
|
||||||
"patient_name": "%s %s"% (obj.first_name or "",obj.last_name or ""),
|
"patient_name": "%s %s"% (obj.first_name or "",obj.last_name or ""),
|
||||||
"patient_type": obj.type_id.name,
|
"patient_type": obj.type_id.name,
|
||||||
|
|
|
@ -51,6 +51,9 @@ class ReportLaborCost(Model):
|
||||||
date_to=line.date_stop
|
date_to=line.date_stop
|
||||||
break
|
break
|
||||||
if defaults.get('report_type_wizard'):
|
if defaults.get('report_type_wizard'):
|
||||||
|
date_from=defaults.get('date_from')
|
||||||
|
date_to=defaults.get('date_to')
|
||||||
|
if defaults.get('period_id') != 'None':
|
||||||
per = get_model('clinic.period.line').browse(int(defaults.get('period_id')))
|
per = get_model('clinic.period.line').browse(int(defaults.get('period_id')))
|
||||||
period_id=per.id
|
period_id=per.id
|
||||||
date_from=per.date_start
|
date_from=per.date_start
|
||||||
|
|
|
@ -400,6 +400,7 @@ class VisitBoard(Model):
|
||||||
'date_from': utils.date2thai(date_from,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"),
|
'date_from': utils.date2thai(date_from,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"),
|
||||||
'date_to': utils.date2thai(date_to,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"),
|
'date_to': utils.date2thai(date_to,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"),
|
||||||
}
|
}
|
||||||
|
# TODO Delete the data if duplicate (date, patient, deparment)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_date(self,context={}):
|
def onchange_date(self,context={}):
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue