source: FOIAVistA/trunk/r/SAGG_PROJECT-A1B5-KMPS/KMPSGE.m@ 1654

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

initial load of FOIAVistA 6/30/08 version

File size: 6.7 KB
Line 
1KMPSGE ;OAK/KAK - Master Routine ;5/3/07 13:57
2 ;;2.0;SAGG;;Jul 02, 2007
3 ;
4EN ;-- this routine can only be run as a TaskMan background job
5 ;
6 Q:'$D(ZTQUEUED)
7 ;
8 N CNT,COMPDT,HANG,KMPSVOLS,KMPSZE,LOC,MAXJOB,MGR,NOWDT,OS
9 N PROD,PTCHINFO,QUIT,SESSNUM,SITENUM,TEMP,TEXT,UCI,UCIVOL
10 N VOL,X,ZUZR
11 ;
12 ; maximum number of consecutively running jobs
13 S MAXJOB=6
14 ; hang time for LOOP and WAIT code
15 S HANG=300
16 ;
17 S SESSNUM=+$H,U="^",SITENUM=$P($$SITE^VASITE(),U,3)
18 ;
19 S NOWDT=$$NOW^XLFDT
20 ;
21 S OS=$$MPLTF^KMPSUTL1
22 I OS="UNK" D Q
23 .S TEXT(1)=" SAGG Project for this M platform is NOT implemented !"
24 .D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
25 ;
26 S MGR=^%ZOSF("MGR"),PROD=$P(^%ZOSF("PROD"),",")
27 S PROD=$S($P(^KMPS(8970.1,1,0),U,3)="":PROD,1:$P(^(0),U,3))
28 S LOC=$P(^KMPS(8970.1,1,0),U,2)
29 ;
30 L +^XTMP("KMPS")
31 S ^XTMP("KMPS",0)=$$FMADD^XLFDT($$DT^XLFDT,14)_U_NOWDT_U_"SAGG data"
32 K ^XTMP("KMPS",SITENUM),^XTMP("KMPS","ERROR")
33 K ^XTMP("KMPS","START"),^XTMP("KMPS","STOP")
34 ;
35 ; routine KMPSUTL will always be updated with patch release
36 S X="KMPSUTL"
37 X "ZL @X S PTCHINFO=$T(+2)"
38 S PTCHINFO=$P(PTCHINFO,";",3)_" "_$P(PTCHINFO,";",5)
39 ; session number^M platform^SAGG version_" "_patch^start date-time^
40 ; -> completed date-time will be set in $$PACK
41 S ^XTMP("KMPS",SITENUM,0)=SESSNUM_U_OS_U_PTCHINFO_U_NOWDT_U
42 S X="ERR1^KMPSGE",@^%ZOSF("TRAP")
43 S TEMP=SITENUM_U_SESSNUM_U_LOC_U_NOWDT_U_PROD
44 ;
45 S (CNT,VOL)=0
46 F S VOL=$O(^KMPS(8970.1,1,1,"B",VOL)) Q:VOL=""!+$G(^XTMP("KMPS","STOP")) D
47 .N UCI,UCIDA
48 .S UCIDA=0 F S UCIDA=$O(^KMPS(8970.1,1,1,"B",VOL,UCIDA)) Q:UCIDA=""!+$G(^XTMP("KMPS","STOP")) D
49 ..S UCI=$P(^KMPS(8970.1,1,1,UCIDA,0),U,2)
50 ..S:UCI="" UCI=PROD S UCIVOL(UCI_","_VOL)="",KMPSVOLS(VOL)=""
51 ..D @OS
52 ..S CNT=CNT+1
53 ..I CNT=MAXJOB S CNT=$$WAIT(HANG,MAXJOB)
54 ;
55 D EN^KMPSLK(SESSNUM,SITENUM)
56 S QUIT=0
57 D LOOP(HANG,SESSNUM,OS)
58 I 'QUIT D
59 .;N RESULT,XMZSENT
60 .S RESULT=$$PACK(SESSNUM,SITENUM)
61 .S XMZSENT=+RESULT,COMPDT=$P(RESULT,U,2)
62 .S X=$$OUT^KMPSLK(NOWDT,OS,SESSNUM,SITENUM,XMZSENT,.TEXT)
63 .D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT,COMPDT)
64 D END^KMPSLK
65 Q
66 ;
67LOOP(HANG,SESSNUM,OS) ;
68 ;---------------------------------------------------------------------
69 ; Loop until all volume sets complete
70 ;
71 ; HANG..... time to wait to see if all volume sets have completed
72 ; OS....... type of operating system
73 ; SESSNUM.. +$Horolog number of session
74 ;---------------------------------------------------------------------
75 N GBL,UCIVOL1
76 ;
77 F Q:'$D(^XTMP("KMPS","START"))!+$G(^XTMP("KMPS","STOP")) H HANG I (+$H>(SESSNUM+3)) D TOOLNG Q
78 ;
79 Q:QUIT
80 ;
81 I $D(^XTMP("KMPS","ERROR")) D Q
82 .N J,JEND,OUT,TEXT,VOL
83 .S QUIT=1
84 .S TEXT(1)=" The SAGG Project has recorded an error on volume set(s):"
85 .S OUT=0,VOL="",JEND=$S(OS="CVMS":2,OS="CWINNT":4,1:5)
86 .F I=3:1 Q:OUT D
87 ..S TEXT(I)=" "
88 ..F J=1:1:JEND S VOL=$O(^XTMP("KMPS","ERROR",VOL)) S:VOL="" OUT=1 Q:VOL="" S TEXT(I)=TEXT(I)_VOL_" "
89 .S (TEXT(2),TEXT(I))=""
90 .S TEXT(I+1)=" See system error log for more details."
91 .I OS["C" D
92 ..S TEXT(I+2)=""
93 ..S TEXT(I+3)=" Also run "_$S(OS="CVMS":"Integrity",1:"INTEGRIT")_" on the listed volume(s)."
94 .D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
95 ;
96 I $D(^XTMP("KMPS","STOP")) D Q
97 .N TEXT
98 .S QUIT=1
99 .S TEXT(1)=" The SAGG Project collection routines have been STOPPED! No report"
100 .S TEXT(2)=" has been generated."
101 .D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
102 ;
103 I '$D(^XTMP("KMPS",SITENUM,SESSNUM,NOWDT)) D Q
104 .N TEXT
105 .S QUIT=1
106 .S TEXT(1)=" The SAGG Project collection routines did NOT obtain ANY global"
107 .S TEXT(2)=" information. Please ensure that the SAGG PROJECT file is"
108 .S TEXT(3)=" properly setup. Then use the 'One-time Option Queue' under"
109 .S TEXT(4)=" Task Manager to re-run the 'SAGG Master Background Task'"
110 .S TEXT(5)=" [KMPS SAGG REPORT] option."
111 .D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
112 ;
113 S GBL=""
114 F S GBL=$O(^XTMP("KMPS",SITENUM,SESSNUM,NOWDT,GBL)) Q:GBL="" D
115 .S UCIVOL1=""
116 .F S UCIVOL1=$O(^XTMP("KMPS",SITENUM,SESSNUM,NOWDT,GBL,UCIVOL1)) Q:UCIVOL1="" D
117 ..K UCIVOL(UCIVOL1)
118 S UCIVOL1=""
119 F S UCIVOL1=$O(^XTMP("KMPS",SITENUM,SESSNUM," NO GLOBALS ",UCIVOL1)) Q:UCIVOL1="" K UCIVOL(UCIVOL1)
120 ;
121 I $D(UCIVOL) D Q
122 .N I,J,K,TEXT
123 .S QUIT=1
124 .S TEXT(1)=" The SAGG Project collection routines did NOT monitor the following:"
125 .S TEXT(2)=""
126 .S I=3,UCIVOL1=""
127 .F S UCIVOL1=$O(UCIVOL(UCIVOL1)) Q:UCIVOL1="" D
128 ..S I=I+1
129 ..S TEXT(I)=$J(" ",12)_UCIVOL1
130 .S I=I+1,TEXT(I)=""
131 .S I=I+1,TEXT(I)=" Please ensure that the SAGG PROJECT file is properly setup. Then use"
132 .S I=I+1,TEXT(I)=" the 'One-time Option Queue' under Task Manager to re-run the 'SAGG"
133 .S I=I+1,TEXT(I)=" Master Background Task' [KMPS SAGG REPORT] option."
134 .D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
135 ;
136 Q
137 ;
138PACK(SESSNUM,SITENUM) ;
139 ;---------------------------------------------------------------------
140 ; PackMan ^XTMP global to KMP1-SAGG-SERVER at Albany FO
141 ;
142 ; SESSNUM.. +$Horolog number of session
143 ; SITENUM.. site number
144 ;
145 ; Return:
146 ; RETURN... number of SAGG data message^completed date-time
147 ;---------------------------------------------------------------------
148 ;
149 N COMPDT,N,NM,RETURN,X,XMSUB,XMTEXT,XMY,XMZ
150 ;
151 S U="^",N=$O(^DIC(4,"D",SITENUM,0))
152 S NM=$S($D(^DIC(4,N,0)):$P(^(0),U),1:SITENUM)
153 ;
154 S:'$D(XMDUZ) XMDUZ=.5 S:'$D(DUZ) DUZ=.5
155 K:$G(IO)="" IO
156 ;
157 ; set completed date-time
158 S COMPDT=$$NOW^XLFDT
159 S $P(^XTMP("KMPS",SITENUM,0),U,5)=COMPDT
160 ;
161 S XMSUB=NM_" (Session #"_SESSNUM_") XTMP(""KMPS"") Global"
162 I SITENUM=+SITENUM S XMTEXT="^XTMP(""KMPS"","_SITENUM_","
163 E S XMTEXT="^XTMP(""KMPS"","""_SITENUM_""","
164 S XMY("S.KMP1-SAGG-SERVER@FO-ALBANY.MED.VA.GOV")=""
165 D ENT^XMPG
166 ;
167 S RETURN=XMZ_U_COMPDT
168 ;
169 Q RETURN
170 ;
171WAIT(HANG,MAXJOB) ;
172 ;---------------------------------------------------------------------
173 ; Wait here until less than MAXJOB volume sets are running
174 ;
175 ; HANG.... amount of time to wait
176 ; MAXJOB.. maximum number of jobs allowed to run
177 ;
178 ; Return:
179 ; RUN..... number of currently running jobs
180 ;---------------------------------------------------------------------
181 ;
182 N RUN
183 ;
184 F H HANG S RUN=$$RUN Q:(RUN<MAXJOB)!+$G(^XTMP("KMPS","STOP"))
185 ;
186 Q RUN
187 ;
188RUN() ;-- number of currently running jobs
189 N RUN,VOL
190 ;
191 S RUN=0,VOL=""
192 F S VOL=$O(^XTMP("KMPS","START",VOL)) Q:VOL="" S RUN=RUN+1
193 ;
194 Q RUN
195 ;
196TOOLNG ;-- job has been running too long
197 ;
198 N TEXT
199 ;
200 S QUIT=1
201 S TEXT(1)=" The SAGG Project collection routines have been running for more"
202 S TEXT(2)=" than 3 days. No report has been generated."
203 D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
204 Q
205 ;
206ERR1 ;
207 S KMPSZE=$ZE,ZUZR=$ZR,X="",@^%ZOSF("TRAP")
208 D @^%ZOSF("ERRTN")
209 K TEXT
210 S TEXT(1)=" SAGG Project Error: "_KMPSZE
211 S TEXT(2)=" See system error log for more details."
212 S ^XTMP("KMPS","STOP")=""
213 D MSG^KMPSLK(NOWDT,SESSNUM,.TEXT)
214 G ^XUSCLEAN
215 ;
216CVMS ;-- for Cache for VMS platform
217CWINNT ;-- for Cache for Windows NT platform
218 J START^%ZOSVKSE(TEMP_U_VOL)
219 Q
Note: See TracBrowser for help on using the repository browser.