MAGNVQ03 ;WOIFO/NST - Retrieve Image Info ; 02 Oct 2017 3:59 PM
;;3.0;IMAGING;**185**;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
;
;***** Return Image Info Report
;
;
; Input Parameters
; ================
;
; DATA - Image IEN in IMAGE SOP INSTANCE file (#2005.64)
; Return Values
; =============
;
; if error MAGRY(0) = 0 ^Error message^
; if success MAGRY(0) = 1
; MAGRY(1..n) = Image Info Report
;
IMGINFO(MAGRY,DATA) ; Return Image Info Report
N MAGPAT,MAGPROC,MAGSTUDY,MAGSER,MAGSOP,MAGIMAGE,MAGAFACT,MAGAINST
N CNT,ERR,FILE,IEN,IENS,LINE,IMAGE
;
N $ETRAP,$ESTACK S $ETRAP="D AERRA^MAGGTERR"
;
K @MAGRY
; Get SOP Details
S FILE("SOP")=2005.64
S IEN("SOP")=DATA
S IENS("SOP")=IEN("SOP")_","
D GETS^DIQ(FILE("SOP"),IEN("SOP"),"**","RIEN","MAGSOP","ERR")
I $D(ERR) S @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("SOP"),IEN("SOP"),.ERR) Q
;
; Get Series Details
S FILE("SERIES")=2005.63
S IEN("SERIES")=$G(MAGSOP(FILE("SOP"),IENS("SOP"),"SERIES REFERENCE","I"))
S IENS("SERIES")=IEN("SERIES")_","
D GETS^DIQ(FILE("SERIES"),IEN("SERIES"),"**","RIEN","MAGSER","ERR")
I $D(ERR) S @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("SERIES"),IEN("SERIES"),.ERR) Q
;
; Get Study Details
S FILE("STUDY")=2005.62
S IEN("STUDY")=$G(MAGSER(FILE("SERIES"),IENS("SERIES"),"STUDY REFERENCE","I"))
S IENS("STUDY")=IEN("STUDY")_","
D GETS^DIQ(FILE("STUDY"),IEN("STUDY"),"**","RIEN","MAGSTUDY","ERR")
I $D(ERR) S @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("STUDY"),IEN("STUDY"),.ERR) Q
;
; Get Procedure Details
S FILE("PROCEDURE")=2005.61
S IEN("PROCEDURE")=$G(MAGSTUDY(FILE("STUDY"),IENS("STUDY"),"PROCEDURE REFERENCE","I"))
S IENS("PROCEDURE")=IEN("PROCEDURE")_","
D GETS^DIQ(FILE("PROCEDURE"),IEN("PROCEDURE"),"**","RIEN","MAGPROC","ERR")
I $D(ERR) S @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("PROCEDURE"),IEN("PROCEDURE"),.ERR) Q
;
; Get Patient Details
S FILE("PATIENT")=2005.6
S IEN("PATIENT")=$G(MAGPROC(FILE("PROCEDURE"),IENS("PROCEDURE"),"PATIENT REFERENCE","I"))
S IENS("PATIENT")=IEN("PATIENT")_","
D GETS^DIQ(FILE("PATIENT"),IEN("PATIENT"),"**","RIEN","MAGPAT","ERR")
I $D(ERR) S @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("PATIENT"),IEN("PATIENT"),.ERR) Q
;
S CNT=0
D ADD(MAGRY,.CNT,.MAGPAT,FILE("PATIENT"),IENS("PATIENT")) ; Add Patient details
D ADD(MAGRY,.CNT,.MAGPROC,FILE("PROCEDURE"),IENS("PROCEDURE")) ; Add Procedure details
D ADD(MAGRY,.CNT,.MAGSTUDY,FILE("STUDY"),IENS("STUDY")) ; Add Study details
D ADD(MAGRY,.CNT,.MAGSER,FILE("SERIES"),IENS("SERIES")) ; Add SERIES details
D ADD(MAGRY,.CNT,.MAGSOP,FILE("SOP"),IENS("SOP")) ; Add SOP details
;
S IMAGE=""
F S IMAGE=$O(^MAGV(2005.65,"C",IEN("SOP"),IMAGE)) Q:'IMAGE D
. D ADDIMGD(MAGRY,.CNT,IMAGE)
. Q
I $G(@MAGRY@(0))=0 Q ; Error during adding records
;
S @MAGRY@(0)=1
Q
;
ADD(MAGRY,CNT,DATA,FILE,IENS) ; Add Entity details to array e.g. Patient, procedure
N ATTR,HEADER,LINE,TYEREF,HEADE,DASH,LEN
;
I CNT>0 S CNT=CNT+1,@MAGRY@(CNT)=""
S HEADER=" "_$$GETFILNM^MAGVAF01(FILE)_" (#"_FILE_") "
S LEN=(78-$L(HEADER))\2
S DASH=$TR($J("-",LEN)," ","-")
S CNT=CNT+1,@MAGRY@(CNT)=DASH_HEADER_DASH
S CNT=CNT+1,@MAGRY@(CNT)=""
;
S ATTR=""
F S ATTR=$O(DATA(FILE,IENS,ATTR)) Q:ATTR="" D
. I $$ISFLDWP^MAGVAF01(.TYEREF,FILE,ATTR) D Q
. . ; TO-DO Do word-procesing field
. . Q
. S LINE=ATTR
. S $E(LINE,25,999)=" = ("_$G(DATA(FILE,IENS,ATTR,"I"))_")"
. S:$G(DATA(FILE,IENS,ATTR,"E"))'=$G(DATA(FILE,IENS,ATTR,"I")) $E(LINE,45,999)=" = "_$G(DATA(FILE,IENS,ATTR,"E"))
. S CNT=CNT+1,@MAGRY@(CNT)=LINE
. Q
Q
;
ADDAINST(MAGRY,CNT,AFACTIEN) ; Add Artifact Instance
N MAGI,FILE,LINEHDR,TMPARR,MAGOUT,OUT,ERR,VALUE,LOCATION
;
S FILE=2006.918
D FIND^DIC(FILE,,"@;","BQX",AFACTIEN,"","","","","OUT","ERR")
S MAGI="" ; IENs
F S MAGI=$O(OUT("DILIST",2,MAGI)) Q:'MAGI D Q:$D(ERR)
. S IEN=OUT("DILIST",2,MAGI)
. D GETS^DIQ(FILE,IEN,"**","RIEN","MAGOUT","ERR")
. I $D(ERR) S @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE,IEN,.ERR) Q
. S VALUE=$G(MAGOUT(FILE,IEN_",","DISK VOLUME","I"))
. S MAGOUT(FILE,IEN_",","DISK VOLUME","E")=$G(MAGOUT(FILE,IEN_",","DISK VOLUME","E"))_" : "_$$GET1^DIQ(2005.2,VALUE,"1")
. D ADD(MAGRY,.CNT,.MAGOUT,FILE,IEN_",")
. Q
Q
;
ADDIMGD(MAGRY,CNT,IMAGE) ; Add one SOP instance
N FILE,IEN,IENS,ERR,MAGIMAGE,MAGAFACT
;
S FILE("IMAGE")=2005.65
S IEN("IMAGE")=IMAGE
S IENS("IMAGE")=IMAGE_","
K MAGOUT
D GETS^DIQ(FILE("IMAGE"),IEN("IMAGE"),"**","RIEN","MAGIMAGE","ERR")
I $D(ERR) S @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("IMAGE"),IEN("IMAGE"),.ERR) Q
D ADD(MAGRY,.CNT,.MAGIMAGE,FILE("IMAGE"),IENS("IMAGE"))
;
; Get Artifact Details
S FILE("ARTIFACT")=2006.916
S IEN("ARTIFACT")=$G(MAGIMAGE(FILE("IMAGE"),IENS("IMAGE"),"ARTIFACT REFERENCE","I"))
S IENS("ARTIFACT")=IEN("ARTIFACT")_","
D GETS^DIQ(FILE("ARTIFACT"),IEN("ARTIFACT"),"**","RIEN","MAGAFACT","ERR")
I $D(ERR) S @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("ARTIFACT"),IEN("ARTIFACT"),.ERR) Q
;
D ADDAINST(MAGRY,.CNT,MAGIMAGE(FILE("IMAGE"),IENS("IMAGE"),"ARTIFACT REFERENCE","I")) ; Add Artifact Instance
;
Q
;
ERRTEXT(ACTION,FILE,IEN,ERR) ; Format error message
Q ACTION_" : "_FILE_" : "_IEN_" : "_$G(ERR("DIERR",1,"TEXT",1))
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGNVQ03 6325 printed Dec 13, 2024@02:07:36 Page 2
MAGNVQ03 ;WOIFO/NST - Retrieve Image Info ; 02 Oct 2017 3:59 PM
+1 ;;3.0;IMAGING;**185**;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 ;***** Return Image Info Report
+20 ;
+21 ;
+22 ; Input Parameters
+23 ; ================
+24 ;
+25 ; DATA - Image IEN in IMAGE SOP INSTANCE file (#2005.64)
+26 ; Return Values
+27 ; =============
+28 ;
+29 ; if error MAGRY(0) = 0 ^Error message^
+30 ; if success MAGRY(0) = 1
+31 ; MAGRY(1..n) = Image Info Report
+32 ;
IMGINFO(MAGRY,DATA) ; Return Image Info Report
+1 NEW MAGPAT,MAGPROC,MAGSTUDY,MAGSER,MAGSOP,MAGIMAGE,MAGAFACT,MAGAINST
+2 NEW CNT,ERR,FILE,IEN,IENS,LINE,IMAGE
+3 ;
+4 NEW $ETRAP,$ESTACK
SET $ETRAP="D AERRA^MAGGTERR"
+5 ;
+6 KILL @MAGRY
+7 ; Get SOP Details
+8 SET FILE("SOP")=2005.64
+9 SET IEN("SOP")=DATA
+10 SET IENS("SOP")=IEN("SOP")_","
+11 DO GETS^DIQ(FILE("SOP"),IEN("SOP"),"**","RIEN","MAGSOP","ERR")
+12 IF $DATA(ERR)
SET @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("SOP"),IEN("SOP"),.ERR)
QUIT
+13 ;
+14 ; Get Series Details
+15 SET FILE("SERIES")=2005.63
+16 SET IEN("SERIES")=$GET(MAGSOP(FILE("SOP"),IENS("SOP"),"SERIES REFERENCE","I"))
+17 SET IENS("SERIES")=IEN("SERIES")_","
+18 DO GETS^DIQ(FILE("SERIES"),IEN("SERIES"),"**","RIEN","MAGSER","ERR")
+19 IF $DATA(ERR)
SET @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("SERIES"),IEN("SERIES"),.ERR)
QUIT
+20 ;
+21 ; Get Study Details
+22 SET FILE("STUDY")=2005.62
+23 SET IEN("STUDY")=$GET(MAGSER(FILE("SERIES"),IENS("SERIES"),"STUDY REFERENCE","I"))
+24 SET IENS("STUDY")=IEN("STUDY")_","
+25 DO GETS^DIQ(FILE("STUDY"),IEN("STUDY"),"**","RIEN","MAGSTUDY","ERR")
+26 IF $DATA(ERR)
SET @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("STUDY"),IEN("STUDY"),.ERR)
QUIT
+27 ;
+28 ; Get Procedure Details
+29 SET FILE("PROCEDURE")=2005.61
+30 SET IEN("PROCEDURE")=$GET(MAGSTUDY(FILE("STUDY"),IENS("STUDY"),"PROCEDURE REFERENCE","I"))
+31 SET IENS("PROCEDURE")=IEN("PROCEDURE")_","
+32 DO GETS^DIQ(FILE("PROCEDURE"),IEN("PROCEDURE"),"**","RIEN","MAGPROC","ERR")
+33 IF $DATA(ERR)
SET @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("PROCEDURE"),IEN("PROCEDURE"),.ERR)
QUIT
+34 ;
+35 ; Get Patient Details
+36 SET FILE("PATIENT")=2005.6
+37 SET IEN("PATIENT")=$GET(MAGPROC(FILE("PROCEDURE"),IENS("PROCEDURE"),"PATIENT REFERENCE","I"))
+38 SET IENS("PATIENT")=IEN("PATIENT")_","
+39 DO GETS^DIQ(FILE("PATIENT"),IEN("PATIENT"),"**","RIEN","MAGPAT","ERR")
+40 IF $DATA(ERR)
SET @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("PATIENT"),IEN("PATIENT"),.ERR)
QUIT
+41 ;
+42 SET CNT=0
+43 ; Add Patient details
DO ADD(MAGRY,.CNT,.MAGPAT,FILE("PATIENT"),IENS("PATIENT"))
+44 ; Add Procedure details
DO ADD(MAGRY,.CNT,.MAGPROC,FILE("PROCEDURE"),IENS("PROCEDURE"))
+45 ; Add Study details
DO ADD(MAGRY,.CNT,.MAGSTUDY,FILE("STUDY"),IENS("STUDY"))
+46 ; Add SERIES details
DO ADD(MAGRY,.CNT,.MAGSER,FILE("SERIES"),IENS("SERIES"))
+47 ; Add SOP details
DO ADD(MAGRY,.CNT,.MAGSOP,FILE("SOP"),IENS("SOP"))
+48 ;
+49 SET IMAGE=""
+50 FOR
SET IMAGE=$ORDER(^MAGV(2005.65,"C",IEN("SOP"),IMAGE))
if 'IMAGE
QUIT
Begin DoDot:1
+51 DO ADDIMGD(MAGRY,.CNT,IMAGE)
+52 QUIT
End DoDot:1
+53 ; Error during adding records
IF $GET(@MAGRY@(0))=0
QUIT
+54 ;
+55 SET @MAGRY@(0)=1
+56 QUIT
+57 ;
ADD(MAGRY,CNT,DATA,FILE,IENS) ; Add Entity details to array e.g. Patient, procedure
+1 NEW ATTR,HEADER,LINE,TYEREF,HEADE,DASH,LEN
+2 ;
+3 IF CNT>0
SET CNT=CNT+1
SET @MAGRY@(CNT)=""
+4 SET HEADER=" "_$$GETFILNM^MAGVAF01(FILE)_" (#"_FILE_") "
+5 SET LEN=(78-$LENGTH(HEADER))\2
+6 SET DASH=$TRANSLATE($JUSTIFY("-",LEN)," ","-")
+7 SET CNT=CNT+1
SET @MAGRY@(CNT)=DASH_HEADER_DASH
+8 SET CNT=CNT+1
SET @MAGRY@(CNT)=""
+9 ;
+10 SET ATTR=""
+11 FOR
SET ATTR=$ORDER(DATA(FILE,IENS,ATTR))
if ATTR=""
QUIT
Begin DoDot:1
+12 IF $$ISFLDWP^MAGVAF01(.TYEREF,FILE,ATTR)
Begin DoDot:2
+13 ; TO-DO Do word-procesing field
+14 QUIT
End DoDot:2
QUIT
+15 SET LINE=ATTR
+16 SET $EXTRACT(LINE,25,999)=" = ("_$GET(DATA(FILE,IENS,ATTR,"I"))_")"
+17 if $GET(DATA(FILE,IENS,ATTR,"E"))'=$GET(DATA(FILE,IENS,ATTR,"I"))
SET $EXTRACT(LINE,45,999)=" = "_$GET(DATA(FILE,IENS,ATTR,"E"))
+18 SET CNT=CNT+1
SET @MAGRY@(CNT)=LINE
+19 QUIT
End DoDot:1
+20 QUIT
+21 ;
ADDAINST(MAGRY,CNT,AFACTIEN) ; Add Artifact Instance
+1 NEW MAGI,FILE,LINEHDR,TMPARR,MAGOUT,OUT,ERR,VALUE,LOCATION
+2 ;
+3 SET FILE=2006.918
+4 DO FIND^DIC(FILE,,"@;","BQX",AFACTIEN,"","","","","OUT","ERR")
+5 ; IENs
SET MAGI=""
+6 FOR
SET MAGI=$ORDER(OUT("DILIST",2,MAGI))
if 'MAGI
QUIT
Begin DoDot:1
+7 SET IEN=OUT("DILIST",2,MAGI)
+8 DO GETS^DIQ(FILE,IEN,"**","RIEN","MAGOUT","ERR")
+9 IF $DATA(ERR)
SET @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE,IEN,.ERR)
QUIT
+10 SET VALUE=$GET(MAGOUT(FILE,IEN_",","DISK VOLUME","I"))
+11 SET MAGOUT(FILE,IEN_",","DISK VOLUME","E")=$GET(MAGOUT(FILE,IEN_",","DISK VOLUME","E"))_" : "_$$GET1^DIQ(2005.2,VALUE,"1")
+12 DO ADD(MAGRY,.CNT,.MAGOUT,FILE,IEN_",")
+13 QUIT
End DoDot:1
if $DATA(ERR)
QUIT
+14 QUIT
+15 ;
ADDIMGD(MAGRY,CNT,IMAGE) ; Add one SOP instance
+1 NEW FILE,IEN,IENS,ERR,MAGIMAGE,MAGAFACT
+2 ;
+3 SET FILE("IMAGE")=2005.65
+4 SET IEN("IMAGE")=IMAGE
+5 SET IENS("IMAGE")=IMAGE_","
+6 KILL MAGOUT
+7 DO GETS^DIQ(FILE("IMAGE"),IEN("IMAGE"),"**","RIEN","MAGIMAGE","ERR")
+8 IF $DATA(ERR)
SET @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("IMAGE"),IEN("IMAGE"),.ERR)
QUIT
+9 DO ADD(MAGRY,.CNT,.MAGIMAGE,FILE("IMAGE"),IENS("IMAGE"))
+10 ;
+11 ; Get Artifact Details
+12 SET FILE("ARTIFACT")=2006.916
+13 SET IEN("ARTIFACT")=$GET(MAGIMAGE(FILE("IMAGE"),IENS("IMAGE"),"ARTIFACT REFERENCE","I"))
+14 SET IENS("ARTIFACT")=IEN("ARTIFACT")_","
+15 DO GETS^DIQ(FILE("ARTIFACT"),IEN("ARTIFACT"),"**","RIEN","MAGAFACT","ERR")
+16 IF $DATA(ERR)
SET @MAGRY@(0)="0^"_$$ERRTEXT("GETS",FILE("ARTIFACT"),IEN("ARTIFACT"),.ERR)
QUIT
+17 ;
+18 ; Add Artifact Instance
DO ADDAINST(MAGRY,.CNT,MAGIMAGE(FILE("IMAGE"),IENS("IMAGE"),"ARTIFACT REFERENCE","I"))
+19 ;
+20 QUIT
+21 ;
ERRTEXT(ACTION,FILE,IEN,ERR) ; Format error message
+1 QUIT ACTION_" : "_FILE_" : "_IEN_" : "_$GET(ERR("DIERR",1,"TEXT",1))