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

ACRFAUD.m

Go to the documentation of this file.
ACRFAUD ;IHS/OIRM/DSD/AEF - PRINT ARMS AUDITS [ 09/23/2005   9:44 AM ]
 ;;2.1;ADMIN RESOURCE MGT SYSTEM;**19**;NOV 05, 2001
 ;
DESC ;----- ROUTINE DESCRIPTION
 ;;
 ;;   This option prints a listing of audits for the specified file
 ;;   during the specified date range.  The list includes the audit
 ;;   number, date/time recorded, user, file entry number, file entry
 ;;   name, field number, field name, old value, and new value.
 ;;   FileMan Auditing must be active to generate audit entries for
 ;;   this list.
 ;;
 ;;$$END
 ;
EN ;EP -- MAIN ENTRY POINT
 ;
 N ACRDATES,ACRFILE,ZTSAVE
 D ^XBKVAR
 D HOME^%ZIS
 ;
 D TXT
 ;
 D FILE(.ACRFILE)
 Q:ACRFILE']""
 ;
 D DATES(.ACRDATES)
 Q:ACRDATES']""
 ;
 S ZTSAVE("ACRDATES")=""
 S ZTSAVE("ACRFILE")=""
 D QUE^ACRFUTL("DQ^ACRFAUD",.ZTSAVE,"ARMS AUDIT REPORT")
 ;
 Q
DQ ;EP -- QUEUED JOB ENTRY POINT
 ;
 N ACRPAGE
 D HDR(ACRDATES,ACRFILE)
 D LOOP(ACRDATES,ACRFILE)
 D ^%ZISC
 Q
LOOP(ACRDATES,ACRFILE)       ;
 ;----- LOOP THROUGH THE FILE
 ;
 N ACRBEG,ACRCNT,ACRD0,ACRDATE,ACREND,ACRMSG,ACROUT,DIA,DIR,X,Y
 S DIA=+$P(ACRFILE,U)
 S ACRMSG="NO DATA FOUND"
 S ACRBEG=$P(ACRDATES,U)
 S ACREND=$P(ACRDATES,U,2)_".999999"
 S ACRDATE=ACRBEG-1_".999999"
 F  S ACRDATE=$O(^DIA(DIA,"C",ACRDATE)) Q:'ACRDATE  Q:ACRDATE>ACREND  D  Q:$G(ACROUT)
 . S ACRD0=0
 . F  S ACRD0=$O(^DIA(DIA,"C",ACRDATE,ACRD0)) Q:'ACRD0  D  Q:$G(ACROUT)
 . . D PRT(ACRD0,ACRDATES,ACRFILE,.ACROUT)
 . . S ACRMSG=""
 Q:$G(ACROUT)
 W !?5,ACRMSG
 W !
 I $E($G(IOST))="C" S DIR(0)="E" D ^DIR
 Q
PRT(ACRD0,ACRDATES,ACRFILE,ACROUT)     ;
 ;----- PRINT THE DATA
 ;
 N DIA,ACRDATA,ACRDATE,ACRENT,ACRENTN,ACRFLD,ACRFLDN,ACRNEW,ACROLD,ACRUSER,X,Y
 S ACRCNT=$G(ACRCNT)+1
 I $E($G(IOST))="C",ACRCNT>2 D
 . D HDR(ACRDATES,ACRFILE,.ACROUT)
 . S ACRCNT=1
 I $E($G(IOST))="P",ACRCNT>6 D
 . D HDR(ACRDATES,ACRFILE,.ACROUT)
 . S ACRCNT=1
 Q:$G(ACROUT)
 S DIA=+$P(ACRFILE,U)
 S ACRDATA=^DIA(DIA,ACRD0,0)
 S ACRENT=$P(ACRDATA,U)
 S ACRENTN=$$ENTNAM(DIA,ACRD0)
 S Y=$P(ACRDATA,U,2)
 X ^DD("DD")
 S ACRDATE=Y
 S ACRFLD=$P(ACRDATA,U,3)
 S ACRFLDN=$$FLDNAM(DIA,ACRD0)
 S ACRUSER=$P(ACRDATA,U,4)
 ;I ACRUSER S ACRUSER=$P(^VA(200,ACRUSER,0),U)  ;ACR*2.1*19.02 IM16848
 I ACRUSER S ACRUSER=$$NAME2^ACRFUTL1(ACRUSER)  ;ACR*2.1*19.02 IM16848
 S ACROLD=$$OLD(DIA,ACRD0)
 S ACRNEW=$$NEW(DIA,ACRD0)
 ;
 W !!
 W "AUDIT #: "
 W ACRD0
 W ?40,"DATE/TIME RECORDED: "
 W ACRDATE
 W !
 W "USER: "
 W ACRUSER
 W !
 W "FILE ENTRY #: "
 W ACRENT
 W ?40,"FILE ENTRY NAME: "
 W ACRENTN
 W !
 W "FIELD #: "
 W ACRFLD
 W ?40,"FIELD NAME: "
 W ACRFLDN
 W !
 W "OLD VALUE: "
 W ACROLD
 W !
 W "NEW VALUE: "
 W ACRNEW
 Q
