DVBA151P ;ALB/KCL - PATCH DVBA*2.7*151 INSTALL UTILITIES; 4/19/2010
 ;;2.7;AMIE;**151**;Apr 10, 1995;Build 14
 ;
PRE ;Pre-install entry point.
 ;
 ;Used to disable older versions of a template for those templates being
 ;exported with the patch.
 ; - Make sure to call the DISABLE procedure for each template name
 ;   being exported in the patch.
 ; - This must be called as a pre-init or else it will disable the
 ;   templates that are being loaded by the patch.
 ;
 N DVBVERSS,DVBVERSN,DVBACTR
 ;
 ;what the template version will be in the incoming patch
 ;(version pulled from export account)
 S DVBVERSS="151F"
 ;what the final template version should be once the template is 
 ;loaded by the patch on the target system
 S DVBVERSN="151"
 S DVBACTR=0
 ;
 D BMES^XPDUTL("**** PRE-INSTALL PROCESSING ****")
 D BMES^XPDUTL("Disabling templates...")
 D MES^XPDUTL(" ")
 ;
 D DISABLE("AID AND ATTENDANCE OR HOUSEBOUND EXAMINATION")
 D DISABLE("BLANK TEMPLATE")
 D DISABLE("BRAIN AND SPINAL CORD")
 D DISABLE("COLD INJURY PROTOCOL EXAMINATION")
 D DISABLE("CUSHINGS SYNDROME")
 D DISABLE("DIABETES MELLITUS")
 D DISABLE("EPILEPSY AND NARCOLEPSY")
 D DISABLE("EYE EXAMINATION")
 D DISABLE("GENERAL MEDICAL EXAMINATION")
 D DISABLE("GULF WAR GUIDELINES")
 D DISABLE("HYPERTENSION")
 D DISABLE("NEUROLOGICAL DISORDERS, MISCELLANEOUS")
 D DISABLE("PERIPHERAL NERVES")
 D DISABLE("PRISONER OF WAR PROTOCOL EXAMINATION")
 D DISABLE("SOCIAL AND INDUSTRIAL SURVEY")
 D DISABLE("SPINE")
 D DISABLE("TRAUMATIC BRAIN INJURY")
 ;
 D BMES^XPDUTL("  Number of templates disabled:  "_DVBACTR)
 Q
 ;
POST ;Post-install entry point.
 ;
 ;Used to rename templates that were loaded by the patch.
 ; - Make sure to call POSTP procedure for each template
 ;   name being loaded by the patch.
 ; - Must be called as a post-init in order to rename those
 ;   templates being loaded by the patch.
 ;
 N DVBVERSS,DVBVERSN,DVBACTR
 ;
 ;what the template version will be in the incoming patch
 ;(version pulled from export account)
 S DVBVERSS="151F"
 ;what the final template version should be once the template is 
 ;loaded by the patch on the target system
 S DVBVERSN="151"
 S DVBACTR=0
 ;
 D BMES^XPDUTL("**** POST-INSTALL PROCESSING ****")
 D BMES^XPDUTL("Activating templates...")
 D MES^XPDUTL(" ")
 ;
 D POSTP("AID AND ATTENDANCE OR HOUSEBOUND EXAMINATION")
 D POSTP("BLANK TEMPLATE")
 D POSTP("BRAIN AND SPINAL CORD")
 D POSTP("COLD INJURY PROTOCOL EXAMINATION")
 D POSTP("CUSHINGS SYNDROME")
 D POSTP("DIABETES MELLITUS")
 D POSTP("EPILEPSY AND NARCOLEPSY")
 D POSTP("EYE EXAMINATION")
 D POSTP("GENERAL MEDICAL EXAMINATION")
 D POSTP("GULF WAR GUIDELINES")
 D POSTP("HYPERTENSION")
 D POSTP("NEUROLOGICAL DISORDERS, MISCELLANEOUS")
 D POSTP("PERIPHERAL NERVES")
 D POSTP("PRISONER OF WAR PROTOCOL EXAMINATION")
 D POSTP("SOCIAL AND INDUSTRIAL SURVEY")
 D POSTP("SPINE")
 D POSTP("TRAUMATIC BRAIN INJURY")
 ;
 D BMES^XPDUTL("   Number of templates activated:  "_DVBACTR)
 Q
 ;
