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

MAGDSTV1.m

Go to the documentation of this file.
  1. MAGDSTV1 ;WOIFO/PMK - Study Tracker - VistA Query/Retrieve user ; Apr 25, 2022@09:21:50
  1. ;;3.0;IMAGING;**231,305**;Mar 19, 2002;Build 3
  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. ;; | 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. ;
  1. ; Supported IA #10103 reference $$NOW^XLFDT function call
  1. ; Supported IA #10103 reference $$FMTE^XLFDT function call
  1. ;
  1. SOPUIDQ ; Called from batch compare/retrieve for a SOP Instance Query
  1. ; suppress text output when doing a batch query
  1. N BATCHQR
  1. S BATCHQR=1
  1. K ^XTMP(MAGXTMP,HOSTNAME,$J,"AUTOMATIC")
  1. D ENTRY("Q")
  1. Q
  1. ;
  1. SOPUIDR ; Called from batch retrieve for a SOP Instance Retrieval
  1. ; suppress text output when doing a batch retrieve
  1. N BATCHQR
  1. S BATCHQR=1
  1. K ^XTMP(MAGXTMP,HOSTNAME,$J,"AUTOMATIC")
  1. ;
  1. S ^TMP("MAG",$J,"Q/R QUERY",QRSTACK,"ACCESSION NUMBER")=ACNUMB
  1. ;
  1. ; indicate if the retrieve monitor is running - P305 PMK 03/15/2022
  1. I $$ENABLED^MAGDSTV1 S ^TMP("MAG",$J,"Q/R QUERY",QRSTACK,"RETRIEVE MONITOR")="YES"
  1. E S ^TMP("MAG",$J,"Q/R QUERY",QRSTACK,"RETRIEVE MONITOR")="NO"
  1. ;
  1. D ENTRY("R") ; don't show retrieve results
  1. Q
  1. ;
  1. ;
  1. ENTRY(MODE,SHOWRRSL) ; called from ^MAGDSTQ for a VistA Q/R client
  1. N CMOVEAET,GATEWAYHOSTNAME,I,IEN2006541,KEY,REQUESTDATETIME,VALUE,X,ZERONODE
  1. S MODE=$G(MODE)
  1. I MODE'="Q",MODE'="R" D Q
  1. . W !,"Illegal mode in ENTRY^"_$T(+0),": ",MODE
  1. . D CONTINUE^MAGDSTQ
  1. . Q
  1. K ^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"MESSAGE") ; remove any previous query error message
  1. S SHOWRRSL=$G(SHOWRRSL) ; 1 = show retrieval results
  1. ;
  1. ; store the request on the queue
  1. L +^MAGDSTT(2006.541):10 ; foreground process
  1. S ZERONODE=$G(^MAGDSTT(2006.541,0))
  1. S $P(ZERONODE,"^",1,2)="DICOM VISTA Q/R REQUEST QUEUE^2006.541"
  1. S IEN2006541=$O(^MAGDSTT(2006.541," "),-1)+1 ; Next number
  1. S $P(ZERONODE,"^",3)=IEN2006541
  1. S $P(ZERONODE,"^",4)=$P(ZERONODE,"^",4)+1 ; Total count
  1. S ^MAGDSTT(2006.541,0)=ZERONODE
  1. S REQUESTDATETIME=$$NOW^XLFDT
  1. S ^MAGDSTT(2006.541,IEN2006541,0)=REQUESTDATETIME_"^"_MODE_"^"_MAGXTMP_"^"_HOSTNAME_"^"_$J_"^"_QRSTACK_"^"_DUZ
  1. S KEY="" F I=1:1 S KEY=$O(^TMP("MAG",$J,"Q/R QUERY",QRSTACK,KEY)) Q:KEY="" D
  1. . S VALUE=^TMP("MAG",$J,"Q/R QUERY",QRSTACK,KEY)
  1. . S VALUE=$TR(VALUE,"^","~") ; change ^'s in names to ~'s
  1. . S ^MAGDSTT(2006.541,IEN2006541,1,I,0)=KEY_"^"_VALUE
  1. . S ^MAGDSTT(2006.541,IEN2006541,1,"B",KEY,I)=""
  1. . Q
  1. S ^MAGDSTT(2006.541,"B",REQUESTDATETIME,IEN2006541)="" ; create B-xref
  1. S I=I-1
  1. S ^MAGDSTT(2006.541,IEN2006541,1,0)="^2006.5411A^"_I_"^"_I
  1. S ^MAGDSTT(2006.541,0)=ZERONODE
  1. L -^MAGDSTT(2006.541)
  1. ;
  1. I MODE="Q" D
  1. . I '$G(BATCHQR) W !,"Performing query on DICOM Gateway"
  1. . ; "DONE" uses the request IEN for proper synchronization
  1. . I '$$WAIT(.CMOVEAET) Q
  1. . I '$G(BATCHQR) D DISPLAY^MAGDSTQ5
  1. . Q
  1. E I MODE="R" D
  1. . I '$$WAIT(.CMOVEAET) Q
  1. . ; save Move Application Entity Title
  1. . I $D(RUNNUMBER) S $P(^MAGDSTT(2006.543,RUNNUMBER,0),"^",8)=CMOVEAET
  1. . I $G(BATCHQR) Q ; suppress text output
  1. . I 'SHOWRRSL D
  1. . . F Q:$X=0 W @IOBS," ",@IOBS ; erase the line
  1. . . W "Performing retrieve from """,QRSCP,""" from DICOM Gateway"
  1. . . W " (",GATEWAYHOSTNAME,")"
  1. . . R X:3
  1. . Q
  1. Q
  1. ;
  1. WAIT(CMOVEAET) ; wait up to ten minutes for response from DICOM Gateway
  1. N I,J,SUCCESS,TIMESTAMP,X
  1. S CMOVEAET="",SUCCESS=0
  1. S TIMESTAMP=$$NOW^XLFDT ; time at the beginning of the wait
  1. ;
  1. ; check that the gateway surrogated picked up the Q/R request
  1. F I=1:1:10 D Q:SUCCESS
  1. . S X=$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"WORKING...",IEN2006541))
  1. . I $L(X) D Q
  1. . . S GATEWAYHOSTNAME=$P(X,"^",3)
  1. . . S SUCCESS=1
  1. . . Q
  1. . H 1
  1. . Q
  1. I 'SUCCESS D Q SUCCESS
  1. . W !
  1. . W ! F J=1:1:80 W "*"
  1. . W !,"*** No DICOM Gateway Surrogate process is available for VistA Q/R Client"
  1. . W ?77,"***"
  1. . W ! F J=1:1:80 W "*"
  1. . W !
  1. . I $G(BATCHQR) Q ; suppress CONTINUE prompt
  1. . D CONTINUE^MAGDSTQ
  1. . Q
  1. ;
  1. I MODE="Q",'$G(BATCHQR) W " (",GATEWAYHOSTNAME,")"
  1. ;
  1. ; check that the Q/R request was processed
  1. F I=1:1:600 Q:$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"DONE",IEN2006541)) D
  1. . H 1
  1. . I $G(BATCHQR) Q ; suppress text output
  1. . W "."
  1. . Q
  1. S X=$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"DONE",IEN2006541))
  1. S SUCCESS=0
  1. I $L(X) D
  1. . S SUCCESS=1
  1. . S CMOVEAET=$P(X,"^",3)
  1. . Q
  1. E D
  1. . W !
  1. . W ! F J=1:1:80 W "*"
  1. . W !,"*** The "
  1. . W $S(MODE="Q":"query",MODE="R":"retrieve")
  1. . W " was not completed by DICOM Gateway"
  1. . I $D(GATEWAYHOSTNAME) W " (",GATEWAYHOSTNAME,")"
  1. . W " ",$$FMTE^XLFDT(TIMESTAMP),?77,"***"
  1. . W ! F J=1:1:80 W "*"
  1. . W !
  1. . I $G(BATCHQR) Q ; suppress CONTINUE prompt
  1. . D CONTINUE^MAGDSTQ
  1. . Q
  1. ;
  1. ; check for message
  1. S X=$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"MESSAGE","MSG",0))
  1. I X,'$G(BATCHQR) D
  1. . W !!,"Error Message: "
  1. . F I=1:1:X W !,$G(^XTMP(MAGXTMP,HOSTNAME,$J,QRSTACK,"MESSAGE","MSG",I))
  1. . D CONTINUE^MAGDSTQ
  1. . S SUCCESS=0,SHOWRRSL=0
  1. . Q
  1. ;
  1. Q SUCCESS
  1. ;
  1. KILL ; truncate the DICOM VISTA Q/R REQUEST QUEUE file (#2006.541)
  1. N PROMPT,X
  1. S X=$P($G(^MAGDSTT(2006.541,0)),"^",3)
  1. I X="" D Q
  1. . W !!,"The DICOM VISTA Q/R REQUEST QUEUE entries have already been deleted."
  1. . Q
  1. I X=1 D
  1. . W !!,"There is one entry in the DICOM VISTA Q/R REQUEST QUEUE."
  1. . S PROMPT="Do you want to remove it?"
  1. . Q
  1. E D
  1. . W !!,"There are "_X_" entries in the DICOM VISTA Q/R REQUEST QUEUE."
  1. . S PROMPT="Do you want to remove them?"
  1. . Q
  1. I $$YESNO^MAGDSTQ(PROMPT,"n",.X)>0,X="YES" D
  1. . K ^MAGDSTT(2006.541)
  1. . S ^MAGDSTT(2006.541,0)="DICOM VISTA Q/R REQUEST QUEUE"_"^"_2006.541_"^^"
  1. . W !!,"The DICOM VISTA Q/R REQUEST QUEUE file has been truncated."
  1. . Q
  1. E W !!,"The DICOM VISTA Q/R REQUEST QUEUE file has not been truncated."
  1. Q
  1. ;
  1. ENABLED() ; check if monitor is active - P305 PMK 03/15/2022
  1. L +^MAGDRMON:0 ; automatic retrieve monitor is active
  1. L -^MAGDRMON ; automatic retrieve monitor is not active
  1. Q '$T