LR52P476 ;AITC/CR - Post Installation for Patch 476 ; 11/28/17 12:36pm
 ;;5.2;LAB SERVICE;**476**;Sep 27, 1994;Build 11
 ; Stuff codes #1, #20.5 and #26.5 in the Execute Code file, #62.07, field #1,
 ; for the three records that follow below:
 ;
 Q
ERR ; keep a history of any error that happened during the installation
 D BMES^XPDUTL("Post initialization of LR*5.2*476 did not complete.")
 I $D(LRERR) D BMES^XPDUTL(.LRERR)
 ;alert the user if any error occurred
 I $D(LRERR) D
 .N LRTEXT,XMDUZ,XMY,XMDUZ,XMSUB,XMTEXT
 .S XMSUB="ERROR ENCOUNTERED WHILE INSTALLING LR*5.2*476"
 .S XMDUZ=.5
 .S XMY(DUZ)="",XMY(XMDUZ)=""
 .S LRTEXT(1)="During the post-installation operations of patch"
 .S LRTEXT(2)="LR*5.2*476, an error occurred. Please look at the"
 .S LRTEXT(3)="installation log of the patch for details."
 .S XMTEXT="LRTEXT("
 .D ^XMD
 Q
 ;
POST ; edit field #1 for the Bacteriology record (#7)
 I $G(DUZ)="" D BMES^XPDUTL("Your DUZ is not identified in VistA, quiting...") Q
 ;
 D BMES^XPDUTL("Starting Post-Initialization for LR*5.2*476 ...")
 N DA,DIE,DR,LRFDA,LRCODE1,LRCODE2,LRCODE3,LRNECODE,LRERR,LRMICROEC,LRNEC
 ;
 S LRCODE1="BACTERIOLOGY",LRCODE2="TB BACTERIOLOGY",LRCODE3="MYCOLOGY"
 S LRIEN1=$$FIND1^DIC(62.07,,"MX",LRCODE1) ;IEN for the execute code record
 S LRIEN2=$$FIND1^DIC(62.07,,"MX",LRCODE2)
 S LRIEN3=$$FIND1^DIC(62.07,,"MX",LRCODE3)
 F DA=LRIEN1,LRIEN2,LRIEN3 L +^LAB(62.07,DA):5 I '$T D BMES^XPDUTL("Cannot lock file - try later.") G ERR
 ;
 S LRMICROEC=$$GET1^DIQ(62.07,LRIEN1_",",1) ; current execute code before changes
 D BMES^XPDUTL("Execute Code for Bacteriology before changes:")
 D BMES^XPDUTL(LRMICROEC)
 S LRNECODE="S DR=""11.55////""_DUZ_"";.055;.05;.99;11.6;11.5;1;S LRSPEC=$P(LRBG0,U,5),Y=$S(LRSPEC=71:11.57,LRSPEC=68:11.58,1:0);11.57;S Y=0;11.58"",LREND=0 D ^DIE S:$D(Y) LREND=1 Q:$D(Y)  D ^LRMIBUG Q:LREND  S DR=""13;11"" D ^DIE Q"
 ; prepare field for new data
 S DIE="^LAB(62.07,",DR="1///@",DA=LRIEN1 D ^DIE
 ;
 S DA=LRIEN1
 D UPDATE
 D BMES^XPDUTL("Execute Code for Bacteriology after changes:")
 S LRNEC=$$GET1^DIQ(62.07,LRIEN1_",",1) ; updated execute code 
 D BMES^XPDUTL(LRNEC)
 D BMES^XPDUTL("============================================================")
 ;
 ; edit field #1 for the TB Bacteriology record (#8)
 S LRMICROEC=$$GET1^DIQ(62.07,LRIEN2_",",1)
 D BMES^XPDUTL("Execute Code for TB Bacteriology before changes:")
 D BMES^XPDUTL(LRMICROEC)
 S LRNECODE="S DR=""25.5////""_DUZ_"";.05;.99;23;24;25;26;26.5;27;22"",DR(2,63.39)="".01;1:99"" D ^DIE Q"
 S DIE="^LAB(62.07,",DR="1///@",DA=LRIEN2 D ^DIE
 ;
 S DA=LRIEN2
 D UPDATE
 D BMES^XPDUTL("Execute Code for TB Bacteriology after changes:")
 S LRNEC=$$GET1^DIQ(62.07,LRIEN2_",",1)
 D BMES^XPDUTL(LRNEC)
 D BMES^XPDUTL("============================================================")
 ; edit field #1 for the Mycology record (#9)
 S LRMICROEC=$$GET1^DIQ(62.07,LRIEN3_",",1)
 D BMES^XPDUTL("Execute Code for Mycology before changes:")
 D BMES^XPDUTL(LRMICROEC)
 S LRNECODE="S DR=""19.5////""_DUZ_"";.05;.99;19;19.2;20;20.5;21;18"",DR(2,63.37)="".01:99"" D ^DIE Q"
 S DIE="^LAB(62.07,",DR="1///@",DA=LRIEN3 D ^DIE
 ;
 S DA=LRIEN3
 D UPDATE
 D BMES^XPDUTL("Execute Code for Mycology after changes:")
 S LRNEC=$$GET1^DIQ(62.07,LRIEN3_",",1)
 D BMES^XPDUTL(LRNEC)
 D BMES^XPDUTL("Post-initialization of LR*5.2*476 completed!")
 F DA=LRIEN1,LRIEN2,LRIEN3 L -^LAB(62.07,DA)
 Q
 ;
