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

DIAU.m

Go to the documentation of this file.
DIAU ;SFISC/XAK-AUDIT OPTIONS ;24JUNE2003
 ;;22.0;VA FileMan;**76,129**;Mar 30, 1999
 ;Per VHA Directive 10-93-142, this routine should not be modified.
0 S DIC="^DOPT(""DIAU"","
 G OPT:$D(^DOPT("DIAU",5)) S ^(0)="AUDIT OPTION^1.01" K ^("B")
 F X=1:1:5 S ^DOPT("DIAU",X,0)=$P($T(@X),";;",2)
 S DIK=DIC D IXALL^DIK
OPT ;
 S DIC(0)="AEQIZ" D ^DIC G Q:Y<0 S DI=+Y D EN G 0
EN ;
 D @DI W !!
Q K %,DIC,DIK,DI,DA,I,J,X,Y Q
 ;
1 ;;FIELDS BEING AUDITED
 D L^DICRW1 Q:'$D(DIC)  S (DUB,DIB,DFF)=+Y,BY(0)="^DD(DFF,""AUDIT"",",L(0)=1
 S DIB(1)=$O(^DD($O(^DIC(DIB(1)))),-1) S:'DIB(1) DIB(1)=DIB
 I $O(^DD(DIB,"AUDIT",""))="" F  S DIB=$O(^DD(+DIB)) Q:'DIB!(DIB>DIB(1))  I $O(^DD(DIB,"AUDIT",""))]"" S (DUB,DFF)=DIB Q
 I 'DIB!(DIB>DIB(1)) G Q2
 S FLDS="W DFF;C1;L9;""FILE"",.001;L9,.01;L20,.25;L15,1.1",DISUPNO=1
 S L=0,DHD="AUDITED FIELDS",DIS(0)="I $D(^DD(DFF,D0,""AUDIT"")),""n""'[^(""AUDIT"")"
 S DIA=1,DIC="^DD(DFF,",DIOEND="G L^DIDC" D EN1^DIP
 G Q2
 ;
2 ;;DATA DICTIONARIES BEING AUDITED
 S DIC=1,BY=.001,FLDS=".001;L14;""FILE"",.01",L=0
 S DIS(0)="I $D(^DD(D0,0,""DDA"")),^(""DDA"")[""Y"""
 S DHD="DATA DICTIONARIES BEING AUDITED" D EN1^DIP
Q2 K DIA,A,B,DIJ,DP,P,BY,FLDS,DIS,DHD,DCC,L,DNP,DFF,DIB,DIJS,DIPQ,DIMS,DIPP,DUB,DIOEND Q
 ;
3 ;;PURGE DATA AUDITS
 S DIC("S")="I $D(^DIA(+Y)),'$D(^DD(+Y,0,""AUDPURGEFORBID"")) S DIAC=""AUDIT"",DIFILE=+Y D ^DIAC I DIAC"
 S DIA="" D AU^DICRW K DIC("S") G Q2:$D(DTOUT),Q2:Y<0,Q2:'$D(DIC)
 S DDA="DATA" D ALL G Q2:$D(DIRUT)
 I Y W !!,"..." K ^DIA(DIA) H 3 W "DELETED" G Q2
 W ! S L="PURGE AUDIT RECORDS",DIOEND="D ENDKILL^DIAU",DISTOP=0
 S FLDS="",DHD="PURGE OF AUDIT DATA: "_$O(^DD(DIA,0,"NM",0))_" FILE",DISUPNO=1
 S DHIT="D KILLDIA^DIAU",DIACNT=0
 D EN1^DIP K DISTOP,DHIT,DIK,DA,DIACNT G Q2
 ;
KILLDIA ;CALLED FROM DHIT
 S X=$G(^DIA(DIA,D0,0)) K ^DIA(DIA,D0)
 S Y=$P(X,U) I Y K ^DIA(DIA,"B",Y,D0)
 S Y=$P(X,U,2) I Y K ^DIA(DIA,"C",Y,D0)
 S Y=$P(X,U,4) K ^DIA(DIA,"D",+Y,D0)
 S DIACNT=DIACNT+1 Q
 ;
ENDKILL ;CHECK DANGLERS
 S $P(^(0),U,4)=$P($G(^DIA(DIA,0)),U,4)-DIACNT
 W !!,"...",! W $$DANGLE(DIA)," POINTERS FIXED."
 W !!,DIACNT," RECORDS PURGED."
 Q
 ;
