- MAGDHRS1 ;WOIFO/PMK - Read HL7 and generate DICOM ; 08/20/2004 08:27
- ;;3.0;IMAGING;**11,30**;16-September-2004
- ;; +---------------------------------------------------------------+
- ;; | 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
- ; M-to-M Broker Server
- ;
- ENTRY(RESULT,REQUEST) ; RPC = MAG DICOM TEXT PROCESSING
- N HIT ;------ indicates that the requested HL7 message exists
- N HL7MSGNO ;- number of HL7 message
- N ITIMEOUT ;- second counter incremented up to TIMEOUT
- N SEGCOUNT ;- count of segments in the HL7 message
- N TIMEOUT ;-- number of seconds to wait before returning void
- N WAIT ;----- number of seconds to wait for an HL7 message
- N I,J,X,Y,Z ;---- working variables
- ;
- K RESULT
- ;
- S WAIT=200 ; Time-out period for incomplete message
- ; (30 seconds was not enough in Amarillo)
- ;
- S HL7MSGNO=+$P(REQUEST(2),"|",1),TIMEOUT=$P(REQUEST(2),"|",2)
- D:'$D(^MAGDHL7(2006.5,HL7MSGNO))
- . S I=$O(^MAGDHL7(2006.5,HL7MSGNO)) Q:'I
- . S HL7MSGNO=I
- . Q
- ;
- ; wait for HL7 message to be generated
- S HIT=0 F D Q:HIT S TIMEOUT=TIMEOUT-1 Q:TIMEOUT<0 H 1
- . I $D(^MAGDHL7(2006.5,HL7MSGNO)) S HIT=1
- . Q
- ;
- I HIT D
- . I $$WAIT(0,WAIT) Q
- . S SEGCOUNT=$P(^MAGDHL7(2006.5,HL7MSGNO,1,0),"^",3)
- . S RESULT(1)=HL7MSGNO
- . S RESULT(2)=^MAGDHL7(2006.5,HL7MSGNO,0)
- . S RESULT(3)=^MAGDHL7(2006.5,HL7MSGNO,1,0)
- . F I=1:1:SEGCOUNT D
- . . I $$WAIT(I,WAIT) S I=999999 Q
- . . S (X,Y)=^MAGDHL7(2006.5,HL7MSGNO,1,I,0)
- . . D:$TR($T(+2^XWBVLL),",","*")'["*34*"
- . . . N E,J
- . . . S Y="" F J=1:1:$L(X) S E=$E(X,J),Y=Y_$S(E="<":"<",E=">":">",E="&":"&",E="""":""",1:E)
- . . . Q
- . . S RESULT(I+3)=Y
- . . Q
- . Q
- E S RESULT(1)=""
- Q
- ;
- WAIT(I,WAIT) ; wait for node to be written
- N JTIMEOUT
- F JTIMEOUT=1:1:WAIT Q:$D(^MAGDHL7(2006.5,HL7MSGNO,1,I)) H 1
- I JTIMEOUT=WAIT D Q 1
- . ; an error occurred during the waiting
- . K RESULT
- . S RESULT(1)="-1 ^MAGDHL7(2006.5,"_HL7MSGNO_","_I_",...) is incomplete"
- . Q
- Q 0
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGDHRS1 2860 printed Jan 18, 2025@03:01:30 Page 2
- MAGDHRS1 ;WOIFO/PMK - Read HL7 and generate DICOM ; 08/20/2004 08:27
- +1 ;;3.0;IMAGING;**11,30**;16-September-2004
- +2 ;; +---------------------------------------------------------------+
- +3 ;; | Property of the US Government. |
- +4 ;; | No permission to copy or redistribute this software is given. |
- +5 ;; | Use of unreleased versions of this software requires the user |
- +6 ;; | to execute a written test agreement with the VistA Imaging |
- +7 ;; | Development Office of the Department of Veterans Affairs, |
- +8 ;; | telephone (301) 734-0100. |
- +9 ;; | |
- +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 ; M-to-M Broker Server
- +19 ;
- ENTRY(RESULT,REQUEST) ; RPC = MAG DICOM TEXT PROCESSING
- +1 ;------ indicates that the requested HL7 message exists
- NEW HIT
- +2 ;- number of HL7 message
- NEW HL7MSGNO
- +3 ;- second counter incremented up to TIMEOUT
- NEW ITIMEOUT
- +4 ;- count of segments in the HL7 message
- NEW SEGCOUNT
- +5 ;-- number of seconds to wait before returning void
- NEW TIMEOUT
- +6 ;----- number of seconds to wait for an HL7 message
- NEW WAIT
- +7 ;---- working variables
- NEW I,J,X,Y,Z
- +8 ;
- +9 KILL RESULT
- +10 ;
- +11 ; Time-out period for incomplete message
- SET WAIT=200
- +12 ; (30 seconds was not enough in Amarillo)
- +13 ;
- +14 SET HL7MSGNO=+$PIECE(REQUEST(2),"|",1)
- SET TIMEOUT=$PIECE(REQUEST(2),"|",2)
- +15 if '$DATA(^MAGDHL7(2006.5,HL7MSGNO))
- Begin DoDot:1
- +16 SET I=$ORDER(^MAGDHL7(2006.5,HL7MSGNO))
- if 'I
- QUIT
- +17 SET HL7MSGNO=I
- +18 QUIT
- End DoDot:1
- +19 ;
- +20 ; wait for HL7 message to be generated
- +21 SET HIT=0
- FOR
- Begin DoDot:1
- +22 IF $DATA(^MAGDHL7(2006.5,HL7MSGNO))
- SET HIT=1
- +23 QUIT
- End DoDot:1
- if HIT
- QUIT
- SET TIMEOUT=TIMEOUT-1
- if TIMEOUT<0
- QUIT
- HANG 1
- +24 ;
- +25 IF HIT
- Begin DoDot:1
- +26 IF $$WAIT(0,WAIT)
- QUIT
- +27 SET SEGCOUNT=$PIECE(^MAGDHL7(2006.5,HL7MSGNO,1,0),"^",3)
- +28 SET RESULT(1)=HL7MSGNO
- +29 SET RESULT(2)=^MAGDHL7(2006.5,HL7MSGNO,0)
- +30 SET RESULT(3)=^MAGDHL7(2006.5,HL7MSGNO,1,0)
- +31 FOR I=1:1:SEGCOUNT
- Begin DoDot:2
- +32 IF $$WAIT(I,WAIT)
- SET I=999999
- QUIT
- +33 SET (X,Y)=^MAGDHL7(2006.5,HL7MSGNO,1,I,0)
- +34 if $TRANSLATE($TEXT(+2^XWBVLL),",","*")'["*34*"
- Begin DoDot:3
- +35 NEW E,J
- +36 SET Y=""
- FOR J=1:1:$LENGTH(X)
- SET E=$EXTRACT(X,J)
- SET Y=Y_$SELECT(E="<":"<",E=">":">",E="&":"&",E="""":""",1:E)
- +37 QUIT
- End DoDot:3
- +38 SET RESULT(I+3)=Y
- +39 QUIT
- End DoDot:2
- +40 QUIT
- End DoDot:1
- +41 IF '$TEST
- SET RESULT(1)=""
- +42 QUIT
- +43 ;
- WAIT(I,WAIT) ; wait for node to be written
- +1 NEW JTIMEOUT
- +2 FOR JTIMEOUT=1:1:WAIT
- if $DATA(^MAGDHL7(2006.5,HL7MSGNO,1,I))
- QUIT
- HANG 1
- +3 IF JTIMEOUT=WAIT
- Begin DoDot:1
- +4 ; an error occurred during the waiting
- +5 KILL RESULT
- +6 SET RESULT(1)="-1 ^MAGDHL7(2006.5,"_HL7MSGNO_","_I_",...) is incomplete"
- +7 QUIT
- End DoDot:1
- QUIT 1
- +8 QUIT 0