POSTP(NM) ;Rename templates loaded by the patch.
 ;
 ;This procedure is used to lookup and rename a template in the
 ;CAPRI TEMPLATE DEFINITIONS (#396.18) file. This is done to rename
 ;the imported version of a template (i.e. ACROMEGALY~142F) to it's
 ;new name/version (i.e. ACROMEGALY~142T1).
 ;
 N DVBABIEN,DVBABIE2 ;ien of CAPRI TEMPLATE DEFINITIONS file
 N DVBABST  ;template NAME field (i.e. ACROMEGALY~151F)
 N DVBABS2  ;template NAME field (i.e. ACROMEGALY~151T1)
 N DVBACH   ;flag to indicate if template version is found or not
 N DVBAFDA  ;FDA array for FILE^DIE
 N DVBAERR  ;Error array for FILE^DIE
 N DVBAMSG,DVBAMSG1  ;Used to write message to installer/Install file entry
 N DVBAADT  ;Template activation date
 ;
 S DVBABIEN=0
 ;
 ;main loop-walk through CAPRI TEMPLATE DEFINITIONS file entries
 F  S DVBABIEN=$O(^DVB(396.18,DVBABIEN)) Q:'DVBABIEN  D
 .S DVBABST=$P($G(^DVB(396.18,DVBABIEN,0)),"^",1) ;template name
 .;look for template versions just loaded by the patch (~151F)
 .I $P(DVBABST,"~",1)=NM  I $P(DVBABST,"~",2)=DVBVERSS  D
 ..S DVBABIE2=0,DVBACH=0
 ..;secondary loop-walk through CAPRI TEMPLATE DEFINITIONS file entries
 ..F  S DVBABIE2=$O(^DVB(396.18,DVBABIE2)) Q:'DVBABIE2  D
 ...S DVBABS2=$P($G(^DVB(396.18,DVBABIE2,0)),"^",1) ;template name
 ...;if new version of template already exists in file, set flag
 ...I $P(DVBABS2,"~",1)=NM  I $P(DVBABS2,"~",2)=DVBVERSN  S DVBACH=1
 ..;if new version already exists, delete the imported version (abort rename)
 ..I DVBACH=1  D
 ...S DVBAMSG="   Found existing "_NM_".  No modifications made."
 ...S DVBAFDA(396.18,DVBABIEN_",",.01)="@"
 ...D FILE^DIE("","DVBAFDA","DVBAERR")
 ..;otherwise, if new version isn't found, rename imported template
 ..;name to the new version name (i.e. ACROMEGALY~151F --> ACROMEGALY~151T1)
 ..I DVBACH=0  D
 ...S DVBAADT=$P($G(^DVB(396.18,DVBABIEN,2)),"^")
 ...S DVBACTR=DVBACTR+1
 ...S DVBAFDA(396.18,DVBABIEN_",",.01)=NM_"~"_DVBVERSN
 ...I DVBAADT=""!(DVBAADT<DT) S DVBAFDA(396.18,DVBABIEN_",",2)=DT
 ...D FILE^DIE("","DVBAFDA","DVBAERR")
 ...S DVBAMSG="   Activating: "_$P($G(^DVB(396.18,DVBABIEN,0)),"^",1)
 ..D MES^XPDUTL(DVBAMSG)
 ..I $D(DVBAERR) D
 ...D MSG^DIALOG("AE",.DVBAMSG1,"","","DVBAERR")
 ...D MES^XPDUTL(.DVBAMSG1)
 ;
 K DVBABIEN,DVBABST,DVBACH
 Q
 ;
 ; 
DISABLE(NM) ;Disable matching exam template entries.
 ;
 ;This procedure will find each entry in the CAPRI TEMPLATE DEFINITIONS
 ;(#396.18) file that matches the name (NM) of the template being exported.
 ;Once a matching entry is found, it will be disabled if the version
 ;suffix (i.e. ~139) does not match the version suffix that will be used
 ;for templates loaded by the patch on the target system (i.e. ~151T1).
 ;
 ;An entry will be disabled by doing the following:
 ; - Turning off the SELECTABLE BY USER? field. This will keep the entry
 ;   from showing in the CAPRI GUI template list.
 ; - Looking at DE-ACTIVATION DATE field. If there's no date, set it to today.
 ;
 N DVBABIEN ;ien of CAPRI TEMPLATE DEFINITIONS file
 N DVBABST  ;template NAME field (i.e. ACROMEGALY~151T1)
 N DVBACH   ;flag used to indicate template was disabled
 N DVBAFDA  ;FDA array for FILE^DIE
 N DVBAERR  ;Error array for FILE^DIE
 N DVBAMSG1 ;Used to write message to installer/Install file entry
 ;
 S DVBABIEN=0
 ;
 ;walk through CAPRI TEMPLATE DEFINITIONS file entries
 F  S DVBABIEN=$O(^DVB(396.18,DVBABIEN)) Q:'DVBABIEN  D
 .S DVBABST=$P($G(^DVB(396.18,DVBABIEN,0)),"^",1) ;template name
 .;if name matches and version is different, then disable entry
 .I $P(DVBABST,"~",1)=NM  I $P(DVBABST,"~",2)'=DVBVERSN  D
 ..S DVBACH=0
 ..;turn SELECTABLE BY USER (#7) field off
 ..I $P($G(^DVB(396.18,DVBABIEN,6)),"^",1)'="0" S DVBAFDA(396.18,DVBABIEN_",",7)="0",DVBACH=1
 ..;set DE-ACTIVATION DATE (#3) field to TODAY
 ..I $P($G(^DVB(396.18,DVBABIEN,2)),"^",2)="" S DVBAFDA(396.18,DVBABIEN_",",3)=DT,DVBACH=1
 ..;output list of disabled templates
 ..I DVBACH=1 D
 ...S DVBACTR=DVBACTR+1
 ...D FILE^DIE("","DVBAFDA","DVBAERR")
 ...D MES^XPDUTL("   Disabling: "_DVBABST)
 ...I $D(DVBAERR) D
 ....D MSG^DIALOG("AE",.DVBAMSG1,"","","DVBAERR")
 ....D MES^XPDUTL(.DVBAMSG1)
 ;
 K DVBABIEN,DVBABST,DVBACH
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDVBA151P   7311     printed  Sep 23, 2025@19:15:04                                                                                                                                                                                                    Page 2
DVBA151P  ;ALB/KCL - PATCH DVBA*2.7*151 INSTALL UTILITIES; 4/19/2010
 +1       ;;2.7;AMIE;**151**;Apr 10, 1995;Build 14
 +2       ;
PRE       ;Pre-install entry point.
 +1       ;
 +2       ;Used to disable older versions of a template for those templates being
 +3       ;exported with the patch.
 +4       ; - Make sure to call the DISABLE procedure for each template name
 +5       ;   being exported in the patch.
 +6       ; - This must be called as a pre-init or else it will disable the
 +7       ;   templates that are being loaded by the patch.
 +8       ;
 +9        NEW DVBVERSS,DVBVERSN,DVBACTR
 +10      ;
 +11      ;what the template version will be in the incoming patch
 +12      ;(version pulled from export account)
 +13       SET DVBVERSS="151F"
 +14      ;what the final template version should be once the template is 
 +15      ;loaded by the patch on the target system
 +16       SET DVBVERSN="151"
 +17       SET DVBACTR=0
 +18      ;
 +19       DO BMES^XPDUTL("**** PRE-INSTALL PROCESSING ****")
 +20       DO BMES^XPDUTL("Disabling templates...")
 +21       DO MES^XPDUTL(" ")
 +22      ;
 +23       DO DISABLE("AID AND ATTENDANCE OR HOUSEBOUND EXAMINATION")
 +24       DO DISABLE("BLANK TEMPLATE")
 +25       DO DISABLE("BRAIN AND SPINAL CORD")
 +26       DO DISABLE("COLD INJURY PROTOCOL EXAMINATION")
 +27       DO DISABLE("CUSHINGS SYNDROME")
 +28       DO DISABLE("DIABETES MELLITUS")
 +29       DO DISABLE("EPILEPSY AND NARCOLEPSY")
 +30       DO DISABLE("EYE EXAMINATION")
 +31       DO DISABLE("GENERAL MEDICAL EXAMINATION")
 +32       DO DISABLE("GULF WAR GUIDELINES")
 +33       DO DISABLE("HYPERTENSION")
 +34       DO DISABLE("NEUROLOGICAL DISORDERS, MISCELLANEOUS")
 +35       DO DISABLE("PERIPHERAL NERVES")
 +36       DO DISABLE("PRISONER OF WAR PROTOCOL EXAMINATION")
 +37       DO DISABLE("SOCIAL AND INDUSTRIAL SURVEY")
 +38       DO DISABLE("SPINE")
 +39       DO DISABLE("TRAUMATIC BRAIN INJURY")
 +40      ;
 +41       DO BMES^XPDUTL("  Number of templates disabled:  "_DVBACTR)
 +42       QUIT 
 +43      ;
POST      ;Post-install entry point.
 +1       ;
 +2       ;Used to rename templates that were loaded by the patch.
 +3       ; - Make sure to call POSTP procedure for each template
 +4       ;   name being loaded by the patch.
 +5       ; - Must be called as a post-init in order to rename those
 +6       ;   templates being loaded by the patch.
 +7       ;
 +8        NEW DVBVERSS,DVBVERSN,DVBACTR
 +9       ;
 +10      ;what the template version will be in the incoming patch
 +11      ;(version pulled from export account)
 +12       SET DVBVERSS="151F"
 +13      ;what the final template version should be once the template is 
 +14      ;loaded by the patch on the target system
 +15       SET DVBVERSN="151"
 +16       SET DVBACTR=0
 +17      ;
 +18       DO BMES^XPDUTL("**** POST-INSTALL PROCESSING ****")
 +19       DO BMES^XPDUTL("Activating templates...")
 +20       DO MES^XPDUTL(" ")
 +21      ;
 +22       DO POSTP("AID AND ATTENDANCE OR HOUSEBOUND EXAMINATION")
 +23       DO POSTP("BLANK TEMPLATE")
 +24       DO POSTP("BRAIN AND SPINAL CORD")
 +25       DO POSTP("COLD INJURY PROTOCOL EXAMINATION")
 +26       DO POSTP("CUSHINGS SYNDROME")
 +27       DO POSTP("DIABETES MELLITUS")
 +28       DO POSTP("EPILEPSY AND NARCOLEPSY")
 +29       DO POSTP("EYE EXAMINATION")
 +30       DO POSTP("GENERAL MEDICAL EXAMINATION")
 +31       DO POSTP("GULF WAR GUIDELINES")
 +32       DO POSTP("HYPERTENSION")
 +33       DO POSTP("NEUROLOGICAL DISORDERS, MISCELLANEOUS")
 +34       DO POSTP("PERIPHERAL NERVES")
 +35       DO POSTP("PRISONER OF WAR PROTOCOL EXAMINATION")
 +36       DO POSTP("SOCIAL AND INDUSTRIAL SURVEY")
 +37       DO POSTP("SPINE")
 +38       DO POSTP("TRAUMATIC BRAIN INJURY")
 +39      ;
 +40       DO BMES^XPDUTL("   Number of templates activated:  "_DVBACTR)
 +41       QUIT 
 +42      ;
POSTP(NM) ;Rename templates loaded by the patch.
 +1       ;
 +2       ;This procedure is used to lookup and rename a template in the
 +3       ;CAPRI TEMPLATE DEFINITIONS (#396.18) file. This is done to rename
 +4       ;the imported version of a template (i.e. ACROMEGALY~142F) to it's
 +5       ;new name/version (i.e. ACROMEGALY~142T1).
 +6       ;
 +7       ;ien of CAPRI TEMPLATE DEFINITIONS file
           NEW DVBABIEN,DVBABIE2
 +8       ;template NAME field (i.e. ACROMEGALY~151F)
           NEW DVBABST
 +9       ;template NAME field (i.e. ACROMEGALY~151T1)
           NEW DVBABS2
 +10      ;flag to indicate if template version is found or not
           NEW DVBACH
 +11      ;FDA array for FILE^DIE
           NEW DVBAFDA
 +12      ;Error array for FILE^DIE
           NEW DVBAERR
 +13      ;Used to write message to installer/Install file entry
           NEW DVBAMSG,DVBAMSG1
 +14      ;Template activation date
           NEW DVBAADT
 +15      ;
 +16       SET DVBABIEN=0
 +17      ;
 +18      ;main loop-walk through CAPRI TEMPLATE DEFINITIONS file entries
 +19       FOR 
               SET DVBABIEN=$ORDER(^DVB(396.18,DVBABIEN))
               if 'DVBABIEN
                   QUIT 
               Begin DoDot:1
 +20      ;template name
                   SET DVBABST=$PIECE($GET(^DVB(396.18,DVBABIEN,0)),"^",1)
 +21      ;look for template versions just loaded by the patch (~151F)
 +22               IF $PIECE(DVBABST,"~",1)=NM
                       IF $PIECE(DVBABST,"~",2)=DVBVERSS
                           Begin DoDot:2
 +23                           SET DVBABIE2=0
                               SET DVBACH=0
 +24      ;secondary loop-walk through CAPRI TEMPLATE DEFINITIONS file entries
 +25                           FOR 
                                   SET DVBABIE2=$ORDER(^DVB(396.18,DVBABIE2))
                                   if 'DVBABIE2
                                       QUIT 
                                   Begin DoDot:3
 +26      ;template name
                                       SET DVBABS2=$PIECE($GET(^DVB(396.18,DVBABIE2,0)),"^",1)
 +27      ;if new version of template already exists in file, set flag
 +28                                   IF $PIECE(DVBABS2,"~",1)=NM
                                           IF $PIECE(DVBABS2,"~",2)=DVBVERSN
                                               SET DVBACH=1
                                   End DoDot:3
 +29      ;if new version already exists, delete the imported version (abort rename)
 +30                           IF DVBACH=1
                                   Begin DoDot:3
 +31                                   SET DVBAMSG="   Found existing "_NM_".  No modifications made."
 +32                                   SET DVBAFDA(396.18,DVBABIEN_",",.01)="@"
 +33                                   DO FILE^DIE("","DVBAFDA","DVBAERR")
                                   End DoDot:3
 +34      ;otherwise, if new version isn't found, rename imported template
 +35      ;name to the new version name (i.e. ACROMEGALY~151F --> ACROMEGALY~151T1)
 +36                           IF DVBACH=0
                                   Begin DoDot:3
 +37                                   SET DVBAADT=$PIECE($GET(^DVB(396.18,DVBABIEN,2)),"^")
 +38                                   SET DVBACTR=DVBACTR+1
 +39                                   SET DVBAFDA(396.18,DVBABIEN_",",.01)=NM_"~"_DVBVERSN
 +40                                   IF DVBAADT=""!(DVBAADT<DT)
                                           SET DVBAFDA(396.18,DVBABIEN_",",2)=DT
 +41                                   DO FILE^DIE("","DVBAFDA","DVBAERR")
 +42                                   SET DVBAMSG="   Activating: "_$PIECE($GET(^DVB(396.18,DVBABIEN,0)),"^",1)
                                   End DoDot:3
 +43                           DO MES^XPDUTL(DVBAMSG)
 +44                           IF $DATA(DVBAERR)
                                   Begin DoDot:3
 +45                                   DO MSG^DIALOG("AE",.DVBAMSG1,"","","DVBAERR")
 +46                                   DO MES^XPDUTL(.DVBAMSG1)
                                   End DoDot:3
                           End DoDot:2
               End DoDot:1
 +47      ;
 +48       KILL DVBABIEN,DVBABST,DVBACH
 +49       QUIT 
 +50      ;
 +51      ; 
DISABLE(NM) ;Disable matching exam template entries.
 +1       ;
 +2       ;This procedure will find each entry in the CAPRI TEMPLATE DEFINITIONS
 +3       ;(#396.18) file that matches the name (NM) of the template being exported.
 +4       ;Once a matching entry is found, it will be disabled if the version
 +5       ;suffix (i.e. ~139) does not match the version suffix that will be used
 +6       ;for templates loaded by the patch on the target system (i.e. ~151T1).
 +7       ;
 +8       ;An entry will be disabled by doing the following:
 +9       ; - Turning off the SELECTABLE BY USER? field. This will keep the entry
 +10      ;   from showing in the CAPRI GUI template list.
 +11      ; - Looking at DE-ACTIVATION DATE field. If there's no date, set it to today.
 +12      ;
 +13      ;ien of CAPRI TEMPLATE DEFINITIONS file
           NEW DVBABIEN
 +14      ;template NAME field (i.e. ACROMEGALY~151T1)
           NEW DVBABST
 +15      ;flag used to indicate template was disabled
           NEW DVBACH
 +16      ;FDA array for FILE^DIE
           NEW DVBAFDA
 +17      ;Error array for FILE^DIE
           NEW DVBAERR
 +18      ;Used to write message to installer/Install file entry
           NEW DVBAMSG1
 +19      ;
 +20       SET DVBABIEN=0
 +21      ;
 +22      ;walk through CAPRI TEMPLATE DEFINITIONS file entries
 +23       FOR 
               SET DVBABIEN=$ORDER(^DVB(396.18,DVBABIEN))
               if 'DVBABIEN
                   QUIT 
               Begin DoDot:1
 +24      ;template name
                   SET DVBABST=$PIECE($GET(^DVB(396.18,DVBABIEN,0)),"^",1)
 +25      ;if name matches and version is different, then disable entry
 +26               IF $PIECE(DVBABST,"~",1)=NM
                       IF $PIECE(DVBABST,"~",2)'=DVBVERSN
                           Begin DoDot:2
 +27                           SET DVBACH=0
 +28      ;turn SELECTABLE BY USER (#7) field off
 +29                           IF $PIECE($GET(^DVB(396.18,DVBABIEN,6)),"^",1)'="0"
                                   SET DVBAFDA(396.18,DVBABIEN_",",7)="0"
                                   SET DVBACH=1
 +30      ;set DE-ACTIVATION DATE (#3) field to TODAY
 +31                           IF $PIECE($GET(^DVB(396.18,DVBABIEN,2)),"^",2)=""
                                   SET DVBAFDA(396.18,DVBABIEN_",",3)=DT
                                   SET DVBACH=1
 +32      ;output list of disabled templates
 +33                           IF DVBACH=1
                                   Begin DoDot:3
 +34                                   SET DVBACTR=DVBACTR+1
 +35                                   DO FILE^DIE("","DVBAFDA","DVBAERR")
 +36                                   DO MES^XPDUTL("   Disabling: "_DVBABST)
 +37                                   IF $DATA(DVBAERR)
                                           Begin DoDot:4
 +38                                           DO MSG^DIALOG("AE",.DVBAMSG1,"","","DVBAERR")
 +39                                           DO MES^XPDUTL(.DVBAMSG1)
                                           End DoDot:4
                                   End DoDot:3
                           End DoDot:2
               End DoDot:1
 +40      ;
 +41       KILL DVBABIEN,DVBABST,DVBACH
 +42       QUIT