MAGIP186 ;WOIFO/JSL,DAC,GEK - INSTALL CODE FOR MAG*3.0*186 BP FIX; 27 Jul 2017  9:23 AM
 ;;3.0;IMAGING;**186**;Mar 19, 2002;Build 23
 ;; Per VHA Directive 2004-038, this routine should not be modified.
 ;; +---------------------------------------------------------------+
 ;; | Property of the US Government.                                |
 ;; | No permission to copy or redistribute this software is given. |
 ;; | Use of unreleased versions of this software requires the user |
 ;; | to execute a written test agreement with the VistA Imaging    |
 ;; | Development Office of the Department of Veterans Affairs,     |
 ;; | telephone (301) 734-0100.                                     |
 ;; | The Food and Drug Administration classifies this software as  |
 ;; | a medical device.  As such, it may not be changed in any way. |
 ;; | Modifications to this software may result in an adulterated   |
 ;; | medical device under 21CFR820, the use of which is considered |
 ;; | to be a violation of US Federal Statutes.                     |
 ;; +---------------------------------------------------------------+
 ;;
 ; There are no environment checks here but the MAGIP186 has to be
 ; referenced by the "Environment Check Routine" field of the KIDS
 ; build so that entry points of the routine are available to the
 ; KIDS during all installation phases.
 ;
 Q
 ;
 ;+++++ INSTALLATION ERROR HANDLING
ERROR ;
 S:$D(XPDNM) XPDABORT=1
 ;--- Display the messages and store them to the INSTALL file
 D DUMP^MAGUERR1(),ABTMSG^MAGKIDS()
 Q
 ;
POST ;***** POST-INSTALL CODE
POS ;
 N CALLBACK
 D CLEAR^MAGUERR(1)
 I $G(DUZ)<.5 S XPDABORT=1 Q
 ;--- Send the notification e-mail
 D BMES^XPDUTL("Post Install Mail Message: "_$$FMTE^XLFDT($$NOW^XLFDT))
 D INS^MAGQBUT4(XPDNM,DUZ,$$NOW^XLFDT,XPDA)
 ;
 Q
 ;
 ;***** PRE-INSTALL CODE
PRE ;
 ;
QCLN ;;CLEAN "D" X-REF of BP MAGQUEUE #2006.03 
 N LOC,QTYP,STG,QIEN,NO,MAX,LNT,BADCT,BADTCT
 S LOC=0,BADTCT=0
 W !,"Removing bad references from IMAGE BACKGROUND QUEUE (2006.03)"
 F NO=1:1 S LOC=$O(^MAGQUEUE(2006.03,"D",LOC)) Q:'LOC  I $D(^MAG(2006.1,LOC)) W !!,"Location(PLACE) = '",LOC,"'  ",$P($G(^MAG(2006.1,LOC,0)),"^",9) D 
 . S QTYP="A" 
 . F  S QTYP=$O(^MAGQUEUE(2006.03,"D",LOC,QTYP)) Q:QTYP=""  W !!,"Queue = '",QTYP,"'" D
 .. S STG="" 
 .. F  S STG=$O(^MAGQUEUE(2006.03,"D",LOC,QTYP,STG)) Q:STG=""  W !,?4,"Category = '",STG,"'" D
 ... S QIEN=0,BADCT=0
 ... F MAX=1:1:1000000 S QIEN=$O(^MAGQUEUE(2006.03,"D",LOC,QTYP,STG,QIEN)) Q:'QIEN  I '$D(^MAGQUEUE(2006.03,QIEN,0)) D
 .... W "*",QIEN S BADCT=BADCT+1 K ^MAGQUEUE(2006.03,"D",LOC,QTYP,STG,QIEN)
 .... F LNT=1:1:$L(QIEN)+1 W $C(8)
 ... I 'BADCT W !,?4,BADCT," bad references."
 ... I BADCT S BADTCT=BADTCT+BADCT W !,?4,BADCT," bad references removed."
 ... Q
 .. Q
 . Q
 W !!,"Processing is complete."
 I 'BADTCT W "  0 bad references."
 I BADTCT W "  Total of ",BADTCT," bad references removed."
 Q
 ;
 ;****
 QUIT
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGIP186   2978     printed  Sep 23, 2025@19:40:49                                                                                                                                                                                                    Page 2
MAGIP186  ;WOIFO/JSL,DAC,GEK - INSTALL CODE FOR MAG*3.0*186 BP FIX; 27 Jul 2017  9:23 AM
 +1       ;;3.0;IMAGING;**186**;Mar 19, 2002;Build 23
 +2       ;; Per VHA Directive 2004-038, this routine should not be modified.
 +3       ;; +---------------------------------------------------------------+
 +4       ;; | Property of the US Government.                                |
 +5       ;; | No permission to copy or redistribute this software is given. |
 +6       ;; | Use of unreleased versions of this software requires the user |
 +7       ;; | to execute a written test agreement with the VistA Imaging    |
 +8       ;; | Development Office of the Department of Veterans Affairs,     |
 +9       ;; | telephone (301) 734-0100.                                     |
 +10      ;; | The Food and Drug Administration classifies this software as  |
 +11      ;; | a medical device.  As such, it may not be changed in any way. |
 +12      ;; | Modifications to this software may result in an adulterated   |
 +13      ;; | medical device under 21CFR820, the use of which is considered |
 +14      ;; | to be a violation of US Federal Statutes.                     |
 +15      ;; +---------------------------------------------------------------+
 +16      ;;
 +17      ; There are no environment checks here but the MAGIP186 has to be
 +18      ; referenced by the "Environment Check Routine" field of the KIDS
 +19      ; build so that entry points of the routine are available to the
 +20      ; KIDS during all installation phases.
 +21      ;
 +22       QUIT 
 +23      ;
 +24      ;+++++ INSTALLATION ERROR HANDLING
