MAGDQR12 ;WOIFO/EdM,MLH,NST - Imaging RPCs for Query/Retrieve ; 16 Apr 2013 1:12 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
; -- overflow from MAGDQR02
;
STUDYID(REQ,T,SID,ANY) ; TAG = 0020,0010 R Study ID
; The references below to ^RADPT are permitted according to the
; existing Integration Agreement # 1172
N D1,ID,PATREFDTA,MAGD0,MAGD1,I,ACCARY,P,TMPQ,V
S TMPQ=$NA(^TMP("MAG",$J,"QR"))
S P="" F S P=$O(REQ(T,P)) Q:P="" S ID=+REQ(T,P) D:ID
. S ANY=1
. ; First scan for images in the new structure
. S I=$$MATCHD^MAGDQR03("*-"_ID,"^MAGV(2005.61,""B"",LOOP)","^TMP(""MAG"",$J,""QR"",19.1,LOOP)")
. S I=$$MATCHD^MAGDQR03("*-"_ID,"^RADPT(""ADC"",LOOP)","^TMP(""MAG"",$J,""QR"",19.1,LOOP)") ; Radiology lookup
. S I=$$MATCHD^MAGDQR03("*-"_ID,"^RADPT(""ADC1"",LOOP)","^TMP(""MAG"",$J,""QR"",19.1,LOOP)") ; Radiology lookup
. S V=""
. F S V=$O(^TMP("MAG",$J,"QR",19.1,V)) Q:V="" D ; V is an accession number
. . S:$$ADDSTUDY^MAGDQR74(V,$NA(@TMPQ@(10)),$NA(@TMPQ@(19))) SID=1
. . Q
. ; Then scan for legacy Radiology Related Images (including site specific accession numbers)
. S I=$$MATCHD^MAGDQR03("*-"_ID,"^RADPT(""ADC"",LOOP)","^TMP(""MAG"",$J,""QR"",9,LOOP)")
. S I=$$MATCHD^MAGDQR03("*-"_ID,"^RADPT(""ADC1"",LOOP)","^TMP(""MAG"",$J,""QR"",9,LOOP)")
. S V="" F S V=$O(^TMP("MAG",$J,"QR",9,V)) Q:V="" D
. . Q:$D(^TMP("MAG",$J,"QR",19,V)) ; already picked up from new structure
. . D ACCFIND^RAAPI(V,.ACCARY) ; Radiology acc# lookup utility Private IA (#5020)
. . S I=0 F S I=$O(ACCARY(I)) Q:'I D
. . . S ^TMP("MAG",$J,"QR",10,"R^"_ACCARY(I))="",SID=1
. . . Q
. . Q
. ; Then scan for legacy Consult Related Images
. S D1=0
. I '$D(^TMP("MAG",$J,"QR",19,ID)) F S D1=$O(^GMR(123,ID,50,D1)) Q:'D1 D
. . N I,T,X
. . S X=$P($G(^GMR(123,ID,50,D1,0)),"^",1) Q:X'[";TIU(8925,"
. . S T=+X
. . S MAGD1="" F S MAGD1=$O(^TIU(8925.91,"B",T,MAGD1)) Q:MAGD1="" D
. . . S X=$G(^TIU(8925.91,MAGD1,0)),I=$P(X,"^",2) Q:'I
. . . S ^TMP("MAG",$J,"QR",10,"C^"_MAGD0_"^8925^"_T_"^"_I_"^"_ID)="",SID=1
. . . Q
. . Q
. Q
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGDQR12 3119 printed Nov 22, 2024@17:11:07 Page 2
MAGDQR12 ;WOIFO/EdM,MLH,NST - Imaging RPCs for Query/Retrieve ; 16 Apr 2013 1:12 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 ; -- overflow from MAGDQR02
+19 ;
STUDYID(REQ,T,SID,ANY) ; TAG = 0020,0010 R Study ID
+1 ; The references below to ^RADPT are permitted according to the
+2 ; existing Integration Agreement # 1172
+3 NEW D1,ID,PATREFDTA,MAGD0,MAGD1,I,ACCARY,P,TMPQ,V
+4 SET TMPQ=$NAME(^TMP("MAG",$JOB,"QR"))
+5 SET P=""
FOR
SET P=$ORDER(REQ(T,P))
if P=""
QUIT
SET ID=+REQ(T,P)
if ID
Begin DoDot:1
+6 SET ANY=1
+7 ; First scan for images in the new structure
+8 SET I=$$MATCHD^MAGDQR03("*-"_ID,"^MAGV(2005.61,""B"",LOOP)","^TMP(""MAG"",$J,""QR"",19.1,LOOP)")
+9 ; Radiology lookup
SET I=$$MATCHD^MAGDQR03("*-"_ID,"^RADPT(""ADC"",LOOP)","^TMP(""MAG"",$J,""QR"",19.1,LOOP)")
+10 ; Radiology lookup
SET I=$$MATCHD^MAGDQR03("*-"_ID,"^RADPT(""ADC1"",LOOP)","^TMP(""MAG"",$J,""QR"",19.1,LOOP)")
+11 SET V=""
+12 ; V is an accession number
FOR
SET V=$ORDER(^TMP("MAG",$JOB,"QR",19.1,V))
if V=""
QUIT
Begin DoDot:2
+13 if $$ADDSTUDY^MAGDQR74(V,$NAME(@TMPQ@(10)),$NAME(@TMPQ@(19)))
SET SID=1
+14 QUIT
End DoDot:2
+15 ; Then scan for legacy Radiology Related Images (including site specific accession numbers)
+16 SET I=$$MATCHD^MAGDQR03("*-"_ID,"^RADPT(""ADC"",LOOP)","^TMP(""MAG"",$J,""QR"",9,LOOP)")
+17 SET I=$$MATCHD^MAGDQR03("*-"_ID,"^RADPT(""ADC1"",LOOP)","^TMP(""MAG"",$J,""QR"",9,LOOP)")
+18 SET V=""
FOR
SET V=$ORDER(^TMP("MAG",$JOB,"QR",9,V))
if V=""
QUIT
Begin DoDot:2
+19 ; already picked up from new structure
if $DATA(^TMP("MAG",$JOB,"QR",19,V))
QUIT
+20 ; Radiology acc# lookup utility Private IA (#5020)
DO ACCFIND^RAAPI(V,.ACCARY)
+21 SET I=0
FOR
SET I=$ORDER(ACCARY(I))
if 'I
QUIT
Begin DoDot:3
+22 SET ^TMP("MAG",$JOB,"QR",10,"R^"_ACCARY(I))=""
SET SID=1
+23 QUIT
End DoDot:3
+24 QUIT
End DoDot:2
+25 ; Then scan for legacy Consult Related Images
+26 SET D1=0
+27 IF '$DATA(^TMP("MAG",$JOB,"QR",19,ID))
FOR
SET D1=$ORDER(^GMR(123,ID,50,D1))
if 'D1
QUIT
Begin DoDot:2
+28 NEW I,T,X
+29 SET X=$PIECE($GET(^GMR(123,ID,50,D1,0)),"^",1)
if X'[";TIU(8925,"
QUIT
+30 SET T=+X
+31 SET MAGD1=""
FOR
SET MAGD1=$ORDER(^TIU(8925.91,"B",T,MAGD1))
if MAGD1=""
QUIT
Begin DoDot:3
+32 SET X=$GET(^TIU(8925.91,MAGD1,0))
SET I=$PIECE(X,"^",2)
if 'I
QUIT
+33 SET ^TMP("MAG",$JOB,"QR",10,"C^"_MAGD0_"^8925^"_T_"^"_I_"^"_ID)=""
SET SID=1
+34 QUIT
End DoDot:3
+35 QUIT
End DoDot:2
+36 QUIT
End DoDot:1
+37 QUIT