source: WorldVistAEHR/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLOTLNK.m@ 1005

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

initial load of WorldVistAEHR

File size: 6.0 KB
Line 
1HLOTLNK ;IRMFO-ALB/CJM - APIs for the HL Logical Link file;03/24/2004 14:43 ;1/23/07 16:59
2 ;;1.6;HEALTH LEVEL SEVEN;**126,130,131,135**;Oct 13, 1995;Build 10
3 ; Modified from FOIA VISTA,
4 ; Copyright (C) 2007 WorldVistA
5 ;
6 ; This program is free software; you can redistribute it and/or modify
7 ; it under the terms of the GNU General Public License as published by
8 ; the Free Software Foundation; either version 2 of the License, or
9 ; (at your option) any later version.
10 ;
11 ; This program is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ; GNU General Public License for more details.
15 ;
16 ; You should have received a copy of the GNU General Public License
17 ; along with this program; if not, write to the Free Software
18 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 ;
20 ;; VWSD LOGICAL TO ALLOW A NON-VA STATION ( NODE )WITH $D(HLVWNOVA) VARIABLE EXIST FOR HL LOGICAL LINKS
21 ;
22SETSHUT(LINKIEN) ;
23 ;sets the shutdown flag (can not fail - if the link doesn't exist, by definition its shutdown)
24 Q:'$G(LINKIEN) 1
25 Q:'$D(^HLCS(870,LINKIEN,0)) 1
26 S $P(^HLCS(870,LINKIEN,0),"^",16)=1
27 Q 1
28SETOPEN(LINKIEN) ;
29 ;clears the shutdown flag, returns 1 on success, 0 on failure
30 Q:'$G(LINKIEN) 0
31 Q:'$D(^HLCS(870,LINKIEN,0)) 0
32 S $P(^HLCS(870,LINKIEN,0),"^",16)=""
33 Q 1
34 ;
35IFSHUT(LINKNAME) ;
36 ;returns 1 if the link was shut down to HLO
37 N IEN,LINK
38 S LINK=$P($G(LINKNAME),":")
39 Q:LINK=""
40 S IEN=$O(^HLCS(870,"B",LINK,0))
41 Q:'IEN 1
42 Q:$P($G(^HLCS(870,IEN,0)),"^",16) 1
43 Q 0
44 ;
45DOMAIN(LINKIEN) ;
46 ;Returns the domain associated with this link
47 ;
48 Q:'$G(LINKIEN) ""
49 N NODE,DOMAIN
50 S DOMAIN=""
51 S NODE=$G(^HLCS(870,LINKIEN,0))
52 I $P(NODE,"^",7) D
53 .S DOMAIN=$P($G(^DIC(4.2,$P(NODE,"^",7),0)),"^")
54 .S DOMAIN=$S($L(DOMAIN):"HL7."_DOMAIN,1:"")
55 I '$L(DOMAIN) S DOMAIN=$P(NODE,"^",8)
56 Q DOMAIN
57PORT(LINKIEN) ;
58 ;Returns the HLO port associated with this link
59 ;
60 Q:'$G(LINKIEN) ""
61 N NODE,PORT
62 S NODE=$G(^HLCS(870,LINKIEN,400))
63 S PORT=$P(NODE,"^",8)
64 S:'PORT PORT=$S($P($G(^HLD(779.1,1,0)),"^",3)="P":5001,1:5026)
65 Q PORT
66 ;
67PORT2(LINKNAME) ;given the name of the link, returns its HLO port
68 Q $$PORT($O(^HLCS(870,"B",LINKNAME,0)))
69 ;
70STATNUM(LINKIEN) ;
71 ;Given the ien of the link, this function returns the station #.
72 ;
73 Q:'$G(LINKIEN) ""
74 N INST
75 S INST=$P($G(^HLCS(870,LINKIEN,0)),"^",2)
76 Q:'INST ""
77 Q $P($G(^DIC(4,INST,99)),"^")
78 ;
79FINDLINK(STATN) ;
80 ;Returns the link ien based on the station # =STATN
81 ;The link found must have a name starting with "VA", as these are
82 ;reserved for officially released links associated with VHA institutions
83 ;** EXCEPTION** MPIVA is an official link associated with 200M
84 ;***LOCAL VWSD - ALLOW NON-VA STATION (NODE) AS VARIABLE HLVWNOVA TO BE USED TO DETERMINE FACILITY LINK
85 Q:'$L($G(STATN)) 0
86 ;
87 N NAME,IEN
88 S (NAME,IEN)=""
89 ; START LOCAL MOD VWSD FLAG HLVWNOVA
90 ; 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
91 F S NAME=$O(^HLCS(870,"AC",STATN,NAME)) Q:NAME="" I (NAME'="VA-VIE"),(($E(NAME,1,2)="VA")!(NAME="MPIVA"))!$D(HLVWNOVA) S IEN=$O(^HLCS(870,"AC",STATN,NAME,0)) Q
92 ;END LOCAL MOD
93 Q IEN
94 ;
95GETLINK(LINKNAME,LINK) ;
96 N IEN
97 S IEN=$O(^HLCS(870,"B",LINKNAME,0))
98 I IEN Q $$GET(IEN,.LINK)
99 I LINKNAME="HLO DEFAULT LISTENER" D Q 1
100 .N NODE
101 .S LINK("NAME")=LINKNAME
102 .S LINK("IEN")=0
103 .S LINK("SHUTDOWN")=""
104 .S LINK("LLP")="TCP"
105 .S LINK("SERVER")="1^"_"M"
106 .S NODE=$G(^HLD(779.1,1,0))
107 .S LINK("DOMAIN")=$P(NODE,"^",1)
108 .S LINK("PORT")=$S($P(NODE,"^",3)="P":5001,$P(NODE,"^",3)="T":5026,1:"")
109 .S LINK("IP")=""
110 Q 0
111GET(IEN,LINK) ;
112 N NODE,PTR
113 K LINK
114 S NODE=$G(^HLCS(870,IEN,0))
115 Q:NODE="" 0
116 S LINK("NAME")=$P(NODE,"^")
117 S LINK("IEN")=IEN
118 S LINK("SHUTDOWN")=+$P(NODE,"^",16)
119 I $P(NODE,"^",7) D
120 .S LINK("DOMAIN")=$P(^DIC(4.2,$P(NODE,"^",7),0),"^")
121 .S LINK("DOMAIN")=$S($L(LINK("DOMAIN")):"HL7."_LINK("DOMAIN"),1:"")
122 I $G(LINK("DOMAIN"))="" S LINK("DOMAIN")=$P(NODE,"^",8)
123 S PTR=$P(NODE,"^",3)
124 S LINK("LLP")=$S('PTR:"",1:$P($G(^HLCS(869.1,PTR,0)),"^"))
125 S LINK("SERVER")=""
126 I LINK("LLP")="TCP" D
127 .S LINK("SERVER")=1
128 .S NODE=$G(^HLCS(870,IEN,400))
129 .S LINK("IP")=$P(NODE,"^")
130 .S LINK("PORT")=$P(NODE,"^",8)
131 .S:'LINK("PORT") LINK("PORT")=$S($P($G(^HLD(779.1,1,0)),"^",3)="P":5001,1:5026)
132 .S:$P(NODE,"^",3)="C" LINK("SERVER")=0
133 .I LINK("SERVER") S LINK("SERVER")=LINK("SERVER")_"^"_$P(NODE,"^",3)
134 Q 1
135 ;
136SET1(LINK,MDOMAIN) ;
137 N DOMAIN
138 Q:'$L(MDOMAIN)
139 S DOMAIN=$P($G(^DIC(4.2,MDOMAIN,0)),"^")
140 S DOMAIN=$S($L(DOMAIN):"HL7."_DOMAIN,1:"")
141 I DOMAIN'="" S ^HLCS(870,"AD","TCP",DOMAIN,LINK)=""
142 Q
143KILL1(LINK,MDOMAIN) ;
144 N DOMAIN
145 Q:'$L(MDOMAIN)
146 S DOMAIN=$P($G(^DIC(4.2,MDOMAIN,0)),"^")
147 S DOMAIN=$S($L(DOMAIN):"HL7."_DOMAIN,1:"")
148 I DOMAIN'="" K ^HLCS(870,"AD","TCP",DOMAIN,LINK)
149 Q
150SET2(LINK,DOMAIN) ;
151 I DOMAIN'="" S ^HLCS(870,"AD","TCP",DOMAIN,LINK)=""
152 Q
153KILL2(LINK,DOMAIN) ;
154 I DOMAIN'="" K ^HLCS(870,"AD","TCP",DOMAIN,LINK)
155 Q
156SET3(LINK,DEVICE) ;
157 Q:'DEVICE
158 S ^HLCS(870,"AD","HLLP",DEVICE,LINK)=""
159 Q
160KILL3(LINK,DEVICE) ;
161 Q:'DEVICE
162 S ^HLCS(870,"AD","HLLP",DEVICE,LINK)=""
163 Q
164LLP(LINKNAME) ;
165 ;finds the type of LLP for a named link
166 N IEN,LLP
167 S IEN=$O(^HLCS(870,"B",LINKNAME,0))
168 Q:'IEN ""
169 S LLP=$P($G(^HLCS(870,IEN,0)),"^",3)
170 Q:'LLP ""
171 Q $P($G(^HLCS(869.1,LLP,0)),"^")
172 ;
173DEVICE(LINKNAME) ;
174 N IEN
175 S IEN=$O(^HLCS(870,"B",LINKNAME,0))
176 Q:'IEN ""
177 Q $P($G(^HLCS(870,IEN,200)),"^")
178 ;
179RTRNLNK(COMP1,COMP2,COMP3) ;
180 ;based on the sending facility from the original header, this function finds the return link, or "" if not successful
181 ;Inputs:
182 ; COMP1,COMP2,COMP3 - 3 components of the sending facility from the original message
183 ;
184 N LINK,IEN
185 S LINK=""
186 I $G(COMP3)="DNS",$P($G(COMP2),":")]"" S LINK=$O(^HLCS(870,"AD","TCP",$P(COMP2,":"),""))
187 I LINK="",$L($G(COMP1)) S IEN=$$FINDLINK(COMP1) S:IEN LINK=$P($G(^HLCS(870,IEN,0)),"^")
188 Q LINK
189 ;
190 ;HLLP is not implemented in HLO
191 ;I LLP="HLLP" N DEVICE S DEVICE=$$DEVICE(FROMLINK) I DEVICE Q $O(^HLCS(870,"AD","TCP",DEVICE,""))
192 ;Q ""
193 ;
194CHKLINK(LINK) ;
195 Q:'$L(LINK) 0
196 Q:'$O(^HLCS(870,"B",LINK,0)) 0
197 Q 1
Note: See TracBrowser for help on using the repository browser.