source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLOAPP.m@ 1470

Last change on this file since 1470 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

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