RORP027 ;ALB/TK - CCR PRE/POST-INSTALL PATCH 27 ;29 Jul 2014  4:02 PM
 ;;1.5;CLINICAL CASE REGISTRIES;**27**;Feb 17, 2006;Build 58
 ;
 ; This routine uses the following IAs:
 ; #3277         OWNSKEY^XUSRB (supported)
 ; #10141        BMES^XPDUTL
 ;               MES^XPDUTL
 ;
 ;******************************************************************************
 ;******************************************************************************
 ;                       --- ROUTINE MODIFICATION LOG ---
 ;        
 ;PKG/PATCH    DATE        DEVELOPER    MODIFICATION
 ;-----------  ----------  -----------  ----------------------------------------
 ;ROR*1.5*27   FEB  2015   T KOPP       Patch 27 pre and post install
 ;******************************************************************************
 ;******************************************************************************
 ;
 Q
 ;Pre-Install routine for Patch 27
PRE ;
 ; CHECK FOR ROR VA IRM KEY, ABORT IF USER DOES NOT POSSESS
 N RORKEYOK
 D BMES^XPDUTL("Verifying installing user has the ROR VA IRM security key")
 D OWNSKEY^XUSRB(.RORKEYOK,"ROR VA IRM",DUZ)
 I '$G(RORKEYOK(0)) D  Q
 . S XPDABORT=1
 . D BMES^XPDUTL("****** INSTALL ABORTED!!! ******")
 . D BMES^XPDUTL("This patch can only be installed by a user who is assigned the ROR VA IRM key")
 . D BMES^XPDUTL("Restart the installation again once the appropriate key has been assigned")
 D BMES^XPDUTL("  User has the ROR VA IRM key - OK to install")
 Q
 ;
 ;Post-Install routine for Patch 27
POST ;
 N CT,ROR,RORERR,REGNAME,REGIEN,RORBUF,RORFDA,RORMSG,RORMSGX
 D BMES^XPDUTL("Post install started")
 ; Check if any registries from patch 24 have been inactivated
 S ROR(1)="VA ALS",ROR(2)="VA OSTEOPOROSIS",ROR(3)="VA HCC",ROR(4)="VA LUNG CANCER"
 S ROR(5)="VA MELANOMA",ROR(6)="VA COLORECTAL CANCER",ROR(7)="VA PANCREATIC CANCER",ROR(8)="VA PROSTATE CANCER"
 D BMES^XPDUTL("Checking for inactive registries")
 S CT=1,RORERR=0
 F ROR=1:1:8 D
 . K RORBUF,RORMSGX,RORFDA
 . S REGIEN=$$REGIEN^RORUTL02(ROR(ROR),"11I",.RORBUF)
 . I $G(RORBUF("DILIST","ID",1,11)) D
 .. S RORFDA(798.1,REGIEN_",",11)=0
 .. D FILE^DIE(,"RORFDA","RORMSGX")
 .. S CT=CT+1,RORMSG(CT)=$J("",10)_ROR(ROR)
 .. I '$G(RORMSGX) D
 ... S RORMSG(CT)=RORMSG(CT)_" was reactivated"
 .. E  D
 ... S RORMSG(CT)=RORMSG(CT)_" must be manually reactivated",RORERR=1
 I CT=1 K RORMSG D BMES^XPDUTL("No inactive registries found")
 I CT>1 D
 . S RORMSG(1)="REGISTRY UPDATE STATUS:" D MES^XPDUTL(.RORMSG)
 . I RORERR D BMES^XPDUTL("***** AT LEAST ONE REGISTRY MUST BE MANUALLY REACTIVATED *****")
 D BMES^XPDUTL("    Step Complete")
 ;
 D BMES^XPDUTL("Updating List Items")
 D UPDLIST
 D BMES^XPDUTL("    Step Complete")
 ;
 D BMES^XPDUTL("Post install completed")
 Q
 ;
