source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLOTLNK.m@ 1328

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

initial load of FOIAVistA 6/30/08 version

File size: 4.8 KB
Line 
1HLOTLNK ;IRMFO-ALB/CJM - APIs for the HL Logical Link file;03/24/2004 14:43
2 ;;1.6;HEALTH LEVEL SEVEN;**126,130,131**;Oct 13, 1995;Build 10
3 ;
4SETSHUT(LINKIEN) ;
5 ;sets the shutdown flag (can not fail - if the link doesn't exist, by definition its shutdown)
6 Q:'$G(LINKIEN) 1
7 Q:'$D(^HLCS(870,LINKIEN,0)) 1
8 S $P(^HLCS(870,LINKIEN,0),"^",16)=1
9 Q 1
10SETOPEN(LINKIEN) ;
11 ;clears the shutdown flag, returns 1 on success, 0 on failure
12 Q:'$G(LINKIEN) 0
13 Q:'$D(^HLCS(870,LINKIEN,0)) 0
14 S $P(^HLCS(870,LINKIEN,0),"^",16)=""
15 Q 1
16 ;
17IFSHUT(LINKNAME) ;
18 ;returns 1 if the link was shut down to HLO
19 N IEN,LINK
20 S LINK=$P($G(LINKNAME),":")
21 Q:LINK=""
22 S IEN=$O(^HLCS(870,"B",LINK,0))
23 Q:'IEN 1
24 Q:$P($G(^HLCS(870,IEN,0)),"^",16) 1
25 Q 0
26 ;
27DOMAIN(LINKIEN) ;
28 ;Returns the domain associated with this link
29 ;
30 Q:'$G(LINKIEN) ""
31 N NODE,DOMAIN
32 S DOMAIN=""
33 S NODE=$G(^HLCS(870,LINKIEN,0))
34 I $P(NODE,"^",7) D
35 .S DOMAIN=$P($G(^DIC(4.2,$P(NODE,"^",7),0)),"^")
36 .S DOMAIN=$S($L(DOMAIN):"HL7."_DOMAIN,1:"")
37 I '$L(DOMAIN) S DOMAIN=$P(NODE,"^",8)
38 Q DOMAIN
39PORT(LINKIEN) ;
40 ;Returns the HLO port associated with this link
41 ;
42 Q:'$G(LINKIEN) ""
43 N NODE,PORT
44 S NODE=$G(^HLCS(870,LINKIEN,400))
45 S PORT=$P(NODE,"^",8)
46 S:'PORT PORT=$S($P($G(^HLD(779.1,1,0)),"^",3)="P":5001,1:5026)
47 Q PORT
48 ;
49PORT2(LINKNAME) ;given the name of the link, returns its HLO port
50 Q $$PORT($O(^HLCS(870,"B",LINKNAME,0)))
51 ;
52STATNUM(LINKIEN) ;
53 ;Given the ien of the link, this function returns the station #.
54 ;
55 Q:'$G(LINKIEN) ""
56 N INST
57 S INST=$P($G(^HLCS(870,LINKIEN,0)),"^",2)
58 Q:'INST ""
59 Q $P($G(^DIC(4,INST,99)),"^")
60 ;
61FINDLINK(STATN) ;
62 ;Returns the link ien based on the station # =STATN
63 ;The link found must have a name starting with "VA", as these are
64 ;reserved for officially released links associated with VHA institutions
65 ;** EXCEPTION** MPIVA is an official link associated with 200M
66 ;
67 Q:'$L($G(STATN)) 0
68 ;
69 N NAME,IEN
70 S (NAME,IEN)=""
71 F S NAME=$O(^HLCS(870,"AC",STATN,NAME)) Q:NAME="" I (NAME'="VA-VIE"),($E(NAME,1,2)="VA")!(NAME="MPIVA") S IEN=$O(^HLCS(870,"AC",STATN,NAME,0)) Q
72 Q IEN
73 ;
74GETLINK(LINKNAME,LINK) ;
75 N IEN
76 S IEN=$O(^HLCS(870,"B",LINKNAME,0))
77 I IEN Q $$GET(IEN,.LINK)
78 I LINKNAME="HLO DEFAULT LISTENER" D Q 1
79 .N NODE
80 .S LINK("NAME")=LINKNAME
81 .S LINK("IEN")=0
82 .S LINK("SHUTDOWN")=""
83 .S LINK("LLP")="TCP"
84 .S LINK("SERVER")="1^"_"M"
85 .S NODE=$G(^HLD(779.1,1,0))
86 .S LINK("DOMAIN")=$P(NODE,"^",1)
87 .S LINK("PORT")=$S($P(NODE,"^",3)="P":5001,$P(NODE,"^",3)="T":5026,1:"")
88 .S LINK("IP")=""
89 Q 0
90GET(IEN,LINK) ;
91 N NODE,PTR
92 K LINK
93 S NODE=$G(^HLCS(870,IEN,0))
94 Q:NODE="" 0
95 S LINK("NAME")=$P(NODE,"^")
96 S LINK("IEN")=IEN
97 S LINK("SHUTDOWN")=+$P(NODE,"^",16)
98 I $P(NODE,"^",7) D
99 .S LINK("DOMAIN")=$P(^DIC(4.2,$P(NODE,"^",7),0),"^")
100 .S LINK("DOMAIN")=$S($L(LINK("DOMAIN")):"HL7."_LINK("DOMAIN"),1:"")
101 I $G(LINK("DOMAIN"))="" S LINK("DOMAIN")=$P(NODE,"^",8)
102 S PTR=$P(NODE,"^",3)
103 S LINK("LLP")=$S('PTR:"",1:$P($G(^HLCS(869.1,PTR,0)),"^"))
104 S LINK("SERVER")=""
105 I LINK("LLP")="TCP" D
106 .S LINK("SERVER")=1
107 .S NODE=$G(^HLCS(870,IEN,400))
108 .S LINK("IP")=$P(NODE,"^")
109 .S LINK("PORT")=$P(NODE,"^",8)
110 .S:'LINK("PORT") LINK("PORT")=$S($P($G(^HLD(779.1,1,0)),"^",3)="P":5001,1:5026)
111 .S:$P(NODE,"^",3)="C" LINK("SERVER")=0
112 .I LINK("SERVER") S LINK("SERVER")=LINK("SERVER")_"^"_$P(NODE,"^",3)
113 Q 1
114 ;
115SET1(LINK,MDOMAIN) ;
116 N DOMAIN
117 Q:'$L(MDOMAIN)
118 S DOMAIN=$P($G(^DIC(4.2,MDOMAIN,0)),"^")
119 S DOMAIN=$S($L(DOMAIN):"HL7."_DOMAIN,1:"")
120 I DOMAIN'="" S ^HLCS(870,"AD","TCP",DOMAIN,LINK)=""
121 Q
122KILL1(LINK,MDOMAIN) ;
123 N DOMAIN
124 Q:'$L(MDOMAIN)
125 S DOMAIN=$P($G(^DIC(4.2,MDOMAIN,0)),"^")
126 S DOMAIN=$S($L(DOMAIN):"HL7."_DOMAIN,1:"")
127 I DOMAIN'="" K ^HLCS(870,"AD","TCP",DOMAIN,LINK)
128 Q
129SET2(LINK,DOMAIN) ;
130 I DOMAIN'="" S ^HLCS(870,"AD","TCP",DOMAIN,LINK)=""
131 Q
132KILL2(LINK,DOMAIN) ;
133 I DOMAIN'="" K ^HLCS(870,"AD","TCP",DOMAIN,LINK)
134 Q
135SET3(LINK,DEVICE) ;
136 Q:'DEVICE
137 S ^HLCS(870,"AD","HLLP",DEVICE,LINK)=""
138 Q
139KILL3(LINK,DEVICE) ;
140 Q:'DEVICE
141 S ^HLCS(870,"AD","HLLP",DEVICE,LINK)=""
142 Q
143LLP(LINKNAME) ;
144 ;finds the type of LLP for a named link
145 N IEN,LLP
146 S IEN=$O(^HLCS(870,"B",LINKNAME,0))
147 Q:'IEN ""
148 S LLP=$P($G(^HLCS(870,IEN,0)),"^",3)
149 Q:'LLP ""
150 Q $P($G(^HLCS(869.1,LLP,0)),"^")
151 ;
152DEVICE(LINKNAME) ;
153 N IEN
154 S IEN=$O(^HLCS(870,"B",LINKNAME,0))
155 Q:'IEN ""
156 Q $P($G(^HLCS(870,IEN,200)),"^")
157 ;
158RTRNLNK(COMP1,COMP2,COMP3) ;
159 ;based on the sending facility from the original header, this function finds the return link, or "" if not successful
160 ;Inputs:
161 ; COMP1,COMP2,COMP3 - 3 components of the sending facility from the original message
162 ;
163 N LINK,IEN
164 S LINK=""
165 I $G(COMP3)="DNS",$P($G(COMP2),":")]"" S LINK=$O(^HLCS(870,"AD","TCP",$P(COMP2,":"),""))
166 I LINK="",$L($G(COMP1)) S IEN=$$FINDLINK(COMP1) S:IEN LINK=$P($G(^HLCS(870,IEN,0)),"^")
167 Q LINK
168 ;
169 ;HLLP is not implemented in HLO
170 ;I LLP="HLLP" N DEVICE S DEVICE=$$DEVICE(FROMLINK) I DEVICE Q $O(^HLCS(870,"AD","TCP",DEVICE,""))
171 ;Q ""
172 ;
173CHKLINK(LINK) ;
174 Q:'$L(LINK) 0
175 Q:'$O(^HLCS(870,"B",LINK,0)) 0
176 Q 1
Note: See TracBrowser for help on using the repository browser.