source: FOIAVistA/trunk/r/IMAGING-MAG-ZMAG/MAGDAUDR.m@ 1757

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

initial load of FOIAVistA 6/30/08 version

File size: 4.3 KB
Line 
1MAGDAUDR ;WOIFO/EdM - RPC to fetch a Audit Info ; 03/17/2003 10:30
2 ;;3.0;IMAGING;**11**;14-April-2004
3 ;; +---------------------------------------------------------------+
4 ;; | Property of the US Government. |
5 ;; | No permission to copy or redistribute this software is given. |
6 ;; | Use of unreleased versions of this software requires the user |
7 ;; | to execute a written test agreement with the VistA Imaging |
8 ;; | Development Office of the Department of Veterans Affairs, |
9 ;; | telephone (301) 734-0100. |
10 ;; | |
11 ;; | The Food and Drug Administration classifies this software as |
12 ;; | a medical device. As such, it may not be changed in any way. |
13 ;; | Modifications to this software may result in an adulterated |
14 ;; | medical device under 21CFR820, the use of which is considered |
15 ;; | to be a violation of US Federal Statutes. |
16 ;; +---------------------------------------------------------------+
17 ;;
18 Q
19 ;
20GET1(OUT,LOCATION,TODAY) ; Get the numbers of text-messages per day per purpose
21 N COUNT,D2,DATE,I,MSG,N,X
22 D:'$D(DT) DT^DICRW
23 K OUT S (OUT(0),N)=0,I=100
24 S TODAY=+$G(TODAY),DATE=DT
25 D:TODAY I 'TODAY S DATE=0 F S DATE=$O(^MAGDAUDT(2006.5761,DATE)) Q:'DATE D
26 . Q:'$D(^MAGDAUDT(2006.5761,DATE,1,LOCATION))
27 . ; Retrieve one day's statistics
28 . S MSG="" F S MSG=$O(^MAGDAUDT(2006.5761,DATE,1,LOCATION,1,"B",MSG)) Q:MSG="" D
29 . . S D2=$O(^MAGDAUDT(2006.5761,DATE,1,LOCATION,1,"B",MSG,"")) Q:'D2
30 . . S X=$G(^MAGDAUDT(2006.5761,DATE,1,LOCATION,1,D2,0))
31 . . S COUNT=$P(X,"^",2) Q:'COUNT
32 . . S LAST=$P(X,"^",3)
33 . . S I=I+1,N=N+1,OUT(I)=DATE_"^"_COUNT_"^"_MSG_"^"_LAST,MSG(MSG)=""
34 . . Q
35 . Q
36 S I=0,MSG="" F S MSG=$O(MSG(MSG)) Q:MSG="" D
37 . S I=I+1,N=N+1,OUT(I)="^^"_MSG
38 . Q
39 S OUT(0)=N
40 Q
41 ;
42GET2(OUT,LOCATION,START,STOP) ; Get the numbers of messages per day per instrument
43 N COUNT,D2,DATE,I,INSTR,N,X
44 D:'$D(DT) DT^DICRW
45 K OUT S (OUT(0),N)=0,I=100
46 S START=+$G(START)-1,STOP=+$G(STOP)
47 S:START<0 START=0
48 S:'STOP STOP=9999999
49 S DATE=START F S DATE=$O(^MAGDAUDT(2006.5762,DATE)) Q:'DATE Q:DATE>STOP D
50 . Q:'$D(^MAGDAUDT(2006.5762,DATE,1,LOCATION))
51 . ; Retrieve one day's statistics
52 . S INSTR="" F S INSTR=$O(^MAGDAUDT(2006.5762,DATE,1,LOCATION,1,"B",INSTR)) Q:INSTR="" D
53 . . S D2=$O(^MAGDAUDT(2006.5762,DATE,1,LOCATION,1,"B",INSTR,"")) Q:'D2
54 . . S X=$G(^MAGDAUDT(2006.5762,DATE,1,LOCATION,1,D2,0))
55 . . S COUNT=$P(X,"^",2) S:$P(X,"^",4)>COUNT COUNT=$P(X,"^",4)
56 . . Q:'COUNT
57 . . S INSTR(INSTR)=""
58 . . S I=I+1,N=N+1,OUT(I)=DATE_"^"_$P(X,"^",2)_"^"_INSTR_"^"_$P(X,"^",3,5)
59 . . Q
60 . Q
61 S I=0,INSTR="" F S INSTR=$O(INSTR(INSTR)) Q:INSTR="" D
62 . S I=I+1,N=N+1,OUT(I)="^^"_INSTR
63 . Q
64 S OUT(0)=N
65 Q
66 ;
67RANGE(OUT) ; Get the date-ranges for the various audit files
68 N DF,DL,FM,N
69 K OUT S N=0
70 F FM=2006.5761,2006.5762 D
71 . S DF=$O(^MAGDAUDT(FM,0)) S:'DF DF=""
72 . S DL=$O(^MAGDAUDT(FM," "),-1) S:'DL DL=""
73 . S N=N+1,OUT(N)=FM_"^"_DF_"^"_DL
74 . Q
75 S N=N+1,OUT(N)="-END-"
76 Q
77 ;
78PURGE(OUT,FM,DATE) ; Purge Audit FIle
79 N D0,DATE,DAYS,X
80 L +^MAGDAUDT(FM)
81 S DAYS=$P($G(^MAGDAUDT(FM,0)),"^",4),OUT=0
82 S X=0 F S X=$O(^MAGDAUDT(FM,X)) Q:'X Q:X'<DATE D
83 . K ^MAGDAUDT(FM,X)
84 . S DAYS=DAYS-1,OUT=OUT+1
85 . Q
86 S:DAYS<1 DAYS=0
87 S $P(^MAGDAUDT(FM,0),"^",4)=DAYS
88 L -^MAGDAUDT(FM)
89 S OUT=OUT_" day"_$S(OUT=1:"",1:"s")_" purged."
90 Q
91 ;
92COUNT(OUT,LOCATION,MESSAGE) ; update today's count
93 N %,D2,%H,%I,TODAY,NOW,X
94 I '$G(LOCATION) S OUT="-1,No Location Specified" Q
95 I $G(MESSAGE)="" S OUT="-2,No Message Specified" Q
96 ;
97 D NOW^%DTC S TODAY=X,NOW=%
98 S D2=$O(^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,"B",MESSAGE,""))
99 D:'D2
100 . L +^MAGDAUDT(2006.5761,TODAY)
101 . S D2=$O(^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1," "),-1)+1
102 . S X=$G(^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,0))
103 . S $P(X,"^",2)="2006.576111"
104 . S $P(X,"^",3)=D2
105 . S $P(X,"^",4)=$P(X,"^",4)+1
106 . S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,0)=LOCATION
107 . S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,0)=X
108 . S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,D2,0)=MESSAGE
109 . S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,"B",MESSAGE,D2)=""
110 . L -^MAGDAUDT(2006.5761,TODAY)
111 . Q
112 S X=$G(^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,D2,0))
113 S X=MESSAGE_"^"_($P(X,"^",2)+1)_"^"_NOW
114 S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,D2,0)=X
115 S OUT=$P(X,"^",2)
116 Q
Note: See TracBrowser for help on using the repository browser.