MDCPSIGN ;HINES OIFO/BJ - CliO HL7 Handler/validator;23 Aug 2006
;;1.0;CLINICAL PROCEDURES;**16**;Apr 01, 2004;Build 280
;Per VHA Directive 2004-038, this routine should not be modified.
; This routine uses the following IAs:
; # 2118 - %ZISTCP calls Kernel (supported)
; #10063 - %ZTLOAD calls Kernel (supported)
; # 2263 - XPAR calls Toolkit (supported)
;
;only call via line tags.
Q
;
EN(MDCPIEN) ; Main entry point.
;
; This is meant to be called from the routine that changes the STATUS field on
; the CLIO_HL7_LOG file. The concept will be that this entry point is called, which will
; then notify a specific IP address and port that traffic is waiting.
;
; Note that there is also an assumption that the MD PARAMETERS parameter has had an "GATEWAY_SERVER_IP" instance
; and a "GATEWAY_NOTIFIER_PORT" instance added.
;
L +^MDC("MDC GATEWAY"):0 E Q ; Can't get the lock, this means it's already running :)
; Queue this puppy up!
S ZTRTN="ZTSK^MDCPSIGN"
S ZTDESC="CliO Gateway Service Notifier"
S ZTDTH=$H ; Start it NOW!
S ZTIO=""
D ^%ZTLOAD
L -^MDC("MDC GATEWAY") ; Drop the lock so that the ZTSK dude can get it!
Q
;
ZTSK ; This is the part that will notify the gateway and then monitor the progress
N MDCPIP,MDCPPORT,MDCPIEN,POP
S ZTREQ="@" ; Ensure that the task goes away
Q:'$O(^MDC(704.002,"AS",2,0)) ; No data - See Ya!
L +^MDC("MDC GATEWAY"):10 E Q ; Somebody beat us to it - See Ya!
;
; We have the lock, we have the data!
; We are in charge until we have no messages in
; status 2 or find that the messages aren't processing.
;
H 30 ; Wait for anymore messages to be delivered
;
S MDCPIEN=+$O(^MDC(704.002,"AS",2,0))
S MDCPIP=$$GET^XPAR("SYS","MD PARAMETERS","GATEWAY_SERVER_IP")
S MDCPPORT=$$GET^XPAR("SYS","MD PARAMETERS","GATEWAY_NOTIFY_PORT")
I '$G(MDCPIP)!'$G(MDCPPORT) D ZTSKERR("Missing IP/Port Info") Q
D CALL^%ZISTCP(MDCPIP,MDCPPORT,2) I POP D ZTSKERR("Unable to open the Gateway Port") Q
U IO
W "<?xml version=""1.0"" encoding=""utf-8""?>",!
W "<message type=""hl7"">",!
W "<id>",$G(MDCPIEN),!,"</id>",!
W "<text/>",!
W "</message>",!
D CLOSE^%ZISTCP
;
; The gateway has been notified.
;
; We wait in 60 second chunks and then do the following:
;
; 1. Check to see if the top item (MDCPIEN) is still in status 2 - i.e. The gateway isn't running
; if it has changed...
; 2. Get the top item in the index for the next loop/check or quit if it doesn't exist
;
F H 60 Q:$D(^MDC(704.002,"AS",2,MDCPIEN)) S MDCPIEN=+$O(^MDC(704.002,"AS",2,0)) Q:'MDCPIEN
L -^MDC("MDC GATEWAY")
Q
;
ZTSKERR(MDERR) ; Log an error and quit
; Need a logging method here
N MDHL7,MDADMIN,MDMSG
S MDHL7=$$GET^XPAR("SYS","MD PARAMETERS","NOTIFICATION_HL7_ERRORS","Q")
S MDADMIN=$$GET^XPAR("SYS","MD PARAMETERS","NOTIFICATION_CPADMIN","Q")
S MDMSG(0)="SUB:Error occurred in HL7 Processing"
S MDMSG(1)="TEXT:Error Message: "_MDERR
S MDMSG(2)="TO:"_MDHL7
S MDMSG(3)="TO:"_MDADMIN
D RPC^MDCLIO(.MDRET,"EXECUTE","SendEMailMessage",.MDMSG)
L -^MDC("MDC GATEWAY")
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HMDCPSIGN 3267 printed Dec 13, 2024@01:42:32 Page 2
MDCPSIGN ;HINES OIFO/BJ - CliO HL7 Handler/validator;23 Aug 2006
+1 ;;1.0;CLINICAL PROCEDURES;**16**;Apr 01, 2004;Build 280
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
+3 ; This routine uses the following IAs:
+4 ; # 2118 - %ZISTCP calls Kernel (supported)
+5 ; #10063 - %ZTLOAD calls Kernel (supported)
+6 ; # 2263 - XPAR calls Toolkit (supported)
+7 ;
+8 ;only call via line tags.
+9 QUIT
+10 ;
EN(MDCPIEN) ; Main entry point.
+1 ;
+2 ; This is meant to be called from the routine that changes the STATUS field on
+3 ; the CLIO_HL7_LOG file. The concept will be that this entry point is called, which will
+4 ; then notify a specific IP address and port that traffic is waiting.
+5 ;
+6 ; Note that there is also an assumption that the MD PARAMETERS parameter has had an "GATEWAY_SERVER_IP" instance
+7 ; and a "GATEWAY_NOTIFIER_PORT" instance added.
+8 ;
+9 ; Can't get the lock, this means it's already running :)
LOCK +^MDC("MDC GATEWAY"):0
IF '$TEST
QUIT
+10 ; Queue this puppy up!
+11 SET ZTRTN="ZTSK^MDCPSIGN"
+12 SET ZTDESC="CliO Gateway Service Notifier"
+13 ; Start it NOW!
SET ZTDTH=$HOROLOG
+14 SET ZTIO=""
+15 DO ^%ZTLOAD
+16 ; Drop the lock so that the ZTSK dude can get it!
LOCK -^MDC("MDC GATEWAY")
+17 QUIT
+18 ;
ZTSK ; This is the part that will notify the gateway and then monitor the progress
+1 NEW MDCPIP,MDCPPORT,MDCPIEN,POP
+2 ; Ensure that the task goes away
SET ZTREQ="@"
+3 ; No data - See Ya!
if '$ORDER(^MDC(704.002,"AS",2,0))
QUIT
+4 ; Somebody beat us to it - See Ya!
LOCK +^MDC("MDC GATEWAY"):10
IF '$TEST
QUIT
+5 ;
+6 ; We have the lock, we have the data!
+7 ; We are in charge until we have no messages in
+8 ; status 2 or find that the messages aren't processing.
+9 ;
+10 ; Wait for anymore messages to be delivered
HANG 30
+11 ;
+12 SET MDCPIEN=+$ORDER(^MDC(704.002,"AS",2,0))
+13 SET MDCPIP=$$GET^XPAR("SYS","MD PARAMETERS","GATEWAY_SERVER_IP")
+14 SET MDCPPORT=$$GET^XPAR("SYS","MD PARAMETERS","GATEWAY_NOTIFY_PORT")
+15 IF '$GET(MDCPIP)!'$GET(MDCPPORT)
DO ZTSKERR("Missing IP/Port Info")
QUIT
+16 DO CALL^%ZISTCP(MDCPIP,MDCPPORT,2)
IF POP
DO ZTSKERR("Unable to open the Gateway Port")
QUIT
+17 USE IO
+18 WRITE "<?xml version=""1.0"" encoding=""utf-8""?>",!
+19 WRITE "<message type=""hl7"">",!
+20 WRITE "<id>",$GET(MDCPIEN),!,"</id>",!
+21 WRITE "<text/>",!
+22 WRITE "</message>",!
+23 DO CLOSE^%ZISTCP
+24 ;
+25 ; The gateway has been notified.
+26 ;
+27 ; We wait in 60 second chunks and then do the following:
+28 ;
+29 ; 1. Check to see if the top item (MDCPIEN) is still in status 2 - i.e. The gateway isn't running
+30 ; if it has changed...
+31 ; 2. Get the top item in the index for the next loop/check or quit if it doesn't exist
+32 ;
+33 FOR
HANG 60
if $DATA(^MDC(704.002,"AS",2,MDCPIEN))
QUIT
SET MDCPIEN=+$ORDER(^MDC(704.002,"AS",2,0))
if 'MDCPIEN
QUIT
+34 LOCK -^MDC("MDC GATEWAY")
+35 QUIT
+36 ;
ZTSKERR(MDERR) ; Log an error and quit
+1 ; Need a logging method here
+2 NEW MDHL7,MDADMIN,MDMSG
+3 SET MDHL7=$$GET^XPAR("SYS","MD PARAMETERS","NOTIFICATION_HL7_ERRORS","Q")
+4 SET MDADMIN=$$GET^XPAR("SYS","MD PARAMETERS","NOTIFICATION_CPADMIN","Q")
+5 SET MDMSG(0)="SUB:Error occurred in HL7 Processing"
+6 SET MDMSG(1)="TEXT:Error Message: "_MDERR
+7 SET MDMSG(2)="TO:"_MDHL7
+8 SET MDMSG(3)="TO:"_MDADMIN
+9 DO RPC^MDCLIO(.MDRET,"EXECUTE","SendEMailMessage",.MDMSG)
+10 LOCK -^MDC("MDC GATEWAY")
+11 QUIT
+12 ;