Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: MAGGI11

MAGGI11.m

Go to the documentation of this file.
  1. MAGGI11 ;WOIFO/GEK/SG - IMAGE FILE API (LOW LEVEL) ; 1/16/09 10:04am
  1. ;;3.0;IMAGING;**93**;Dec 02, 2009;Build 163
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. ; Unless stated otherwise, error descriptors returned to the ERR
  1. ; parameter of entry points in this routine are NOT stored regardless
  1. ; of the mode set by the CLEAR^MAGUERR. If you need to store them
  1. ; (e.g. to return from an RPC), then you have to do this in your
  1. ; code using the STORE^MAGUERR.
  1. ;
  1. Q
  1. ;
  1. ;##### CHECKS IF THE CURRENT USER CAN DELETE THE IMAGE
  1. ;
  1. ; IMGIEN Internal Entry Number of the image record
  1. ;
  1. ; [FLAGS] Flags that control the execution (can be combined):
  1. ;
  1. ; S Allow deletion regardless of security keys
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; 0 Image cannot be deleted or there was an error;
  1. ; check the value of the ERR parameter.
  1. ; 1 User can delete the image
  1. ;
  1. CANDEL(IMGIEN,FLAGS,ERR) ;
  1. S FLAGS=$G(FLAGS)
  1. I $TR(FLAGS,"S")'="" S ERR=$$IPVE^MAGUERR("FLAGS") Q 0
  1. ;--- Validate IEN and check if the image is already deleted
  1. I $$ISDEL(IMGIEN,.ERR) S ERR=$$ERROR^MAGUERR(-37,,"Deleted") Q 0
  1. Q:ERR<0 0
  1. ;--- Check the security key if necessary
  1. I FLAGS'["S",'$D(^XUSEC("MAG DELETE",DUZ)) D Q 0
  1. . S ERR=$$ERROR^MAGUERR(-36)
  1. . Q
  1. ;--- User can delete the image
  1. Q 1
  1. ;
  1. ;##### CHECKS IF THE IMAGE CAN BE VIEWED
  1. ;
  1. ; IMGIEN Internal Entry Number of the image record
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; 0 Image cannot be viewed or there was an error;
  1. ; check the value of the ERR parameter.
  1. ; 1 Image is viewable
  1. ;
  1. CANVIEW(IMGIEN,ERR) ;
  1. N STATUS
  1. S STATUS=$$IMGST(IMGIEN,.ERR)
  1. I STATUS'<10 S ERR=$$ERROR^MAGUERR("-33S",,$P(STATUS,U,2)) Q 0
  1. Q (ERR'<0)
  1. ;
  1. ;##### RETURNS NUMBER OF THE FILE THAT STORES THE IMAGE RECORD
  1. ;
  1. ; IMGIEN Internal Entry Number of the image record
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; "" Invalid IEN or there is no such record
  1. ; >0 Image file number (2005 or 2005.1)
  1. ;
  1. FILE(IMGIEN,ERR) ;
  1. S ERR=""
  1. ;--- Validate the IMGIEN parameter
  1. I (IMGIEN'>0)!(+IMGIEN'=IMGIEN) D Q ""
  1. . S ERR=$$ERROR^MAGUERR("-3S",,"IMGIEN",IMGIEN)
  1. . Q
  1. ;--- Check if the image data exists
  1. Q:$D(^MAG(2005,IMGIEN)) 2005
  1. ;~~~ Delete this comment and the following line of code when
  1. ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
  1. Q:$D(^MAG(2005.1,IMGIEN)) 2005.1
  1. ;--- There is no such record
  1. S ERR=$$ERROR^MAGUERR("-22S",,2005,IMGIEN_",")
  1. Q ""
  1. ;
  1. ;***** RETURNS THE IMAGE STATUS
  1. ;
  1. ; IMGIEN Internal Entry Number of the image record
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; "" Status is not defined or there was an error;
  1. ; check the value of the ERR parameter.
  1. ; >0 Image status
  1. ; ^01: Status code (internal value)
  1. ; ^02: Description (external value)
  1. ;
  1. IMGST(IMGIEN,ERR) ;
  1. N MAGMSG,NODE,STCODE
  1. S NODE=$$NODE(IMGIEN,.ERR) Q:NODE="" ""
  1. ;--- Get the internal value of the STATUS field (113)
  1. S STCODE=+$P($G(@NODE@(100)),U,8) Q:'STCODE ""
  1. ;--- Return the status
  1. Q STCODE_U_$$IMGSTDSC(STCODE)
  1. ;
  1. ;##### RETURNS THE DESCRIPTION FOR THE IMAGE STATUS CODE
  1. ;
  1. ; STCODE Internal value of the STATUS field (113)
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; Description of the image status (usually, the
  1. ; external value of the STATUS field)
  1. ;
  1. IMGSTDSC(STCODE,ERR) ;
  1. Q:'STCODE ""
  1. N MAGMSG,STDESCR
  1. ;--- Get the external value of the STATUS field
  1. S STDESCR=$$EXTERNAL^DILFD(2005,113,,STCODE,"MAGMSG")
  1. S:$G(DIERR) ERR=$$ERROR^MAGUERR("-38S",,STCODE)
  1. ;--- Return the description
  1. Q $S(STDESCR'="":STDESCR,1:"<Status: "_STCODE_">")
  1. ;
  1. ;##### CHECKS IF THE IMAGE IS MARKED AS DELETED
  1. ;
  1. ; IMGIEN Internal Entry Number of the image record
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; 0 Image is not marked as deleted or there was an error;
  1. ; check the value of the ERR parameter.
  1. ; 1 IMGIEN references a deleted image
  1. ;
  1. ISDEL(IMGIEN,ERR) ;
  1. ;~~~ Delete this comment and the following lines of code when
  1. ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
  1. S ERR=""
  1. I $D(^MAG(2005.1,IMGIEN)) Q:'$D(^MAG(2005,IMGIEN)) 1 D Q 0
  1. . S ERR=$$ERROR^MAGUERR("-43S",,IMGIEN)
  1. . Q
  1. ;---
  1. Q (+$$IMGST(IMGIEN,.ERR)=12)
  1. ;
  1. ;##### CHECKS IF THE IEN IS INVALID OR THE IMAGE IS DELETED
  1. ;
  1. ; IMGIEN Internal Entry Number of the image record
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; 0 IEN is valid and the image is not deleted
  1. ; 1 Invalid IEN or the image is marked as delete;
  1. ; check the value of the ERR parameter for details.
  1. ;
  1. ISDELINV(IMGIEN,ERR) ;
  1. Q $S($$ISDEL(IMGIEN,.ERR):1,1:ERR<0)
  1. ;
  1. ;##### CHECKS IF THE IMGIEN REFERENCES A GROUP PARENT
  1. ;
  1. ; IMGIEN Internal Entry Number of the image record
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; 0 Image is not a group parent or there was an error;
  1. ; check the value of the ERR parameter.
  1. ; 1 IMGIEN references a group parent
  1. ;
  1. ISGRP(IMGIEN,ERR) ;
  1. N NODE,OBJTYPE
  1. S NODE=$$NODE(IMGIEN,.ERR) Q:NODE="" 0
  1. S OBJTYPE=$P($G(@NODE@(0)),U,6) ; OBJECT TYPE (3)
  1. Q (OBJTYPE=11)!(OBJTYPE=16)
  1. ;
  1. ;##### CHECKS IF THE PARAMETER VALUE IS A VALID IMAGE IEN
  1. ;
  1. ; IMGIEN Internal Entry Number of the image record
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; 0 Parameter value is not a valid image IEN;
  1. ; check the value of the ERR parameter.
  1. ; 1 Valid image IEN
  1. ;
  1. ISVALID(IMGIEN,ERR) ;
  1. Q $$NODE(IMGIEN,.ERR)'=""
  1. ;
  1. ;##### RETURNS THE CLOSED REFERENCE TO THE IMAGE RECORD
  1. ;
  1. ; IMGIEN Internal Entry Number of the image record
  1. ;
  1. ; [.ERR] Reference to a local variable where the error
  1. ; descriptor (see the $$ERROR^MAGUERR) is returned to.
  1. ;
  1. ; Return Values
  1. ; =============
  1. ; "" Invalid IEN or there is no such record
  1. ; "^MAG(...)" Closed reference to the image data node
  1. ;
  1. NODE(IMGIEN,ERR) ;
  1. S ERR=""
  1. ;--- Validate the IMGIEN parameter
  1. I (IMGIEN'>0)!(+IMGIEN'=IMGIEN) D Q ""
  1. . S ERR=$$ERROR^MAGUERR("-3S",,"IMGIEN",IMGIEN)
  1. . Q
  1. ;--- Check if the image data exists
  1. Q:$D(^MAG(2005,IMGIEN)) $NA(^(IMGIEN))
  1. ;~~~ Delete this comment and the following line of code when
  1. ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
  1. Q:$D(^MAG(2005.1,IMGIEN)) $NA(^(IMGIEN))
  1. ;--- There is no such record
  1. S ERR=$$ERROR^MAGUERR("-22S",,2005,IMGIEN_",")
  1. Q ""