UPDATE ; common code for update of field #1, Execute Code File
 S LRFDA(62.07,DA_",",1)=LRNECODE
 D FILE^DIE("E","LRFDA","LRERR")
 I $D(LRERR) D BMES^XPDUTL("Unable to edit the Execute Code field of Record #: "_DA) D ERR
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HLR52P476   3685     printed  Sep 23, 2025@19:39:59                                                                                                                                                                                                    Page 2
LR52P476  ;AITC/CR - Post Installation for Patch 476 ; 11/28/17 12:36pm
 +1       ;;5.2;LAB SERVICE;**476**;Sep 27, 1994;Build 11
 +2       ; Stuff codes #1, #20.5 and #26.5 in the Execute Code file, #62.07, field #1,
 +3       ; for the three records that follow below:
 +4       ;
 +5        QUIT 
ERR       ; keep a history of any error that happened during the installation
 +1        DO BMES^XPDUTL("Post initialization of LR*5.2*476 did not complete.")
 +2        IF $DATA(LRERR)
               DO BMES^XPDUTL(.LRERR)
 +3       ;alert the user if any error occurred
 +4        IF $DATA(LRERR)
               Begin DoDot:1
 +5                NEW LRTEXT,XMDUZ,XMY,XMDUZ,XMSUB,XMTEXT
 +6                SET XMSUB="ERROR ENCOUNTERED WHILE INSTALLING LR*5.2*476"
 +7                SET XMDUZ=.5
 +8                SET XMY(DUZ)=""
                   SET XMY(XMDUZ)=""
 +9                SET LRTEXT(1)="During the post-installation operations of patch"
 +10               SET LRTEXT(2)="LR*5.2*476, an error occurred. Please look at the"
 +11               SET LRTEXT(3)="installation log of the patch for details."
 +12               SET XMTEXT="LRTEXT("
 +13               DO ^XMD
               End DoDot:1
 +14       QUIT 
 +15      ;
