- MAGGI11 ;WOIFO/GEK/SG - IMAGE FILE API (LOW LEVEL) ; 1/16/09 10:04am
- ;;3.0;IMAGING;**93**;Dec 02, 2009;Build 163
- ;;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. |
- ;; +---------------------------------------------------------------+
- ;;
- ; Unless stated otherwise, error descriptors returned to the ERR
- ; parameter of entry points in this routine are NOT stored regardless
- ; of the mode set by the CLEAR^MAGUERR. If you need to store them
- ; (e.g. to return from an RPC), then you have to do this in your
- ; code using the STORE^MAGUERR.
- ;
- Q
- ;
- ;##### CHECKS IF THE CURRENT USER CAN DELETE THE IMAGE
- ;
- ; IMGIEN Internal Entry Number of the image record
- ;
- ; [FLAGS] Flags that control the execution (can be combined):
- ;
- ; S Allow deletion regardless of security keys
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; 0 Image cannot be deleted or there was an error;
- ; check the value of the ERR parameter.
- ; 1 User can delete the image
- ;
- CANDEL(IMGIEN,FLAGS,ERR) ;
- S FLAGS=$G(FLAGS)
- I $TR(FLAGS,"S")'="" S ERR=$$IPVE^MAGUERR("FLAGS") Q 0
- ;--- Validate IEN and check if the image is already deleted
- I $$ISDEL(IMGIEN,.ERR) S ERR=$$ERROR^MAGUERR(-37,,"Deleted") Q 0
- Q:ERR<0 0
- ;--- Check the security key if necessary
- I FLAGS'["S",'$D(^XUSEC("MAG DELETE",DUZ)) D Q 0
- . S ERR=$$ERROR^MAGUERR(-36)
- . Q
- ;--- User can delete the image
- Q 1
- ;
- ;##### CHECKS IF THE IMAGE CAN BE VIEWED
- ;
- ; IMGIEN Internal Entry Number of the image record
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; 0 Image cannot be viewed or there was an error;
- ; check the value of the ERR parameter.
- ; 1 Image is viewable
- ;
- CANVIEW(IMGIEN,ERR) ;
- N STATUS
- S STATUS=$$IMGST(IMGIEN,.ERR)
- I STATUS'<10 S ERR=$$ERROR^MAGUERR("-33S",,$P(STATUS,U,2)) Q 0
- Q (ERR'<0)
- ;
- ;##### RETURNS NUMBER OF THE FILE THAT STORES THE IMAGE RECORD
- ;
- ; IMGIEN Internal Entry Number of the image record
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; "" Invalid IEN or there is no such record
- ; >0 Image file number (2005 or 2005.1)
- ;
- FILE(IMGIEN,ERR) ;
- S ERR=""
- ;--- Validate the IMGIEN parameter
- I (IMGIEN'>0)!(+IMGIEN'=IMGIEN) D Q ""
- . S ERR=$$ERROR^MAGUERR("-3S",,"IMGIEN",IMGIEN)
- . Q
- ;--- Check if the image data exists
- Q:$D(^MAG(2005,IMGIEN)) 2005
- ;~~~ Delete this comment and the following line of code when
- ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
- Q:$D(^MAG(2005.1,IMGIEN)) 2005.1
- ;--- There is no such record
- S ERR=$$ERROR^MAGUERR("-22S",,2005,IMGIEN_",")
- Q ""
- ;
- ;***** RETURNS THE IMAGE STATUS
- ;
- ; IMGIEN Internal Entry Number of the image record
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; "" Status is not defined or there was an error;
- ; check the value of the ERR parameter.
- ; >0 Image status
- ; ^01: Status code (internal value)
- ; ^02: Description (external value)
- ;
- IMGST(IMGIEN,ERR) ;
- N MAGMSG,NODE,STCODE
- S NODE=$$NODE(IMGIEN,.ERR) Q:NODE="" ""
- ;--- Get the internal value of the STATUS field (113)
- S STCODE=+$P($G(@NODE@(100)),U,8) Q:'STCODE ""
- ;--- Return the status
- Q STCODE_U_$$IMGSTDSC(STCODE)
- ;
- ;##### RETURNS THE DESCRIPTION FOR THE IMAGE STATUS CODE
- ;
- ; STCODE Internal value of the STATUS field (113)
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; Description of the image status (usually, the
- ; external value of the STATUS field)
- ;
- IMGSTDSC(STCODE,ERR) ;
- Q:'STCODE ""
- N MAGMSG,STDESCR
- ;--- Get the external value of the STATUS field
- S STDESCR=$$EXTERNAL^DILFD(2005,113,,STCODE,"MAGMSG")
- S:$G(DIERR) ERR=$$ERROR^MAGUERR("-38S",,STCODE)
- ;--- Return the description
- Q $S(STDESCR'="":STDESCR,1:"<Status: "_STCODE_">")
- ;
- ;##### CHECKS IF THE IMAGE IS MARKED AS DELETED
- ;
- ; IMGIEN Internal Entry Number of the image record
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; 0 Image is not marked as deleted or there was an error;
- ; check the value of the ERR parameter.
- ; 1 IMGIEN references a deleted image
- ;
- ISDEL(IMGIEN,ERR) ;
- ;~~~ Delete this comment and the following lines of code when
- ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
- S ERR=""
- I $D(^MAG(2005.1,IMGIEN)) Q:'$D(^MAG(2005,IMGIEN)) 1 D Q 0
- . S ERR=$$ERROR^MAGUERR("-43S",,IMGIEN)
- . Q
- ;---
- Q (+$$IMGST(IMGIEN,.ERR)=12)
- ;
- ;##### CHECKS IF THE IEN IS INVALID OR THE IMAGE IS DELETED
- ;
- ; IMGIEN Internal Entry Number of the image record
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; 0 IEN is valid and the image is not deleted
- ; 1 Invalid IEN or the image is marked as delete;
- ; check the value of the ERR parameter for details.
- ;
- ISDELINV(IMGIEN,ERR) ;
- Q $S($$ISDEL(IMGIEN,.ERR):1,1:ERR<0)
- ;
- ;##### CHECKS IF THE IMGIEN REFERENCES A GROUP PARENT
- ;
- ; IMGIEN Internal Entry Number of the image record
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; 0 Image is not a group parent or there was an error;
- ; check the value of the ERR parameter.
- ; 1 IMGIEN references a group parent
- ;
- ISGRP(IMGIEN,ERR) ;
- N NODE,OBJTYPE
- S NODE=$$NODE(IMGIEN,.ERR) Q:NODE="" 0
- S OBJTYPE=$P($G(@NODE@(0)),U,6) ; OBJECT TYPE (3)
- Q (OBJTYPE=11)!(OBJTYPE=16)
- ;
- ;##### CHECKS IF THE PARAMETER VALUE IS A VALID IMAGE IEN
- ;
- ; IMGIEN Internal Entry Number of the image record
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; 0 Parameter value is not a valid image IEN;
- ; check the value of the ERR parameter.
- ; 1 Valid image IEN
- ;
- ISVALID(IMGIEN,ERR) ;
- Q $$NODE(IMGIEN,.ERR)'=""
- ;
- ;##### RETURNS THE CLOSED REFERENCE TO THE IMAGE RECORD
- ;
- ; IMGIEN Internal Entry Number of the image record
- ;
- ; [.ERR] Reference to a local variable where the error
- ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- ;
- ; Return Values
- ; =============
- ; "" Invalid IEN or there is no such record
- ; "^MAG(...)" Closed reference to the image data node
- ;
- NODE(IMGIEN,ERR) ;
- S ERR=""
- ;--- Validate the IMGIEN parameter
- I (IMGIEN'>0)!(+IMGIEN'=IMGIEN) D Q ""
- . S ERR=$$ERROR^MAGUERR("-3S",,"IMGIEN",IMGIEN)
- . Q
- ;--- Check if the image data exists
- Q:$D(^MAG(2005,IMGIEN)) $NA(^(IMGIEN))
- ;~~~ Delete this comment and the following line of code when
- ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
- Q:$D(^MAG(2005.1,IMGIEN)) $NA(^(IMGIEN))
- ;--- There is no such record
- S ERR=$$ERROR^MAGUERR("-22S",,2005,IMGIEN_",")
- Q ""
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGGI11 9007 printed Jan 18, 2025@03:03:40 Page 2
- MAGGI11 ;WOIFO/GEK/SG - IMAGE FILE API (LOW LEVEL) ; 1/16/09 10:04am
- +1 ;;3.0;IMAGING;**93**;Dec 02, 2009;Build 163
- +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 ;; | |
- +11 ;; | The Food and Drug Administration classifies this software as |
- +12 ;; | a medical device. As such, it may not be changed in any way. |
- +13 ;; | Modifications to this software may result in an adulterated |
- +14 ;; | medical device under 21CFR820, the use of which is considered |
- +15 ;; | to be a violation of US Federal Statutes. |
- +16 ;; +---------------------------------------------------------------+
- +17 ;;
- +18 ; Unless stated otherwise, error descriptors returned to the ERR
- +19 ; parameter of entry points in this routine are NOT stored regardless
- +20 ; of the mode set by the CLEAR^MAGUERR. If you need to store them
- +21 ; (e.g. to return from an RPC), then you have to do this in your
- +22 ; code using the STORE^MAGUERR.
- +23 ;
- +24 QUIT
- +25 ;
- +26 ;##### CHECKS IF THE CURRENT USER CAN DELETE THE IMAGE
- +27 ;
- +28 ; IMGIEN Internal Entry Number of the image record
- +29 ;
- +30 ; [FLAGS] Flags that control the execution (can be combined):
- +31 ;
- +32 ; S Allow deletion regardless of security keys
- +33 ;
- +34 ; [.ERR] Reference to a local variable where the error
- +35 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +36 ;
- +37 ; Return Values
- +38 ; =============
- +39 ; 0 Image cannot be deleted or there was an error;
- +40 ; check the value of the ERR parameter.
- +41 ; 1 User can delete the image
- +42 ;
- CANDEL(IMGIEN,FLAGS,ERR) ;
- +1 SET FLAGS=$GET(FLAGS)
- +2 IF $TRANSLATE(FLAGS,"S")'=""
- SET ERR=$$IPVE^MAGUERR("FLAGS")
- QUIT 0
- +3 ;--- Validate IEN and check if the image is already deleted
- +4 IF $$ISDEL(IMGIEN,.ERR)
- SET ERR=$$ERROR^MAGUERR(-37,,"Deleted")
- QUIT 0
- +5 if ERR<0
- QUIT 0
- +6 ;--- Check the security key if necessary
- +7 IF FLAGS'["S"
- IF '$DATA(^XUSEC("MAG DELETE",DUZ))
- Begin DoDot:1
- +8 SET ERR=$$ERROR^MAGUERR(-36)
- +9 QUIT
- End DoDot:1
- QUIT 0
- +10 ;--- User can delete the image
- +11 QUIT 1
- +12 ;
- +13 ;##### CHECKS IF THE IMAGE CAN BE VIEWED
- +14 ;
- +15 ; IMGIEN Internal Entry Number of the image record
- +16 ;
- +17 ; [.ERR] Reference to a local variable where the error
- +18 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +19 ;
- +20 ; Return Values
- +21 ; =============
- +22 ; 0 Image cannot be viewed or there was an error;
- +23 ; check the value of the ERR parameter.
- +24 ; 1 Image is viewable
- +25 ;
- CANVIEW(IMGIEN,ERR) ;
- +1 NEW STATUS
- +2 SET STATUS=$$IMGST(IMGIEN,.ERR)
- +3 IF STATUS'<10
- SET ERR=$$ERROR^MAGUERR("-33S",,$PIECE(STATUS,U,2))
- QUIT 0
- +4 QUIT (ERR'<0)
- +5 ;
- +6 ;##### RETURNS NUMBER OF THE FILE THAT STORES THE IMAGE RECORD
- +7 ;
- +8 ; IMGIEN Internal Entry Number of the image record
- +9 ;
- +10 ; [.ERR] Reference to a local variable where the error
- +11 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +12 ;
- +13 ; Return Values
- +14 ; =============
- +15 ; "" Invalid IEN or there is no such record
- +16 ; >0 Image file number (2005 or 2005.1)
- +17 ;
- FILE(IMGIEN,ERR) ;
- +1 SET ERR=""
- +2 ;--- Validate the IMGIEN parameter
- +3 IF (IMGIEN'>0)!(+IMGIEN'=IMGIEN)
- Begin DoDot:1
- +4 SET ERR=$$ERROR^MAGUERR("-3S",,"IMGIEN",IMGIEN)
- +5 QUIT
- End DoDot:1
- QUIT ""
- +6 ;--- Check if the image data exists
- +7 if $DATA(^MAG(2005,IMGIEN))
- QUIT 2005
- +8 ;~~~ Delete this comment and the following line of code when
- +9 ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
- +10 if $DATA(^MAG(2005.1,IMGIEN))
- QUIT 2005.1
- +11 ;--- There is no such record
- +12 SET ERR=$$ERROR^MAGUERR("-22S",,2005,IMGIEN_",")
- +13 QUIT ""
- +14 ;
- +15 ;***** RETURNS THE IMAGE STATUS
- +16 ;
- +17 ; IMGIEN Internal Entry Number of the image record
- +18 ;
- +19 ; [.ERR] Reference to a local variable where the error
- +20 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +21 ;
- +22 ; Return Values
- +23 ; =============
- +24 ; "" Status is not defined or there was an error;
- +25 ; check the value of the ERR parameter.
- +26 ; >0 Image status
- +27 ; ^01: Status code (internal value)
- +28 ; ^02: Description (external value)
- +29 ;
- IMGST(IMGIEN,ERR) ;
- +1 NEW MAGMSG,NODE,STCODE
- +2 SET NODE=$$NODE(IMGIEN,.ERR)
- if NODE=""
- QUIT ""
- +3 ;--- Get the internal value of the STATUS field (113)
- +4 SET STCODE=+$PIECE($GET(@NODE@(100)),U,8)
- if 'STCODE
- QUIT ""
- +5 ;--- Return the status
- +6 QUIT STCODE_U_$$IMGSTDSC(STCODE)
- +7 ;
- +8 ;##### RETURNS THE DESCRIPTION FOR THE IMAGE STATUS CODE
- +9 ;
- +10 ; STCODE Internal value of the STATUS field (113)
- +11 ;
- +12 ; [.ERR] Reference to a local variable where the error
- +13 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +14 ;
- +15 ; Return Values
- +16 ; =============
- +17 ; Description of the image status (usually, the
- +18 ; external value of the STATUS field)
- +19 ;
- IMGSTDSC(STCODE,ERR) ;
- +1 if 'STCODE
- QUIT ""
- +2 NEW MAGMSG,STDESCR
- +3 ;--- Get the external value of the STATUS field
- +4 SET STDESCR=$$EXTERNAL^DILFD(2005,113,,STCODE,"MAGMSG")
- +5 if $GET(DIERR)
- SET ERR=$$ERROR^MAGUERR("-38S",,STCODE)
- +6 ;--- Return the description
- +7 QUIT $SELECT(STDESCR'="":STDESCR,1:"<Status: "_STCODE_">")
- +8 ;
- +9 ;##### CHECKS IF THE IMAGE IS MARKED AS DELETED
- +10 ;
- +11 ; IMGIEN Internal Entry Number of the image record
- +12 ;
- +13 ; [.ERR] Reference to a local variable where the error
- +14 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +15 ;
- +16 ; Return Values
- +17 ; =============
- +18 ; 0 Image is not marked as deleted or there was an error;
- +19 ; check the value of the ERR parameter.
- +20 ; 1 IMGIEN references a deleted image
- +21 ;
- ISDEL(IMGIEN,ERR) ;
- +1 ;~~~ Delete this comment and the following lines of code when
- +2 ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
- +3 SET ERR=""
- +4 IF $DATA(^MAG(2005.1,IMGIEN))
- if '$DATA(^MAG(2005,IMGIEN))
- QUIT 1
- Begin DoDot:1
- +5 SET ERR=$$ERROR^MAGUERR("-43S",,IMGIEN)
- +6 QUIT
- End DoDot:1
- QUIT 0
- +7 ;---
- +8 QUIT (+$$IMGST(IMGIEN,.ERR)=12)
- +9 ;
- +10 ;##### CHECKS IF THE IEN IS INVALID OR THE IMAGE IS DELETED
- +11 ;
- +12 ; IMGIEN Internal Entry Number of the image record
- +13 ;
- +14 ; [.ERR] Reference to a local variable where the error
- +15 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +16 ;
- +17 ; Return Values
- +18 ; =============
- +19 ; 0 IEN is valid and the image is not deleted
- +20 ; 1 Invalid IEN or the image is marked as delete;
- +21 ; check the value of the ERR parameter for details.
- +22 ;
- ISDELINV(IMGIEN,ERR) ;
- +1 QUIT $SELECT($$ISDEL(IMGIEN,.ERR):1,1:ERR<0)
- +2 ;
- +3 ;##### CHECKS IF THE IMGIEN REFERENCES A GROUP PARENT
- +4 ;
- +5 ; IMGIEN Internal Entry Number of the image record
- +6 ;
- +7 ; [.ERR] Reference to a local variable where the error
- +8 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +9 ;
- +10 ; Return Values
- +11 ; =============
- +12 ; 0 Image is not a group parent or there was an error;
- +13 ; check the value of the ERR parameter.
- +14 ; 1 IMGIEN references a group parent
- +15 ;
- ISGRP(IMGIEN,ERR) ;
- +1 NEW NODE,OBJTYPE
- +2 SET NODE=$$NODE(IMGIEN,.ERR)
- if NODE=""
- QUIT 0
- +3 ; OBJECT TYPE (3)
- SET OBJTYPE=$PIECE($GET(@NODE@(0)),U,6)
- +4 QUIT (OBJTYPE=11)!(OBJTYPE=16)
- +5 ;
- +6 ;##### CHECKS IF THE PARAMETER VALUE IS A VALID IMAGE IEN
- +7 ;
- +8 ; IMGIEN Internal Entry Number of the image record
- +9 ;
- +10 ; [.ERR] Reference to a local variable where the error
- +11 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +12 ;
- +13 ; Return Values
- +14 ; =============
- +15 ; 0 Parameter value is not a valid image IEN;
- +16 ; check the value of the ERR parameter.
- +17 ; 1 Valid image IEN
- +18 ;
- ISVALID(IMGIEN,ERR) ;
- +1 QUIT $$NODE(IMGIEN,.ERR)'=""
- +2 ;
- +3 ;##### RETURNS THE CLOSED REFERENCE TO THE IMAGE RECORD
- +4 ;
- +5 ; IMGIEN Internal Entry Number of the image record
- +6 ;
- +7 ; [.ERR] Reference to a local variable where the error
- +8 ; descriptor (see the $$ERROR^MAGUERR) is returned to.
- +9 ;
- +10 ; Return Values
- +11 ; =============
- +12 ; "" Invalid IEN or there is no such record
- +13 ; "^MAG(...)" Closed reference to the image data node
- +14 ;
- NODE(IMGIEN,ERR) ;
- +1 SET ERR=""
- +2 ;--- Validate the IMGIEN parameter
- +3 IF (IMGIEN'>0)!(+IMGIEN'=IMGIEN)
- Begin DoDot:1
- +4 SET ERR=$$ERROR^MAGUERR("-3S",,"IMGIEN",IMGIEN)
- +5 QUIT
- End DoDot:1
- QUIT ""
- +6 ;--- Check if the image data exists
- +7 if $DATA(^MAG(2005,IMGIEN))
- QUIT $NAME(^(IMGIEN))
- +8 ;~~~ Delete this comment and the following line of code when
- +9 ;~~~ the IMAGE AUDIT file (#2005.1) is completely eliminated.
- +10 if $DATA(^MAG(2005.1,IMGIEN))
- QUIT $NAME(^(IMGIEN))
- +11 ;--- There is no such record
- +12 SET ERR=$$ERROR^MAGUERR("-22S",,2005,IMGIEN_",")
- +13 QUIT ""