source: WorldVistAEHR/trunk/r/HEALTH_LEVEL_SEVEN-HL/HLCSLM.m@ 619

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

initial load of WorldVistAEHR

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