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

HLOPING.m

Go to the documentation of this file.
  1. HLOPING ;ALB/CJM - HLO PING UTILITY 10/4/94 1pm ; 07/12/2012
  1. ;;1.6;HEALTH LEVEL SEVEN;**147,155,158,172**;Oct 13, 1995;Build 11
  1. ;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ;
  1. PING ;
  1. I '$G(DUZ) W !,"Your DUZ must be set!" Q
  1. N LINK,CONF,HLCSTATE,PORT,LINK,HLODONE
  1. S HLODONE=0
  1. I '(($P($$VERSION^%ZOSV(1),"/",1)[("Cache"))!($$VERSION^%ZOSV(1)["IRIS")) D Q
  1. .W !!," Sorry, this tool can only be used under Cache or IRIS",!!
  1. W !,"What HL Logical Link do you want to test?"
  1. S LINK=$$ASKLINK^HLOUSR
  1. Q:LINK=""
  1. I $$NOPING(LINK) W !,"That link does not allowing PINGING!" D PAUSE^VALM1 Q
  1. S PORT=$$ASKPORT(LINK)
  1. Q:'PORT
  1. L +^HLB("QUEUE","OUT",LINK_":"_PORT,"HLOPING"_$J):1
  1. D STOPQUE^HLOQUE("OUT","HLOPING"_$J)
  1. D BREAKS
  1. D CHECKAPP
  1. I $$ADDMSG(LINK) D
  1. .ZB /INTERRUPT:NORMAL ;disable CTRL-C breaks
  1. .S WORK("QUEUE")="HLOPING"_$J,WORK("LINK")=LINK_":"_PORT
  1. .D DOWORK^HLOCLNT(.WORK)
  1. .D:$G(HLCSTATE("CONNECTED")) CLOSE^HLOT(.HLCSTATE)
  1. .;
  1. .U $PRINCIPAL
  1. D PURGE(LINK_":"_PORT)
  1. ZB /CLEAR
  1. L -^HLB("QUEUE","OUT",LINK_":"_PORT,"HLOPING"_$J)
  1. D STARTQUE^HLOQUE("OUT","HLOPING"_$J)
  1. Q
  1. ;
  1. NOPING(LINK) ;
  1. N IEN,RETURN
  1. S RETURN=1
  1. S IEN=$O(^HLCS(870,"B",LINK,0))
  1. I IEN S RETURN=$P($G(^HLCS(870,IEN,0)),"^",24)
  1. Q RETURN
  1. ;
  1. ASKPORT(LINK) ;
  1. N IEN,NODE,HLOPORT,HL7PORT,DIR,X,Y
  1. S IEN=$O(^HLCS(870,"B",LINK,0))
  1. Q:'IEN ""
  1. S NODE=$G(^HLCS(870,IEN,400))
  1. S HLOPORT=$P(NODE,"^",8)
  1. S:'HLOPORT HLOPORT=$S($P($G(^HLD(779.1,1,0)),"^",3)="P":5001,1:5026)
  1. S HL7PORT=$P(NODE,"^",2)
  1. S:'HL7PORT HL7PORT=$S($P($G(^HLD(779.1,1,0)),"^",3)="P":5000,1:5025)
  1. W !,"Do you want to PING the port used by HLO or the one used by HL7 1.6?"
  1. S DIR(0)="S^1:HLO --> Port #"_HLOPORT_";2:HL7 1.6 --> Port #"_HL7PORT
  1. S DIR("B")=1
  1. D ^DIR
  1. Q:'X ""
  1. Q:$D(DUOUT) ""
  1. Q:X=1 HLOPORT
  1. Q:X=2 HL7PORT
  1. Q ""
  1. ADDMSG(LINK) ;
  1. N PARMS,MSG,SEG,ERROR
  1. S PARMS("MESSAGE TYPE")="ZZZ"
  1. S PARMS("EVENT")="ZZZ"
  1. I '$$NEWMSG^HLOAPI(.PARMS,.MSG,.ERROR) W !,"ERROR",ERROR Q 0
  1. D SET^HLOAPI(.SEG,"NTE",0)
  1. D SET^HLOAPI(.SEG,"This is a PING message to test connectivity. Sender DUZ: "_$G(DUZ),1)
  1. I '$$ADDSEG^HLOAPI(.MSG,.SEG,.ERROR) W !,"ERROR",ERROR Q 0
  1. S PARMS("SENDING APPLICATION")="HLO PING CLIENT",WHOTO("RECEIVING APPLICATION")="HLO PING SERVER",WHOTO("FACILITY LINK NAME")=LINK
  1. S PARMS("ACCEPT ACK TYPE")="AL"
  1. S PARMS("APP ACK TYPE")="NE"
  1. S PARMS("QUEUE")="HLOPING"_$J
  1. I '$$SENDONE^HLOAPI1(.MSG,.PARMS,.WHOTO,.ERROR) W !,"There is a problem in the setup!",!,ERROR Q 0
  1. Q 1
  1. ;
  1. PURGE(LINK) ;
  1. N IEN
  1. S IEN=0
  1. F S IEN=$O(^HLB("QUEUE","OUT",LINK,"HLOPING"_$J,IEN)) Q:'IEN D DEQUE^HLOQUE(LINK,"HLOPING"_$J,"OUT",IEN),SETPURGE^HLOUSR7(IEN)
  1. Q
  1. ;
  1. BREAKS ;
  1. ZB /CLEAR
  1. ;
  1. ZB SEND^HLOAPI1:"N":1:"S HLMSTATE(""STATUS"",""PORT"")="_PORT
  1. ZB CHECKWHO^HLOASUB1:"N":1:"S WHO(""PORT"")="_PORT
  1. ZB ZB25^HLOASUB1:"N":1:"D ZB25^HLOPING"
  1. ;set break in $$STOPPED^HLOQUE to circumvent shutdown of the queue
  1. ZB ZB0^HLOQUE:"N":1:"S RET=0"
  1. ;set break in $$IFSHUT^HLOTLNK to circumvent shutdown of the link
  1. ZB ZB0^HLOTLNK:"N":1:"S RET=0"
  1. ;set break at ZB1 in client ($$CONNECT)
  1. ;
  1. ZB ZB1^HLOCLNT1:"N":1:"D WRITE^HLOPING(""Trying to connect..."")"
  1. ;
  1. ;set break at ZB2 in client (end of $$CONNECT)
  1. ZB ZB2^HLOCLNT1:"N":1:"D ZB2^HLOPING"
  1. ;
  1. ;set break at ZB6 in client (start of $$TRANSMIT^HLOCLNT1)
  1. ZB ZB6^HLOCLNT1:"N":1:"D WRITE^HLOPING(""Sending PING ..."")"
  1. ;set break at ZB7 in client (end of $$TRANSMIT^HLOCLNT1)
  1. ZB ZB7^HLOCLNT1:"N":1:"D WRITE^HLOPING(""PING sent!"")"
  1. ;set break at ZB8 in client (start of $$READACK^HLOCLNT1)
  1. ZB ZB8^HLOCLNT1:"N":1:"D WRITE^HLOPING(""Reading acknowledgment...."")"
  1. ;set break at ZB9 in client (end of $$READACK^HLOCLNT1)
  1. ;
  1. ZB ZB9^HLOCLNT1:"N":1:"D ZB9^HLOPING"
  1. ;
  1. ;set break at ZB4 in client (FOR loop on the outgoing queue)
  1. ZB ZB4^HLOCLNT:"N":1:"S SUCCESS=0 I 'HLODONE S (SUCCESS,HLODONE)=1"
  1. ;
  1. ;set status to SU so that the PING doesn't appear on the error report
  1. ZB ZB22^HLOCLNT:"N":1:"S $P(UPDATE,""^"",3)=""SU"",$P(UPDATE,""^"",4)=1"
  1. ;
  1. ZB ZB24^HLOCLNT1:"N":1:"D ZB24^HLOPING"
  1. ZB ZB27^HLOT:"N":1:"D ZB27^HLOPING"
  1. ;
  1. ;set break at ZB3 in client (ERROR TRAP)
  1. ZB ZB3^HLOCLNT:"N":1:"D ZB3^HLOPING"
  1. Q
  1. ;
  1. CHECKAPP ;
  1. I '$O(^HLD(779.2,"C","HLO PING CLIENT",0)) D
  1. .N DATA,ERROR
  1. .S DATA(.01)="HLO PING CLIENT"
  1. .D ADD^HLOASUB1(779.2,,.DATA)
  1. Q
  1. WRITE(MSG) ;
  1. N OLD
  1. S OLD=$IO
  1. U $PRINCIPAL
  1. W !,MSG
  1. U OLD
  1. Q
  1. ZB2 ;
  1. D WRITE($S('HLCSTATE("CONNECTED"):"Unable to Connect!",1:"Connected!"))
  1. ;!!!!!!!!!!!!
  1. ;F I=1:1:15 H 1
  1. Q
  1. ZB3 ;
  1. N CON,MSG
  1. S CON=($ZA\8192#2)
  1. S MSG="Error encountered, $ECODE="_$ECODE
  1. D WRITE(MSG)
  1. S MSG=$S(CON:" TCP connection still active",1:" TCP connection was dropped")
  1. D WRITE(MSG)
  1. D ^%ZTER
  1. Q
  1. ZB9 ;
  1. I $G(SUCCESS) D
  1. .D WRITE("Acknowledgment received!")
  1. E D
  1. .D WRITE("Acknowledgment NOT returned!")
  1. ;!!!!!!!!!!!!
  1. ;H 50
  1. Q
  1. ZB24 ;
  1. S HLCSTATE("LINK","SHUTDOWN")=0
  1. Q
  1. ZB25 ;
  1. I '$L(PARMS("RECEIVING FACILITY",2)),'PARMS("RECEIVING FACILITY",1) S PARMS("RECEIVING FACILITY",2)="REMOTE FACILITY TO PING"
  1. Q
  1. ;
  1. ZB27 ;
  1. Q:'$G(HLCSTATE("LOCK FAILED"))
  1. D WRITE("Remote server is single threaded and is locked by another process!")
  1. Q