BXPARPTU ;IHS/OIT/FBD - PARAMETER AUDIT USER REPORTS ;
;;1.0;IHS EXTENSIONS TO KERNEL TOOLKIT;;Dec 19, 2013;Build 12
;
;PARAMETER VALUE REPORT FOR A SPECIFIED USER/PROVIDER
;ON A SPECIFIED DATE (DEFAULT TODAY)
;
;
;SELECT USER
N DIC,DA,GLOBROOT,MSG
S (DIC,GLOBROOT)="^VA(200,"
S DIC(0)="AEMQ"
D ^DIC K DIC
Q:+Y'>0
S BXPAUSER=+Y ;NEW USER FILE #200 RECORD POINTER
S BXPAUNM=$P(^VA(200,BXPAUSER,0),U,1) ;USER NAME
;
;SELECT EFFECTIVE DATE OF REPORT (DEFAULT TODAY)
K DIR
S DIR(0)="D^3130801:"_DT_".2359:AETX"
S DIR("A")="Enter effective date/time of report: "
S DIR("B")="NOW"
D ^DIR Q:'+Y ;EXIT IF NO DATE SPECIFIED
S BXPAEFDT=+Y
;
;SELECT DEVICE
K %ZIS S %ZIS="Q"
D ^%ZIS Q:POP
I $D(IO("Q")) D Q
.S ZTRTN="TSK^BXPARPTU"
.S ZTDESC="Parameter Audit Report for "_BXPAUNM
.F %="BXPAEFDT","BXPAUSER","BXPAUNM" S ZTSAVE(%)=""
.D ^%ZTLOAD
.D HOME^%ZIS K IO("Q")
;
TSK ;QUEUED TASK ENTRY POINT FOR REPORT
S U="^"
D COMPILE
D OUTPUT
D CLEANUP
Q
;
;
COMPILE ;COMPILE REPORT DATA
N PTR,DATE,INST,VALUE
K BXPADATA
S BXPAENT=BXPAUSER_";VA(200," ;ENTITY SPECIFIER FOR THIS USER
Q:'$D(^BXPA(9002026.01,"AENT",BXPAENT)) ;EXIT IF NO AUDIT RECORDS ON FILE FOR THIS USER
;
;STEP 1: BUILD WORK ARRAY
S PTR=""
F S PTR=$O(^BXPA(9002026.01,"AENT",BXPAENT,PTR)) Q:PTR="" D ;SCAN ALL AUDIT RECORDS FOR THIS ENTRY
.S DATE=$P(^BXPA(9002026.01,PTR,0),U,1) ;AUDIT RECORD DATE/TIME
.S INST=$P(^BXPA(9002026.01,PTR,0),U,7) ;PARAMETER NAME
.S VALUE=$P(^BXPA(9002026.01,PTR,0),U,9) ;PARAMETER VALUE
.S BXPADATA(BXPAUSER,INST,DATE)=VALUE
;
;STEP 2: SCAN FOR PARAMETER'S VALUE ON EFFECTIVE DATE
S INST=""
F S INST=$O(BXPADATA(BXPAUSER,INST)) Q:INST="" D ;SCAN WORK ARRAY FOR EACH PARAMETER INSTANCE
.S BXPADATA(BXPAUSER,INST)="Not defined in audit log by this date"
.S DATE=""
.F S DATE=$O(BXPADATA(BXPAUSER,INST,DATE)) Q:(DATE="")!(DATE>BXPAEFDT) D ;SCAN ALL DATED RECORDS FOR VALUE CHANGES
..S BXPADATA(BXPAUSER,INST)=BXPADATA(BXPAUSER,INST,DATE)
Q
;
;
OUTPUT ;PRINT OUT REPORT
N LINE,PAGE,PDATE,EFFDATE,INST,DASH,VALUE
S PDATE=$E(DT,4,5)_"/"_$E(DT,6,7)_"/"_(1700+$E(DT,1,3)) ;TODAY'S DATE IN A PRINTABLE FORMAT
S EFFDATE=$E(BXPAEFDT,4,5)_"/"_$E(BXPAEFDT,6,7)_"/"_(1700+$E(BXPAEFDT,1,3)) ;EFFECTIVE DATE IN A PRINTABLE FORMAT
S DASH="",$P(DASH,"-",IOM)="" ;DASHED LINE FOR OUTPUT SEPARATOR
S PAGE=0 ;INITIALIZE REPORT PAGE COUNTER
S IOSL=$S(IOST["C-":IOSL-2,1:IOSL) ;FOR TERMINAL OUTPUT, LEAVE ROOM FOR A 'PAUSE' MESSAGE AT BOTTOM OF SCREEN
S LINE=IOSL ;REPORT LINE COUNTER
;
S INST=""
F S INST=$O(BXPADATA(BXPAUSER,INST)) Q:INST="" D ;
.S VALUE=BXPADATA(BXPAUSER,INST)
.D LINEOUT
Q
;
;
LINEOUT ;OUTPUT A SINGLE LINE OF THE REPORT
S LINE=LINE+1
I LINE>IOSL D ;
.I (IOST["C-"),+PAGE D ;EXECUTE PAUSE MESSAGE WHEN BOTTOM OF SCREEN IS REACHED
..K DIR
..S DIR(0)="E" ;END-OF-PAGE
..D ^DIR
.D HEADER
W $E(INST,1,38),?41,VALUE,!
Q
;
;
I +PAGE!(IOST["C-") W @IOF ;SKIP FORM FEED ON FIRST PAGE, IF OUTPUT DEVICE NOT A CRT
S PAGE=PAGE+1
W "PARAMETER SETTINGS FOR",?24,BXPAUNM,?69,PDATE,!
W ?6,"IN EFFECT ON DATE",?24,EFFDATE,?71,"PAGE ",PAGE,!
W !,?5,"PARAMETER",?41,"VALUE",!
W DASH,!
S LINE=6
Q
;
;
CLEANUP ;CLEAN PARTITION BEFORE EXITING PROCESS
K BXPAEFDT,BXPAUSER,BXPAUNM,BXPAENT,BXPADATA
D ^%ZISC
Q
BXPARPTU ;IHS/OIT/FBD - PARAMETER AUDIT USER REPORTS ;
+1 ;;1.0;IHS EXTENSIONS TO KERNEL TOOLKIT;;Dec 19, 2013;Build 12
+2 ;
+3 ;PARAMETER VALUE REPORT FOR A SPECIFIED USER/PROVIDER
+4 ;ON A SPECIFIED DATE (DEFAULT TODAY)
+5 ;
+6 ;
+7 ;SELECT USER
+8 NEW DIC,DA,GLOBROOT,MSG
+9 SET (DIC,GLOBROOT)="^VA(200,"
+10 SET DIC(0)="AEMQ"
+11 DO ^DIC
KILL DIC
+12 IF +Y'>0
QUIT
+13 ;NEW USER FILE #200 RECORD POINTER
SET BXPAUSER=+Y
+14 ;USER NAME
SET BXPAUNM=$PIECE(^VA(200,BXPAUSER,0),U,1)
+15 ;
+16 ;SELECT EFFECTIVE DATE OF REPORT (DEFAULT TODAY)
+17 KILL DIR
+18 SET DIR(0)="D^3130801:"_DT_".2359:AETX"
+19 SET DIR("A")="Enter effective date/time of report: "
+20 SET DIR("B")="NOW"
+21 ;EXIT IF NO DATE SPECIFIED
DO ^DIR
IF '+Y
QUIT
+22 SET BXPAEFDT=+Y
+23 ;
+24 ;SELECT DEVICE
+25 KILL %ZIS
SET %ZIS="Q"
+26 DO ^%ZIS
IF POP
QUIT
+27 IF $DATA(IO("Q"))
Begin DoDot:1
+28 SET ZTRTN="TSK^BXPARPTU"
+29 SET ZTDESC="Parameter Audit Report for "_BXPAUNM
+30 FOR %="BXPAEFDT","BXPAUSER","BXPAUNM"
SET ZTSAVE(%)=""
+31 DO ^%ZTLOAD
+32 DO HOME^%ZIS
KILL IO("Q")
End DoDot:1
QUIT
+33 ;
TSK ;QUEUED TASK ENTRY POINT FOR REPORT
+1 SET U="^"
+2 DO COMPILE
+3 DO OUTPUT
+4 DO CLEANUP
+5 QUIT
+6 ;
+7 ;
COMPILE ;COMPILE REPORT DATA
+1 NEW PTR,DATE,INST,VALUE
+2 KILL BXPADATA
+3 ;ENTITY SPECIFIER FOR THIS USER
SET BXPAENT=BXPAUSER_";VA(200,"
+4 ;EXIT IF NO AUDIT RECORDS ON FILE FOR THIS USER
IF '$DATA(^BXPA(9002026.01,"AENT",BXPAENT))
QUIT
+5 ;
+6 ;STEP 1: BUILD WORK ARRAY
+7 SET PTR=""
+8 ;SCAN ALL AUDIT RECORDS FOR THIS ENTRY
FOR
SET PTR=$ORDER(^BXPA(9002026.01,"AENT",BXPAENT,PTR))
IF PTR=""
QUIT
Begin DoDot:1
+9 ;AUDIT RECORD DATE/TIME
SET DATE=$PIECE(^BXPA(9002026.01,PTR,0),U,1)
+10 ;PARAMETER NAME
SET INST=$PIECE(^BXPA(9002026.01,PTR,0),U,7)
+11 ;PARAMETER VALUE
SET VALUE=$PIECE(^BXPA(9002026.01,PTR,0),U,9)
+12 SET BXPADATA(BXPAUSER,INST,DATE)=VALUE
End DoDot:1
+13 ;
+14 ;STEP 2: SCAN FOR PARAMETER'S VALUE ON EFFECTIVE DATE
+15 SET INST=""
+16 ;SCAN WORK ARRAY FOR EACH PARAMETER INSTANCE
FOR
SET INST=$ORDER(BXPADATA(BXPAUSER,INST))
IF INST=""
QUIT
Begin DoDot:1
+17 SET BXPADATA(BXPAUSER,INST)="Not defined in audit log by this date"
+18 SET DATE=""
+19 ;SCAN ALL DATED RECORDS FOR VALUE CHANGES
FOR
SET DATE=$ORDER(BXPADATA(BXPAUSER,INST,DATE))
IF (DATE="")!(DATE>BXPAEFDT)
QUIT
Begin DoDot:2
+20 SET BXPADATA(BXPAUSER,INST)=BXPADATA(BXPAUSER,INST,DATE)
End DoDot:2
End DoDot:1
+21 QUIT
+22 ;
+23 ;
OUTPUT ;PRINT OUT REPORT
+1 NEW LINE,PAGE,PDATE,EFFDATE,INST,DASH,VALUE
+2 ;TODAY'S DATE IN A PRINTABLE FORMAT
SET PDATE=$EXTRACT(DT,4,5)_"/"_$EXTRACT(DT,6,7)_"/"_(1700+$EXTRACT(DT,1,3))
+3 ;EFFECTIVE DATE IN A PRINTABLE FORMAT
SET EFFDATE=$EXTRACT(BXPAEFDT,4,5)_"/"_$EXTRACT(BXPAEFDT,6,7)_"/"_(1700+$EXTRACT(BXPAEFDT,1,3))
+4 ;DASHED LINE FOR OUTPUT SEPARATOR
SET DASH=""
SET $PIECE(DASH,"-",IOM)=""
+5 ;INITIALIZE REPORT PAGE COUNTER
SET PAGE=0
+6 ;FOR TERMINAL OUTPUT, LEAVE ROOM FOR A 'PAUSE' MESSAGE AT BOTTOM OF SCREEN
SET IOSL=$SELECT(IOST["C-":IOSL-2,1:IOSL)
+7 ;REPORT LINE COUNTER
SET LINE=IOSL
+8 ;
+9 SET INST=""
+10 ;
FOR
SET INST=$ORDER(BXPADATA(BXPAUSER,INST))
IF INST=""
QUIT
Begin DoDot:1
+11 SET VALUE=BXPADATA(BXPAUSER,INST)
+12 DO LINEOUT
End DoDot:1
+13 QUIT
+14 ;
+15 ;
LINEOUT ;OUTPUT A SINGLE LINE OF THE REPORT
+1 SET LINE=LINE+1
+2 ;
IF LINE>IOSL
Begin DoDot:1
+3 ;EXECUTE PAUSE MESSAGE WHEN BOTTOM OF SCREEN IS REACHED
IF (IOST["C-")
IF +PAGE
Begin DoDot:2
+4 KILL DIR
+5 ;END-OF-PAGE
SET DIR(0)="E"
+6 DO ^DIR
End DoDot:2
+7 DO HEADER
End DoDot:1
+8 WRITE $EXTRACT(INST,1,38),?41,VALUE,!
+9 QUIT
+10 ;
+11 ;
+1 ;SKIP FORM FEED ON FIRST PAGE, IF OUTPUT DEVICE NOT A CRT
IF +PAGE!(IOST["C-")
WRITE @IOF
+2 SET PAGE=PAGE+1
+3 WRITE "PARAMETER SETTINGS FOR",?24,BXPAUNM,?69,PDATE,!
+4 WRITE ?6,"IN EFFECT ON DATE",?24,EFFDATE,?71,"PAGE ",PAGE,!
+5 WRITE !,?5,"PARAMETER",?41,"VALUE",!
+6 WRITE DASH,!
+7 SET LINE=6
+8 QUIT
+9 ;
+10 ;
CLEANUP ;CLEAN PARTITION BEFORE EXITING PROCESS
+1 KILL BXPAEFDT,BXPAUSER,BXPAUNM,BXPAENT,BXPADATA
+2 DO ^%ZISC
+3 QUIT