source: FOIAVistA/trunk/r/CAPACITY_MANAGEMENT_TOOLS-KMPD-KMPL/KMPDUTL2.m@ 1635

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

initial load of FOIAVistA 6/30/08 version

File size: 4.4 KB
Line 
1KMPDUTL2 ;OAK/RAK - CM Tools Utility ;6/21/05 10:18
2 ;;2.0;CAPACITY MANAGEMENT TOOLS;**4**;Mar 22, 2002
3 ;
4DATERNG(KMPUY,KMPUSTR,KMPUEND) ;-- date range
5 ;---------------------------------------------------------------------
6 ; KMPUY..... Value returned in four pieces:
7 ; fmstartdate^fmenddate^ouputstartdate^outputenddate
8 ;
9 ; Piece one and two are the date ranges in fileman format.
10 ; Piece three and four are the same dates in output format:
11 ; dy-Mon-yr
12 ;
13 ; ********
14 ; * NOTE *
15 ; ********
16 ; - The first piece will always be the earliest date entered.
17 ;
18 ; Optional Parameters:
19 ;
20 ; KMPUSTR... If defined, the earliest date that may be selected.
21 ; (must be in fileman format)
22 ;
23 ; KMPUEND... If defined, the latest date that may be selected.
24 ; (must be in fileman format)
25 ;-----------------------------------------------------------------------
26 ;
27 N DATE1,DATE2,DIR,DIRUT,LINE,X,Y
28 ;
29 S KMPUY="",KMPUSTR=$G(KMPUSTR),KMPUEND=$G(KMPUEND)
30 ;
31RANGE ;-- Ask date ranges
32 S DIR(0)="DOA^"_$S(KMPUSTR:KMPUSTR,1:"")_":"_$S(KMPUEND:KMPUEND,1:"")_":ET)"
33 S DIR("A")="Start with Date: "
34 S:KMPUSTR DIR("B")=$$FMTE^XLFDT(KMPUSTR,2)
35 S DIR("?")=" "
36 S DIR("?",1)="Enter the starting date.",LINE=2
37 ; if starting date.
38 I KMPUSTR D
39 .S DIR("?",LINE)="Date must not precede "_$$FMTE^XLFDT(KMPUSTR)
40 .S LINE=LINE+1
41 ; if ending date.
42 I KMPUEND S DIR("?",LINE)="Date must not follow "_$$FMTE^XLFDT(KMPUEND)
43 W ! D ^DIR I $D(DIRUT) S KMPUY="" Q
44 S DATE1=Y
45 S DIR("A")=" End with Date: "
46 S:KMPUEND DIR("B")=$$FMTE^XLFDT(KMPUEND,2)
47 S DIR("?",1)="Enter the ending date."
48 D ^DIR G:Y="" RANGE I Y="^" S KMPUY="" Q
49 S DATE2=Y
50 ; Set earliest date into first piece.
51 S KMPUY=$S(DATE2<DATE1:DATE2,1:DATE1)_U_$S(DATE2>DATE1:DATE2,1:DATE1)
52 S $P(KMPUY,U,3)=$$FMTE^XLFDT($P(KMPUY,U))
53 S $P(KMPUY,U,4)=$$FMTE^XLFDT($P(KMPUY,U,2))
54 Q
55 ;
56EMAIL(KMPDSUBJ,KMPDTEXT,KMPDTO) ; check and process errors.
57 ;-----------------------------------------------------------------------
58 ; KMPDSUBJ... Free text - to be included in subject
59 ; KMPDTEXT(). Array containing message text. This must be in a format
60 ; accepted by XMTEXT - TEXT(
61 ; ^TMP($J,"TEXT",
62 ; KMPDTO..... Address for email recipient:
63 ; G.KMP2-RUM@FO-ALBANY.MED.VA.GOV
64 ; G.KMP4-CMTOOLS@FO-ALBANY.MED.VA.GOV
65 ; G.CAPACITY,MANAGEMENT@FO-ALBANY.MED.GOV
66 ; If no value is passed the default will be
67 ; G.KMP4-CMTOOLS@FO-ALBANY.MED.VA.GOV
68 ;
69 ;-----------------------------------------------------------------------
70 ;
71 Q:$G(KMPDTEXT)=""
72 S KMPDSUBJ=$S($G(KMPDSUBJ)="":"CM Error",1:KMPDSUBJ)
73 S KMPDTO=$S($G(KMPDTO)="":"G.KMP4-CMTOOLS@FO-ALBANY.MED.VA.GOV",1:KMPDTO)
74 ;
75 N H,I,LN,N,O,SITE,TEXT,TL,XMSUB,X,XMTEXT,XMY,XMZ,Y,Z
76 ;
77 S TL=$$TESTLAB^KMPDUT1
78 S SITE=$$SITE^VASITE
79 S XMSUB=KMPDSUBJ_" at site "_$P(TL,U,2)_$P(SITE,U,3)_" on "_$$FMTE^XLFDT($$DT^XLFDT)
80 S XMTEXT=KMPDTEXT
81 S XMY(KMPDTO)=""
82 D ^XMD
83 W:'$D(ZTQUEUED) !,"Message #"_$G(XMZ)_" sent..."
84 ;
85 Q
86 ;
87STRSTP(KMPDAPP,KMPDDW,KMPDBP,KMPDSTM) ;-- record start/stop times
88 ;-----------------------------------------------------------------------
89 ; KMPDAPP.... CP application:
90 ; 1 - sagg
91 ; 2 - rum
92 ; 3 - hl7
93 ; 4 - timing
94 ; KMPDDW..... Daily or Weekly
95 ; 1 - daily
96 ; 2 - weekly
97 ; KMPDBP.... Background or Purge
98 ; 1 - background
99 ; 2 - purge
100 ; KMPDSTM.... Start Time in internal fileman format
101 ;
102 ; This api will calculate END time and DELTA time (END-KMPDSTM) and
103 ; store the results in:
104 ; ^XTMP("KMPD","BACKGROUND",KMPDAPP,KMPDDW,KMPDBP,...)
105 ;-----------------------------------------------------------------------
106 Q:'$G(KMPDAPP)
107 Q:KMPDAPP<1!(KMPDAPP>4)
108 Q:'$G(KMPDDW)
109 Q:KMPDDW<1!(KMPDDW>2)
110 Q:'$G(KMPDBP)
111 Q:KMPDBP<1!(KMPDBP>2)
112 Q:'$G(KMPDSTM)
113 ;
114 N END,ERROR,FDA,FIELD S END=$$NOW^XLFDT
115 ;
116 ; starting field for daily or background
117 S FIELD=KMPDAPP+($S(KMPDDW=1:5,1:8)*.01)
118 ; if purge
119 S:KMPDBP=2 FIELD=FIELD+.07
120 ;
121 ; store start time, end time, and delta
122 S FDA($J,8973,"1,",FIELD)=KMPDSTM
123 S FDA($J,8973,"1,",FIELD+.01)=END
124 S FDA($J,8973,"1,",FIELD+.02)=$$FMDIFF^XLFDT(END,KMPDSTM,3)
125 ;
126 D FILE^DIE("","FDA($J)","ERROR")
127 ;
128 Q
Note: See TracBrowser for help on using the repository browser.