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

BXPARPTU.m

Go to the documentation of this file.
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