DANGLE(DIA) ;CLEAN DANGLERS
 N A,B,D0,AA,C
 S C=0
 F AA=1,2,4 S A=$E("BC D",AA),B="" D
 .F  S B=$O(^DIA(DIA,A,B)) Q:B=""  D
 ..F D0=0:0 S D0=$O(^DIA(DIA,A,B,D0)) Q:'D0  I $P($G(^DIA(DIA,D0,0)),U,AA)'=B K ^DIA(DIA,A,B,D0) S C=C+1
 Q C
 ;
4 ;;PURGE DD AUDITS
 S DIC("S")="I '$D(^DD(+Y,0,""DDAUDPURGEFORBID"")) S DIAC=""AUDIT"",DIFILE=+Y D ^DIAC I DIAC"
 S DIA="DDA",DDA="DD" D A^DICRW G Q:$D(DTOUT)!(Y<0)!'$D(DIC)
 D ALL G:$D(DIRUT) Q I Y S X=DIA D PR G Q
 W ! S L="PURGE DD AUDIT RECORDS",DIOEND="G M^DIAU",DISTOP=0,DISUPNO=1
 S FLDS="",DHD="PURGE OF DD AUDIT: "_$O(^DD(DIA,0,"NM",0))_" FILE"
 S DHIT="S DIK=DCC,DA=D0,DIACNT=DIACNT+1 D ^DIK",DIACNT=0,DIC="^DDA(DDA,"
 S DDA=DIA D EN1^DIP K DISTOP,DHIT,DIK,DA,DIACNT G Q2
 ;
5 ;;TURN DATA AUDIT ON/OFF
 N J,DUOUT,DIRUT,DA,DDA,DIAU,DIA,C,D,%,DIC,X,Y,DIR
 S (DDA,DIA)=0 D AU^DICRW I 'DIA Q
51 S DIC="^DD("_DIA_",",DIC(0)="QEANIZ",DA(1)=DIA
 S DIC("S")="I 1 S %=$P(^(0),U,2) Q:'%&($E(%)'=""C"")  I $E(%)'=""C"",$P(^DD(+%,.01,0),U,2)'[""W"""
52 S DIC("W")="W:$P(^(0),U,2) ""  (multiple)"" W ""   "",$G(^(""AUDIT""))"
 D ^DIC I Y<0 K DIA G Q
 I $P(Y(0),U,2) S DA(1)=+$P(Y(0),U,2),DIC="^DD("_DA(1)_"," G 52
 K DIC,DIR S DDA=+Y S:$D(^("AUDIT")) DIR("B")=^("AUDIT")
 S DIR(0)="0,1.1" D ^DIR I $D(DIRUT) Q:X'="@"  S Y="n"
 D TURNON^DIAUTL(DA(1),DDA,Y) I $D(DIRUT) K ^DD(DA(1),DDA,"AUDIT")
 W !! G 51
 ;
ALL S DIR(0)="Y",DIR("B")="NO"
 S DIR("A")="DO YOU WANT TO PURGE ALL "_DDA_" AUDIT RECORDS"
 S DIR("??")="^W !!?5,""Answer 'YES' to purge all the "_DDA_" audit records for this file, or"",!?5,""answer 'NO' to sort out the records to be purged."""
 D ^DIR Q:$D(DIRUT)  I Y S DIR("A")="ARE YOU SURE" D ^DIR
 K DIR Q
 ;
PR ;
 N DIA S DIA=X N X K ^DDA(DIA)
 F X=0:0 S X=$O(^DD(DIA,"SB",X)) Q:X'>0  D PR
 Q
M S DDA=$O(^DDA(DDA))
 I DDA'>0!(DDA-1>DIA) W !!,DIACNT," RECORDS PURGED." G QM
 S %=0,X=DDA D UP G P:%,M:'%
UP Q:'$D(^DD(X,0,"UP"))  S X=^("UP") I X=DIA S %=1 Q
 G UP
P K ^UTILITY($J,0) S %X="DIPP(",%Y="DPP(" D %XY^%RCR
 S DPP=DIPP,L=0,DJ=DIJS,DPQ=DIPQ,M=DIMS,C=",",DIOSL=IOSL G ^DIO
 Q
QM ;RETURN TO ^DIO4 FROM LINE TAG M
 G STOP^DIO4