ERROR     ;
 +1        if $DATA(XPDNM)
               SET XPDABORT=1
 +2       ;--- Display the messages and store them to the INSTALL file
 +3        DO DUMP^MAGUERR1()
           DO ABTMSG^MAGKIDS()
 +4        QUIT 
 +5       ;
POST      ;***** POST-INSTALL CODE
POS       ;
 +1        NEW CALLBACK
 +2        DO CLEAR^MAGUERR(1)
 +3        IF $GET(DUZ)<.5
               SET XPDABORT=1
               QUIT 
 +4       ;--- Send the notification e-mail
 +5        DO BMES^XPDUTL("Post Install Mail Message: "_$$FMTE^XLFDT($$NOW^XLFDT))
 +6        DO INS^MAGQBUT4(XPDNM,DUZ,$$NOW^XLFDT,XPDA)
 +7       ;
 +8        QUIT 
 +9       ;
 +10      ;***** PRE-INSTALL CODE
PRE       ;
 +1       ;
QCLN      ;;CLEAN "D" X-REF of BP MAGQUEUE #2006.03 
 +1        NEW LOC,QTYP,STG,QIEN,NO,MAX,LNT,BADCT,BADTCT
 +2        SET LOC=0
           SET BADTCT=0
 +3        WRITE !,"Removing bad references from IMAGE BACKGROUND QUEUE (2006.03)"
 +4        FOR NO=1:1
               SET LOC=$ORDER(^MAGQUEUE(2006.03,"D",LOC))
               if 'LOC
                   QUIT 
               IF $DATA(^MAG(2006.1,LOC))
                   WRITE !!,"Location(PLACE) = '",LOC,"'  ",$PIECE($GET(^MAG(2006.1,LOC,0)),"^",9)
                   Begin DoDot:1
 +5                    SET QTYP="A"
 +6                    FOR 
                           SET QTYP=$ORDER(^MAGQUEUE(2006.03,"D",LOC,QTYP))
                           if QTYP=""
                               QUIT 
                           WRITE !!,"Queue = '",QTYP,"'"
                           Begin DoDot:2
 +7                            SET STG=""
 +8                            FOR 
                                   SET STG=$ORDER(^MAGQUEUE(2006.03,"D",LOC,QTYP,STG))
                                   if STG=""
                                       QUIT 
                                   WRITE !,?4,"Category = '",STG,"'"
                                   Begin DoDot:3
 +9                                    SET QIEN=0
                                       SET BADCT=0
 +10                                   FOR MAX=1:1:1000000
                                           SET QIEN=$ORDER(^MAGQUEUE(2006.03,"D",LOC,QTYP,STG,QIEN))
                                           if 'QIEN
                                               QUIT 
                                           IF '$DATA(^MAGQUEUE(2006.03,QIEN,0))
                                               Begin DoDot:4
 +11                                               WRITE "*",QIEN
                                                   SET BADCT=BADCT+1
                                                   KILL ^MAGQUEUE(2006.03,"D",LOC,QTYP,STG,QIEN)
 +12                                               FOR LNT=1:1:$LENGTH(QIEN)+1
                                                       WRITE $CHAR(8)
                                               End DoDot:4
 +13                                   IF 'BADCT
                                           WRITE !,?4,BADCT," bad references."
 +14                                   IF BADCT
                                           SET BADTCT=BADTCT+BADCT
                                           WRITE !,?4,BADCT," bad references removed."
 +15                                   QUIT 
                                   End DoDot:3
 +16                           QUIT 
                           End DoDot:2
 +17                   QUIT 
                   End DoDot:1
 +18       WRITE !!,"Processing is complete."
 +19       IF 'BADTCT
               WRITE "  0 bad references."
 +20       IF BADTCT
               WRITE "  Total of ",BADTCT," bad references removed."
 +21       QUIT 
 +22      ;
 +23      ;****
 +24       QUIT