HDR(ACRDATES,ACRFILE,ACROUT) ;
 ;
 N DIR,I,X,Y
 I $E($G(IOST))="C",$G(ACRPAGE) D  Q:$G(ACROUT)
 . S DIR(0)="E"
 . D ^DIR
 . I 'Y S ACROUT=1
 S ACRPAGE=$G(ACRPAGE)+1
 W @IOF
 W !,"AUDIT LISTING OF "_$P(ACRFILE,U,2)_" FILE"
 W ?IOM-20,$$NOW^ACRFUTL
 S Y=$P(ACRDATES,U)
 X ^DD("DD")
 W !,"FROM "_Y
 S Y=$P(ACRDATES,U,2)
 X ^DD("DD")
 W " TO "_Y
 W ?IOM-20,"PAGE: ",ACRPAGE
 W !
 F I=1:1:IOM W "-"
 W !
 Q
FILE(ACRFILE)      ;
 ;----- ASK WHICH FILE
 ;
 N DIC,DTOUT,DUOUT,X,Y
 S ACRFILE=""
 S DIC="^DIC("
 S DIC(0)="AEMQ"
 D ^DIC
 Q:$D(DTOUT)!($D(DUOUT))
 Q:+Y'>0
 S ACRFILE=Y
 Q
DATES(ACRDATES)    ;
 ;----- ASK DATE RANGE
 ;
DLOOP ;----- DATE LOOP
 ;
 N ACRBEG,ACREND,DIR,DIRUT,DTOUT,DUOUT,X,Y
 S ACRDATES=""
 W !
 S DIR(0)="DO^::E"
 S DIR("A")="Begin with AUDIT DATE"
 S DIR("?")="The first date in the audit date range"
 D ^DIR
 Q:$D(DTOUT)!($D(DUOUT))!($D(DIRUT))
 Q:Y=""
 S ACRBEG=Y
 S DIR("A")="End with AUDIT DATE"
 S DIR("?")="The last date in the audit date range"
 D ^DIR
 Q:$D(DTOUT)!($D(DUOUT))!($D(DIRUT))
 Q:Y=""
 S ACREND=Y
 I ACREND<ACRBEG D  G DLOOP
 . W *7,!?5,"ENDING DATE cannot be less than BEGINNING DATE"
 S ACRDATES=ACRBEG_U_ACREND
 Q
ENTNAM(DIA,D0)     ;
 ;----- EXTRINSIC FUNCTION - GET EXTERNAL FILE ENTRY NAME
 ;
 ;      INPUT:
 ;      DIA  =  FILE NUMBER
 ;      D0   =  INTERNAL NUMBER OF AUDIT ENTRY
 ;
 ;      RETURNS EXTERNAL ENTRY NAME
 ;
 N %,C,X,Y
 Q:'$D(^DIA(DIA,D0))
 S %=^DIC(DIA,0,"GL")
 S X=^DIA(DIA,D0,0)
 S X=$S($D(@(%_+X_",0)")):$P(^(0),U),1:"")
 S C=$S($D(^DD(DIA,.01,0)):$P(^(0),U,2),1:"")
 S Y=X
 D:Y]"" Y^DIQ:C]""
 S X=Y
 Q X
 ;
