source: WorldVistAEHR/trunk/r/CAPACITY_MANAGEMENT_TOOLS-KMPD-KMPL/KMPDTU01.m@ 808

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

initial load of WorldVistAEHR

File size: 4.6 KB
Line 
1KMPDTU01 ;OAK/RAK - CM Tools Timing Utility ;4/6/06 08:40
2 ;;2.0;CAPACITY MANAGEMENT TOOLS;**4,5**;Mar 22, 2002
3 ;
4DAILY(KMPDT) ;-- transmit daily stats to national database
5 ;-----------------------------------------------------------------------
6 ; KMPDT.... Compression date in internal fileman formt. It represents
7 ; the date from which the previous days data should be
8 ; transmitted.
9 ; Example: if KMPDT = 2981011 then tranmission will be
10 ; on 2981010 (KMPDT-1)
11 ;-----------------------------------------------------------------------
12 ;
13 Q:'$G(KMPDT)
14 ;
15 N DATE,DATA,DELTA,ERROR,FDA,HOUR,I,IEN,PIECE,PTNP,SDTM,SITE,SS
16 N STR
17 ;
18 ; storage processed
19 K ^TMP($J),^TMP("KMPDTU01",$J)
20 ; site info.
21 S SITE=$$SITE^VASITE Q:SITE=""
22 S IEN=0
23 W:'$D(ZTQUEUED) !,"Compressing data into daily format..."
24 F S IEN=$O(^KMPD(8973.2,"ADT",KMPDT,IEN)) Q:'IEN D
25 .Q:'$D(^KMPD(8973.2,IEN,0)) S DATA(0)=^(0)
26 .; quit if daily data has already been sent to national database
27 .;Q:$P(DATA(0),U,10)
28 .W:'$D(ZTQUEUED)&('(IEN#1000)) "."
29 .; start date/time date w/no time delta
30 .S SDTM=$P(DATA(0),U,3),DATE=$P(SDTM,"."),DELTA=$P(DATA(0),U,4)
31 .; hour
32 .S HOUR=+$E($P(SDTM,".",2),1,2)
33 .; quit if no kmptmp subscript
34 .S SS=$P(DATA(0),U,7) Q:SS=""
35 .;
36 .S PTNP=$$PTNP^KMPDHU03(SDTM) Q:'PTNP
37 .; piece 4 - prime time
38 .; piece 5 - non-prime time
39 .S PIECE=$S(PTNP=1:4,1:5)
40 .;
41 .S $P(^TMP($J,KMPDT,SS),U)=KMPDT
42 .S $P(^TMP($J,KMPDT,SS),U,3)=SS
43 .S $P(^TMP($J,KMPDT,SS),U,PIECE)=$P(^TMP($J,KMPDT,SS),U,PIECE)+DELTA
44 .S $P(^TMP($J,KMPDT,SS),U,(PIECE+2))=$P(^TMP($J,KMPDT,SS),U,(PIECE+2))+1
45 .; hourly delta
46 .S $P(^TMP($J,KMPDT,SS,PTNP),U,(HOUR+1))=$P($G(^TMP($J,KMPDT,SS,PTNP)),U,(HOUR+1))+DELTA
47 .; hourly occurrences
48 .S $P(^TMP($J,KMPDT,SS,PTNP+.1),U,(HOUR+1))=$P($G(^TMP($J,KMPDT,SS,PTNP+.1)),U,(HOUR+1))+1
49 .; node 99.1 is for national database (end date^facility name)
50 .S ^TMP($J,KMPDT,SS,99.1)=KMPDT_"^"_$P(SITE,U,2)_"^"_$P(SITE,U,3)_"^"_$$WORKDAY^XUWORKDY(DATE)
51 .; add to processed array.
52 .S ^TMP("KMPDTU01",$J,IEN)=""
53 ;
54 D:$D(^TMP($J)) TRANSMIT(2)
55 K ^TMP($J)
56 ;
57 ; update field .1 (DAILY - SENT TO CM NATIONAL DB) to 'YES' for all
58 ; processed entries.
59 W:'$D(ZTQUEUED) !!,"Updating records to reflect transmission..."
60 S IEN=0
61 F S IEN=$O(^TMP("KMPDTU01",$J,IEN)) Q:'IEN D
62 .K FDA,ERROR W:'$D(ZTQUEUED)&('(IEN#1000)) "."
63 .S FDA($J,8973.2,IEN_",",.1)=1
64 .D FILE^DIE("","FDA($J)","ERROR")
65 ;
66 K ^TMP("KMPDTU01",$J)
67 ;
68 W:'$D(ZTQUEUED) !!,"Finished!"
69 ;
70 Q
71 ;
72TRANSMIT(KMPDTWD) ;-- format data into e-mail and send to cm national database
73 ;-----------------------------------------------------------------------
74 ; KMPDTWD... Weekly/Daily
75 ; 1 - weekly
76 ; 2 - daily
77 ;
78 ; D = date
79 ; S = subscript
80 ;-----------------------------------------------------------------------
81 ;
82 Q:'$G(KMPDTWD)
83 Q:'$D(^TMP($J))
84 ;
85 N CPU,D,DATE,I,IEN,LN,S,TL,TRANSTO,XMSUB,X,XMTEXT,XMY,XMZ,Y,Z
86 ;
87 K ^TMP("KMPDTU01-2",$J)
88 ;
89 S DATE=$S(KMPDTWD=1:$G(START),1:$G(KMPDT))
90 S LN=0
91 ; version and patch info
92 S LN=LN+1,^TMP("KMPDTU01-2",$J,LN)="VERSION="_$$VERSION^KMPDUTL
93 ; system information
94 S LN=LN+1,^TMP("KMPDTU01-2",$J,LN)="SYSINFO="_$$SYSINFO^KMPDUTL1()
95 ; send cpu data to national database
96 D CPU^KMPDUTL5(.CPU) I $D(CPU) S I="" F S I=$O(CPU(I)) Q:I="" D
97 .S LN=LN+1,^TMP("KMPDTU01-2",$J,LN)="CPU="_I_U_CPU(I)
98 ;
99 W:'$D(ZTQUEUED) !!,"Formatting ",$$FMTE^XLFDT($G(START))," data for mail delivery..."
100 ; reformat so that data is in ^TMP("KMPR UPLOAD",$J,LN)= format.
101 S IEN=0,D=""
102 F S D=$O(^TMP($J,D)) Q:D="" S S="" W "." D
103 .W !,D
104 .F S S=$O(^TMP($J,D,S)) Q:S="" D
105 ..S IEN=IEN+1,LN=LN+1
106 ..S ^TMP("KMPDTU01-2",$J,LN)=IEN_",0)="_^TMP($J,D,S)
107 ..; if prime time
108 ..I $D(^TMP($J,D,S,1)) D
109 ...S LN=LN+1
110 ...S ^TMP("KMPDTU01-2",$J,LN)=IEN_",1)="_^TMP($J,D,S,1)
111 ...S LN=LN+1
112 ...S ^TMP("KMPDTU01-2",$J,LN)=IEN_",1.1)="_^TMP($J,D,S,1.1)
113 ..; if non-prime time
114 ..I $D(^TMP($J,D,S,2)) D
115 ...S LN=LN+1
116 ...S ^TMP("KMPDTU01-2",$J,LN)=IEN_",2)="_^TMP($J,D,S,2)
117 ...S LN=LN+1
118 ...S ^TMP("KMPDTU01-2",$J,LN)=IEN_",2.1)="_^TMP($J,D,S,2.1)
119 ..; node 99.1 for national database
120 ..S LN=LN+1,^TMP("KMPDTU01-2",$J,LN)=IEN_",99.1)="_$G(^TMP($J,D,S,99.1))
121 ;
122 ; quit if no data to transmit.
123 Q:'$D(^TMP("KMPDTU01-2",$J))
124 S TL=$$TESTLAB^KMPDUT1
125 ; send packman message.
126 S XMTEXT="^TMP(""KMPDTU01-2"","_$J_","
127 S XMSUB=$S(KMPDTWD=1:"CM TIMING DATA~",1:"CM TIMING DATA-DAILY~")_$P(TL,U,2)_$P(SITE,U,2)_" ("_$P(SITE,U,3)_")~"_$$FMTE^XLFDT(DATE,2)
128 D TRANSTO^KMPDUTL7(1,4,.TRANSTO) Q:'$D(TRANSTO)
129 S I=""
130 F S I=$O(TRANSTO(I)) Q:I="" S XMY(I)=""
131 D ^XMD
132 W:'$D(ZTQUEUED) !,"Message #",$G(XMZ)," sent..."
133 K ^TMP("KMPDTU01-2",$J)
134 ;
135 Q
Note: See TracBrowser for help on using the repository browser.