source: WorldVistAEHR/trunk/r/IMAGING-MAG-ZMAG/MAGDHRS1.m@ 1297

Last change on this file since 1297 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 2.7 KB
Line 
1MAGDHRS1 ;WOIFO/PMK - Read HL7 and generate DICOM ; 08/20/2004 08:27
2 ;;3.0;IMAGING;**11,30**;16-September-2004
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 ;; | |
11 ;; | The Food and Drug Administration classifies this software as |
12 ;; | a medical device. As such, it may not be changed in any way. |
13 ;; | Modifications to this software may result in an adulterated |
14 ;; | medical device under 21CFR820, the use of which is considered |
15 ;; | to be a violation of US Federal Statutes. |
16 ;; +---------------------------------------------------------------+
17 ;;
18 Q
19 ; M-to-M Broker Server
20 ;
21ENTRY(RESULT,REQUEST) ; RPC = MAG DICOM TEXT PROCESSING
22 N HIT ;------ indicates that the requested HL7 message exists
23 N HL7MSGNO ;- number of HL7 message
24 N ITIMEOUT ;- second counter incremented up to TIMEOUT
25 N SEGCOUNT ;- count of segments in the HL7 message
26 N TIMEOUT ;-- number of seconds to wait before returning void
27 N WAIT ;----- number of seconds to wait for an HL7 message
28 N I,J,X,Y,Z ;---- working variables
29 ;
30 K RESULT
31 ;
32 S WAIT=200 ; Time-out period for incomplete message
33 ; (30 seconds was not enough in Amarillo)
34 ;
35 S HL7MSGNO=+$P(REQUEST(2),"|",1),TIMEOUT=$P(REQUEST(2),"|",2)
36 D:'$D(^MAGDHL7(2006.5,HL7MSGNO))
37 . S I=$O(^MAGDHL7(2006.5,HL7MSGNO)) Q:'I
38 . S HL7MSGNO=I
39 . Q
40 ;
41 ; wait for HL7 message to be generated
42 S HIT=0 F D Q:HIT S TIMEOUT=TIMEOUT-1 Q:TIMEOUT<0 H 1
43 . I $D(^MAGDHL7(2006.5,HL7MSGNO)) S HIT=1
44 . Q
45 ;
46 I HIT D
47 . I $$WAIT(0,WAIT) Q
48 . S SEGCOUNT=$P(^MAGDHL7(2006.5,HL7MSGNO,1,0),"^",3)
49 . S RESULT(1)=HL7MSGNO
50 . S RESULT(2)=^MAGDHL7(2006.5,HL7MSGNO,0)
51 . S RESULT(3)=^MAGDHL7(2006.5,HL7MSGNO,1,0)
52 . F I=1:1:SEGCOUNT D
53 . . I $$WAIT(I,WAIT) S I=999999 Q
54 . . S (X,Y)=^MAGDHL7(2006.5,HL7MSGNO,1,I,0)
55 . . D:$TR($T(+2^XWBVLL),",","*")'["*34*"
56 . . . N E,J
57 . . . S Y="" F J=1:1:$L(X) S E=$E(X,J),Y=Y_$S(E="<":"&lt;",E=">":"&gt;",E="&":"&amp;",E="""":"&quot;",1:E)
58 . . . Q
59 . . S RESULT(I+3)=Y
60 . . Q
61 . Q
62 E S RESULT(1)=""
63 Q
64 ;
65WAIT(I,WAIT) ; wait for node to be written
66 N JTIMEOUT
67 F JTIMEOUT=1:1:WAIT Q:$D(^MAGDHL7(2006.5,HL7MSGNO,1,I)) H 1
68 I JTIMEOUT=WAIT D Q 1
69 . ; an error occurred during the waiting
70 . K RESULT
71 . S RESULT(1)="-1 ^MAGDHL7(2006.5,"_HL7MSGNO_","_I_",...) is incomplete"
72 . Q
73 Q 0
Note: See TracBrowser for help on using the repository browser.