FLDNAM(DIA,D0)     ;
 ;----- EXTRINSIC FUNCTION - GET FIELD NAME
 ;
 ;      INPUT:
 ;      DIA  =  FILE NUMBER
 ;      D0   =  INTERNAL NUMBER OF AUDIT ENTRY
 ;
 ;      RETURNS EXTERNAL FIELD NAME
 ;
 N X,Y
 S Y(1.1,1.1)=$S($D(^DIA(DIA,D0,0)):$P(^(0),U,3),1:"")
 X ^DD(1.1,1.1,9.2)
 K Y(1.1)
 S X=$E(X,1,$L(X)-1)
 Q X
 ;
OLD(DIA,D0)        ;
 ;----- EXTRINSIC FUNCTION - GET OLD VALUE
 ;
 ;      INPUT:
 ;      DIA  =  FILE NUMBER
 ;      D0   =  INTERNAL NUMBER OF AUDIT ENTRY
 ;
 ;      RETURNS OLD VALUE OF AUDIT FIELD
 ;
 N X
 S X=$S($D(^DIA(DIA,D0,2)):^(2),1:"<no previous value>")
 Q X
 ;
NEW(DIA,D0)        ;
 ;----- EXTRINSIC FUNCTION - GET NEW VALUE
 ;
 ;      INPUT:
 ;      DIA  =  FILE NUMBER
 ;      D0   =  INTERNAL NUMBER OF AUDIT ENTRY
 ;
 ;      RETURNS NEW VALUE OF AUDIT FIELD
 ;
 N X
 S X=$S($D(^DIA(DIA,D0,3)):^(3),1:"<deleted>")
 Q X
 ;
TXT ;----- PRINT OPTION DESCRIPTION
 ;
 N I,X
 F I=1:1 S X=$P($T(DESC+I),";",3) Q:X["$$END"  W !,X
 Q
ONE ;EP -- DISPLAY AUDIT TRAIL FOR ONE ENTRY
 ;
 N ACRFILE,DA,DIC,X,Y,ZTSAVE
 ;
 D FILE(.ACRFILE)
 Q:ACRFILE']""
 S DIC=^DIC(+ACRFILE,0,"GL")
 ;
 D ENTRY(DIC,.Y)
 Q:+Y'>0
 S DA=+Y
 ;
 S ZTSAVE("DIC")=""
 S ZTSAVE("DA")=""
 S ZTSAVE("ACRFILE")=""
 D QUE^ACRFUTL("DQ1^ACRFAUD",.ZTSAVE,"ARMS AUDIT REPORT")
 Q
DQ1 ;EP -- QUEUED REPORT STARTS HERE
 ;
 N ACRPAGE
 D HDR1(ACRFILE,DA,.ACROUT)
 D DIQ(DIC,DA)
 D ^%ZISC
 Q
ENTRY(DIC,Y)       ;
 ;----- LOOK UP FILE ENTRY
 ;
 S DIC(0)="AEMQ"
 D ^DIC
 Q
DIQ(DIC,DA)        ;
 ;----- CALL EN^DIQ TO DISPLAY THE ENTRY
 ;
 S DIQ(0)="ACR"
 D EN^DIQ
 Q
HDR1(ACRFILE,DA,ACROUT)      ;
 ;----- PRINT HEADER FOR ONE ENTRY AUDIT REPORT
 ;
 N ACRENT,DIR,I,X,Y
 I $E($G(IOST))="C",$G(ACRPAGE) D  Q:$G(ACROUT)
 . S DIR(0)="E"
 . D ^DIR
 . I 'Y S ACROUT=1
 S ACRPAGE=$G(ACRPAGE)+1
 W @IOF
 W !,"AUDIT LISTING OF ",$P(ACRFILE,U,2)," FILE ENTRY "
 W ?IOM-20,$$NOW^ACRFUTL
 W !?IOM-20,"PAGE: ",ACRPAGE
 W !
 F I=1:1:IOM W "-"
 W !
 Q