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

MAGDHRS1.m

Go to the documentation of this file.
  1. MAGDHRS1 ;WOIFO/PMK - Read HL7 and generate DICOM ; 08/20/2004 08:27
  1. ;;3.0;IMAGING;**11,30**;16-September-2004
  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. ;; | |
  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. Q
  1. ; M-to-M Broker Server
  1. ;
  1. ENTRY(RESULT,REQUEST) ; RPC = MAG DICOM TEXT PROCESSING
  1. N HIT ;------ indicates that the requested HL7 message exists
  1. N HL7MSGNO ;- number of HL7 message
  1. N ITIMEOUT ;- second counter incremented up to TIMEOUT
  1. N SEGCOUNT ;- count of segments in the HL7 message
  1. N TIMEOUT ;-- number of seconds to wait before returning void
  1. N WAIT ;----- number of seconds to wait for an HL7 message
  1. N I,J,X,Y,Z ;---- working variables
  1. ;
  1. K RESULT
  1. ;
  1. S WAIT=200 ; Time-out period for incomplete message
  1. ; (30 seconds was not enough in Amarillo)
  1. ;
  1. S HL7MSGNO=+$P(REQUEST(2),"|",1),TIMEOUT=$P(REQUEST(2),"|",2)
  1. D:'$D(^MAGDHL7(2006.5,HL7MSGNO))
  1. . S I=$O(^MAGDHL7(2006.5,HL7MSGNO)) Q:'I
  1. . S HL7MSGNO=I
  1. . Q
  1. ;
  1. ; wait for HL7 message to be generated
  1. S HIT=0 F D Q:HIT S TIMEOUT=TIMEOUT-1 Q:TIMEOUT<0 H 1
  1. . I $D(^MAGDHL7(2006.5,HL7MSGNO)) S HIT=1
  1. . Q
  1. ;
  1. I HIT D
  1. . I $$WAIT(0,WAIT) Q
  1. . S SEGCOUNT=$P(^MAGDHL7(2006.5,HL7MSGNO,1,0),"^",3)
  1. . S RESULT(1)=HL7MSGNO
  1. . S RESULT(2)=^MAGDHL7(2006.5,HL7MSGNO,0)
  1. . S RESULT(3)=^MAGDHL7(2006.5,HL7MSGNO,1,0)
  1. . F I=1:1:SEGCOUNT D
  1. . . I $$WAIT(I,WAIT) S I=999999 Q
  1. . . S (X,Y)=^MAGDHL7(2006.5,HL7MSGNO,1,I,0)
  1. . . D:$TR($T(+2^XWBVLL),",","*")'["*34*"
  1. . . . N E,J
  1. . . . S Y="" F J=1:1:$L(X) S E=$E(X,J),Y=Y_$S(E="<":"<",E=">":">",E="&":"&",E="""":""",1:E)
  1. . . . Q
  1. . . S RESULT(I+3)=Y
  1. . . Q
  1. . Q
  1. E S RESULT(1)=""
  1. Q
  1. ;
  1. WAIT(I,WAIT) ; wait for node to be written
  1. N JTIMEOUT
  1. F JTIMEOUT=1:1:WAIT Q:$D(^MAGDHL7(2006.5,HL7MSGNO,1,I)) H 1
  1. I JTIMEOUT=WAIT D Q 1
  1. . ; an error occurred during the waiting
  1. . K RESULT
  1. . S RESULT(1)="-1 ^MAGDHL7(2006.5,"_HL7MSGNO_","_I_",...) is incomplete"
  1. . Q
  1. Q 0