improve & fix bug

fix1
SPP 2018-05-28 10:35:22 +07:00
parent 882429f5d7
commit 4acb59ad24
9 changed files with 61 additions and 11 deletions

View File

@ -19,4 +19,5 @@ from . import clinic_setting
#from . import revise
#from . import add_patient_moves #XXX do not run it again!!!
#from . import check_patient
from . import update_patient_name
#from . import update_patient_name
from . import del_dbl_visit

View File

@ -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()

View File

@ -13,18 +13,22 @@ class UpdatePatientName(Migration):
for f, model in [('date', 'clinic.hd.case'),('visit_date','clinic.visit')]:
cond=[
[f,'>=','%s-01-01'%(y)],
#[f,'>=','%s-01-01'%(y)],
[f,'>=','2014-01-01'],
[f,'<=',datenow],
['patient_name','=',None],
]
print("update %s ... "%model)
context={
'migration': True,
}
objs=get_model(model).search_browse(cond)
for index, obj in enumerate(objs):
patient=obj.patient_id
vals={
'patient_name': patient.name_get()[-1][1]
}
obj.write(vals)
obj.write(vals,context=context)
#print("%s/%s"%(index+1, len(hdcases)))
UpdatePatientName.register()

View File

@ -1109,7 +1109,7 @@ class HDCase(Model):
# update sickbed
if obj.sickbed_id:
obj.sickbed_id.write({
'available': False,
'available': True, #reset to available, => please recheck art
})
obj.recompute_labor_cost()
return {
@ -1618,7 +1618,8 @@ class HDCase(Model):
})
sb=get_model("clinic.sickbed").browse(vals['sickbed_id'])
sb.write({
'state': 'not_available',
'available': False,
'state': 'not_available', #XXX Check state.
})
set_active_user(user_id)
if 'lines' in vals.keys():

View File

@ -112,8 +112,8 @@ class Patient(Model):
"hn_no": fields.Char("HN",function="_get_hn_no",store=True),
"hn": fields.Char("REF/HN",search=False),
'title_id': fields.Many2One("clinic.name.title","Title"),
"first_name": fields.Char("First Name"),
"last_name": fields.Char("Last Name"),
"first_name": fields.Char("First Name", search=True),
"last_name": fields.Char("Last Name", 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
'type_id': fields.Many2One("clinic.patient.type","Type",search=True,required=True),
@ -389,6 +389,7 @@ class Patient(Model):
obj=self.browse(ids)[0]
if obj.walkin=='no':
patient_move={
'date': obj.resign_date, #XXX
"patient_id": obj.id,
"patient_name": "%s %s"% (obj.first_name or "",obj.last_name or ""),
"patient_type": obj.type_id.name,

View File

@ -51,10 +51,13 @@ class ReportLaborCost(Model):
date_to=line.date_stop
break
if defaults.get('report_type_wizard'):
per = get_model('clinic.period.line').browse(int(defaults.get('period_id')))
period_id=per.id
date_from=per.date_start
date_to=per.date_stop
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')))
period_id=per.id
date_from=per.date_start
date_to=per.date_stop
res={
'period_id': period_id,
'date': time.strftime("%Y-%m-%d"),

View File

@ -400,6 +400,7 @@ class VisitBoard(Model):
'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"),
}
# TODO Delete the data if duplicate (date, patient, deparment)
return data
def onchange_date(self,context={}):