source: WorldVistAEHR/trunk/r/AUTOMATED_LAB_INSTRUMENTS-LA/LA66.m@ 1000

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

initial load of WorldVistAEHR

File size: 6.7 KB
Line 
1LA66 ;DALOI/JMC - LA*5.2*66 PATCH ENVIRONMENT CHECK ROUTINE ;May 7, 2008
2 ;;5.2;AUTOMATED LAB INSTRUMENTS;**66**;Sep 27, 1994;Build 30
3 ;
4 ; Pre, Post, and Environment checks for LA*5.2*66
5 ;
6ENV ;
7 ; Environment checks
8 S XPDNOQUE=1 ; no queuing
9 N LAERR,LAADL
10 K ^TMP($$RTNNM(),$J)
11 I '$G(XPDENV) D ;
12 . N MSG
13 . S MSG="Transport global for patch "_$G(XPDNM,"Unknown patch")_" loaded on "_$$HTE^XLFDT($H)
14 . D ALERT(MSG)
15 . D BMES("Sending transport global loaded alert to mail group G.LMI")
16 ;
17 I $G(XPDENV) D ;
18 . N MSG
19 . S MSG="Installation of patch "_$G(XPDNM,"Unknown patch")_" started on "_$$HTE^XLFDT($H)
20 . D ALERT(MSG)
21 . D BMES("Sending install started alert to mail group G.LMI")
22 ;
23 S LAERR=0
24 I $S('$G(IOM):1,'$G(IOSL):1,$G(U)'="^":1,1:0) D ;
25 . D BMES("Terminal Device is not defined.")
26 . S LAERR=2
27 ;
28 I $S('$G(DUZ):1,$D(DUZ)[0:1,$D(DUZ(0))[0:1,1:0) D ;
29 . D BMES("Please login to set local DUZ variables.")
30 . S LAERR=2
31 ;
32 I 'LAERR,$P($$ACTIVE^XUSER(DUZ),"^")'=1 D ;
33 . D BMES("You are not a valid user on this system.")
34 . S LAERR=2
35 ;
36 ; If installing, run system config
37 I 'LAERR,$G(XPDENV) D ;
38 . S LAADL=$G(^LA("ADL","STOP"))
39 . D ENV2
40 . I $P(LAADL,"^")=0 D ;
41 . . D BMES("N O T E: If you abort this installation")
42 . . D MES("restart the Lab Universal Interface background job.")
43 ;
44 I LAERR!$D(XPDABORT)!$D(XPDQUIT) D ;
45 . S LAERR=1
46 . S XPDABORT=2 S XPDQUIT=2
47 . W !,$C(7) W ! D BMES("* * * Environment check FAILED * * *")
48 ;
49 I 'LAERR W ! D BMES("--- Environment is okay ---")
50 ;
51 I $G(XPDENV) S XPDDIQ("XPZ1","B")="NO"
52 Q
53 ;
54 ;
55PRE ;
56 ; Pre install
57 D BMES("*** Pre install started ***")
58 D BMES("--- No action required for pre-install ---")
59 D BMES("*** Pre install completed ***")
60 Q
61 ;
62 ;
63POST ;
64 ; Post install
65 N LAERR,LAFDA,LA7DIE,LA7FAC,LA7I,LA7X,LA7Y,LAMSG,LAPOST,DIERR
66 S (LAERR,LAPOST)=0
67 D BMES("*** Post install started ***")
68 ;
69 ; Set facility station number into FACILITY NAME field in file #771.
70 S LA7FAC=$P($$SITE^VASITE(DT),"^",3)
71 I 'LA7FAC D ;
72 . S LAERR=1
73 . D BMES("ERROR: Could not determine Facility Number.")
74 . D BMES("Edit file #771, FACILITY NAME field for LA7UI*")
75 I LA7FAC'="" D
76 . D BMES("*** Updating facility name for LA7UI* entries in file #771 ***")
77 . ; Okayed by Thomas Grohowski
78 . F LA7I=1:1:10 D ;
79 . . I LA7I S LA7X="LA7UI"_LA7I
80 . . K DIERR
81 . . S LA7Y=$$FIND1^DIC(771,"","OX",LA7X,"B")
82 . . I LA7Y<1 D Q
83 . . . S LAERR=1
84 . . . D BMES("ERROR: "_LA7X_" not found in file #771")
85 . . K LAFDA,DIERR,LAMSG
86 . . S LAFDA(1,771,LA7Y_",",3)=LA7FAC
87 . . D FILE^DIE("","LAFDA(1)","LAMSG")
88 . . ; notify if could not update
89 . . S LAERR=$$FMERR("LAMSG","ERROR: unable to update "_LA7X_" in file #771")
90 . ; delete facility ID for LA7LAB
91 . K LAFDA,LAMSG,DIERR
92 . S LA7Y=$$FIND1^DIC(771,"","OX","LA7LAB","B")
93 . I 'LA7Y D
94 . . S LAERR=1
95 . . D BMES("*** Missing 'LA7LAB' entry in HL7 APPLICATION PARAMETER (#771) file ***")
96 . I LA7Y D
97 . . K DIERR,LAFDA,LAMSG
98 . . S LAFDA(1,771,LA7Y_",",3)="@"
99 . . D FILE^DIE("","LAFDA(1)","LAMSG")
100 . . S LAERR=$$FMERR("LAMSG","ERROR: Failed to update LA7LAB entry in file #771.")
101 . S LAPOST=1
102 . D BMES("*** Updating facility name completed"_$S(LAERR:" but with errors",1:"")_" ***")
103 ;
104 ;
105 I $D(^TMP("LA66",$J,"62.48")) D
106 . D BMES("*** Restoring existing LA7UI* entries to ACTIVE in file #62.48 ***")
107 . S LA7I=0,LAPOST=1
108 . F S LA7I=$O(^TMP("LA66",$J,"62.48",LA7I)) Q:'LA7I D
109 . . K DIERR,LAFDA,LAMSG
110 . . S LA7Y=$P(^LAHM(62.48,LA7I,0),"^")
111 . . D BMES("*** Updating entry "_LA7Y_" to ACTIVE in file #62.48 ***")
112 . . S LAFDA(2,62.48,LA7I_",",2)=^TMP("LA66",$J,"62.48",LA7I)
113 . . D FILE^DIE("","LAFDA(2)","LAMSG")
114 . . S LAERR=$$FMERR("LAMSG","ERROR: Failed to update "_LA7Y_" entry in file #62.48.")
115 . D BMES("*** Updating existing LA7UI* entries to ACTIVE completed ***")
116 ;
117 I 'LAERR,'LAPOST D BMES("--- No actions required for post install ---")
118 ;
119 D RESTORE
120 D BMES("*** Post install completed"_$S(LAERR:" but with errors",1:"")_" ***")
121 ;
122 N MSG
123 S MSG="Installation of patch "_$G(XPDNM,"Unknown patch")_" completed on "_$$HTE^XLFDT($H)
124 D ALERT(MSG)
125 D BMES("Sending install completion alert to mail group G.LMI")
126 ;
127 K ^TMP($$RTNNM(),$J),^TMP("LA66",$J)
128 Q
129 ;
130 ;
131BMES(STR,POS) ;
132 ; Display messages using BMES^XPDUTL or MES^XPDUTL
133 ; Accepts single string or string array
134 ; Input
135 ; STR The string to display (byRef or byValue)
136 ; POS <opt> value for $$CJ^XLFSTR (80=default)
137 ;
138 N I,X
139 S POS=$G(POS,80)
140 ; If an array, step through it and pass each node to MES since $$CJ^XLFSTR can't handle arrays
141 I $D(STR)>9 D
142 . S I=0
143 . F S I=$O(STR(I)) Q:'I S X=STR(I) D MES^XPDUTL($$TRIM^XLFSTR($$CJ^XLFSTR(X,POS),"R"," "))
144 ;
145 I $D(STR)<2 D MES^XPDUTL($$TRIM^XLFSTR($$CJ^XLFSTR(STR,POS),"R"," "))
146 Q
147 ;
148 ;
149MES(STR,CJ,LM) ;
150 ; Displays a string using MES^XPDUTL
151 ; Inputs
152 ; STR: String to display
153 ; CJ: Center text? 1=yes 0=1 <dflt=1>
154 ; LM: Left Margin (padding)
155 N X
156 S STR=$G(STR)
157 S CJ=$G(CJ,1)
158 S LM=$G(LM)
159 I LM<0 S LM=0
160 I CJ S STR=$$TRIM^XLFSTR($$CJ^XLFSTR(STR,$G(IOM,80)),"R"," ")
161 I 'CJ I LM S X="" S $P(X," ",LM)=" " S STR=X_STR
162 D MES^XPDUTL(STR)
163 Q
164 ;
165 ;
166FMERR(LAREF,MSG) ;
167 ; Checks if a FileMan error occurred and displays help message
168 ; and error text message.
169 ; Input
170 ; LAREF Name of array that has the FM DIERR subscripts
171 ; ie FILE^DIE msg_root variable
172 ; MSG <opt> Additional help text
173 ; Output
174 ; 1 if an error occurred, 0 if no error
175 ; Also writes the messages to the device
176 N LAERRMSG,OK,FMERR
177 S LAREF=$G(LAREF)
178 S MSG=$G(MSG)
179 S FMERR=0
180 D MSG^DIALOG("AE",.LAERRMSG,,,LAREF)
181 I $D(LAERRMSG) D ;
182 . I MSG'="" D BMES(MSG)
183 . D BMES(.LAERRMSG)
184 . S FMERR=1
185 Q FMERR
186 ;
187 ;
188ENV2 ;
189 ; Secondary Environment checks
190 N X,I
191 ; check and shutdown Auto Download job.
192 S X=$G(^LA("ADL","STOP"))
193 I $P(X,"^")=0 D ;
194 . D SETSTOP^LA7ADL1(2,DUZ)
195 . D BMES("Shutting down Lab Universal Interface Auto Download Job")
196 . S ^TMP($$RTNNM(),$J,"ADL")=1
197 . F I=1:1:10 W "." H 1
198 ;
199 ;
200 ; If previously installed then save current ACTIVE LA7UI* entries.
201 K ^TMP("LA66",$J,"62.48")
202 S I=0
203 F S I=$O(^LAHM(62.48,I)) Q:'I I $E($P(^LAHM(62.48,I,0),"^"),1,5)="LA7UI",$P(^LAHM(62.48,I,0),"^",3)=1 S ^TMP("LA66",$J,"62.48",I)=1
204 Q
205 ;
206 ;
207RESTORE ;
208 ; Restore system after install
209 N LAADL,X
210 ; Restart auto download process status if stopped by install
211 S LAADL=$G(^TMP($$RTNNM(),$J,"ADL"))
212 I LAADL=1 D ;
213 . D ZTSK^LA7ADL
214 . D SETSTOP^LA7ADL1(1,DUZ)
215 . D BMES("Restarting Lab Universal Interface Auto Download Job")
216 . K ^TMP($$RTNNM(),$J,"ADL")
217 . H 3
218 ;
219 ; If ADL not started, notify user to restart
220 S X=$G(^LA("ADL","STOP"))
221 S X=$P(X,"^")
222 I X'=0 D BMES("Be sure to restart the Lab Universal Interface Auto Download Job")
223 K ^TMP($$RTNNM(),$J)
224 Q
225 ;
226 ;
227ALERT(MSG,RECIPS) ;
228 N DA,DIK,XQA,XQAMSG
229 S XQAMSG=$G(MSG)
230 S XQA("G.LMI")=""
231 I $D(RECIPS) M XQA=RECIPS
232 D SETUP^XQALERT
233 Q
234 ;
235 ;
236RTNNM() ;
237 Q $T(+0)
Note: See TracBrowser for help on using the repository browser.