MAGVD008 ;WOIFO/DAC - Delete an image by accession number ; 3 Feb 2012 01:17 PM
 ;;3.0;IMAGING;**118**;Mar 19, 2002;Build 4525;May 01, 2013
 ;; 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
 ;
 ;Called by legacy delete function
 ;
 ;Input Variables:
 ;      ACC - Accession number
 ;      REASON - The reason for deletion
 ;      
 ;Output Variable:
 ;OUT - status`status message
 ;      a status of 0 indicates success, a negative integer indicates an error occurred 
 ; 
DELNEW(OUT,ACC,REASON) ; Given an accession number delete entries for the 2005.6x structure
 N OUT20056,PROCIEN,STUDIEN,ISEP,SSEP,OUTAUD,EVENT,HOST,APP,MESSAGE,DATA,OUTAUD
 S ISEP=$$INPUTSEP^MAGVRS41,SSEP=$$STATSEP^MAGVRS41
 I $G(ACC)="" S OUT=-8_SSEP_"No accession number provided" Q
 I $G(REASON)="" S OUT=-9_SSEP_"No reason provided" Q
 I '$D(^MAGV(2005.61,"B",ACC)) S OUT=1_SSEP_"Accession number not found" Q
 S OUT=0
 S PROCIEN=$O(^MAGV(2005.61,"B",ACC,""))
 S STUDIEN=""
 F  S STUDIEN=$O(^MAGV(2005.62,"C",PROCIEN,STUDIEN)) Q:STUDIEN=""  D
 . D INACTIVT^MAGVRS41(.OUT20056,2005.62,STUDIEN,"",1,REASON)
 . I OUT20056(1)<0 S OUT=OUT20056(1)
 . Q
 S EVENT="DELETE"
 S HOST=""
 S APP="MAG SYS-DELETE IMAGEGROUP"
 S MESSAGE=""
 S DATA(1)="DUZ"_ISEP_DUZ
 I OUT'<0 D EVENT^MAGUAUD(.OUTAUD,EVENT,HOST,APP,MESSAGE,.DATA)
 Q
 
--- Routine Detail   --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGVD008   2280     printed  Sep 23, 2025@19:45:59                                                                                                                                                                                                    Page 2
MAGVD008  ;WOIFO/DAC - Delete an image by accession number ; 3 Feb 2012 01:17 PM
 +1       ;;3.0;IMAGING;**118**;Mar 19, 2002;Build 4525;May 01, 2013
 +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      ;Called by legacy delete function
 +20      ;
 +21      ;Input Variables:
 +22      ;      ACC - Accession number
 +23      ;      REASON - The reason for deletion
 +24      ;      
 +25      ;Output Variable:
 +26      ;OUT - status`status message
 +27      ;      a status of 0 indicates success, a negative integer indicates an error occurred 
 +28      ; 
DELNEW(OUT,ACC,REASON) ; Given an accession number delete entries for the 2005.6x structure
 +1        NEW OUT20056,PROCIEN,STUDIEN,ISEP,SSEP,OUTAUD,EVENT,HOST,APP,MESSAGE,DATA,OUTAUD
 +2        SET ISEP=$$INPUTSEP^MAGVRS41
           SET SSEP=$$STATSEP^MAGVRS41
 +3        IF $GET(ACC)=""
               SET OUT=-8_SSEP_"No accession number provided"
               QUIT 
 +4        IF $GET(REASON)=""
               SET OUT=-9_SSEP_"No reason provided"
               QUIT 
 +5        IF '$DATA(^MAGV(2005.61,"B",ACC))
               SET OUT=1_SSEP_"Accession number not found"
               QUIT 
 +6        SET OUT=0
 +7        SET PROCIEN=$ORDER(^MAGV(2005.61,"B",ACC,""))
 +8        SET STUDIEN=""
 +9        FOR 
               SET STUDIEN=$ORDER(^MAGV(2005.62,"C",PROCIEN,STUDIEN))
               if STUDIEN=""
                   QUIT 
               Begin DoDot:1
 +10               DO INACTIVT^MAGVRS41(.OUT20056,2005.62,STUDIEN,"",1,REASON)
 +11               IF OUT20056(1)<0
                       SET OUT=OUT20056(1)
 +12               QUIT 
               End DoDot:1
 +13       SET EVENT="DELETE"
 +14       SET HOST=""
 +15       SET APP="MAG SYS-DELETE IMAGEGROUP"
 +16       SET MESSAGE=""
 +17       SET DATA(1)="DUZ"_ISEP_DUZ
 +18       IF OUT'<0
               DO EVENT^MAGUAUD(.OUTAUD,EVENT,HOST,APP,MESSAGE,.DATA)
 +19       QUIT