MAGNVQ04 ;WOIFO/NST - List images for a patient ; OCT 17, 2018@3:59 PM
;;3.0;IMAGING;**185,221**;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
;
;***** List Images by Patient
;
; RPC: MAGN PATIENT IMAGE LIST
;
; Input Parameters
; ================
;
; IDTYPE = "DFN"or "ICN"
; ID = Patient ID
; [IMGLESS] flag to speed up queries: if=1 (true), just get study-level data
; [FLAGS] for feature use
; [FROMDATE],[TODATE],[MISCPRMS] - see GETIMGS^MAGSIXG1 for discription
;
; Return Values
; =============
;
; if error MAGRY(0) = 0 ^Error message^
; if success MAGRY(0) = 1
; MAGRY(1..n) = images in format defined in RPC [MAGN CPRS IMAGE LIST]
;
IMAGEL(MAGRY,IDTYPE,ID,IMGLESS,FLAGS,FROMDATE,TODATE,MISCPRMS) ;RPC [MAGN PATIENT IMAGE LIST]
N DFN,MAGRY2005,MAGRYP34,MAGDATA,ERROR,FOUND
;
N $ETRAP,$ESTACK S $ETRAP="D AERRA^MAGGTERR"
D CLEAR^MAGUERR(1)
S IMGLESS=$S($D(IMGLESS):+IMGLESS,1:1) ; Default is IMAGELESS
S FLAGS=$G(FLAGS)
;
S MAGRY=$NA(^TMP("MAGNVQ04",$J))
K @MAGRY
S @MAGRY@(0)=0
S IDTYPE=$G(IDTYPE)
I (IDTYPE'="DFN")&(IDTYPE'="ICN") S @MAGRY@(0)="0^Invalid IDTYPE "_IDTYPE Q
;
I IDTYPE="DFN" D I DFN'>0 S @MAGRY@(0)="0^Invalid patient ID: "_DFN Q
. S DFN=$G(ID)
. Q
I IDTYPE="ICN" D I DFN'>0 S @MAGRY@(0)="0^Error: "_DFN Q
. S DFN=$S($T(GETDFN^MPIF001)'="":$$GETDFN^MPIF001(ID),1:"-1^NO MPI") ; Supported IA (#2701)
. Q
;
S FLAGS=$S($G(FLAGS)="":"E",1:FLAGS)
;
I DFN'>0 S @MAGRY@(0)="0^Invalid patient ID: "_DFN Q
;
S I=""
S FOUND=0
F S I=$O(MISCPRMS(I)) Q:FOUND!'I I $P(MISCPRMS(I),"^")="IDFN" S FOUND=I
I 'FOUND D
. S I=$O(MISCPRMS(""),-1)+1 ; set next parameter counter
. S MISCPRMS(I)="IDFN^^"_DFN
. Q
;
;=== Validate parameters
S ERROR=$$VALPARAM^MAGSIXG1(.MAGDATA,FLAGS,.FROMDATE,.TODATE,"",.MISCPRMS)
;
;--- Check for errors
I ERROR D ERROR^MAGUERR(-30),ERRORS^MAGSIXG1(.MAGRY) Q
;
D IMG2005(MAGRY,DFN,IMGLESS,FLAGS,FROMDATE,TODATE,.MAGDATA) ; Get #2005 images
;
D IMAGEP34(MAGRY,DFN,IMGLESS,FLAGS,FROMDATE,TODATE,.MAGDATA) ; Get P34 images
;
S @MAGRY@(0)=1
Q
;
IMG2005(MAGRYOUT,DFN,IMGLESS,FLAGS,FROMDATE,TODATE,MAGDATA) ; Get images from #2005
; DFN = Patient DFN
; IMGLESS = 0|1 Include images
; [FLAGS] = for feature use
;
N I,IMAGE,GROUPS,OUT,QF,RC,TMP
;
;=== Query the image file(s)
S MAGDATA("FLAGS")=FLAGS,MAGDATA("MAXNUM")=""
S TMP=$S(TODATE<9999999:$$FMADD^XLFDT(TODATE,1),1:TODATE)
S QF=$$TRFLAGS^MAGUTL05(FLAGS,"CDEG")
;
K ^TMP("MAGNVQ07",$J,"QRY2005")
S RC=$$QUERY^MAGGI13("$$QRY2005^MAGNVQ07",QF,.MAGDATA,FROMDATE,TMP,DFN)
I RC<0 D Q
. D ERRORS^MAGSIXG1(.OUT,RC)
. M @MAGRYOUT=OUT
. Q
;
K ^TMP("MAGNVQ07",$J,"QRY2005",0) ; remove the counter
M GROUPS=^TMP("MAGNVQ07",$J,"QRY2005")
K ^TMP("MAGNVQ07",$J,"QRY2005")
D STUDY2^MAGDQR21(.OUT,.GROUPS,DFN,IMGLESS) ; MAG DOD GET STUDIES IEN
;
D UPD2005(MAGRYOUT,.OUT,IMGLESS)
S MAGRYOUT=OUT
S @MAGRYOUT@(0)=1
Q
;
UPD2005(MAGOUT,MAGIN,IMGLESS) ; Add Additional study information
N MAGI,IMGIEN,MAGNCNT,MAGSTUDY
S MAGNCNT=0
S MAGI=1 ; start from line number 2. Line number 1 is a records count
F S MAGI=$O(@MAGIN@(MAGI)) Q:'MAGI D
. S MAGNCNT=MAGNCNT+1
. S @MAGOUT@(MAGNCNT)=@MAGIN@(MAGI)
. I $P(@MAGIN@(MAGI),"|")="STUDY_IEN" D ; Add STUDY_INFO. Better place will be MAGDQR21
. . S MAGNCNT=MAGNCNT+1
. . S IMGIEN=$P(@MAGIN@(MAGI),"|",2) ; IEN of the group
. . S @MAGOUT@(MAGNCNT)="STUDY_INFO|"_$$STDINFO(IMGIEN)
. . S MAGSTUDY=@MAGIN@(MAGI)
. . Q
. I IMGLESS,($P(@MAGIN@(MAGI),"|")="STUDY_PAT") D INSFIMG^MAGNU003(MAGSTUDY,.MAGNCNT,MAGOUT) ; Append First Image Info
. Q
Q
;
IMAGEP34(MAGRY,DFN,IMGLESS,FLAGS,FROMDATE,TODATE,MAGDATA) ; Get P34 images
; DFN = Patient DFN
; IMGLESS = 0|1 Include images
; [FLAGS] = for feature use
;
N IARRAY
S MAGDATA("FLAGS")=FLAGS,MAGDATA("MAXNUM")=""
S TMP=$S(TODATE<9999999:$$FMADD^XLFDT(TODATE,1),1:TODATE)
D PATIMG34^MAGNVQ05(.IARRAY,DFN,IMGLESS,FROMDATE,TODATE,.MAGDATA) ; Get patient images
;
D GETSTUDY^MAGNVQ01(MAGRY,.IARRAY,"","","") ; Get Study by graph ien
Q
;
STDINFO(IMGIEN) ; Get Study Info by IEN in IMAGE file (#2005)
N IMGNODE,X2,PFILE,REFTYPE,REFIEN
;
S IMGNODE=$$NODE^MAGGI11(IMGIEN)
Q:IMGNODE="" ""
;
S X2=$G(@IMGNODE@(2))
;
S PFILE=$P(X2,U,6) ; PARENT DATA FILE#
S REFTYPE=$$GET1^DIQ(2005.03,PFILE,.02)
;
S REFIEN=$P(X2,U,7) ;PARENT GLOBAL ROOT D0
;
Q $$STDINFO^MAGNU003(IMGIEN,REFTYPE,REFIEN,"")
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGNVQ04 5561 printed Dec 13, 2024@02:07:37 Page 2
MAGNVQ04 ;WOIFO/NST - List images for a patient ; OCT 17, 2018@3:59 PM
+1 ;;3.0;IMAGING;**185,221**;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 ;***** List Images by Patient
+20 ;
+21 ; RPC: MAGN PATIENT IMAGE LIST
+22 ;
+23 ; Input Parameters
+24 ; ================
+25 ;
+26 ; IDTYPE = "DFN"or "ICN"
+27 ; ID = Patient ID
+28 ; [IMGLESS] flag to speed up queries: if=1 (true), just get study-level data
+29 ; [FLAGS] for feature use
+30 ; [FROMDATE],[TODATE],[MISCPRMS] - see GETIMGS^MAGSIXG1 for discription
+31 ;
+32 ; Return Values
+33 ; =============
+34 ;
+35 ; if error MAGRY(0) = 0 ^Error message^
+36 ; if success MAGRY(0) = 1
+37 ; MAGRY(1..n) = images in format defined in RPC [MAGN CPRS IMAGE LIST]
+38 ;
IMAGEL(MAGRY,IDTYPE,ID,IMGLESS,FLAGS,FROMDATE,TODATE,MISCPRMS) ;RPC [MAGN PATIENT IMAGE LIST]
+1 NEW DFN,MAGRY2005,MAGRYP34,MAGDATA,ERROR,FOUND
+2 ;
+3 NEW $ETRAP,$ESTACK
SET $ETRAP="D AERRA^MAGGTERR"
+4 DO CLEAR^MAGUERR(1)
+5 ; Default is IMAGELESS
SET IMGLESS=$SELECT($DATA(IMGLESS):+IMGLESS,1:1)
+6 SET FLAGS=$GET(FLAGS)
+7 ;
+8 SET MAGRY=$NAME(^TMP("MAGNVQ04",$JOB))
+9 KILL @MAGRY
+10 SET @MAGRY@(0)=0
+11 SET IDTYPE=$GET(IDTYPE)
+12 IF (IDTYPE'="DFN")&(IDTYPE'="ICN")
SET @MAGRY@(0)="0^Invalid IDTYPE "_IDTYPE
QUIT
+13 ;
+14 IF IDTYPE="DFN"
Begin DoDot:1
+15 SET DFN=$GET(ID)
+16 QUIT
End DoDot:1
IF DFN'>0
SET @MAGRY@(0)="0^Invalid patient ID: "_DFN
QUIT
+17 IF IDTYPE="ICN"
Begin DoDot:1
+18 ; Supported IA (#2701)
SET DFN=$SELECT($TEXT(GETDFN^MPIF001)'="":$$GETDFN^MPIF001(ID),1:"-1^NO MPI")
+19 QUIT
End DoDot:1
IF DFN'>0
SET @MAGRY@(0)="0^Error: "_DFN
QUIT
+20 ;
+21 SET FLAGS=$SELECT($GET(FLAGS)="":"E",1:FLAGS)
+22 ;
+23 IF DFN'>0
SET @MAGRY@(0)="0^Invalid patient ID: "_DFN
QUIT
+24 ;
+25 SET I=""
+26 SET FOUND=0
+27 FOR
SET I=$ORDER(MISCPRMS(I))
if FOUND!'I
QUIT
IF $PIECE(MISCPRMS(I),"^")="IDFN"
SET FOUND=I
+28 IF 'FOUND
Begin DoDot:1
+29 ; set next parameter counter
SET I=$ORDER(MISCPRMS(""),-1)+1
+30 SET MISCPRMS(I)="IDFN^^"_DFN
+31 QUIT
End DoDot:1
+32 ;
+33 ;=== Validate parameters
+34 SET ERROR=$$VALPARAM^MAGSIXG1(.MAGDATA,FLAGS,.FROMDATE,.TODATE,"",.MISCPRMS)
+35 ;
+36 ;--- Check for errors
+37 IF ERROR
DO ERROR^MAGUERR(-30)
DO ERRORS^MAGSIXG1(.MAGRY)
QUIT
+38 ;
+39 ; Get #2005 images
DO IMG2005(MAGRY,DFN,IMGLESS,FLAGS,FROMDATE,TODATE,.MAGDATA)
+40 ;
+41 ; Get P34 images
DO IMAGEP34(MAGRY,DFN,IMGLESS,FLAGS,FROMDATE,TODATE,.MAGDATA)
+42 ;
+43 SET @MAGRY@(0)=1
+44 QUIT
+45 ;
IMG2005(MAGRYOUT,DFN,IMGLESS,FLAGS,FROMDATE,TODATE,MAGDATA) ; Get images from #2005
+1 ; DFN = Patient DFN
+2 ; IMGLESS = 0|1 Include images
+3 ; [FLAGS] = for feature use
+4 ;
+5 NEW I,IMAGE,GROUPS,OUT,QF,RC,TMP
+6 ;
+7 ;=== Query the image file(s)
+8 SET MAGDATA("FLAGS")=FLAGS
SET MAGDATA("MAXNUM")=""
+9 SET TMP=$SELECT(TODATE<9999999:$$FMADD^XLFDT(TODATE,1),1:TODATE)
+10 SET QF=$$TRFLAGS^MAGUTL05(FLAGS,"CDEG")
+11 ;
+12 KILL ^TMP("MAGNVQ07",$JOB,"QRY2005")
+13 SET RC=$$QUERY^MAGGI13("$$QRY2005^MAGNVQ07",QF,.MAGDATA,FROMDATE,TMP,DFN)
+14 IF RC<0
Begin DoDot:1
+15 DO ERRORS^MAGSIXG1(.OUT,RC)
+16 MERGE @MAGRYOUT=OUT
+17 QUIT
End DoDot:1
QUIT
+18 ;
+19 ; remove the counter
KILL ^TMP("MAGNVQ07",$JOB,"QRY2005",0)
+20 MERGE GROUPS=^TMP("MAGNVQ07",$JOB,"QRY2005")
+21 KILL ^TMP("MAGNVQ07",$JOB,"QRY2005")
+22 ; MAG DOD GET STUDIES IEN
DO STUDY2^MAGDQR21(.OUT,.GROUPS,DFN,IMGLESS)
+23 ;
+24 DO UPD2005(MAGRYOUT,.OUT,IMGLESS)
+25 SET MAGRYOUT=OUT
+26 SET @MAGRYOUT@(0)=1
+27 QUIT
+28 ;
UPD2005(MAGOUT,MAGIN,IMGLESS) ; Add Additional study information
+1 NEW MAGI,IMGIEN,MAGNCNT,MAGSTUDY
+2 SET MAGNCNT=0
+3 ; start from line number 2. Line number 1 is a records count
SET MAGI=1
+4 FOR
SET MAGI=$ORDER(@MAGIN@(MAGI))
if 'MAGI
QUIT
Begin DoDot:1
+5 SET MAGNCNT=MAGNCNT+1
+6 SET @MAGOUT@(MAGNCNT)=@MAGIN@(MAGI)
+7 ; Add STUDY_INFO. Better place will be MAGDQR21
IF $PIECE(@MAGIN@(MAGI),"|")="STUDY_IEN"
Begin DoDot:2
+8 SET MAGNCNT=MAGNCNT+1
+9 ; IEN of the group
SET IMGIEN=$PIECE(@MAGIN@(MAGI),"|",2)
+10 SET @MAGOUT@(MAGNCNT)="STUDY_INFO|"_$$STDINFO(IMGIEN)
+11 SET MAGSTUDY=@MAGIN@(MAGI)
+12 QUIT
End DoDot:2
+13 ; Append First Image Info
IF IMGLESS
IF ($PIECE(@MAGIN@(MAGI),"|")="STUDY_PAT")
DO INSFIMG^MAGNU003(MAGSTUDY,.MAGNCNT,MAGOUT)
+14 QUIT
End DoDot:1
+15 QUIT
+16 ;
IMAGEP34(MAGRY,DFN,IMGLESS,FLAGS,FROMDATE,TODATE,MAGDATA) ; Get P34 images
+1 ; DFN = Patient DFN
+2 ; IMGLESS = 0|1 Include images
+3 ; [FLAGS] = for feature use
+4 ;
+5 NEW IARRAY
+6 SET MAGDATA("FLAGS")=FLAGS
SET MAGDATA("MAXNUM")=""
+7 SET TMP=$SELECT(TODATE<9999999:$$FMADD^XLFDT(TODATE,1),1:TODATE)
+8 ; Get patient images
DO PATIMG34^MAGNVQ05(.IARRAY,DFN,IMGLESS,FROMDATE,TODATE,.MAGDATA)
+9 ;
+10 ; Get Study by graph ien
DO GETSTUDY^MAGNVQ01(MAGRY,.IARRAY,"","","")
+11 QUIT
+12 ;
STDINFO(IMGIEN) ; Get Study Info by IEN in IMAGE file (#2005)
+1 NEW IMGNODE,X2,PFILE,REFTYPE,REFIEN
+2 ;
+3 SET IMGNODE=$$NODE^MAGGI11(IMGIEN)
+4 if IMGNODE=""
QUIT ""
+5 ;
+6 SET X2=$GET(@IMGNODE@(2))
+7 ;
+8 ; PARENT DATA FILE#
SET PFILE=$PIECE(X2,U,6)
+9 SET REFTYPE=$$GET1^DIQ(2005.03,PFILE,.02)
+10 ;
+11 ;PARENT GLOBAL ROOT D0
SET REFIEN=$PIECE(X2,U,7)
+12 ;
+13 QUIT $$STDINFO^MAGNU003(IMGIEN,REFTYPE,REFIEN,"")