UPDATE vclib.t_dataform_template t
SET templateData = OVERLAY(
    t.templateData 
    PLACING ';     if(@bo->{ObjectProperties / ObjectTypeID} IS "AKUZ.DOCTOR_VISIT")
    begin()
    @bo->{MedicalExamination / DoctorVisitNewLink} := @bo;
    end;'
    FROM POSITION(
        ';' IN SUBSTRING(
            t.templateData 
            FROM POSITION('@bo->{MedicalExamination} := (@ap.GetInstance("AKUZ.MEDICAL_EXAMINATION' IN t.templateData)
        )
    ) + POSITION('@bo->{MedicalExamination} := (@ap.GetInstance("AKUZ.MEDICAL_EXAMINATION' IN t.templateData) - 1
    FOR 1
)
FROM vclib.t_entities e
WHERE e.entityid = t.entities
  AND t.lastusagedatetime > '2025-01-01'
  AND t.templatedata LIKE '%@bo->{MedicalExamination} := (@ap.GetInstance("AKUZ.MEDICAL_EXAMINATION%'
  AND e.entname <> 'PROTOCOL_PEDIATRIST';