Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: MAGDAUDR

MAGDAUDR.m

Go to the documentation of this file.
  1. MAGDAUDR ;WOIFO/EdM - RPC to fetch a Audit Info ; 03/17/2003 10:30
  1. ;;3.0;IMAGING;**11**;14-April-2004
  1. ;; +---------------------------------------------------------------+
  1. ;; | Property of the US Government. |
  1. ;; | No permission to copy or redistribute this software is given. |
  1. ;; | Use of unreleased versions of this software requires the user |
  1. ;; | to execute a written test agreement with the VistA Imaging |
  1. ;; | Development Office of the Department of Veterans Affairs, |
  1. ;; | telephone (301) 734-0100. |
  1. ;; | |
  1. ;; | The Food and Drug Administration classifies this software as |
  1. ;; | a medical device. As such, it may not be changed in any way. |
  1. ;; | Modifications to this software may result in an adulterated |
  1. ;; | medical device under 21CFR820, the use of which is considered |
  1. ;; | to be a violation of US Federal Statutes. |
  1. ;; +---------------------------------------------------------------+
  1. ;;
  1. Q
  1. ;
  1. GET1(OUT,LOCATION,TODAY) ; Get the numbers of text-messages per day per purpose
  1. N COUNT,D2,DATE,I,MSG,N,X
  1. D:'$D(DT) DT^DICRW
  1. K OUT S (OUT(0),N)=0,I=100
  1. S TODAY=+$G(TODAY),DATE=DT
  1. D:TODAY I 'TODAY S DATE=0 F S DATE=$O(^MAGDAUDT(2006.5761,DATE)) Q:'DATE D
  1. . Q:'$D(^MAGDAUDT(2006.5761,DATE,1,LOCATION))
  1. . ; Retrieve one day's statistics
  1. . S MSG="" F S MSG=$O(^MAGDAUDT(2006.5761,DATE,1,LOCATION,1,"B",MSG)) Q:MSG="" D
  1. . . S D2=$O(^MAGDAUDT(2006.5761,DATE,1,LOCATION,1,"B",MSG,"")) Q:'D2
  1. . . S X=$G(^MAGDAUDT(2006.5761,DATE,1,LOCATION,1,D2,0))
  1. . . S COUNT=$P(X,"^",2) Q:'COUNT
  1. . . S LAST=$P(X,"^",3)
  1. . . S I=I+1,N=N+1,OUT(I)=DATE_"^"_COUNT_"^"_MSG_"^"_LAST,MSG(MSG)=""
  1. . . Q
  1. . Q
  1. S I=0,MSG="" F S MSG=$O(MSG(MSG)) Q:MSG="" D
  1. . S I=I+1,N=N+1,OUT(I)="^^"_MSG
  1. . Q
  1. S OUT(0)=N
  1. Q
  1. ;
  1. GET2(OUT,LOCATION,START,STOP) ; Get the numbers of messages per day per instrument
  1. N COUNT,D2,DATE,I,INSTR,N,X
  1. D:'$D(DT) DT^DICRW
  1. K OUT S (OUT(0),N)=0,I=100
  1. S START=+$G(START)-1,STOP=+$G(STOP)
  1. S:START<0 START=0
  1. S:'STOP STOP=9999999
  1. S DATE=START F S DATE=$O(^MAGDAUDT(2006.5762,DATE)) Q:'DATE Q:DATE>STOP D
  1. . Q:'$D(^MAGDAUDT(2006.5762,DATE,1,LOCATION))
  1. . ; Retrieve one day's statistics
  1. . S INSTR="" F S INSTR=$O(^MAGDAUDT(2006.5762,DATE,1,LOCATION,1,"B",INSTR)) Q:INSTR="" D
  1. . . S D2=$O(^MAGDAUDT(2006.5762,DATE,1,LOCATION,1,"B",INSTR,"")) Q:'D2
  1. . . S X=$G(^MAGDAUDT(2006.5762,DATE,1,LOCATION,1,D2,0))
  1. . . S COUNT=$P(X,"^",2) S:$P(X,"^",4)>COUNT COUNT=$P(X,"^",4)
  1. . . Q:'COUNT
  1. . . S INSTR(INSTR)=""
  1. . . S I=I+1,N=N+1,OUT(I)=DATE_"^"_$P(X,"^",2)_"^"_INSTR_"^"_$P(X,"^",3,5)
  1. . . Q
  1. . Q
  1. S I=0,INSTR="" F S INSTR=$O(INSTR(INSTR)) Q:INSTR="" D
  1. . S I=I+1,N=N+1,OUT(I)="^^"_INSTR
  1. . Q
  1. S OUT(0)=N
  1. Q
  1. ;
  1. RANGE(OUT) ; Get the date-ranges for the various audit files
  1. N DF,DL,FM,N
  1. K OUT S N=0
  1. F FM=2006.5761,2006.5762 D
  1. . S DF=$O(^MAGDAUDT(FM,0)) S:'DF DF=""
  1. . S DL=$O(^MAGDAUDT(FM," "),-1) S:'DL DL=""
  1. . S N=N+1,OUT(N)=FM_"^"_DF_"^"_DL
  1. . Q
  1. S N=N+1,OUT(N)="-END-"
  1. Q
  1. ;
  1. PURGE(OUT,FM,DATE) ; Purge Audit FIle
  1. N D0,DATE,DAYS,X
  1. L +^MAGDAUDT(FM)
  1. S DAYS=$P($G(^MAGDAUDT(FM,0)),"^",4),OUT=0
  1. S X=0 F S X=$O(^MAGDAUDT(FM,X)) Q:'X Q:X'<DATE D
  1. . K ^MAGDAUDT(FM,X)
  1. . S DAYS=DAYS-1,OUT=OUT+1
  1. . Q
  1. S:DAYS<1 DAYS=0
  1. S $P(^MAGDAUDT(FM,0),"^",4)=DAYS
  1. L -^MAGDAUDT(FM)
  1. S OUT=OUT_" day"_$S(OUT=1:"",1:"s")_" purged."
  1. Q
  1. ;
  1. COUNT(OUT,LOCATION,MESSAGE) ; update today's count
  1. N %,D2,%H,%I,TODAY,NOW,X
  1. I '$G(LOCATION) S OUT="-1,No Location Specified" Q
  1. I $G(MESSAGE)="" S OUT="-2,No Message Specified" Q
  1. ;
  1. D NOW^%DTC S TODAY=X,NOW=%
  1. S D2=$O(^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,"B",MESSAGE,""))
  1. D:'D2
  1. . L +^MAGDAUDT(2006.5761,TODAY)
  1. . S D2=$O(^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1," "),-1)+1
  1. . S X=$G(^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,0))
  1. . S $P(X,"^",2)="2006.576111"
  1. . S $P(X,"^",3)=D2
  1. . S $P(X,"^",4)=$P(X,"^",4)+1
  1. . S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,0)=LOCATION
  1. . S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,0)=X
  1. . S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,D2,0)=MESSAGE
  1. . S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,"B",MESSAGE,D2)=""
  1. . L -^MAGDAUDT(2006.5761,TODAY)
  1. . Q
  1. S X=$G(^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,D2,0))
  1. S X=MESSAGE_"^"_($P(X,"^",2)+1)_"^"_NOW
  1. S ^MAGDAUDT(2006.5761,TODAY,1,LOCATION,1,D2,0)=X
  1. S OUT=$P(X,"^",2)
  1. Q