source: FOIAVistA/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLCSLM.m@ 1783

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

initial load of FOIAVistA 6/30/08 version

File size: 6.3 KB
Line 
1HLCSLM ;SFCIOFO/AC - HL7 LINK MANAGER ;06/14/2005 10:29
2 ;;1.6;HEALTH LEVEL SEVEN;**49,57,109,123**;Oct 13, 1995
3 ;
4EN ;Entry point for start up task
5 N %,HLEVLCHK,HLTSKCNT
6 F %=1:1:10 L +^HLCS("HLCSLM"):2 Q:$T
7 E Q
8 I $G(ZTQUEUED) S Y=$$PSET^%ZTLOAD(ZTQUEUED)
9 D INIT,SAVDOLRH
10 D SETNM^%ZOSV($E("HLmgr:"_$G(ZTQUEUED),1,15))
11 ;
12LOOP ;
13 D CHKQUE
14 I $$CKLMSTOP G EXIT
15 D SAVDOLRH
16 D CHECKMST^HLEVMST ;HL*1.6*109 - Make sure event monitor current
17 H 10
18 G LOOP
19 ;
20EXIT N HLJ,X
21 S X=1
22 F L +^HLCS(869.3,X,5):2 Q:$T
23 ;52=Link Manager task number
24 S HLJ(869.3,X_",",52)="@"
25 D FILE^HLDIE("","HLJ","","EXIT","HLCSLM") ;HL*1.6*109
26 L -^HLCS(869.3,X,5)
27 L -^HLCS("HLCSLM")
28 Q
29 ;
30SAVDOLRH ;Save Last Known $H
31 N HLJ,X
32 S X=1
33 F L +^HLCS(869.3,X,5):2 Q:$T
34 ;54=LM LAST KNOWN $H
35 S HLJ(869.3,X_",",54)=$H
36 D FILE^HLDIE("","HLJ","","SAVDOLRH","HLCSLM") ;HL*1.6*109
37 L -^HLCS(869.3,X,5)
38 Q
39 ;
40CHKQUE ;Check queues for messages to send
41 ;HLTSKCNT(logical link)=task #^$H
42 N HLDA,HLDP,HLMSG,HLTSK,Y
43 S (HLDA,HLMSG)=""
44 F HLDP=0:0 S HLDP=+$O(^HLMA("AC","O",HLDP)) Q:HLDP'>0 S HLMSG=+$O(^(HLDP,0)) I HLMSG D L -^HLCS("HLCSLSM",HLDP)
45 .;quit if persistent link
46 .Q:$P($G(^HLCS(870,HLDP,400)),U,4)="Y"
47 .L +^HLCS("HLCSLSM",HLDP):0 E K HLTSKCNT(HLDP) Q
48 .Q:'$$LLOK(+HLDP)
49 .;get tasknumber from file 870 and HLTSKCNT array
50 .S Y=$$TASKNUM(HLDP),HLTSK=$G(HLTSKCNT(HLDP))
51 . ;
52 . ;patch HL*1.6*123 start
53 . S HLDP("TASK-ACTIVE")=0
54 . ;
55 . I Y D
56 .. N ZTSK
57 .. S ZTSK=Y
58 .. ; Check status of task
59 .. D STAT^%ZTLOAD
60 .. I "12"[ZTSK(1) S HLDP("TASK-ACTIVE")=1
61 . Q:HLDP("TASK-ACTIVE")
62 . ;
63 . I HLTSK D
64 .. N ZTSK
65 .. S ZTSK=+HLTSK
66 .. ; Check status of task
67 .. D STAT^%ZTLOAD
68 .. I "12"[ZTSK(1) S HLDP("TASK-ACTIVE")=1
69 . Q:HLDP("TASK-ACTIVE")
70 . ;
71 . ;no tasknumber, link not running nor queued, task it
72 . I 'HLTSK!'Y D TASKLSUB(HLDP),SAVTSK(HLDP) Q
73 ; comment out the following lines
74 ; .;link was tasked, check time
75 ; .S Y=$P(HLTSK,U,2)
76 ; .;check that time task is less than 30 minutes
77 ; .Q:$$HDIFF^XLFDT($H,Y,2)<1800
78 ; .;shutdown and send alert
79 ; .D SDFLD^HLCSTCP,EXITS^HLCSTCP("Shutdown"),SNDALERT
80 ; loop through links that have been tasked
81 ; F HLDP=0:0 S HLDP=$O(HLTSKCNT(HLDP)) Q:HLDP'>0 K:'$D(^HLMA("AC","O",HLDP)) HLTSKCNT(HLDP)
82 F HLDP=0:0 S HLDP=$O(HLTSKCNT(HLDP)) Q:HLDP'>0 D
83 . N ZTSK
84 . S ZTSK=+HLTSKCNT(HLDP)
85 . ; Check status of task
86 . D STAT^%ZTLOAD
87 . ; kill HLTSKCNT(HLDP) if process is not active
88 . I "12"'[ZTSK(1) K HLTSKCNT(HLDP)
89 ; patch HL*1.6*123 end
90 Q
91 ;
92INIT ;Create Task number and clear Stop flag.
93 N HLJ,X
94 S X=1
95 F L +^HLCS(869.3,X,5):2 Q:$T
96 ;52=Link Manager task number,53=Stop Link Manager
97 S HLJ(869.3,X_",",52)=$G(ZTQUEUED)
98 S HLJ(869.3,X_",",53)="@"
99 D FILE^HLDIE("","HLJ","","INIT","HLCSLM") ;HL*1.6*109
100 L -^HLCS(869.3,X,5)
101 Q
102TASKNUM(X) ;Look-up task number
103 N %,DA,Y
104 S DA=X
105 ;
106 ;**109**
107 ;F L +^HLCS(870,+DA,0):2 Q:$T
108 ;
109 S Y=$$GET1^DIQ(870,DA_",",11)
110 ;
111 ;**109
112 ;L -^HLCS(870,+DA,0)
113 ;
114 Q Y
115STATUS(X) ;Status of task
116 N Y,ZTSK
117 S ZTSK=X
118 D STAT^%ZTLOAD
119 S Y=ZTSK(1)
120 Q Y
121 ;
122LLOK(X) ;Function to check whether LL ok.
123 ;return value 1 = ok, 0 = not ok.
124 Q:'$G(X)
125 N HLDP,HLDP0,HLPARM4,HLTYPTR
126 S HLDP=+X,HLDP0=$G(^HLCS(870,HLDP,0)),HLPARM4=$G(^(400)) Q:HLDP0="" 0
127 ;must be a client
128 Q:$P(HLPARM4,U,3)'="C" 0
129 ;
130 ; patch HL*1.6*123
131 ;shutdown LLP must be 0
132 ; Q:$P(HLDP0,U,15)'=0 0
133 ; change to 1, in case the data is empty
134 Q:$P(HLDP0,U,15)=1 0
135 ;
136 ;must have LLP Type of TCP
137 S HLTYPTR=+$P(HLDP0,U,3) Q:$P($G(^HLCS(869.1,HLTYPTR,0)),U)'="TCP" 0
138 Q 1
139 ;
140SAVTSK(X) ;
141 N HLDP,HLJ
142 S HLDP=X
143 ;
144 ;**109**
145 F L +^HLCS(870,HLDP,0):2 Q:$T
146 ;
147 ;4=status,10=Time Stopped,9=Time Started,11=Task Number,3=Online ?
148 S X=$NA(HLJ(870,HLDP_",")),@X@(11)=$G(ZTSK)
149 ;S HLJ(870,HLDP_",",11)=$G(ZTSK)
150 D FILE^HLDIE("","HLJ","","SAVTSK","HLCSLM") ; HL*1.6*109
151 S HLTSKCNT(HLDP)=$G(ZTSK)_"^"_$H
152 ;
153 ;**109**
154 L -^HLCS(870,HLDP,0)
155 ;
156 Q
157 ;
158STRTSTOP ;ENTRY POINT TO START/STOP TCP LINK MANAGER
159 N DIR,DIRUT,Y
160 L +^HLCS("HLCSLM"):3 E D Q
161 .W !,*7,"Link Manager already running!"
162 .W ! S DIR(0)="YO",DIR("A")="Would you like to stop the Link Manager now",DIR("B")="NO" D ^DIR K DIR
163 .I $D(DIRUT)!'Y Q
164 .D STOPLM
165 W !,*7,"Link Manager is NOT currently running!"
166 W ! S DIR(0)="YO",DIR("A")="Would you like to start the Link Manager now",DIR("B")="YES" D ^DIR K DIR
167 I '$D(DIRUT)&Y D TASKLM
168 L -^HLCS("HLCSLM")
169 Q
170 ;
171STOPLM ;ENTRY POINT TO STOP LINK MANAGER
172 N DIC,X,Y,DTOUT,DUOUT,DLAYGO,DIE,DA,DR
173 S DIC="^HLCS(869.3,"
174 S X=1
175 D ^DIC
176 S DA=+Y,DIE=DIC
177 S DR="53////1"
178 D ^DIE
179 W !,"Link Manager has been asked to stop"
180 Q
181STAT() ;Status of LINK MANAGER--up, down or unable to determine.
182 N %,DA,X,Y
183 S DA=1
184 S X=$$GET1^DIQ(869.3,DA_",",52)
185 Q:X']"" 0
186 S X=$$GET1^DIQ(869.3,DA_",",54)
187 Q:X']"" 0
188 I $$HDIFF^XLFDT($H,X,2)>500 Q 0
189 Q 1
190 ;
191TASKLSUB(X) ;Task LINK SUB-MANAGER.
192 ;This may be a place to log the time which the LINK SUBMANAGER is tasked.
193 N HLDP,HLDP0,HLDAPP,HLTYPTR,HLBGR,HLENV,HLPARM,HLPARM4,HLQUIT,ZTRTN,ZTDESC,ZTCPU,ZTSAVE
194 ;ZTSK is not Newed here because it will be needed by SAVTSK.
195 S HLDP=X,HLDP0=$G(^HLCS(870,HLDP,0)),HLPARM4=$G(^(400))
196 ; Q:"N"'[$P(HLPARM4,U,4) ; patch HL*1.6*123: comment out
197 ;quit if no LLP TYPE
198 S HLDAPP=$P(HLDP0,U),HLTYPTR=$P(HLDP0,U,3) Q:'HLTYPTR
199 S HLBGR=$G(^HLCS(869.1,HLTYPTR,100)),HLENV=$G(^(200))
200 I HLENV'="" K HLQUIT X HLENV Q:$D(HLQUIT)
201 S ZTRTN="^HLCSLSM",HLBGR=$P(HLBGR," ",2)
202 S ZTDESC=HLDAPP_" Low Level Protocol",ZTSAVE("HLDP")="",ZTSAVE("HLBGR")=""
203 S ZTIO="",ZTDTH=$H
204 ;get startup node
205 I $P(HLPARM4,U,6),$D(^%ZIS(14.7,+$P(HLPARM4,U,6),0)) S ZTCPU=$P(^(0),U)
206 D ^%ZTLOAD
207 D MON^HLCSTCP("Tasked") ;HL*1.6*123
208 Q
209 ;
210TASKLM ;Task Link Manager
211 ;Declare variables
212 N ZTRTN,ZTDESC,ZTIO,ZTDTH,ZTSK,TMP
213 S ZTIO=""
214 S ZTDTH=$H
215 ;Task Link Manager
216 S ZTRTN="EN^HLCSLM"
217 S ZTDESC="HL7 Link Manager"
218 ;Call TaskMan
219 D ^%ZTLOAD
220 I $G(ZTSK) W !,"Link Manager queued as task number ",ZTSK
221 E W $C(7),!!,"Unable to start/restart Link Manager"
222 Q
223 ;
224CKLMSTOP() ;Check whether Link Manager should stop
225 N PTRMAIN,NODE5,STOP
226 S PTRMAIN=+$O(^HLCS(869.3,0))
227 L +^HLCS(869.3,PTRMAIN,5):1
228 I $T L -^HLCS(869.3,PTRMAIN,5)
229 S NODE5=$G(^HLCS(869.3,PTRMAIN,5))
230 S STOP=+$P(NODE5,"^",3)
231 Q:STOP STOP
232 S STOP=$$S^%ZTLOAD
233 Q STOP
234 ;
235SNDALERT ;Send Alert
236 N XQA,XQAMSG,XQAOPT,XQAROU,XQAID,Z
237 S Z=$P($$PARAM^HLCS2,U,8) Q:Z=""
238 S XQA("G."_Z)="",XQAMSG="HL7 Logical Link "_$P(^HLCS(870,HLDP,0),U)_" shutdown due to TaskMan unable to process task request"
239 D SETUP^XQALERT
240 Q
Note: See TracBrowser for help on using the repository browser.