ORRHCQ1 ; SLC/SRM - CPRS Query Tools - Utilities ;6/10/03 15:11
;;3.0;ORDER ENTRY/RESULTS REPORTING;**174,248**;Dec 17, 1997;Build 1
;
QRYSITR(VAL,ORRITR) ; Do query for the standard Iterator, saving off the sensitive patients
; VAL=PtSearched^RecordsFound^Iterator
S VAL=$$SSCREEN($P(ORRITR,";",2))
I VAL S VAL=$$PTSCRN^ORRHCQ($P(ORRITR,";",2))
I VAL S $P(VAL,U,2)=$$QRYPT^ORRHCQ($P(ORRITR,";",2))
S $P(VAL,U,3)=$$NXTITER^ORRHCQ(ORRITR)
Q
;
QSITR(VAL,SITR) ; Do query for the current sensitive patient iterator
; VAL=PtSearched^RecordsFound^Iterator
N LEVEL,RET
I $G(SITR)="" S SITR=0
S SITR=$O(^TMP("ORRHCQ",$J,"DFN","S",SITR))
I +SITR<1 S VAL=0_U_0_U Q
;
; Sensitive notifications, exclusions
;
S LEVEL=+$G(^TMP("ORRHCQ",$J,"DFN","S",SITR))
I LEVEL=2 D
.D NOTICE^DGSEC4(.RET,SITR,"ORRCMP QUERY TOOL^ORRCM CLIENT",1)
.I +$G(RET)=0 D ERROR("Error logging sensitive patient use.") S VAL=0_U_0_U Q
S VAL=0
I LEVEL<3 D
.S VAL=$$PTSCRN^ORRHCQ(SITR)
;
I +VAL S $P(VAL,U,2)=$$QRYPT^ORRHCQ(SITR)
S $P(VAL,U,3)=SITR
Q
;
GETSPT(RES,START,LEN) ;Returns a list of DFN^Patient Name^Level given a start position and a length. The START
;parameter should be in the form "NAME!DFN" (a 'bang' between name and DFN.)
N I,X S I=START,X=1
I +$G(LEN)<1 Q
F S I=$O(^TMP("ORRHCQ",$J,"DFN","S","B",I)) Q:X>+$G(LEN)!(I="") D
.S RES(X)=$P(I,"!",2)_U_$P(I,"!",1)_U_$G(^TMP("ORRHCQ",$J,"DFN","S","B",I)),X=X+1
Q
;
GETSLN(RES,DFN) ;Returns the sensitive patient message text lines for the given patient.
N I,CODE S RES="",I=0
I $D(^TMP("ORRHCQ",$J,"DFN","S",DFN)) D
.S CODE=^TMP("ORRHCQ",$J,"DFN","S",DFN)
.M RES=^TMP("ORRHCQ",$J,"DFN","S","MESSAGE",CODE)
Q
;
DELSEN(RES,DFN) ;Removes Sensitive Patient from list
S RES=0
I $D(^TMP("ORRHCQ",$J,"DFN","S",DFN)) D
.S RES=1 K ^TMP("ORRHCQ",$J,"DFN","S",DFN),^TMP("ORRHCQ",$J,"DFN","S","B",$$PTNAME(DFN)_"!"_DFN)
Q
;
GETCNT(LEN) ; Returns the count of sensitive patients
S LEN=0
I $D(^TMP("ORRHCQ",$J,"DFN","S")) D
.N I S I=0
.F S I=$O(^TMP("ORRHCQ",$J,"DFN","S",I)) Q:I'>0 S LEN=LEN+1
Q
;
SSCREEN(PATID) ; Screen sensitive patients - returns 1 if not a sensitive patient; returns 0 if is a sensitive patient or has error
; check for sensitive pt level here and store in "DFN","S",DFN)=LEVEL??
N RESULT,CODE
D PTSEC^DGSEC4(.RESULT,PATID,0,"ORRCMP QUERY TOOL^ORRCM CLIENT")
I $D(RESULT)<1 D ERROR("PTSEC^DGSEC4 did not return expected values.") Q 0
I $G(RESULT(1))<0 D ERROR("PTSEC^DGSEC4 returned an error code of:"_RESULT(1)) Q 0
I $G(RESULT(1))>0 D Q 0
.S ^TMP("ORRHCQ",$J,"DFN","S",PATID)=RESULT(1),^TMP("ORRHCQ",$J,"DFN","S","B",$$PTNAME(PATID)_"!"_PATID)=RESULT(1)
.S CODE=RESULT(1) K RESULT(1)
.M ^TMP("ORRHCQ",$J,"DFN","S","MESSAGE",CODE)=RESULT
Q 1
;
ERROR(MESSAGE) ;Log an error searching for sensitive patient information
Q
;
PTNAME(DFN) ; Returns patient name
N VADM,VA,VAERR
D DEM^VADPT
Q VADM(1)
;
ORRHCQ1 ; SLC/SRM - CPRS Query Tools - Utilities ;6/10/03 15:11
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**174,248**;Dec 17, 1997;Build 1
+2 ;
QRYSITR(VAL,ORRITR) ; Do query for the standard Iterator, saving off the sensitive patients
+1 ; VAL=PtSearched^RecordsFound^Iterator
+2 SET VAL=$$SSCREEN($PIECE(ORRITR,";",2))
+3 IF VAL
SET VAL=$$PTSCRN^ORRHCQ($PIECE(ORRITR,";",2))
+4 IF VAL
SET $PIECE(VAL,U,2)=$$QRYPT^ORRHCQ($PIECE(ORRITR,";",2))
+5 SET $PIECE(VAL,U,3)=$$NXTITER^ORRHCQ(ORRITR)
+6 QUIT
+7 ;
QSITR(VAL,SITR) ; Do query for the current sensitive patient iterator
+1 ; VAL=PtSearched^RecordsFound^Iterator
+2 NEW LEVEL,RET
+3 IF $GET(SITR)=""
SET SITR=0
+4 SET SITR=$ORDER(^TMP("ORRHCQ",$JOB,"DFN","S",SITR))
+5 IF +SITR<1
SET VAL=0_U_0_U
QUIT
+6 ;
+7 ; Sensitive notifications, exclusions
+8 ;
+9 SET LEVEL=+$GET(^TMP("ORRHCQ",$JOB,"DFN","S",SITR))
+10 IF LEVEL=2
Begin DoDot:1
+11 DO NOTICE^DGSEC4(.RET,SITR,"ORRCMP QUERY TOOL^ORRCM CLIENT",1)
+12 IF +$GET(RET)=0
DO ERROR("Error logging sensitive patient use.")
SET VAL=0_U_0_U
QUIT
End DoDot:1
+13 SET VAL=0
+14 IF LEVEL<3
Begin DoDot:1
+15 SET VAL=$$PTSCRN^ORRHCQ(SITR)
End DoDot:1
+16 ;
+17 IF +VAL
SET $PIECE(VAL,U,2)=$$QRYPT^ORRHCQ(SITR)
+18 SET $PIECE(VAL,U,3)=SITR
+19 QUIT
+20 ;
GETSPT(RES,START,LEN) ;Returns a list of DFN^Patient Name^Level given a start position and a length. The START
+1 ;parameter should be in the form "NAME!DFN" (a 'bang' between name and DFN.)
+2 NEW I,X
SET I=START
SET X=1
+3 IF +$GET(LEN)<1
QUIT
+4 FOR
SET I=$ORDER(^TMP("ORRHCQ",$JOB,"DFN","S","B",I))
IF X>+$GET(LEN)!(I="")
QUIT
Begin DoDot:1
+5 SET RES(X)=$PIECE(I,"!",2)_U_$PIECE(I,"!",1)_U_$GET(^TMP("ORRHCQ",$JOB,"DFN","S","B",I))
SET X=X+1
End DoDot:1
+6 QUIT
+7 ;
GETSLN(RES,DFN) ;Returns the sensitive patient message text lines for the given patient.
+1 NEW I,CODE
SET RES=""
SET I=0
+2 IF $DATA(^TMP("ORRHCQ",$JOB,"DFN","S",DFN))
Begin DoDot:1
+3 SET CODE=^TMP("ORRHCQ",$JOB,"DFN","S",DFN)
+4 MERGE RES=^TMP("ORRHCQ",$JOB,"DFN","S","MESSAGE",CODE)
End DoDot:1
+5 QUIT
+6 ;
DELSEN(RES,DFN) ;Removes Sensitive Patient from list
+1 SET RES=0
+2 IF $DATA(^TMP("ORRHCQ",$JOB,"DFN","S",DFN))
Begin DoDot:1
+3 SET RES=1
KILL ^TMP("ORRHCQ",$JOB,"DFN","S",DFN),^TMP("ORRHCQ",$JOB,"DFN","S","B",$$PTNAME(DFN)_"!"_DFN)
End DoDot:1
+4 QUIT
+5 ;
GETCNT(LEN) ; Returns the count of sensitive patients
+1 SET LEN=0
+2 IF $DATA(^TMP("ORRHCQ",$JOB,"DFN","S"))
Begin DoDot:1
+3 NEW I
SET I=0
+4 FOR
SET I=$ORDER(^TMP("ORRHCQ",$JOB,"DFN","S",I))
IF I'>0
QUIT
SET LEN=LEN+1
End DoDot:1
+5 QUIT
+6 ;
SSCREEN(PATID) ; Screen sensitive patients - returns 1 if not a sensitive patient; returns 0 if is a sensitive patient or has error
+1 ; check for sensitive pt level here and store in "DFN","S",DFN)=LEVEL??
+2 NEW RESULT,CODE
+3 DO PTSEC^DGSEC4(.RESULT,PATID,0,"ORRCMP QUERY TOOL^ORRCM CLIENT")
+4 IF $DATA(RESULT)<1
DO ERROR("PTSEC^DGSEC4 did not return expected values.")
QUIT 0
+5 IF $GET(RESULT(1))<0
DO ERROR("PTSEC^DGSEC4 returned an error code of:"_RESULT(1))
QUIT 0
+6 IF $GET(RESULT(1))>0
Begin DoDot:1
+7 SET ^TMP("ORRHCQ",$JOB,"DFN","S",PATID)=RESULT(1)
SET ^TMP("ORRHCQ",$JOB,"DFN","S","B",$$PTNAME(PATID)_"!"_PATID)=RESULT(1)
+8 SET CODE=RESULT(1)
KILL RESULT(1)
+9 MERGE ^TMP("ORRHCQ",$JOB,"DFN","S","MESSAGE",CODE)=RESULT
End DoDot:1
QUIT 0
+10 QUIT 1
+11 ;
ERROR(MESSAGE) ;Log an error searching for sensitive patient information
+1 QUIT
+2 ;
PTNAME(DFN) ; Returns patient name
+1 NEW VADM,VA,VAERR
+2 DO DEM^VADPT
+3 QUIT VADM(1)
+4 ;