migrate patient_name visit and hdcase
parent
af3bc05fe4
commit
44beefcb08
|
@ -18,4 +18,5 @@ from . import clinic_setting
|
||||||
#from . import update_line_amount
|
#from . import update_line_amount
|
||||||
#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
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
import time
|
||||||
|
from netforce.migration import Migration
|
||||||
|
from netforce.model import Model, fields, get_model
|
||||||
|
|
||||||
|
|
||||||
|
class UpdatePatientName(Migration):
|
||||||
|
_name='update.petient.name'
|
||||||
|
_version="2.12.9"
|
||||||
|
|
||||||
|
def migrate(self):
|
||||||
|
datenow=time.strftime("%Y-%m-%d")
|
||||||
|
y,m,d=datenow.split("-")
|
||||||
|
|
||||||
|
for f, model in [('date', 'clinic.hd.case'),('visit_date','clinic.visit')]:
|
||||||
|
cond=[
|
||||||
|
[f,'>=','%s-01-01'%(y)],
|
||||||
|
[f,'<=',datenow],
|
||||||
|
['patient_name','=',None],
|
||||||
|
]
|
||||||
|
print("update %s ... "%model)
|
||||||
|
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)
|
||||||
|
#print("%s/%s"%(index+1, len(hdcases)))
|
||||||
|
|
||||||
|
UpdatePatientName.register()
|
Loading…
Reference in New Issue