MAGNID01 ;WOIFO/NST - DELETE IMAGES RPCS ; 28 Jul 2017 11:43 AM
 ;;3.0;IMAGING;**185**;Mar 19, 2002;Build 92;Aug 02, 2012
 ;; 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.                     |
 ;; +---------------------------------------------------------------+
 ;;
 Q
 ;
 ;***** DELETE IMAGES BY IEN
 ;
 ; RPC: MAGN DELETE IMAGES BY IEN
 ;
 ; .MAGOUT       Reference to a local variable where the results are returned to
 ; .MAGPARAM
 ;    MAGPARAM(1..n)=IMAGE IEN^GROUP DELETE FLAG (0|1)^REASON
 ;
 ; Return Values
 ; =============   
 ; MAGOUT(1..n) = Image IEN^1^SUCCESS 
 ;                Image IEN^0^reason for failure
DELIMGS(MAGOUT,MAGPARAM) ;RPC [MAGN DELETE IMAGES BY IEN]
 N MAGNI,MAGGRY,MAGNIEN,MAGNGDF,MAGNRSN
 S MAGOUT=$NA(^TMP($J,"MAGNID01"))
 K @MAGOUT
 ;
 S MAGNI=""
 F  S MAGNI=$O(MAGPARAM(MAGNI)) Q:MAGNI=""  D
 . S MAGNIEN=$P(MAGPARAM(MAGNI),"^",1)  ; Image IEN
 . S MAGNGDF=$P(MAGPARAM(MAGNI),"^",2)  ; Group delete flag
 . S MAGNRSN=$P(MAGPARAM(MAGNI),"^",3)  ; Reason
 . K MAGGRY
 . D IMAGEDEL^MAGGTID(.MAGGRY,MAGNIEN,MAGNGDF,MAGNRSN)
 . I ($P(MAGGRY(0),"^")=1)!($P(MAGGRY(0),"^")=0) S @MAGOUT@(MAGNI)=MAGNIEN_"^"_MAGGRY(0)
 . E  S @MAGOUT@(MAGNI)=MAGNIEN_"^0^"_MAGGRY(0)
 . Q
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGNID01   2089     printed  Sep 23, 2025@19:43:32                                                                                                                                                                                                    Page 2
MAGNID01  ;WOIFO/NST - DELETE IMAGES RPCS ; 28 Jul 2017 11:43 AM
 +1       ;;3.0;IMAGING;**185**;Mar 19, 2002;Build 92;Aug 02, 2012
 +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       QUIT 
 +18      ;
 +19      ;***** DELETE IMAGES BY IEN
 +20      ;
 +21      ; RPC: MAGN DELETE IMAGES BY IEN
 +22      ;
 +23      ; .MAGOUT       Reference to a local variable where the results are returned to
 +24      ; .MAGPARAM
 +25      ;    MAGPARAM(1..n)=IMAGE IEN^GROUP DELETE FLAG (0|1)^REASON
 +26      ;
 +27      ; Return Values
 +28      ; =============   
 +29      ; MAGOUT(1..n) = Image IEN^1^SUCCESS 
 +30      ;                Image IEN^0^reason for failure
DELIMGS(MAGOUT,MAGPARAM) ;RPC [MAGN DELETE IMAGES BY IEN]
 +1        NEW MAGNI,MAGGRY,MAGNIEN,MAGNGDF,MAGNRSN
 +2        SET MAGOUT=$NAME(^TMP($JOB,"MAGNID01"))
 +3        KILL @MAGOUT
 +4       ;
 +5        SET MAGNI=""
 +6        FOR 
               SET MAGNI=$ORDER(MAGPARAM(MAGNI))
               if MAGNI=""
                   QUIT 
               Begin DoDot:1
 +7       ; Image IEN
                   SET MAGNIEN=$PIECE(MAGPARAM(MAGNI),"^",1)
 +8       ; Group delete flag
                   SET MAGNGDF=$PIECE(MAGPARAM(MAGNI),"^",2)
 +9       ; Reason
                   SET MAGNRSN=$PIECE(MAGPARAM(MAGNI),"^",3)
 +10               KILL MAGGRY
 +11               DO IMAGEDEL^MAGGTID(.MAGGRY,MAGNIEN,MAGNGDF,MAGNRSN)
 +12               IF ($PIECE(MAGGRY(0),"^")=1)!($PIECE(MAGGRY(0),"^")=0)
                       SET @MAGOUT@(MAGNI)=MAGNIEN_"^"_MAGGRY(0)
 +13              IF '$TEST
                       SET @MAGOUT@(MAGNI)=MAGNIEN_"^0^"_MAGGRY(0)
 +14               QUIT 
               End DoDot:1
 +15       QUIT