UPDLIST ;
 N RORI,RORI1,RORREG,RORDATA,REGIEN,Z,CT
 F RORI=1:1 S RORREG=$P($P($T(@("REGS+"_RORI_"^RORP027")),";;",2),U) Q:RORREG=""  D
 . S REGIEN=$$REGIEN^RORUTL02(RORREG)
 . I REGIEN>0 D
 .. F RORI1=1:1 S RORDATA=$P($T(@("LISTITEM+"_RORI1_"^RORP027")),";;",2) Q:RORDATA=""  D
 ... Q:$D(^ROR(799.1,"KEY",+$P(RORDATA,U,2),REGIEN,+$P(RORDATA,U,3)))  ; Entry already exists
 ... K RORFDA,RORMSG,RORERR,DIERR
 ... S RORFDA(799.1,"?+1,",.01)=$P(RORDATA,U)
 ... S RORFDA(799.1,"?+1,",.02)=$P(RORDATA,U,2)
 ... S RORFDA(799.1,"?+1,",.03)=REGIEN
 ... S RORFDA(799.1,"?+1,",.04)=$P(RORDATA,U,3)
 ... D UPDATE^DIE(,"RORFDA",,"RORMSG")
 ... I $G(DIERR) D
 .... K RORERR
 .... S RORERR(1)="     New entry for "_RORREG_"(ien #"_REGIEN_") encountered the following error"
 .... S RORERR(2)="     and was not added to the ROR LIST ITEM file."
 .... S RORERR(3)="     (Data = "_RORDATA_")"
 .... S RORERR(4)="     Please report this error to your CCR contact:"
 .... S RORERR(5)=""
 .... S Z=0,CT=5 F  S Z=$O(RORMSG("DIERR",1,"TEXT",Z)) Q:'Z  S CT=CT+1,RORERR(CT)=$J("",6)_$G(RORMSG("DIERR",1,"TEXT",Z))
 .... D MES^XPDUTL(.RORERR)
 Q
 ;
REGS ; List of registries whose LIST ITEM entries should be added to file 799.1
 ;;VA ALS
 ;;VA APNEA
 ;;VA COLORECTAL CANCER
 ;;VA HCC
 ;;VA LUNG CANCER
 ;;VA MELANOMA
 ;;VA OSTEOPOROSIS
 ;;VA PANCREATIC CANCER
 ;;VA PROSTATE CANCER
 ;;
 ;
LISTITEM ;  Entries to add to file 799.1  text^group^code
 ;;eGFR by CKD-EPI^7^3
 ;;eGFR by MDRD^7^2
 ;;Creatinine clearance by Cockcroft-Gault^7^1
 ;;FIB-4^6^4
 ;;APRI^6^3
 ;;MELD-Na^6^2
 ;;MELD^6^1
 ;;BMI^5^1
 ;;Registry Lab^3^1
 ;;
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRORP027   4452     printed  Sep 23, 2025@19:18:35                                                                                                                                                                                                     Page 2
RORP027   ;ALB/TK - CCR PRE/POST-INSTALL PATCH 27 ;29 Jul 2014  4:02 PM
 +1       ;;1.5;CLINICAL CASE REGISTRIES;**27**;Feb 17, 2006;Build 58
 +2       ;
 +3       ; This routine uses the following IAs:
 +4       ; #3277         OWNSKEY^XUSRB (supported)
 +5       ; #10141        BMES^XPDUTL
 +6       ;               MES^XPDUTL
 +7       ;
 +8       ;******************************************************************************
 +9       ;******************************************************************************
 +10      ;                       --- ROUTINE MODIFICATION LOG ---
 +11      ;        
 +12      ;PKG/PATCH    DATE        DEVELOPER    MODIFICATION
 +13      ;-----------  ----------  -----------  ----------------------------------------
 +14      ;ROR*1.5*27   FEB  2015   T KOPP       Patch 27 pre and post install
 +15      ;******************************************************************************
 +16      ;******************************************************************************
 +17      ;
 +18       QUIT 
 +19      ;Pre-Install routine for Patch 27
