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

MDCPSIGN.m

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