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

ACHSMAUD.m

Go to the documentation of this file.
ACHSMAUD ; IHS/ITSC/PMF - TPF MENU OPTION USE AUDIT ;  
 ;;3.1;CONTRACT HEALTH MGMT SYSTEM;;JUN 11, 2001
 ;
 ;
 ;THIS IS CALLED FROM ACHS OPTIONS THAT NEED TO BE AUDITED FOR FREQUENCY
 ;OF USE
AUDIT(NAMESPAC,LEVEL) ;EP
 ;
 I $G(LEVEL)="" S LEVEL=0
 S LEVEL=LEVEL+1
 S U="^"
 S %H=$H D YX^%DTC S NOW=Y    ;NOW INCLUDES SECONDS
 S GLOBAL=U_NAMESPAC_"AUD("   ;ADD AUD FOR AUDIT TO NAMESPACE PASSED
 ;
 ;XQDIC = INITIAL OPTION KICKED OFF?????
 ;XQY0  = CURRENT OPTION?????
 D NOW^%DTC
 S NOW=%
 S @(GLOBAL_"""OPTION"","_XQY_")")=$G(@(GLOBAL_"""OPTION"","_XQY_")"))+1
 S @(GLOBAL_"""OPTION"","_XQY_","""_XQUSER_""")")=$G(@(GLOBAL_"""OPTION"","_XQY_","""_XQUSER_""")"))+1
 S @(GLOBAL_DUZ_","_NOW_","_LEVEL_","_XQY_","""_XQUSER_""")")=XQY0
 S @(GLOBAL_DUZ_","""_XQUSER_""","_LEVEL_","_XQY_","_""""_$P(XQY0,U)_""""_")")=$G(@(GLOBAL_DUZ_","""_XQUSER_""","_LEVEL_","_XQY_","_""""_$P(XQY0,U)_""""_")"))+1
 ;
 K GLOBAL,NAMESPAC,NOW,%H
 Q
 ;
 ;SUB-ROUTINE TO PRINT OUT REPORT FROM AUDIT GLOBAL
REPORT ;
 ;THREE REPORTS 1) BY DATE/TIM
 ;              2) BY USER NAME
 ;              3) BY OPTION USED A) FREQUENCY BY ALL USERS
 ;                                B) FREQUENCY USED BY EACH USER 
 S $P(LINE,"-",81)=""
 S U="^"
 ;
 ;ASK FOR NAMESPACE
ASKNMSP ;
 K DIC
 S DIC="^DIC(9.4,"
 S DIC("A")="Enter namespace: "
 S DIC(0)="MEAQZ"
 D ^DIC
 I Y=-1 Q
 S NAMESPAC=$P(Y(0),U,2)
 S NAME=$P(Y(0),U)
 W !!,"REPORTING FROM ",NAME
 ;
 ;ASK FOR DEVICE 
ASKDEV ;
 D ^%ZIS
 I POP G ASKNMSP
 ;
 ;ASK FOR WHICH REPORT
ASKREP ;
 K DIR
 S DIR(0)="N^1:4^K:X'?.N X"
 S DIR("A",1)="Select Option Use Report:"
 S DIR("A",2)="  1. By Date"
 S DIR("A",3)="  2. By User"
 S DIR("A",4)="  3. Frequency of use (All Users)"
 S DIR("A",5)="  4. Frequency of use (By User)"
 S DIR("A")="Option: "
 S DIR("B")="1"
 D ^DIR
 Q:X=""!$D(DUOUT)!$D(DTOUT)
 S CHOICE=$S(X=1:"BYDATE",X=2:"BYUSER",1:"END")
 D @CHOICE
 G ASKNMSP
 Q
 ;
 ;DEPENDING ON SORT CHOICE DO THE SORT
GENERIC ;
 ;
 S ACHSDUZ=""
 F  S ACHSDUZ=$O(^ACHSAUD(ACHSDUZ)) Q:ACHSDUZ=""!(ACHSDUZ="OPTION")  D  Q:$G(ACHSQUIT)
 .W !!
 .S DTTIME=""
 .F  S DTTIME=$O(^ACHSAUD(ACHSDUZ,DTTIME)) Q:DTTIME=""!(+DTTIME=0)  D  Q:$G(ACHSQUIT)
 ..S Y=DTTIME X ^DD("DD") S DATE=Y
 ..S LEVEL=""
 ..F  S LEVEL=$O(^ACHSAUD(ACHSDUZ,DTTIME,LEVEL)) Q:LEVEL=""  D  Q:$G(ACHSQUIT)
 ...S OPTNUM=""
 ...F  S OPTNUM=$O(^ACHSAUD(ACHSDUZ,DTTIME,LEVEL,OPTNUM)) Q:OPTNUM=""  D  Q:$G(ACHSQUIT)
 ....S NAME="",OLDNAME=""
 ....F  S NAME=$O(^ACHSAUD(ACHSDUZ,DTTIME,LEVEL,OPTNUM,NAME)) Q:NAME=""  D  Q:$G(ACHSQUIT)
 ....I SORTBY="BY USER" D RPTLINE(ACHSDUZ,DTTIME,LEVEL,OPTNUM,NAME) Q
 ....I SORTBY="BY DATE" S ^TMP($J,"ACHSMAUD",SORTBY,DTTIME,NAME,LEVEL,OPTNUM)=""
 ....I SORTBY="BY OPTION" S ^TMP($J,"ACHSMAUD",SORTBY,NAME,OPTNUM,ACHSDUZ,DTTIME)=""
 D:SORTBY'="BY USER" SORTLOOP(SORTBY)
 Q
 ;GO THROUGH SORTED GLOBAL
SORTLOOP(SORTBY) ;
 S SUB3=""
 F  S SUB3=$O(^TMP($J,"ACHSMAUD",SORTBY,SUB3)) Q:SUB3=""  D
 .S SUB4=""
 .F  S SUB4=$O(^TMP($J,"ACHSMAUD",SORTBY,SUB3,SUB4)) Q:SUB4=""  D
 ..S SUB5=""
 ..F  S SUB5=$O(^TMP($J,"ACHSMAUD",SORTBY,SUB3,SUB4,SUB5)) Q:SUB5=""  D
 ...S SUB6=""
 ...F  S SUB6=$O(^TMP($J,"ACHSMAUD",SORTBY,SUB3,SUB4,SUB5,SUB6)) Q:SUB6=""  D
 ....;D RPTLINE() 
 ;
 Q
 ;WRITE THE LINE
RPTLINE(SORTBY,ACHSDUZ,DTTIME,LEVEL,OPTNUM,NAME) ;
 I SORTBY="BY USER" W !,ACHSDUZ,?25,DTTIME,?35,LEVEL,?45,OPTNUM,?60,NAME
 I SORTBY="BY OPTION" W !,OPTNUM
 ;
 Q
 ;
 ;LIST BY USER
BYUSER ;
 S SORTBY="BY USER"
 Q
 ;LIST BY DATE
BYDATE ;
 S SORTBY="BY DATE"
 Q
BYOPTION ;
 S SORTBY="BY OPTION"
 Q
 ;
PGHDR ;
 W @IOF
 W $$C^XBFUNC(HEADER)
 Q
SETAUD(NAMESPAC) ;EP
 Q       ;ONE TIME USE BY PROGRAMMER. NEEDS TO BE REWRITTEN
 ;SET THIS ROUTINE INTO THE ENTRY POINT FIELD OF ALL OPTIONS FOR
 ;THE PASSED NAMESPACE
 S U="^"
 S OPTNAME=NAMESPAC_" "
 F  S OPTNAME=$O(^DIC(19,"B",OPTNAME)) Q:OPTNAME'[(NAMESPAC)  D
 .S OPTNUM=$O(^DIC(19,"B",OPTNAME,""))
 .Q:OPTNUM=""
 .W !,OPTNUM,?10,OPTNAME
 .S ENTRYACT=$G(^DIC(19,OPTNUM,20))
 .W !,ENTRYACT
 .I ENTRYACT="" D  Q
 ..W "D "_U_$ZN_"("""_NAMESPAC_""")"
 ..;S ^DIC(19,OPTNUM,20)="D "_U_$ZN_"("""_NAMESPAC_""")"
 .Q:ENTRYACT[($ZN)            ;IF THE AUDIT RTN IS ALREADY THERE
 .                            ;DONT DO ANYTHING
 .W !,OPTNUM   ;W $G(^DIC(19,OPTNUM,20))_" D "_U_$ZN_"("""_NAMESPAC_""")" ;S ^DIC(19,OPTNUM,20)=$G(^DIC(19,OPTNUM,20))_" D "_U_$ZN_"("""_NAMESPAC_""")"
 ;
 ;
 ;FIND THIS AUDIT ROUTINE IN THE ENTRY ACTION FIELD IN THE OPTION FILE
 ;FOR THE PASSED NAMESPACE. USED BY PROGRAMMER ONLY. NEEDS TO BE
 ;RE-WRITTEN
FINDAUD(NAMESPAC) ;
 Q
 S U="^"
 S OPTNAME=NAMESPAC_" "
 F CNT=1:1 S OPTNAME=$O(^DIC(19,"B",OPTNAME)) Q:OPTNAME'[(NAMESPAC)  D
 .S OPTNUM=$O(^DIC(19,"B",OPTNAME,""))
 .Q:OPTNUM=""
 .S ENTRYACT=$G(^DIC(19,OPTNUM,20))
 .W !,CNT
 .I ENTRYACT[("ACHSMAUD") W ?5,"AUDIT FOUND: ",OPTNAME,!,$G(^DIC(19,OPTNUM,20))
 .E  W ?15,"AUDIT NOT FOUND: ",OPTNAME
 ;
 Q
 ;