PRE       ;
 +1       ; CHECK FOR ROR VA IRM KEY, ABORT IF USER DOES NOT POSSESS
 +2        NEW RORKEYOK
 +3        DO BMES^XPDUTL("Verifying installing user has the ROR VA IRM security key")
 +4        DO OWNSKEY^XUSRB(.RORKEYOK,"ROR VA IRM",DUZ)
 +5        IF '$GET(RORKEYOK(0))
               Begin DoDot:1
 +6                SET XPDABORT=1
 +7                DO BMES^XPDUTL("****** INSTALL ABORTED!!! ******")
 +8                DO BMES^XPDUTL("This patch can only be installed by a user who is assigned the ROR VA IRM key")
 +9                DO BMES^XPDUTL("Restart the installation again once the appropriate key has been assigned")
               End DoDot:1
               QUIT 
 +10       DO BMES^XPDUTL("  User has the ROR VA IRM key - OK to install")
 +11       QUIT 
 +12      ;
 +13      ;Post-Install routine for Patch 27
POST      ;
 +1        NEW CT,ROR,RORERR,REGNAME,REGIEN,RORBUF,RORFDA,RORMSG,RORMSGX
 +2        DO BMES^XPDUTL("Post install started")
 +3       ; Check if any registries from patch 24 have been inactivated
 +4        SET ROR(1)="VA ALS"
           SET ROR(2)="VA OSTEOPOROSIS"
           SET ROR(3)="VA HCC"
           SET ROR(4)="VA LUNG CANCER"
 +5        SET ROR(5)="VA MELANOMA"
           SET ROR(6)="VA COLORECTAL CANCER"
           SET ROR(7)="VA PANCREATIC CANCER"
           SET ROR(8)="VA PROSTATE CANCER"
 +6        DO BMES^XPDUTL("Checking for inactive registries")
 +7        SET CT=1
           SET RORERR=0
 +8        FOR ROR=1:1:8
               Begin DoDot:1
 +9                KILL RORBUF,RORMSGX,RORFDA
 +10               SET REGIEN=$$REGIEN^RORUTL02(ROR(ROR),"11I",.RORBUF)
 +11               IF $GET(RORBUF("DILIST","ID",1,11))
                       Begin DoDot:2
 +12                       SET RORFDA(798.1,REGIEN_",",11)=0
 +13                       DO FILE^DIE(,"RORFDA","RORMSGX")
 +14                       SET CT=CT+1
                           SET RORMSG(CT)=$JUSTIFY("",10)_ROR(ROR)
 +15                       IF '$GET(RORMSGX)
                               Begin DoDot:3
 +16                               SET RORMSG(CT)=RORMSG(CT)_" was reactivated"
                               End DoDot:3
 +17                      IF '$TEST
                               Begin DoDot:3
 +18                               SET RORMSG(CT)=RORMSG(CT)_" must be manually reactivated"
                                   SET RORERR=1
                               End DoDot:3
                       End DoDot:2
               End DoDot:1
 +19       IF CT=1
               KILL RORMSG
               DO BMES^XPDUTL("No inactive registries found")
 +20       IF CT>1
               Begin DoDot:1
 +21               SET RORMSG(1)="REGISTRY UPDATE STATUS:"
                   DO MES^XPDUTL(.RORMSG)
 +22               IF RORERR
                       DO BMES^XPDUTL("***** AT LEAST ONE REGISTRY MUST BE MANUALLY REACTIVATED *****")
               End DoDot:1
 +23       DO BMES^XPDUTL("    Step Complete")
 +24      ;
 +25       DO BMES^XPDUTL("Updating List Items")
 +26       DO UPDLIST
 +27       DO BMES^XPDUTL("    Step Complete")
 +28      ;
 +29       DO BMES^XPDUTL("Post install completed")
 +30       QUIT 
 +31      ;
