source: FOIAVistA/trunk/r/DSS_EXTRACTS-ECX/ECXTAUTO.m@ 868

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

initial load of FOIAVistA 6/30/08 version

File size: 5.5 KB
Line 
1ECXTAUTO ;ALB/JAP,BIR/DMA-Background Queuing for Package Extracts ; 17 Mar 95 / 1:04 PM
2 ;;3.0;DSS EXTRACTS;**8,24,49**;Dec 22, 1997
3 ;generate extract & auto-requeue
4 ;
5QUE ;entry point from package extracts - determine start and stop date from 727.1
6 ;and variables from setup^routine
7 S EC=$O(^ECX(727.1,"AF",ECFILE,0))
8 S ECDT=$P($$HTFM^XLFDT(ZTDTH,1),".")
9 S ECED=$$LASTMON^ECXDEFIN(ECDT)
10 S ECSD=$E(ECED,1,5)_"01"
11 I '$D(ECNODE) S ECNODE=7
12 ;get station number; ecinst is defined only for prosthetics
13 ;automatic requeue can be setup only for site's with 1 primary prosthetics division
14 S:'$D(ECINST) ECINST=+$P(^ECX(728,1,0),U)
15 S ECXINST=ECINST
16 K ECXDIC S DA=ECINST,DIC="^DIC(4,",DIQ(0)="I",DIQ="ECXDIC",DR=".01;99"
17 D EN^DIQ1 S ECINST=$G(ECXDIC(4,DA,99,"I")) K DIC,DIQ,DA,DR,ECXDIC
18 ;check if currently running
19 I $P(^ECX(728,1,ECNODE+.1),U,ECPIECE)="R" D RUNMSG,REQUE Q
20 ;check if date range has been extracted
21 ;get last date for all extracts except prosthetics
22 I ECGRP'="PRO" D
23 .S ECLDT=$P($G(^ECX(728,1,ECNODE)),U,ECPIECE)
24 ;get last date for prosthetics
25 I ECGRP="PRO" D
26 .S ECLDT=""
27 .S ECXDA1=$O(^ECX(728,0))
28 .I $D(^ECX(728,ECXDA1,1,ECXINST,0)) S ECLDT=$P(^ECX(728,ECXDA1,1,ECXINST,0),U,2)
29 ;if last run date doesn't exist don't allow auto requeue to continue
30 I ECLDT="" S ZTREQ="@" Q
31 ;if last run date is last day of previous fy don't allow auto requeue to continue
32 S X=$$CYFY^ECXUTL1(DT)
33 I ECLDT=$$FMADD^XLFDT($P(X,U,3),-1) S ZTREQ="@" Q
34 ;otherwise continue to check data range
35 S ECFDT=$$FMADD^XLFDT(ECLDT,1)
36 I ECFDT>ECED D ERROR,REQUE Q
37 ;do specific extract using appropriate fiscal year logic
38 S ECXLOGIC=$$FISCAL^ECXUTL1(ECSD)
39 S $P(^ECX(728,1,ECNODE+.1),U,ECPIECE)="R"
40 S ECSDN=$$FMTE^XLFDT(ECSD),ECEDN=$$FMTE^XLFDT(ECED),ECSD1=ECSD-.1
41 L +^ECX(727,0) S EC=$P(^ECX(727,0),U,3)+1,$P(^(0),U,3,4)=EC_U_EC L -^ECX(727,0)
42 S ^ECX(727,EC,0)=EC_U_DT_U_ECPACK_U_ECSD_U_$E(ECED,1,7)
43 S ^ECX(727,EC,"HEAD")=ECHEAD
44 S ^ECX(727,EC,"FILE")=ECFILE
45 S ^ECX(727,EC,"GRP")=ECGRP
46 S ^ECX(727,EC,"VER")=$G(ECVER)_U_ECXLOGIC
47 S ^ECX(727,EC,"DIV")=ECXINST
48 S DA=EC,DIK="^ECX(727," D IX^DIK K DIK,DA
49 S ECRN=0,ECXYM=$$ECXYM^ECXUTL(ECED),EC23=ECXYM_U_EC
50 S ECXSTART=$P($$HTE^XLFDT($H),":",1,2),ECXNOW=$H
51 D @ECRTN
52 ;set last date for all extracts except prosthetics
53 S:(ECGRP'="PRO") $P(^ECX(728,1,ECNODE),U,ECPIECE)=$P(ECED,".")
54 ;set last date for prosthetics
55 I ECGRP="PRO" D
56 .S J=$O(^ECX(728,0))
57 .S $P(^ECX(728,J,1,ECXINST,0),U,2)=$P(ECED,".")
58 S TIME=$P($$HTE^XLFDT($H),":",1,2)
59 S $P(^ECX(727,$P(EC23,U,2),0),U,6)=ECRN
60 ;set piece 3 and 4 of the zero node
61 S ECLAST=$O(^ECX(ECFILE,99999999),-1),ECTOTAL=$P(^ECX(ECFILE,0),U,4)+ECRN,$P(^(0),U,3,4)=ECLAST_U_ECTOTAL K ECLAST,ECTOTAL
62 D MSG
63 S $P(^ECX(728,1,ECNODE+.1),U,ECPIECE)=""
64 D REQUE
65 Q
66 ;
67REQUE ;reque job for next time
68 S EC=$O(^ECX(727.1,"AF",ECFILE,0))
69 S ECFDT=$$HTFM^XLFDT(ZTDTH)
70 S ECFDT=$$NEXTMON^ECXDEFIN(ECFDT)
71 ;do not allow october extract to start from auto-requeue
72 I $E(ECFDT,4,5)="10" D Q
73 .D FYMSG
74 .S $P(^ECX(727.1,ECDA,0),"^",6)=""
75 .S ZTREQ="@"
76 S ZTDTH=$$FMTH^XLFDT(ECFDT)
77 D REQ^%ZTLOAD
78 Q
79 ;
80MSG ; send message to mail group 'DSS-ECGRP'
81 S XMSUB=ECINST_" - "_ECPACK_" AUTO-REQUEUE EXTRACT FOR DSS",XMDUZ="DSS SYSTEM"
82 K XMY S XMY("G.DSS-"_ECGRP_"@"_^XMB("NETNAME"))=""
83 S ECMSG(1,0)="The BACKGROUND DSS-"_ECPACK_" extract (#"_$P(EC23,U,2)_") for "_ECSDN
84 S ECMSG(2,0)="through "_ECEDN_" was begun on "_$P(ECXSTART,"@")_" at "_$P(ECXSTART,"@",2)
85 S ECMSG(3,0)="and completed on "_$P(TIME,"@")_" at "_$P(TIME,"@",2)_"."
86 S ECMSG(4,0)=" "
87 S ECMSG(5,0)="A total of "_ECRN_" records were written."
88 S ECMSG(6,0)=" "
89 S ECMSG(7,0)="Extract time was [HH:MM:SS] "_$$HDIFF^XLFDT($H,ECXNOW,3)
90 S ECMSG(8,0)=" "
91 S X=$E(ECXLOGIC,5) S X=$S((X="")!(X=" "):"",1:"revision "_X_" of ")
92 S ECMSG(9,0)="The data was extracted using "_X_"fiscal year "_$E(ECXLOGIC,1,4)_" logic."
93 S ECMSG(10,0)=" "
94 S XMTEXT="ECMSG(" D ^XMD
95 Q
96 ;
97ERROR ; send message when job was queued to extract data already extracted
98 S ECSDN=$$FMTE^XLFDT(ECSD),ECEDN=$$FMTE^XLFDT(ECED)
99 S XMSUB=ECINST_" - "_ECPACK_" BACKGROUND EXTRACT FAILURE",XMDUZ="DSS SYSTEM"
100 K XMY S XMY("G.DSS-"_ECGRP_"@"_^XMB("NETNAME"))=""
101 S ECMSG(1,0)="The "_ECPACK_" extract was automatically requeued to extract"
102 S ECMSG(2,0)="data for "_ECSDN_" through "_ECEDN_"."
103 S ECMSG(3,0)="Data for this range of dates has already been extracted."
104 S ECMSG(4,0)=" "
105 S ECMSG(5,0)="The extract was NOT generated, but has been requeued to run"
106 S ECMSG(6,0)="next month. "
107 S XMTEXT="ECMSG(" D ^XMD
108 Q
109 ;
110FYMSG ; send message for october extract
111 S Y=$E(ECFDT,1,5)_"00" D DD^%DT
112 S XMSUB=ECINST_" - "_ECPACK_" BACKGROUND EXTRACT FAILURE",XMDUZ="DSS SYSTEM"
113 K XMY S XMY("G.DSS-"_ECGRP_"@"_^XMB("NETNAME"))=""
114 S ECMSG(1,0)="There was an attempt to automatically requeue the "_ECPACK
115 S ECMSG(2,0)="extract for the month of "_Y_"."
116 S ECMSG(3,0)=" "
117 S ECMSG(4,0)="The extract was NOT generated. The first extract of the new fiscal"
118 S ECMSG(5,0)="year will need to be queued to run after any required fiscal year"
119 S ECMSG(6,0)="update is installed."
120 S XMTEXT="ECMSG(" D ^XMD
121 Q
122 ;
123RUNMSG ;
124 S ECSDN=$$FMTE^XLFDT(ECSD),ECEDN=$$FMTE^XLFDT(ECED)
125 S XMSUB=ECINST_" - "_ECPACK_" BACKGROUND EXTRACT FAILURE",XMDUZ="DSS SYSTEM"
126 K XMY S XMY("G.DSS-"_ECGRP_"@"_^XMB("NETNAME"))=""
127 S ECMSG(1,0)="The "_ECPACK_" extract was automatically requeued to extract"
128 S ECMSG(2,0)="data for "_ECSDN_" through "_ECEDN_"."
129 S ECMSG(3,0)="But a "_ECHEAD_" extract appears to be currently running."
130 S ECMSG(4,0)=" "
131 S ECMSG(5,0)="The requeued extract was NOT generated, but has been requeued"
132 S ECMSG(6,0)="for next month."
133 S XMTEXT="ECMSG(" D ^XMD
134 Q
Note: See TracBrowser for help on using the repository browser.