[623] | 1 | HLOAPP ;ALB/CJM-HL7 -Application Registry ;10/31/2006
|
---|
| 2 | ;;1.6;HEALTH LEVEL SEVEN;**126,132**;Oct 13, 1995;Build 6
|
---|
| 3 | ;Per VHA Directive 2004-038, this routine should not be modified.
|
---|
| 4 | ;
|
---|
| 5 | GETIEN(NAME) ;given the application name, it finds the ien. Returns 0 on failure
|
---|
| 6 | Q:'$L($G(NAME)) 0
|
---|
| 7 | N IEN,SUB
|
---|
| 8 | S SUB=$E(NAME,1,60)
|
---|
| 9 | S IEN=0
|
---|
| 10 | F S IEN=$O(^HLD(779.2,"B",SUB,IEN)) Q:'IEN Q:$P($G(^HLD(779.2,IEN,0)),"^")=NAME
|
---|
| 11 | Q +IEN
|
---|
| 12 | ;
|
---|
| 13 | 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.
|
---|
| 14 | ;
|
---|
| 15 | ;Input:
|
---|
| 16 | ; HEADER() subscripts are used: "RECEIVING APPLICATION","SEGMENT TYPE", "MESSAGE TYPE", "EVENT", "VERSION"
|
---|
| 17 | ;Output:
|
---|
| 18 | ; Function returns 1 on success, 0 on failure
|
---|
| 19 | ; ACTION (pass by reference) <tag>^<rtn>
|
---|
| 20 | ; QUEUE (pass by reference) returns the named queue if there is one, else "DEFAULT"
|
---|
| 21 | ;
|
---|
| 22 | N IEN
|
---|
| 23 | S (ACTION,QUEUE)=""
|
---|
| 24 | S IEN=$$GETIEN(HEADER("RECEIVING APPLICATION"))
|
---|
| 25 | Q:'$G(IEN) 0
|
---|
| 26 | I $G(HEADER("SEGMENT TYPE"))="BHS" D
|
---|
| 27 | .S NODE=$G(^HLD(779.2,IEN,0))
|
---|
| 28 | .I $P(NODE,"^",5)]"" D
|
---|
| 29 | ..S ACTION=$P(NODE,"^",4,5)
|
---|
| 30 | .E I $P(NODE,"^",7)]"" S ACTION=$P(NODE,"^",6,7)
|
---|
| 31 | .I $P(NODE,"^",8)]"" D
|
---|
| 32 | ..S QUEUE=$P(NODE,"^",8)
|
---|
| 33 | .E I $P(NODE,"^",3)]"" S QUEUE=$P(NODE,"^",3)
|
---|
| 34 | E I HEADER("SEGMENT TYPE")="MSH" D
|
---|
| 35 | .I HEADER("MESSAGE TYPE")'="",HEADER("EVENT")'="" D
|
---|
| 36 | ..N SUBIEN,NODE
|
---|
| 37 | ..;did the application specify an action for the particular version of this message?
|
---|
| 38 | ..I HEADER("VERSION")'="" S SUBIEN=$O(^HLD(779.2,IEN,1,"D",HEADER("MESSAGE TYPE"),HEADER("EVENT"),HEADER("VERSION"),0))
|
---|
| 39 | ..;if not, look on the "C" index
|
---|
| 40 | ..S:'$G(SUBIEN) SUBIEN=$O(^HLD(779.2,IEN,1,"C",HEADER("MESSAGE TYPE"),HEADER("EVENT"),0))
|
---|
| 41 | ..;
|
---|
| 42 | ..I SUBIEN D
|
---|
| 43 | ...S NODE=$G(^HLD(779.2,IEN,1,SUBIEN,0))
|
---|
| 44 | ...I $P(NODE,"^",5)]"" S ACTION=$P(NODE,"^",4,5)
|
---|
| 45 | ...I $P(NODE,"^",3)]"" S QUEUE=$P(NODE,"^",3)
|
---|
| 46 | ..I ACTION="" S NODE=$G(^HLD(779.2,IEN,0)) I $P(NODE,"^",7)]"" S ACTION=$P(NODE,"^",6,7)
|
---|
| 47 | ..I QUEUE="" S NODE=$G(^HLD(779.2,IEN,0)) I $P(NODE,"^",3)]"" S QUEUE=$P(NODE,"^",3)
|
---|
| 48 | I QUEUE="" S QUEUE="DEFAULT"
|
---|
| 49 | I ACTION="" Q 0
|
---|
| 50 | Q 1
|
---|
| 51 | ;
|
---|
| 52 | RTRNLNK(APPNAME) ;
|
---|
| 53 | ;given the name of a receiving application, this returns the return
|
---|
| 54 | ;link for application acks if one is provided. Otherwise, return
|
---|
| 55 | ;acks are routed based on the information provide in the message hdr
|
---|
| 56 | ;
|
---|
| 57 | Q:(APPNAME="") ""
|
---|
| 58 | N IEN
|
---|
| 59 | S IEN=$$GETIEN(APPNAME)
|
---|
| 60 | Q:IEN $P($G(^HLD(779.2,IEN,0)),"^",2)
|
---|
| 61 | Q ""
|
---|
| 62 | ;
|
---|
| 63 | RTRNPORT(APPNAME) ;
|
---|
| 64 | ;Given the name of the sending application, IF the application has its
|
---|
| 65 | ;own listener, its port # is returned. Application acks should be
|
---|
| 66 | ;returned using that port
|
---|
| 67 | Q:(APPNAME="") ""
|
---|
| 68 | N IEN,LINK
|
---|
| 69 | S IEN=$$GETIEN(APPNAME)
|
---|
| 70 | Q:'IEN ""
|
---|
| 71 | S LINK=$P($G(^HLD(779.2,IEN,0)),"^",9)
|
---|
| 72 | Q:'LINK ""
|
---|
| 73 | Q $$PORT^HLOTLNK(LINK)
|
---|
| 74 | ;
|
---|
| 75 | ACTIVE(APP,MSGTYPE,EVENT,VERSION) ;
|
---|
| 76 | ;Returns 1 if the message's INACTIVE flag has NOT been set.
|
---|
| 77 | ;
|
---|
| 78 | ;Input:
|
---|
| 79 | ; APP (required) the name of the sending application
|
---|
| 80 | ; MSGTYPE (required) 3 character HL7 message type
|
---|
| 81 | ; EVENT (required) 3 character HL7 event
|
---|
| 82 | ; VERSION (optional) HL7 version ID as it appears in the message header
|
---|
| 83 | ;Output:
|
---|
| 84 | ; Function returns 1 if the message type specified by the input parameters has not been set to INACTIVE. It returns 0 otherwise.
|
---|
| 85 | ;
|
---|
| 86 | N IEN,ACTIVE,SUBIEN
|
---|
| 87 | S ACTIVE=1
|
---|
| 88 | S IEN=$$GETIEN($G(APP))
|
---|
| 89 | Q:'$G(IEN) ACTIVE
|
---|
| 90 | Q:$G(MSGTYPE)="" ACTIVE
|
---|
| 91 | Q:$G(EVENT)="" ACTIVE
|
---|
| 92 | ;did the application specify an action for the particular version of this message?
|
---|
| 93 | I $G(VERSION)'="" S SUBIEN=$O(^HLD(779.2,IEN,1,"D",MSGTYPE,EVENT,VERSION,0))
|
---|
| 94 | ;if not, look on the "C" index
|
---|
| 95 | S:'$G(SUBIEN) SUBIEN=$O(^HLD(779.2,IEN,1,"C",MSGTYPE,EVENT,0))
|
---|
| 96 | ;
|
---|
| 97 | S:SUBIEN ACTIVE='(+$P($G(^HLD(779.2,IEN,1,SUBIEN,0)),"^",7))
|
---|
| 98 | Q ACTIVE
|
---|