MAGDHLL ;WOIFO/MLH/PMK - IHE-based ADT interface for PACS - log to gateway ;07 Nov 2017 2:59 PM
;;3.0;IMAGING;**49,138,183**;Mar 19, 2002;Build 11;Jul 26, 2012
;; 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
;
LOGGW(XTYP) ; SUBROUTINE - log a generated message to the DICOM/text gateway
; input: XTYP message type (= MSH-9.1)
; expects: HL() array of HL7 variables
; HLHDR() array containing MSH segment info
; HLA() array of HL7 segments
;
N MSGDT ; ----- message date and time from MSH-7 (in HL7 format)
N MSGDFM ; ---- MSGDT date only (no time) in FileMan format
N MSGDTFM ; --- MSGDT date and time in FileMan format
N GWIX ; ------ gateway message index
N GWHDR ; ----- 0 node of gateway message file
N MSH ; ------- message header for gateway
N GWSGIX ; ---- gateway segment index
N FS ; -------- field separator
N I,IX ;------- scratch variables
;
;
; MSH, the HL7 message header segment, is passed in two different
; variables, depending upon the subscribers to the event driver.
;
; Originally, with just the MAG CPACS Axy SUBS subscriber, the value
; was passed in HLHDR(1).
;
; When the MAG CPACS Axy SUBS-HLO subscriber was added, because it has
; a processing routine, the value was passed in HLREC("HDR") instead.
;
; The code on the line below handles both situations.
;
S MSH=$G(HLHDR(1),$G(HLREC("HDR")))
I MSH'="" S FS=$E(MSH,4) D MAGDHL7
Q
;
MAGDHL7 ; output the ADT message to ^MAGDHL7
L +^MAGDHL7(2006.5,0):1E9 E Q
S GWIX=$O(^MAGDHL7(2006.5," "),-1)+1
S GWHDR=$G(^MAGDHL7(2006.5,0))
S $P(GWHDR,U,3)=GWIX,$P(GWHDR,U,4)=$P(GWHDR,U,4)+1
S ^MAGDHL7(2006.5,0)=GWHDR
S $P(MSH,FS,5)="VISTA DICOM/TEXT GATEWAY"
S ^MAGDHL7(2006.5,GWIX,1,1,0)=MSH
S IX=0,GWSGIX=1
F I=1:1 S IX=$O(HLA("HLS",IX)) Q:'IX D
. S GWSGIX=GWSGIX+1
. S ^MAGDHL7(2006.5,GWIX,1,GWSGIX,0)=HLA("HLS",IX)
. Q
S MSGDT=$P($P(MSH,FS,7),"-",1) ; omit TZ offset
S MSGDFM=$E(MSGDT,1,8)-17000000
S MSGDTFM=+(MSGDFM_"."_$E(MSGDT,9,12))
S ^MAGDHL7(2006.5,GWIX,1,0)=U_U_GWSGIX_U_GWSGIX_U_MSGDFM
S ^MAGDHL7(2006.5,GWIX,0)=MSGDFM_U_XTYP_U_MSGDTFM
S ^MAGDHL7(2006.5,"B",MSGDFM,GWIX)="" ; P183 PMK 3/6/17
S ^MAGDHL7(2006.5,"C",MSGDTFM,GWIX)="" ; P183 PMK 3/6/17
L -^MAGDHL7(2006.5,0)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMAGDHLL 3262 printed Dec 13, 2024@01:59:58 Page 2
MAGDHLL ;WOIFO/MLH/PMK - IHE-based ADT interface for PACS - log to gateway ;07 Nov 2017 2:59 PM
+1 ;;3.0;IMAGING;**49,138,183**;Mar 19, 2002;Build 11;Jul 26, 2012
+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 ;
LOGGW(XTYP) ; SUBROUTINE - log a generated message to the DICOM/text gateway
+1 ; input: XTYP message type (= MSH-9.1)
+2 ; expects: HL() array of HL7 variables
+3 ; HLHDR() array containing MSH segment info
+4 ; HLA() array of HL7 segments
+5 ;
+6 ; ----- message date and time from MSH-7 (in HL7 format)
NEW MSGDT
+7 ; ---- MSGDT date only (no time) in FileMan format
NEW MSGDFM
+8 ; --- MSGDT date and time in FileMan format
NEW MSGDTFM
+9 ; ------ gateway message index
NEW GWIX
+10 ; ----- 0 node of gateway message file
NEW GWHDR
+11 ; ------- message header for gateway
NEW MSH
+12 ; ---- gateway segment index
NEW GWSGIX
+13 ; -------- field separator
NEW FS
+14 ;------- scratch variables
NEW I,IX
+15 ;
+16 ;
+17 ; MSH, the HL7 message header segment, is passed in two different
+18 ; variables, depending upon the subscribers to the event driver.
+19 ;
+20 ; Originally, with just the MAG CPACS Axy SUBS subscriber, the value
+21 ; was passed in HLHDR(1).
+22 ;
+23 ; When the MAG CPACS Axy SUBS-HLO subscriber was added, because it has
+24 ; a processing routine, the value was passed in HLREC("HDR") instead.
+25 ;
+26 ; The code on the line below handles both situations.
+27 ;
+28 SET MSH=$GET(HLHDR(1),$GET(HLREC("HDR")))
+29 IF MSH'=""
SET FS=$EXTRACT(MSH,4)
DO MAGDHL7
+30 QUIT
+31 ;
MAGDHL7 ; output the ADT message to ^MAGDHL7
+1 LOCK +^MAGDHL7(2006.5,0):1E9
IF '$TEST
QUIT
+2 SET GWIX=$ORDER(^MAGDHL7(2006.5," "),-1)+1
+3 SET GWHDR=$GET(^MAGDHL7(2006.5,0))
+4 SET $PIECE(GWHDR,U,3)=GWIX
SET $PIECE(GWHDR,U,4)=$PIECE(GWHDR,U,4)+1
+5 SET ^MAGDHL7(2006.5,0)=GWHDR
+6 SET $PIECE(MSH,FS,5)="VISTA DICOM/TEXT GATEWAY"
+7 SET ^MAGDHL7(2006.5,GWIX,1,1,0)=MSH
+8 SET IX=0
SET GWSGIX=1
+9 FOR I=1:1
SET IX=$ORDER(HLA("HLS",IX))
if 'IX
QUIT
Begin DoDot:1
+10 SET GWSGIX=GWSGIX+1
+11 SET ^MAGDHL7(2006.5,GWIX,1,GWSGIX,0)=HLA("HLS",IX)
+12 QUIT
End DoDot:1
+13 ; omit TZ offset
SET MSGDT=$PIECE($PIECE(MSH,FS,7),"-",1)
+14 SET MSGDFM=$EXTRACT(MSGDT,1,8)-17000000
+15 SET MSGDTFM=+(MSGDFM_"."_$EXTRACT(MSGDT,9,12))
+16 SET ^MAGDHL7(2006.5,GWIX,1,0)=U_U_GWSGIX_U_GWSGIX_U_MSGDFM
+17 SET ^MAGDHL7(2006.5,GWIX,0)=MSGDFM_U_XTYP_U_MSGDTFM
+18 ; P183 PMK 3/6/17
SET ^MAGDHL7(2006.5,"B",MSGDFM,GWIX)=""
+19 ; P183 PMK 3/6/17
SET ^MAGDHL7(2006.5,"C",MSGDTFM,GWIX)=""
+20 LOCK -^MAGDHL7(2006.5,0)
+21 QUIT