BUSAAPI ;GDIT/HS/BEE-IHS USER SECURITY AUDIT Utility API Program ; 31 Jan 2013 9:53 AM
;;1.0;IHS USER SECURITY AUDIT;;Nov 05, 2013;Build 65
;
Q
;
LOG(TYPE,CAT,ACTION,CALL,DESC,DETAIL) ;PEP - Log Security Audit Entries
;
; Required variables:
; DUZ - Pointer to NEW PERSON (#200) file
;
;Input Parameters:
; TYPE - (Optional) - The type of entry to log (R:RPC Call;W:Web Service
; Call;A:API Call;O:Other)
; (Default - A)
; CAT - (Required) - The category of the event to log (S:System Event;
; P:Patient Related;D:Definition Change;
; O:Other Event)
; ACTION - (Required for CAT="P") - The action of the event to log
; (A:Additions;D:Deletions;Q:Queries;P:Print;
; E:Changes;C:Copy)
; CALL - (Required) - Free text entry describing the call which
; originated the audit request (Maximum length
; 200 characters)
; Examples could be an RPC value or calling
; routine
; DESC - (Required) - Free text entry describing the call action
; (Maximum length 250 characters)
; Examples could be 'Patient demographic update',
; 'Copied iCare panel to clipboard' or 'POV Entry'
;
; DETAIL - Array of patient/visit records to log. Required for patient
; related events. Optional for other event types
;
; Format: DETAIL(#)=DFN^VIEN^EVENT DESCRIPTION^NEW VALUE^ORIGINAL VALUE
;
; Where:
; # - Record counter (1,2,3...)
; DFN - (Optional for non-patient related calls) - Pointer to VA PATIENT file (#2)
; VIEN - (Optional for non-visit related calls) - Pointer to VISIT file (#9000010)
; EVENT DESCRIPTION -(Optional) - Additional detail to log for this entry
; NEW VALUE - (Optional) - New value after call completion, if applicable
; ORIGINAL VALUE - (Optional) - Original value prior to call execution, if applicable
;
NEW STS,SIEN,BUSAUPD,ERROR,BUSAII
S STS=""
;
;Make sure logging switch is on
I '+$$STATUS^BUSAOPT("M") S STS="0^Master audit logging switch is off" G XLOG
;
ALTENT ;Entry point from bypass call
;
;Check for DUZ (USER filed)
I +$G(DUZ)<1 S STS="0^Invalid DUZ value" G XLOG
;
;Check for TYPE (ENTRY TYPE field)
S TYPE=$G(TYPE,"") S:TYPE="" TYPE="A"
;
;Check for CAT (CATEGORY field)
I $G(CAT)="" S STS="0^Invalid CAT value" G XLOG
;
;Action
S ACTION=$G(ACTION,"") I ACTION="",CAT="P" S STS="0^Action required if Patient Category" G XLOG
;
;Check for CALL (ORIGINATING CALL field)
I $G(CALL)="" S STS="0^Invalid CALL value" G XLOG
;
;Check for DESC (ENTRY DESCRIPTION field)
I $G(DESC)="" S STS="0^Invalid DESC value" G XLOG
;
;Log new BUSA AUDIT LOG SUMMARY entry
S SIEN=$$NEWS() I 'SIEN S STS="0^Unable to create summary entry" G XLOG
;
;Log remaining summary fields
S BUSAUPD(9002319.01,SIEN_",",.02)=DUZ ;USER
S BUSAUPD(9002319.01,SIEN_",",.03)=CAT ;CATEGORY
S BUSAUPD(9002319.01,SIEN_",",.04)=TYPE ;ENTRY TYPE
S BUSAUPD(9002319.01,SIEN_",",.05)=ACTION ;ACTION
S BUSAUPD(9002319.01,SIEN_",",.06)=$E(CALL,1,200) ;ORIGINATING CALL
S BUSAUPD(9002319.01,SIEN_",",1)=$E(DESC,1,250) ;ENTRY DESCRIPTION
D FILE^DIE("","BUSAUPD","ERROR") I $D(ERROR) S STS="0^"_$G(ERROR) G XLOG
;
;Log BUSA AUDIT LOG DETAIL entries
I $G(DETAIL)]"" S BUSAII=0 F S BUSAII=$O(@DETAIL@(BUSAII)) Q:BUSAII="" D Q:STS]""
. NEW DIEN,BUSADET,ND
. ;
. ;Log detail entry
. S ND=$G(@DETAIL@(BUSAII))
. S DIEN=$$NEWD(SIEN) I 'DIEN S STS="0^Unable to create detail entry" Q
. ;
. ;Plug in DFN using VIEN (if DFN is blank)
. I $P(ND,U)="",$P(ND,U,2)]"" S $P(ND,U)=$$GET1^DIQ(9000010,$P(ND,U,2)_",",".05","I")
. ;
. ;Log remaining detail fields
. S:$P(ND,U)]"" BUSADET(9002319.02,DIEN_",",.02)=$P(ND,U)
. S:$P(ND,U,2)]"" BUSADET(9002319.02,DIEN_",",.03)=$P(ND,U,2)
. S:$P(ND,U,3)]"" BUSADET(9002319.02,DIEN_",",.04)=$E($P(ND,U,3),1,200)
. ;
. ;New value
. I $P(ND,U,4)]"" D
.. N TXT,VAR
.. D WRAP^BUSAUTIL(.TXT,$P(ND,U,4),220)
.. S VAR="TXT"
.. D WP^DIE(9002319.02,DIEN_",",1,"",VAR)
. ;
. ;Original value
. I $P(ND,U,5)]"" D
.. N TXT,VAR
.. D WRAP^BUSAUTIL(.TXT,$P(ND,U,5),220)
.. S VAR="TXT"
.. D WP^DIE(9002319.02,DIEN_",",2,"",VAR)
. D FILE^DIE("","BUSADET","ERROR") I $D(ERROR) S STS="0^"_$G(ERROR)
I STS]"" G XLOG
;
;Successful log
S STS=1
;
;Log Exit Point
XLOG Q STS
;
BYPSLOG(TYPE,CAT,ACTION,CALL,DESC,DETAIL) ;EP - Log Security Audit Entries
;
;This API makes the call to log an audit entry but bypasses the check
;to see if the master audit is turned on
;
NEW STS,SIEN,BUSAUPD,ERROR,BUSAII
S STS=""
;
G ALTENT
;
NEWS() ;EP - Create new BUSA AUDIT LOG SUMMARY entry stub
N DIC,X,Y,DA,DLAYGO,%
S DIC(0)="L",DIC="^BUSAS(",DLAYGO=DIC
D NOW^%DTC
S X=%
K DO,DD D FILE^DICN
Q +Y
;
NEWD(SIEN) ;EP - Create new BUSA AUDIT LOG DETAIL entry stub
N DIC,X,Y,DA,DLAYGO
S DIC(0)="L",DIC="^BUSAD(",DLAYGO=DIC
S X=SIEN
K DO,DD D FILE^DICN
Q +Y
BUSAAPI ;GDIT/HS/BEE-IHS USER SECURITY AUDIT Utility API Program ; 31 Jan 2013 9:53 AM
+1 ;;1.0;IHS USER SECURITY AUDIT;;Nov 05, 2013;Build 65
+2 ;
+3 QUIT
+4 ;
LOG(TYPE,CAT,ACTION,CALL,DESC,DETAIL) ;PEP - Log Security Audit Entries
+1 ;
+2 ; Required variables:
+3 ; DUZ - Pointer to NEW PERSON (#200) file
+4 ;
+5 ;Input Parameters:
+6 ; TYPE - (Optional) - The type of entry to log (R:RPC Call;W:Web Service
+7 ; Call;A:API Call;O:Other)
+8 ; (Default - A)
+9 ; CAT - (Required) - The category of the event to log (S:System Event;
+10 ; P:Patient Related;D:Definition Change;
+11 ; O:Other Event)
+12 ; ACTION - (Required for CAT="P") - The action of the event to log
+13 ; (A:Additions;D:Deletions;Q:Queries;P:Print;
+14 ; E:Changes;C:Copy)
+15 ; CALL - (Required) - Free text entry describing the call which
+16 ; originated the audit request (Maximum length
+17 ; 200 characters)
+18 ; Examples could be an RPC value or calling
+19 ; routine
+20 ; DESC - (Required) - Free text entry describing the call action
+21 ; (Maximum length 250 characters)
+22 ; Examples could be 'Patient demographic update',
+23 ; 'Copied iCare panel to clipboard' or 'POV Entry'
+24 ;
+25 ; DETAIL - Array of patient/visit records to log. Required for patient
+26 ; related events. Optional for other event types
+27 ;
+28 ; Format: DETAIL(#)=DFN^VIEN^EVENT DESCRIPTION^NEW VALUE^ORIGINAL VALUE
+29 ;
+30 ; Where:
+31 ; # - Record counter (1,2,3...)
+32 ; DFN - (Optional for non-patient related calls) - Pointer to VA PATIENT file (#2)
+33 ; VIEN - (Optional for non-visit related calls) - Pointer to VISIT file (#9000010)
+34 ; EVENT DESCRIPTION -(Optional) - Additional detail to log for this entry
+35 ; NEW VALUE - (Optional) - New value after call completion, if applicable
+36 ; ORIGINAL VALUE - (Optional) - Original value prior to call execution, if applicable
+37 ;
+38 NEW STS,SIEN,BUSAUPD,ERROR,BUSAII
+39 SET STS=""
+40 ;
+41 ;Make sure logging switch is on
+42 IF '+$$STATUS^BUSAOPT("M")
SET STS="0^Master audit logging switch is off"
GOTO XLOG
+43 ;
ALTENT ;Entry point from bypass call
+1 ;
+2 ;Check for DUZ (USER filed)
+3 IF +$GET(DUZ)<1
SET STS="0^Invalid DUZ value"
GOTO XLOG
+4 ;
+5 ;Check for TYPE (ENTRY TYPE field)
+6 SET TYPE=$GET(TYPE,"")
IF TYPE=""
SET TYPE="A"
+7 ;
+8 ;Check for CAT (CATEGORY field)
+9 IF $GET(CAT)=""
SET STS="0^Invalid CAT value"
GOTO XLOG
+10 ;
+11 ;Action
+12 SET ACTION=$GET(ACTION,"")
IF ACTION=""
IF CAT="P"
SET STS="0^Action required if Patient Category"
GOTO XLOG
+13 ;
+14 ;Check for CALL (ORIGINATING CALL field)
+15 IF $GET(CALL)=""
SET STS="0^Invalid CALL value"
GOTO XLOG
+16 ;
+17 ;Check for DESC (ENTRY DESCRIPTION field)
+18 IF $GET(DESC)=""
SET STS="0^Invalid DESC value"
GOTO XLOG
+19 ;
+20 ;Log new BUSA AUDIT LOG SUMMARY entry
+21 SET SIEN=$$NEWS()
IF 'SIEN
SET STS="0^Unable to create summary entry"
GOTO XLOG
+22 ;
+23 ;Log remaining summary fields
+24 ;USER
SET BUSAUPD(9002319.01,SIEN_",",.02)=DUZ
+25 ;CATEGORY
SET BUSAUPD(9002319.01,SIEN_",",.03)=CAT
+26 ;ENTRY TYPE
SET BUSAUPD(9002319.01,SIEN_",",.04)=TYPE
+27 ;ACTION
SET BUSAUPD(9002319.01,SIEN_",",.05)=ACTION
+28 ;ORIGINATING CALL
SET BUSAUPD(9002319.01,SIEN_",",.06)=$EXTRACT(CALL,1,200)
+29 ;ENTRY DESCRIPTION
SET BUSAUPD(9002319.01,SIEN_",",1)=$EXTRACT(DESC,1,250)
+30 DO FILE^DIE("","BUSAUPD","ERROR")
IF $DATA(ERROR)
SET STS="0^"_$GET(ERROR)
GOTO XLOG
+31 ;
+32 ;Log BUSA AUDIT LOG DETAIL entries
+33 IF $GET(DETAIL)]""
SET BUSAII=0
FOR
SET BUSAII=$ORDER(@DETAIL@(BUSAII))
IF BUSAII=""
QUIT
Begin DoDot:1
+34 NEW DIEN,BUSADET,ND
+35 ;
+36 ;Log detail entry
+37 SET ND=$GET(@DETAIL@(BUSAII))
+38 SET DIEN=$$NEWD(SIEN)
IF 'DIEN
SET STS="0^Unable to create detail entry"
QUIT
+39 ;
+40 ;Plug in DFN using VIEN (if DFN is blank)
+41 IF $PIECE(ND,U)=""
IF $PIECE(ND,U,2)]""
SET $PIECE(ND,U)=$$GET1^DIQ(9000010,$PIECE(ND,U,2)_",",".05","I")
+42 ;
+43 ;Log remaining detail fields
+44 IF $PIECE(ND,U)]""
SET BUSADET(9002319.02,DIEN_",",.02)=$PIECE(ND,U)
+45 IF $PIECE(ND,U,2)]""
SET BUSADET(9002319.02,DIEN_",",.03)=$PIECE(ND,U,2)
+46 IF $PIECE(ND,U,3)]""
SET BUSADET(9002319.02,DIEN_",",.04)=$EXTRACT($PIECE(ND,U,3),1,200)
+47 ;
+48 ;New value
+49 IF $PIECE(ND,U,4)]""
Begin DoDot:2
+50 NEW TXT,VAR
+51 DO WRAP^BUSAUTIL(.TXT,$PIECE(ND,U,4),220)
+52 SET VAR="TXT"
+53 DO WP^DIE(9002319.02,DIEN_",",1,"",VAR)
End DoDot:2
+54 ;
+55 ;Original value
+56 IF $PIECE(ND,U,5)]""
Begin DoDot:2
+57 NEW TXT,VAR
+58 DO WRAP^BUSAUTIL(.TXT,$PIECE(ND,U,5),220)
+59 SET VAR="TXT"
+60 DO WP^DIE(9002319.02,DIEN_",",2,"",VAR)
End DoDot:2
+61 DO FILE^DIE("","BUSADET","ERROR")
IF $DATA(ERROR)
SET STS="0^"_$GET(ERROR)
End DoDot:1
IF STS]""
QUIT
+62 IF STS]""
GOTO XLOG
+63 ;
+64 ;Successful log
+65 SET STS=1
+66 ;
+67 ;Log Exit Point
XLOG QUIT STS
+1 ;
BYPSLOG(TYPE,CAT,ACTION,CALL,DESC,DETAIL) ;EP - Log Security Audit Entries
+1 ;
+2 ;This API makes the call to log an audit entry but bypasses the check
+3 ;to see if the master audit is turned on
+4 ;
+5 NEW STS,SIEN,BUSAUPD,ERROR,BUSAII
+6 SET STS=""
+7 ;
+8 GOTO ALTENT
+9 ;
NEWS() ;EP - Create new BUSA AUDIT LOG SUMMARY entry stub
+1 NEW DIC,X,Y,DA,DLAYGO,%
+2 SET DIC(0)="L"
SET DIC="^BUSAS("
SET DLAYGO=DIC
+3 DO NOW^%DTC
+4 SET X=%
+5 KILL DO,DD
DO FILE^DICN
+6 QUIT +Y
+7 ;
NEWD(SIEN) ;EP - Create new BUSA AUDIT LOG DETAIL entry stub
+1 NEW DIC,X,Y,DA,DLAYGO
+2 SET DIC(0)="L"
SET DIC="^BUSAD("
SET DLAYGO=DIC
+3 SET X=SIEN
+4 KILL DO,DD
DO FILE^DICN
+5 QUIT +Y