source: FOIAVistA/trunk/r/CAPACITY_MANAGEMENT_RUM-KMPR/KMPRBD04.m@ 1123

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

initial load of FOIAVistA 6/30/08 version

File size: 5.6 KB
Line 
1KMPRBD04 ;OAK/RAK - RUM Data Compression ;5/28/03 08:45
2 ;;2.0;CAPACITY MANAGEMENT - RUM;;May 28, 2003
3 ;
4 ; Background Driver (cont.)
5 ;
6WEEKLY(KMPRDT) ;-- compress daily stats to weekly
7 ;-----------------------------------------------------------------------
8 ; KMPRDT... Compression date in internal fileman formt. This date
9 ; must be a Sunday. It represents the date from which the
10 ; previous weeks data should be compressed.
11 ; Example: if KMPRDT = 2981011 then compression will begin
12 ; on 2981010 (KMPRDT-1)
13 ;
14 ; Every Sunday compress the daily stats in file #8971.1 into weekly
15 ; and upload the data to the CM RUM National Database
16 ;
17 ; ^TMP($J)............. temporary storage for RUM data
18 ; ^TMP("KMPR PROC",$J). entries that have been processed and will be
19 ; updated as 'send to national dabase'
20 ;-----------------------------------------------------------------------
21 ;
22 Q:'$G(KMPRDT)
23 ;
24 N DATA,DATE,DELDATE,END,HOURS,I,IEN,J,NODE,OPTION,SITE,START
25 ;
26 ; quit if not sunday
27 Q:$$DOW^XLFDT(KMPRDT,1)
28 ;
29 K ^TMP($J),^TMP("KMPR PROC",$J)
30 ;
31 ; site info
32 S SITE=$$SITE^VASITE Q:SITE=""
33 ;
34 S DATE=KMPRDT
35 S (START,END)=""
36 ;
37 ; date to begin deletion
38 S DELDATE=$$FMADD^XLFDT(KMPRDT,-14)
39 ;
40 W:'$D(ZTQUEUED) !,"Compressing data into weekly format..."
41 ; reverse $order to get previous dates
42 F S DATE=$O(^KMPR(8971.1,"B",DATE),-1) Q:'DATE D
43 .; if DATE is saturday set START and END dates and kill ^TMP($J)
44 .I $$DOW^XLFDT(DATE,1)=6 D
45 ..S END=DATE,START=$$FMADD^XLFDT(DATE,-6)
46 ..K ^TMP($J)
47 .Q:'START
48 .S IEN=0
49 .F S IEN=$O(^KMPR(8971.1,"B",DATE,IEN)) Q:'IEN D
50 ..;
51 ..Q:'$D(^KMPR(8971.1,IEN,0))
52 ..;
53 ..; data nodes into DATA() array
54 ..S DATA(0)=^KMPR(8971.1,IEN,0),DATA(1)=$G(^(1)),DATA(1.1)=$G(^(1.1)),DATA(1.2)=$G(^(1.2)),DATA(2)=$G(^(2)),DATA(2.1)=$G(^(2.1)),DATA(2.2)=$G(^(2.2)),DATA(3)=$G(^(3))
55 ..;
56 ..; quit if data has already been sent to national database
57 ..Q:$P(DATA(0),U,2)
58 ..;
59 ..; cpu node
60 ..S NODE=$P(DATA(0),U,3) Q:NODE=""
61 ..;
62 ..; option
63 ..S OPTION=$P(DATA(0),U,4)
64 ..; rpc
65 ..S:OPTION="" OPTION=$P(DATA(0),U,7)
66 ..; hl7
67 ..S:OPTION="" OPTION=$P(DATA(0),U,9)
68 ..;
69 ..Q:OPTION=""
70 ..;
71 ..; OPTION = OptionName^ProtocolName
72 ..S $P(OPTION,U,2)=$P(DATA(0),U,5)
73 ..;
74 ..S ^TMP($J,START,NODE,OPTION,0)=DATA(0)
75 ..; change first piece to starting date (START)
76 ..S $P(^TMP($J,START,NODE,OPTION,0),U)=START
77 ..; second piece not applicable to national database
78 ..S $P(^TMP($J,START,NODE,OPTION,0),U,2)=""
79 ..; EndingDate^SiteName^SiteNumber
80 ..S ^TMP($J,START,NODE,OPTION,99)=END_U_$P(SITE,U,2)_U_$P(SITE,U,3)
81 ..;
82 ..; add data to get weekly totals
83 ..F I=1,1.1,1.2,2,2.1,2.2,3 I DATA(I)]"" D
84 ...; if subscript 1 or 2 or 3 ('I#1) add pieces 1 - 8
85 ...; else add pieces 1 - 24
86 ...F J=1:1:$S('(I#1):8,1:24) D
87 ....S $P(^TMP($J,START,NODE,OPTION,I),U,J)=$P($G(^TMP($J,START,NODE,OPTION,I)),U,J)+$P(DATA(I),U,J)
88 ....; update "HOURS" subscript
89 ....S:(I#1)&($P(DATA(I),U,J)) $P(^KMPTMP("KMPR","HOURS",DATE,NODE),U,J)=1
90 ..;
91 ..; back to IEN level
92 ..; add to processed array
93 ..S ^TMP("KMPR PROC",$J,IEN)=""
94 .;
95 .; back to DATE level
96 .; if START then transmit data
97 .I DATE=START I $D(^TMP($J)) D TRANSMIT K ^TMP($J)
98 ;
99 ; transmit data to national database
100 W:'$D(ZTQUEUED) !,"Transmitting data to national database..."
101 D:$D(^TMP($J)) TRANSMIT
102 K ^TMP($J)
103 ;
104 ; update field .02 (SENT TO CM NATIONAL DATABASE) to 'YES' for all
105 ; processed entries
106 W:'$D(ZTQUEUED) !,"Updating records to reflect transmission..."
107 S IEN=0
108 F S IEN=$O(^TMP("KMPR PROC",$J,IEN)) Q:'IEN D
109 .K FDA,ERROR
110 .S FDA($J,8971.1,IEN_",",.02)=1
111 .D FILE^DIE("","FDA($J)","ERROR")
112 K ^TMP("KMPR PROC",$J)
113 ;
114 ; leave two complete weeks of data in file #8971.1
115 D PURGE^KMPRUTL3(DELDATE,1)
116 ;
117 Q
118 ;
119TRANSMIT ;-- format ^TMP($J) data, put into e-mail and send to cm.
120 ;
121 Q:'$D(^TMP($J))
122 ;
123 N HRSDAYS,I,IEN,LN,N,O,S,XMSUB,X,XMTEXT,XMY,XMZ,Y,Z
124 ;
125 K ^TMP("KMPRBD04-3",$J)
126 ;
127 S LN=1
128 ; version and patch info and weekly background info
129 S Z=$G(^KMPTMP("KMPR","BACKGROUND","WEEKLY","TOTAL","START"))_"^"_$G(^("STOP"))_"^"_$G(^("DELTA"))
130 S ^TMP("KMPRBD04-3",$J,LN)="VERSION="_$$VERSION^KMPRUTL_"^"_Z
131 ;
132 ; get system information
133 S LN=LN+1
134 S ^TMP("KMPRBD04-3",$J,LN)="SYSINFO="_$$SYSINFO^KMPDUTL1()
135 ;
136 ; get number of days/hours data for the specified date range
137 D HRSDAYS^KMPRUTL3(START,END,1,.HRSDAYS)
138 ;
139 ; if ^KMPTMP("KMPR","HOURS","START") exists then this is the first time
140 ; the "HOURS" subscript is being accessed. chances are this is only
141 ; partial data, so it should be ignored.
142 I $G(^KMPTMP("KMPR","HOURS","START"))&($D(HRSDAYS)) D
143 .K HRSDAYS,^KMPTMP("KMPR","HOURS","START")
144 ;
145 I $D(HRSDAYS) S S=0 D
146 .F S S=$O(HRSDAYS(S)) Q:'S S N="" D
147 ..F S N=$O(HRSDAYS(S,N)) Q:N="" D
148 ...S LN=LN+1
149 ...; StartDate^Node^EndDate^PTDays^PTHours^NPTDays^NPTHours
150 ...; ... ^WDDays^WDHours^NWDays^NWHours
151 ...S ^TMP("KMPRBD04-3",$J,LN)="HRSDAYS="_START_"^"_N_"^"_END_"^"_HRSDAYS(S,N)
152 ;
153 ; reformat so that data is in ^TMP("KMPR UPLOAD",$J,LN)= format.
154 S IEN=0,S=""
155 F S S=$O(^TMP($J,S)) Q:S="" S N="" D
156 .F S N=$O(^TMP($J,S,N)) Q:N="" S O="" D
157 ..F S O=$O(^TMP($J,S,N,O)) Q:O="" S I="",IEN=IEN+1 D
158 ...F S I=$O(^TMP($J,S,N,O,I)) Q:I="" D
159 ....S LN=LN+1
160 ....S ^TMP("KMPRBD04-3",$J,LN)=IEN_","_I_")="_^TMP($J,S,N,O,I)
161 ;
162 ; quit if no data to transmit.
163 Q:'$D(^TMP("KMPRBD04-3",$J))
164 ; send packman message.
165 S XMTEXT="^TMP(""KMPRBD04-3"","_$J_","
166 S XMSUB="RUM DATA~"_$P(SITE,U,2)_" ("_$P(SITE,U,3)_")~"_$$FMTE^XLFDT(START)_"~"_$P($$VERSION^KMPRUTL,U)
167 S XMY("S.KMP2-RUM-SERVER@FO-ALBANY.MED.VA.GOV")=""
168 S XMY("CAPACITY,MANAGEMENT@FO-ALBANY.MED.VA.GOV")=""
169 D ^XMD
170 W:'$D(ZTQUEUED) !,"Message #",$G(XMZ)," sent..."
171 K ^TMP("KMPRBD04-3",$J)
172 ;
173 Q
Note: See TracBrowser for help on using the repository browser.