POST      ; edit field #1 for the Bacteriology record (#7)
 +1        IF $GET(DUZ)=""
               DO BMES^XPDUTL("Your DUZ is not identified in VistA, quiting...")
               QUIT 
 +2       ;
 +3        DO BMES^XPDUTL("Starting Post-Initialization for LR*5.2*476 ...")
 +4        NEW DA,DIE,DR,LRFDA,LRCODE1,LRCODE2,LRCODE3,LRNECODE,LRERR,LRMICROEC,LRNEC
 +5       ;
 +6        SET LRCODE1="BACTERIOLOGY"
           SET LRCODE2="TB BACTERIOLOGY"
           SET LRCODE3="MYCOLOGY"
 +7       ;IEN for the execute code record
           SET LRIEN1=$$FIND1^DIC(62.07,,"MX",LRCODE1)
 +8        SET LRIEN2=$$FIND1^DIC(62.07,,"MX",LRCODE2)
 +9        SET LRIEN3=$$FIND1^DIC(62.07,,"MX",LRCODE3)
 +10       FOR DA=LRIEN1,LRIEN2,LRIEN3
               LOCK +^LAB(62.07,DA):5
               IF '$TEST
                   DO BMES^XPDUTL("Cannot lock file - try later.")
                   GOTO ERR
 +11      ;
 +12      ; current execute code before changes
           SET LRMICROEC=$$GET1^DIQ(62.07,LRIEN1_",",1)
 +13       DO BMES^XPDUTL("Execute Code for Bacteriology before changes:")
 +14       DO BMES^XPDUTL(LRMICROEC)
 +15       SET LRNECODE="S DR=""11.55////""_DUZ_"";.055;.05;.99;11.6;11.5;1;S LRSPEC=$P(LRBG0,U,5),Y=$S(LRSPEC=71:11.57,LRSPEC=68:11.58,1:0);11.57;S Y=0;11.58"",LREND=0 D ^DIE S:$D(Y) LREND=1 Q:$D(Y)  D ^LRMIBUG Q:LREND  S DR=""13;11"" D ^DIE Q"
 +16      ; prepare field for new data
 +17       SET DIE="^LAB(62.07,"
           SET DR="1///@"
           SET DA=LRIEN1
           DO ^DIE
 +18      ;
 +19       SET DA=LRIEN1
 +20       DO UPDATE
 +21       DO BMES^XPDUTL("Execute Code for Bacteriology after changes:")
 +22      ; updated execute code 
           SET LRNEC=$$GET1^DIQ(62.07,LRIEN1_",",1)
 +23       DO BMES^XPDUTL(LRNEC)
 +24       DO BMES^XPDUTL("============================================================")
 +25      ;
 +26      ; edit field #1 for the TB Bacteriology record (#8)
 +27       SET LRMICROEC=$$GET1^DIQ(62.07,LRIEN2_",",1)
 +28       DO BMES^XPDUTL("Execute Code for TB Bacteriology before changes:")
 +29       DO BMES^XPDUTL(LRMICROEC)
 +30       SET LRNECODE="S DR=""25.5////""_DUZ_"";.05;.99;23;24;25;26;26.5;27;22"",DR(2,63.39)="".01;1:99"" D ^DIE Q"
 +31       SET DIE="^LAB(62.07,"
           SET DR="1///@"
           SET DA=LRIEN2
           DO ^DIE
 +32      ;
 +33       SET DA=LRIEN2
 +34       DO UPDATE
 +35       DO BMES^XPDUTL("Execute Code for TB Bacteriology after changes:")
 +36       SET LRNEC=$$GET1^DIQ(62.07,LRIEN2_",",1)
 +37       DO BMES^XPDUTL(LRNEC)
 +38       DO BMES^XPDUTL("============================================================")
 +39      ; edit field #1 for the Mycology record (#9)
 +40       SET LRMICROEC=$$GET1^DIQ(62.07,LRIEN3_",",1)
 +41       DO BMES^XPDUTL("Execute Code for Mycology before changes:")
 +42       DO BMES^XPDUTL(LRMICROEC)
 +43       SET LRNECODE="S DR=""19.5////""_DUZ_"";.05;.99;19;19.2;20;20.5;21;18"",DR(2,63.37)="".01:99"" D ^DIE Q"
 +44       SET DIE="^LAB(62.07,"
           SET DR="1///@"
           SET DA=LRIEN3
           DO ^DIE
 +45      ;
 +46       SET DA=LRIEN3
 +47       DO UPDATE
 +48       DO BMES^XPDUTL("Execute Code for Mycology after changes:")
 +49       SET LRNEC=$$GET1^DIQ(62.07,LRIEN3_",",1)
 +50       DO BMES^XPDUTL(LRNEC)
 +51       DO BMES^XPDUTL("Post-initialization of LR*5.2*476 completed!")
 +52       FOR DA=LRIEN1,LRIEN2,LRIEN3
               LOCK -^LAB(62.07,DA)
 +53       QUIT 
 +54      ;
UPDATE    ; common code for update of field #1, Execute Code File
 +1        SET LRFDA(62.07,DA_",",1)=LRNECODE
 +2        DO FILE^DIE("E","LRFDA","LRERR")
 +3        IF $DATA(LRERR)
               DO BMES^XPDUTL("Unable to edit the Execute Code field of Record #: "_DA)
               DO ERR
 +4        QUIT