UPDLIST   ;
 +1        NEW RORI,RORI1,RORREG,RORDATA,REGIEN,Z,CT
 +2        FOR RORI=1:1
               SET RORREG=$PIECE($PIECE($TEXT(@("REGS+"_RORI_"^RORP027")),";;",2),U)
               if RORREG=""
                   QUIT 
               Begin DoDot:1
 +3                SET REGIEN=$$REGIEN^RORUTL02(RORREG)
 +4                IF REGIEN>0
                       Begin DoDot:2
 +5                        FOR RORI1=1:1
                               SET RORDATA=$PIECE($TEXT(@("LISTITEM+"_RORI1_"^RORP027")),";;",2)
                               if RORDATA=""
                                   QUIT 
                               Begin DoDot:3
 +6       ; Entry already exists
                                   if $DATA(^ROR(799.1,"KEY",+$PIECE(RORDATA,U,2),REGIEN,+$PIECE(RORDATA,U,3)))
                                       QUIT 
 +7                                KILL RORFDA,RORMSG,RORERR,DIERR
 +8                                SET RORFDA(799.1,"?+1,",.01)=$PIECE(RORDATA,U)
 +9                                SET RORFDA(799.1,"?+1,",.02)=$PIECE(RORDATA,U,2)
 +10                               SET RORFDA(799.1,"?+1,",.03)=REGIEN
 +11                               SET RORFDA(799.1,"?+1,",.04)=$PIECE(RORDATA,U,3)
 +12                               DO UPDATE^DIE(,"RORFDA",,"RORMSG")
 +13                               IF $GET(DIERR)
                                       Begin DoDot:4
 +14                                       KILL RORERR
 +15                                       SET RORERR(1)="     New entry for "_RORREG_"(ien #"_REGIEN_") encountered the following error"
 +16                                       SET RORERR(2)="     and was not added to the ROR LIST ITEM file."
 +17                                       SET RORERR(3)="     (Data = "_RORDATA_")"
 +18                                       SET RORERR(4)="     Please report this error to your CCR contact:"
 +19                                       SET RORERR(5)=""
 +20                                       SET Z=0
                                           SET CT=5
                                           FOR 
                                               SET Z=$ORDER(RORMSG("DIERR",1,"TEXT",Z))
                                               if 'Z
                                                   QUIT 
                                               SET CT=CT+1
                                               SET RORERR(CT)=$JUSTIFY("",6)_$GET(RORMSG("DIERR",1,"TEXT",Z))
 +21                                       DO MES^XPDUTL(.RORERR)
                                       End DoDot:4
                               End DoDot:3
                       End DoDot:2
               End DoDot:1
 +22       QUIT 
 +23      ;
REGS      ; List of registries whose LIST ITEM entries should be added to file 799.1
 +1       ;;VA ALS
 +2       ;;VA APNEA
 +3       ;;VA COLORECTAL CANCER
 +4       ;;VA HCC
 +5       ;;VA LUNG CANCER
 +6       ;;VA MELANOMA
 +7       ;;VA OSTEOPOROSIS
 +8       ;;VA PANCREATIC CANCER
 +9       ;;VA PROSTATE CANCER
 +10      ;;
 +11      ;
LISTITEM  ;  Entries to add to file 799.1  text^group^code
 +1       ;;eGFR by CKD-EPI^7^3
 +2       ;;eGFR by MDRD^7^2
 +3       ;;Creatinine clearance by Cockcroft-Gault^7^1
 +4       ;;FIB-4^6^4
 +5       ;;APRI^6^3
 +6       ;;MELD-Na^6^2
 +7       ;;MELD^6^1
 +8       ;;BMI^5^1
 +9       ;;Registry Lab^3^1
 +10      ;;