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

HLOAPP.m

Go to the documentation of this file.
  1. HLOAPP ;ALB/CJM-HL7 -Application Registry ;02/23/2012
  1. ;;1.6;HEALTH LEVEL SEVEN;**126,132,137,139,158**;Oct 13, 1995;Build 14
  1. ;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. GETIEN(NAME) ;given the application name, it finds the ien. Returns 0 on failure
  1. Q:'$L($G(NAME)) 0
  1. Q +$O(^HLD(779.2,"C",$E(NAME,1,60),0))
  1. ;
  1. ACTION(HEADER,ACTION,QUEUE) ;Given the parsed header of a message it returns both the action that should be performed in response to the message and the incoming queue that it should be placed on.
  1. ;
  1. ;** do not implement the Pass Immediate parameter **
  1. ;ACTION(HEADER,ACTION,QUEUE,IMMEDIATE);Given the parsed header of a message it returns both the action that should be performed in response to the message and the incoming queue that it should be placed on.
  1. ;
  1. ;Input:
  1. ; HEADER() subscripts are used: "RECEIVING APPLICATION","SEGMENT TYPE", "MESSAGE TYPE", "EVENT", "VERSION"
  1. ;Output:
  1. ; Function returns 1 on success, 0 on failure
  1. ; ACTION (pass by reference) <tag>^<rtn>
  1. ; QUEUE (pass by reference) returns the named queue if there is one, else "DEFAULT"
  1. ;
  1. ;** do not implement the Pass Immediate parameter **
  1. ; IMMEDIATE (pass by reference, optional) returns 1 if the application wants its messages passed to the incoming queue immediately, 0 otherwise
  1. ;
  1. N IEN
  1. S (ACTION,QUEUE)=""
  1. S IEN=$$GETIEN(HEADER("RECEIVING APPLICATION"))
  1. Q:'$G(IEN) 0
  1. I $G(HEADER("SEGMENT TYPE"))="BHS" D
  1. .S NODE=$G(^HLD(779.2,IEN,0))
  1. .I $P(NODE,"^",5)]"" D
  1. ..S ACTION=$P(NODE,"^",4,5)
  1. .E I $P(NODE,"^",7)]"" S ACTION=$P(NODE,"^",6,7)
  1. .I $P(NODE,"^",8)]"" D
  1. ..S QUEUE=$P(NODE,"^",8)
  1. .E I $P(NODE,"^",3)]"" S QUEUE=$P(NODE,"^",3)
  1. E I HEADER("SEGMENT TYPE")="MSH" D
  1. .I HEADER("MESSAGE TYPE")'="",HEADER("EVENT")'="" D
  1. ..N SUBIEN,NODE
  1. ..;did the application specify an action for the particular version of this message?
  1. ..I HEADER("VERSION")'="" S SUBIEN=$O(^HLD(779.2,IEN,1,"D",HEADER("MESSAGE TYPE"),HEADER("EVENT"),HEADER("VERSION"),0))
  1. ..;if not, look on the "C" index
  1. ..S:'$G(SUBIEN) SUBIEN=$O(^HLD(779.2,IEN,1,"C",HEADER("MESSAGE TYPE"),HEADER("EVENT"),0))
  1. ..;
  1. ..I SUBIEN D
  1. ...S NODE=$G(^HLD(779.2,IEN,1,SUBIEN,0))
  1. ...I $P(NODE,"^",5)]"" S ACTION=$P(NODE,"^",4,5)
  1. ...I $P(NODE,"^",3)]"" S QUEUE=$P(NODE,"^",3)
  1. ...;
  1. ...;** do not implement the Pass ImMediate parameter **
  1. ...;S IMMEDIATE=$P(NODE,"^",8)
  1. ...;
  1. ..I ACTION="" S NODE=$G(^HLD(779.2,IEN,0)) I $P(NODE,"^",7)]"" S ACTION=$P(NODE,"^",6,7)
  1. ..I QUEUE="" S NODE=$G(^HLD(779.2,IEN,0)) I $P(NODE,"^",3)]"" S QUEUE=$P(NODE,"^",3)
  1. I QUEUE="" S QUEUE="DEFAULT"
  1. ;
  1. ;** do not implement the Pass Immediate parameter **
  1. ;I $G(IMMEDIATE)'=1 S IMMEDIATE=0
  1. ;
  1. I ACTION="" Q 0
  1. Q 1
  1. ;
  1. RTRNLNK(APPNAME) ;
  1. ;given the name of a receiving application, this returns the return
  1. ;link for application acks if one is provided. Otherwise, return
  1. ;acks are routed based on the information provide in the message hdr
  1. ;
  1. Q:(APPNAME="") ""
  1. N IEN
  1. S IEN=$$GETIEN(APPNAME)
  1. Q:IEN $P($G(^HLD(779.2,IEN,0)),"^",2)
  1. Q ""
  1. ;
  1. RTRNPORT(APPNAME) ;
  1. ;Given the name of the sending application, IF the application has its
  1. ;own listener, its port # is returned. Application acks should be
  1. ;returned using that port
  1. Q:(APPNAME="") ""
  1. N IEN,LINK
  1. S IEN=$$GETIEN(APPNAME)
  1. Q:'IEN ""
  1. S LINK=$P($G(^HLD(779.2,IEN,0)),"^",9)
  1. Q:'LINK ""
  1. Q $$PORT^HLOTLNK(LINK)
  1. ;
  1. ACTIVE(APP,MSGTYPE,EVENT,VERSION) ;
  1. ;Returns 1 if the message's INACTIVE flag has NOT been set.
  1. ;
  1. ;Input:
  1. ; APP (required) the name of the sending application
  1. ; MSGTYPE (required) 3 character HL7 message type
  1. ; EVENT (required) 3 character HL7 event
  1. ; VERSION (optional) HL7 version ID as it appears in the message header
  1. ;Output:
  1. ; Function returns 1 if the message type specified by the input parameters has not been set to INACTIVE. It returns 0 otherwise.
  1. ;
  1. N IEN,ACTIVE,SUBIEN
  1. S ACTIVE=1
  1. S IEN=$$GETIEN($G(APP))
  1. Q:'$G(IEN) ACTIVE
  1. Q:$G(MSGTYPE)="" ACTIVE
  1. Q:$G(EVENT)="" ACTIVE
  1. ;did the application specify an action for the particular version of this message?
  1. I $G(VERSION)'="" S SUBIEN=$O(^HLD(779.2,IEN,1,"D",MSGTYPE,EVENT,VERSION,0))
  1. ;if not, look on the "C" index
  1. S:'$G(SUBIEN) SUBIEN=$O(^HLD(779.2,IEN,1,"C",MSGTYPE,EVENT,0))
  1. ;
  1. S:SUBIEN ACTIVE='(+$P($G(^HLD(779.2,IEN,1,SUBIEN,0)),"^",7))
  1. Q ACTIVE
  1. ;
  1. EXCEPT(APPNAME) ;
  1. ;returns the exception handler (tag^routine) that should be invoked
  1. ;when an applicaiton's messages are being sequenced and an app ack
  1. ;is not timely received
  1. ;
  1. N IEN,RTN
  1. S IEN=$$GETIEN($G(APPNAME))
  1. I IEN S RTN=$P($G(^HLD(779.2,IEN,0)),"^",10,11)
  1. I $L($G(RTN))>1 Q RTN
  1. Q "DEFAULT^HLOAPP"
  1. ;
  1. DEFAULT ;default exception handler if the app doesn't specify one
  1. S ^TMP("HLO SEQUENCING EXCEPTION",$J,$$NOW^XLFDT,+$G(HLMSGIEN))=""
  1. Q
  1. ;
  1. TIMEOUT(APPNAME) ;
  1. N IEN,TIME
  1. S IEN=$$GETIEN($G(APPNAME))
  1. I IEN S TIME=$P($G(^HLD(779.2,IEN,0)),"^",12)
  1. Q:'$G(TIME) 10
  1. Q TIME
  1. ;
  1. RTNTN(APP,MSGTYPE,EVENT,VERSION) ;
  1. ;Returns the retention time for this message, if specified.
  1. ;
  1. ;Input:
  1. ; APP (required) the name of the sending application
  1. ; MSGTYPE (required) 3 character HL7 message type
  1. ; EVENT (required) 3 character HL7 event
  1. ; VERSION (optional) HL7 version ID as it appears in the message header
  1. ;Output:
  1. ; Function returns retention time if spcified, 0 otherwise
  1. ;
  1. N IEN,RET,SUBIEN
  1. S RET=0
  1. S IEN=$$GETIEN($G(APP))
  1. Q:'$G(IEN) RET
  1. I $L($G(MSGTYPE)),$L($G(EVENT)) D
  1. .;did the application specify an action for the particular version of this message?
  1. .I $G(VERSION)'="" S SUBIEN=$O(^HLD(779.2,IEN,1,"D",MSGTYPE,EVENT,VERSION,0)) I SUBIEN S RET=$P($G(^HLD(779.2,IEN,1,SUBIEN,0)),"^",8)
  1. .;if not, look on the "C" index
  1. .S:'RET SUBIEN=$O(^HLD(779.2,IEN,1,"C",MSGTYPE,EVENT,0)) I SUBIEN S RET=$P($G(^HLD(779.2,IEN,1,SUBIEN,0)),"^",8)
  1. ;
  1. S:'RET RET=+$P($G(^HLD(779.2,IEN,0)),"^",13)
  1. Q RET
  1. ;
  1. ;
  1. ;
  1. ;
  1. ;
  1. ;