DGRRLU2 ;ALB/AAS - Patient Look-up log data, copied from DGSEC ;7/15/05 14:26
;;5.3;Registration;**538**;Aug 13, 1993
;
NOTICE(RESULT,DFN,DGOPT,ACTION) ;RPC/API entry point for log entry and message generation
;Input parameters:
; DFN = Patient file DFN
; DGOPT = Java application name, needed for DG Security Log file and bulletin
; ACTION = 1 - Set DG Security Log entry, 2 - Generate mail
; message, 3 - Both (Optional - Defaults to both)
;
;Output: RESULT = 1 - DG Security Log updated and/or Sensitive Record msg sent (Determined by ACTION value)
; 0 - Required variable undefined
;
I $G(DFN)="" S RESULT=0 Q
I $G(^DPT(+DFN,0))="" S RESULT=0 Q
I $G(DUZ)="" S RESULT=0 Q
S DGOPT=$G(DGOPT)
I $G(ACTION)="" S ACTION=3
I ACTION'=1 D BULTIN1(DFN,DUZ,.DGOPT)
I ACTION'=2 D SETLOG1(DFN,DUZ,,.DGOPT)
S RESULT=1 ;_"^"_$G(DGOPT)
Q
;
SETLOG1(DFN,DGDUZ,DG1,DGOPT) ;Adds/updates entry in DG Security Log file (38.1)
;Input:
; DFN - Patient (#2) file DFN (Required)
; DGDUZ - New Person (#200) file IEN
; DG1 - Inpatient or Outpatient (Optional)
; DGOPT - Java Application name
;
N DGA1,DGDATE,DGDTE,DGT,DGTIME,XQOPT
;Lock global
LOCK L +^DGSL(38.1,+DFN):1 G:'$T LOCK
;Add new entry for patient if not found
I '$D(^DGSL(38.1,+DFN,0)) D
.S ^DGSL(38.1,+DFN,0)=+DFN
.S ^DGSL(38.1,"B",+DFN,+DFN)=""
.S $P(^DGSL(38.1,0),U,3)=+DFN
.S $P(^DGSL(38.1,0),U,4)=$P(^DGSL(38.1,0),U,4)+1
.;Determine if entry is automatically sensitive
.N ELIG,FLAG,X
.S FLAG=0
.S X=$S($D(^DPT(+DFN,"TYPE")):+^("TYPE"),1:"")
.I $D(^DG(391,+X,0)),$P(^(0),"^",4) S FLAG=1
.I 'FLAG S ELIG=0 F S ELIG=$O(^DPT(+DFN,"E",ELIG)) Q:'ELIG D Q:FLAG
..S X=$G(^DIC(8,ELIG,0))
..I $P(X,"^",12) S FLAG=1
.S $P(^DGSL(38.1,+DFN,0),"^",2)=FLAG
.;Date/time sensitivity was set
.S $P(^DGSL(38.1,+DFN,0),"^",4)=$$NOW^XLFDT()
;determine if an inpatient
D H^DGUTL
S DGT=DGTIME
I $G(DG1)="" D ^DGPMSTAT
;get option name
I $G(DGOPT)="" SET DGOPT="From Java Patient Lookup"
;I $G(DGOPT)="" D OP^XQCHK S DGOPT=$S(+XQOPT<0:"^UNKNOWN",1:$P(XQOPT,U)_U_$P(XQOPT,U,2))
SETUSR ;
S DGDTE=9999999.9999-DGTIME
I $D(^DGSL(38.1,+DFN,"D",DGDTE,0)) S DGTIME=DGTIME+.00001 G SETUSR
S:'$D(^DGSL(38.1,+DFN,"D",0)) ^(0)="^38.11DA^^"
S ^DGSL(38.1,+DFN,"D",DGDTE,0)=DGTIME_U_DGDUZ_U_DGOPT_U_$S(DG1:"y",1:"n")
S $P(^(0),U,3,4)=DGDTE_U_($P(^DGSL(38.1,+DFN,"D",0),U,4)+1)
S ^DGSL(38.1,"AD",DGDTE,+DFN)=""
S ^DGSL(38.1,"AU",+DFN,DGDUZ,DGDTE)=""
L -^DGSL(38.1,+DFN)
Q
;
BULTIN1(DFN,DGDUZ,DGOPT,DGMSG) ;Generate sensitive record access bulletin
;
;Input: DFN = Patient file IEN
; DGDUZ = New Person (#200) file IEN
; DGOPT = OPTION from Java
; DGMSG = Message array (Optional)
;
N DGEMPLEE,XMSUB,XQOPT
K DGB
;I $D(^DG(43,1,"NOT")),+$P(^("NOT"),U,10) S DGB=10
;Q:'$D(DGB)
S XMSUB="RESTRICTED PATIENT RECORD ACCESSED"
;S DGB=+$P($G(^DG(43,1,"NOT")),U,DGB) Q:'DGB
;S DGB=$P($G(^XMB(3.8,DGB,0)),U) Q:'$L(DGB)
S DGB=$$GET1^DIQ(43,1,509)
Q:'$L(DGB)
;
I $G(DGOPT)="" SET DGOPT="From Java Patient Lookup"
N XMB,XMY,XMY0,XMZ
S XMB="DG SENSITIVITY",XMB(1)=$P(^DPT(+DFN,0),U)
S DGEMPLEE=$$EMPL^DGSEC4(+DFN)
I DGEMPLEE=1 S XMB(1)=XMB(1)_" (Employee)"
S XMB(2)=$P(^DPT(+DFN,0),U,9),XMB(3)=DGOPT,XMY("G."_DGB)=""
N Y S Y=$$NOW^XLFDT() X ^DD("DD") S XMB(4)=Y
D SEND(.XMB,.XMY)
S DGMSG(1)="NOTE: A bulletin will now be sent to your station security officer."
Q
;
SEND(XMB,XMY) ;Queue mail bulletin
;Input: XMB,XMY=Mailman bulletin parameters
;
N ZTSK,ZTRTN,ZTDESC,ZTIO,ZTDTH,ZTSAVE,DGI,X,Y
F DGI="XMB","XMB(","XMY(" S ZTSAVE(DGI)=""
S ZTRTN="EN^XMB",ZTDESC="DG Security Bulletin",ZTIO="",ZTDTH=$H
D ^%ZTLOAD
Q
TEST4 ;
N RESULT
SET RESULT=""
D NOTICE(.RESULT,40,"ALAN TEST",3)
W !,"Result = ",RESULT
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDGRRLU2 3878 printed Dec 13, 2024@02:57:36 Page 2
DGRRLU2 ;ALB/AAS - Patient Look-up log data, copied from DGSEC ;7/15/05 14:26
+1 ;;5.3;Registration;**538**;Aug 13, 1993
+2 ;
NOTICE(RESULT,DFN,DGOPT,ACTION) ;RPC/API entry point for log entry and message generation
+1 ;Input parameters:
+2 ; DFN = Patient file DFN
+3 ; DGOPT = Java application name, needed for DG Security Log file and bulletin
+4 ; ACTION = 1 - Set DG Security Log entry, 2 - Generate mail
+5 ; message, 3 - Both (Optional - Defaults to both)
+6 ;
+7 ;Output: RESULT = 1 - DG Security Log updated and/or Sensitive Record msg sent (Determined by ACTION value)
+8 ; 0 - Required variable undefined
+9 ;
+10 IF $GET(DFN)=""
SET RESULT=0
QUIT
+11 IF $GET(^DPT(+DFN,0))=""
SET RESULT=0
QUIT
+12 IF $GET(DUZ)=""
SET RESULT=0
QUIT
+13 SET DGOPT=$GET(DGOPT)
+14 IF $GET(ACTION)=""
SET ACTION=3
+15 IF ACTION'=1
DO BULTIN1(DFN,DUZ,.DGOPT)
+16 IF ACTION'=2
DO SETLOG1(DFN,DUZ,,.DGOPT)
+17 ;_"^"_$G(DGOPT)
SET RESULT=1
+18 QUIT
+19 ;
SETLOG1(DFN,DGDUZ,DG1,DGOPT) ;Adds/updates entry in DG Security Log file (38.1)
+1 ;Input:
+2 ; DFN - Patient (#2) file DFN (Required)
+3 ; DGDUZ - New Person (#200) file IEN
+4 ; DG1 - Inpatient or Outpatient (Optional)
+5 ; DGOPT - Java Application name
+6 ;
+7 NEW DGA1,DGDATE,DGDTE,DGT,DGTIME,XQOPT
+8 ;Lock global
LOCK LOCK +^DGSL(38.1,+DFN):1
if '$TEST
GOTO LOCK
+1 ;Add new entry for patient if not found
+2 IF '$DATA(^DGSL(38.1,+DFN,0))
Begin DoDot:1
+3 SET ^DGSL(38.1,+DFN,0)=+DFN
+4 SET ^DGSL(38.1,"B",+DFN,+DFN)=""
+5 SET $PIECE(^DGSL(38.1,0),U,3)=+DFN
+6 SET $PIECE(^DGSL(38.1,0),U,4)=$PIECE(^DGSL(38.1,0),U,4)+1
+7 ;Determine if entry is automatically sensitive
+8 NEW ELIG,FLAG,X
+9 SET FLAG=0
+10 SET X=$SELECT($DATA(^DPT(+DFN,"TYPE")):+^("TYPE"),1:"")
+11 IF $DATA(^DG(391,+X,0))
IF $PIECE(^(0),"^",4)
SET FLAG=1
+12 IF 'FLAG
SET ELIG=0
FOR
SET ELIG=$ORDER(^DPT(+DFN,"E",ELIG))
if 'ELIG
QUIT
Begin DoDot:2
+13 SET X=$GET(^DIC(8,ELIG,0))
+14 IF $PIECE(X,"^",12)
SET FLAG=1
End DoDot:2
if FLAG
QUIT
+15 SET $PIECE(^DGSL(38.1,+DFN,0),"^",2)=FLAG
+16 ;Date/time sensitivity was set
+17 SET $PIECE(^DGSL(38.1,+DFN,0),"^",4)=$$NOW^XLFDT()
End DoDot:1
+18 ;determine if an inpatient
+19 DO H^DGUTL
+20 SET DGT=DGTIME
+21 IF $GET(DG1)=""
DO ^DGPMSTAT
+22 ;get option name
+23 IF $GET(DGOPT)=""
SET DGOPT="From Java Patient Lookup"
+24 ;I $G(DGOPT)="" D OP^XQCHK S DGOPT=$S(+XQOPT<0:"^UNKNOWN",1:$P(XQOPT,U)_U_$P(XQOPT,U,2))
SETUSR ;
+1 SET DGDTE=9999999.9999-DGTIME
+2 IF $DATA(^DGSL(38.1,+DFN,"D",DGDTE,0))
SET DGTIME=DGTIME+.00001
GOTO SETUSR
+3 if '$DATA(^DGSL(38.1,+DFN,"D",0))
SET ^(0)="^38.11DA^^"
+4 SET ^DGSL(38.1,+DFN,"D",DGDTE,0)=DGTIME_U_DGDUZ_U_DGOPT_U_$SELECT(DG1:"y",1:"n")
+5 SET $PIECE(^(0),U,3,4)=DGDTE_U_($PIECE(^DGSL(38.1,+DFN,"D",0),U,4)+1)
+6 SET ^DGSL(38.1,"AD",DGDTE,+DFN)=""
+7 SET ^DGSL(38.1,"AU",+DFN,DGDUZ,DGDTE)=""
+8 LOCK -^DGSL(38.1,+DFN)
+9 QUIT
+10 ;
BULTIN1(DFN,DGDUZ,DGOPT,DGMSG) ;Generate sensitive record access bulletin
+1 ;
+2 ;Input: DFN = Patient file IEN
+3 ; DGDUZ = New Person (#200) file IEN
+4 ; DGOPT = OPTION from Java
+5 ; DGMSG = Message array (Optional)
+6 ;
+7 NEW DGEMPLEE,XMSUB,XQOPT
+8 KILL DGB
+9 ;I $D(^DG(43,1,"NOT")),+$P(^("NOT"),U,10) S DGB=10
+10 ;Q:'$D(DGB)
+11 SET XMSUB="RESTRICTED PATIENT RECORD ACCESSED"
+12 ;S DGB=+$P($G(^DG(43,1,"NOT")),U,DGB) Q:'DGB
+13 ;S DGB=$P($G(^XMB(3.8,DGB,0)),U) Q:'$L(DGB)
+14 SET DGB=$$GET1^DIQ(43,1,509)
+15 if '$LENGTH(DGB)
QUIT
+16 ;
+17 IF $GET(DGOPT)=""
SET DGOPT="From Java Patient Lookup"
+18 NEW XMB,XMY,XMY0,XMZ
+19 SET XMB="DG SENSITIVITY"
SET XMB(1)=$PIECE(^DPT(+DFN,0),U)
+20 SET DGEMPLEE=$$EMPL^DGSEC4(+DFN)
+21 IF DGEMPLEE=1
SET XMB(1)=XMB(1)_" (Employee)"
+22 SET XMB(2)=$PIECE(^DPT(+DFN,0),U,9)
SET XMB(3)=DGOPT
SET XMY("G."_DGB)=""
+23 NEW Y
SET Y=$$NOW^XLFDT()
XECUTE ^DD("DD")
SET XMB(4)=Y
+24 DO SEND(.XMB,.XMY)
+25 SET DGMSG(1)="NOTE: A bulletin will now be sent to your station security officer."
+26 QUIT
+27 ;
SEND(XMB,XMY) ;Queue mail bulletin
+1 ;Input: XMB,XMY=Mailman bulletin parameters
+2 ;
+3 NEW ZTSK,ZTRTN,ZTDESC,ZTIO,ZTDTH,ZTSAVE,DGI,X,Y
+4 FOR DGI="XMB","XMB(","XMY("
SET ZTSAVE(DGI)=""
+5 SET ZTRTN="EN^XMB"
SET ZTDESC="DG Security Bulletin"
SET ZTIO=""
SET ZTDTH=$HOROLOG
+6 DO ^%ZTLOAD
+7 QUIT
TEST4 ;
+1 NEW RESULT
+2 SET RESULT=""
+3 DO NOTICE(.RESULT,40,"ALAN TEST",3)
+4 WRITE !,"Result = ",RESULT
+5 QUIT