SCDXUTL4 ;ALB/JRP - ACRP ERROR CODE UTILITIES;08-OCT-1996
;;5.3;Scheduling;**68**;AUG 13, 1993
PAT4XMIT(XMITPTR) ;Return patient associated to entry in TRANSMITTED
; OUTPATIENT ENCOUNTER file (#409.73)
;
;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
; ENCOUNTER file (#409.73)
;Output : DFN^Name - Patient that is associated to the encounter
; DFN = Pointer to PATIENT file (#2)
; Name = Patient's name
; 0 - Error/bad input
;Notes : This call follows the link from the TRANSMITTED OUTPATIENT
; ENCOUNTER file (#409.73) to the OUTPATIENT ENCOUNTER file
; (#409.68) [or DELETED OUTPATIENT ENCOUNTER file (#409.74)]
; to the PATIENT file (#2)
;
;Check input
S XMITPTR=+$G(XMITPTR)
Q:('$D(^SD(409.73,XMITPTR,0))) 0
;Declare variables
N DFN,DELPTR,ENCPTR,NODE,NAME
S DFN=0
;Determine if entry in transmit file is for a deleted encounter or
; an existing encounter
S NODE=$G(^SD(409.73,XMITPTR,0))
S ENCPTR=+$P(NODE,"^",2)
S DELPTR=+$P(NODE,"^",3)
Q:(('ENCPTR)&('DELPTR)) 0
;Existing encounter
I (ENCPTR) D
.;Follow pointer to OUTPATIENT ENCOUNTER file
.S NODE=$G(^SCE(ENCPTR,0))
.;Get pointer to PATIENT file
.S DFN=+$P(NODE,"^",2)
;Deleted encounter
I (DELPTR) D
.;Follow pointer to DELETED OUTPATIENT ENCOUNTER file
.S NODE=$G(^SD(409.74,DELPTR,0))
.;Get pointer to PATIENT file
.S DFN=+$P(NODE,"^",2)
;Bad pointer to PATIENT file
Q:('$D(^DPT(DFN,0))) 0
;Get patient's name
S NODE=$G(^DPT(DFN,0))
S NAME=$P(NODE,"^",1)
;No name on file
S:(NAME="") NAME="NAME NOT ON FILE (#"_DFN_")"
;Done
Q DFN_"^"_NAME
;
PAT4ERR(PTRERR) ;Return patient associated to entry in TRANSMITTED OUTPATIENT
; ENCOUNTER ERROR file (#409.75)
;
;Input : PTRERR - Pointer to entry in TRANSMITTED OUTPATIENT
; ENCOUNTER ERROR file (#409.75)
;Output : DFN^Name - Patient that is associated to the error
; DFN = Pointer to PATIENT file (#2)
; Name = Patient's name
; 0 - Error/bad input
;Notes : This call follows the link from the TRANSMITTED OUTPATIENT
; ENCOUNTER ERROR file (#409.75) to the TRANSMITTED OUTPATIENT
; ENCOUNTER file (#409.73) to the OUTPATIENT ENCOUNTER file
; (#409.68) [or DELETED OUTPATIENT ENCOUNTER file (#409.74)]
; to the PATIENT file (#2)
;
;Check input
S PTRERR=+$G(PTRERR)
Q:('$D(^SD(409.75,PTRERR,0))) 0
;Declare variables
N NODE,XMITPTR
;Get pointer to TRANSMITTED OUTPATIENT ENCOUNTER file
S NODE=$G(^SD(409.75,PTRERR,0))
S XMITPTR=+$P(NODE,"^",1)
Q:('XMITPTR) 0
;Return patient info
Q $$PAT4XMIT(XMITPTR)
;
GETREJ(OUTARR,SCREEN,DOTS) ;Return list of all patients/encounters in the
; TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73) that were rejected
;
;Input : OUTARR - Array to store output in (full global reference)
; Defaults to ^TMP("SCDX",$J)
; SCREEN - Flag denoting if entries should be screen
; 0 = Don't apply any screens (default)
; 1 = Screen out entries that are marked for [re]xmit
; 2 = Only return entries that are demographic rejects
; 3 = Apply screen #1 & #2
; DOTS - Flag denoting if dots (.) should be printed
; 0 = Don't print dots whild building list (default)
; N = Print 1 dot for every N encounters found
;Output : PATCNT ^ ENCCNT
; PATS = Number of patients that were found
; COUNT = Number of entries in TRANSMITTED OUTPATIENT
; ENCOUNTER file (#409.73) that were found
; If entries are found, OUTARR() will be in the format
; OUTARR("NAME",NAME) = DFN ^ REJ
; OUTARR("DFN",DFN,XMITPTR) = NAME
; Where NAME = Patient's name
; DFN = Pointer to entry in PATIENT file (#2)
; REJ = Total number of encounters rejected for patient
; XMITPTR = Pointer to entry in TRANSMITTED OUTPATIENT
; ENCOUNTER file (#409.73)
;Notes : It is the responsibility of the calling program to
; initialize (ie KILL) the output array
;
;Check input
S OUTARR=$G(OUTARR)
S:(OUTARR="") OUTARR="^TMP(""SCDX"","_$J_")"
S SCREEN=+$G(SCREEN)
S DOTS=+$G(DOTS)
S:(DOTS<0) DOTS=0
;Declare variables
N DFN,XMITPTR,PATCNT,ENCCNT,NAME,TMP,MARKED
S PATCNT=0
S ENCCNT=0
;Loop through all encounters that have been rejected
S XMITPTR=""
F S XMITPTR=+$O(^SD(409.75,"B",XMITPTR)) Q:('XMITPTR) D
.;If applicable, screen out encounters marked for [re]transmission
.I ((SCREEN=1)!(SCREEN=3)) D Q:(MARKED)
..S TMP=$G(^SD(409.73,XMITPTR,0))
..S MARKED=+$P(TMP,"^",4)
.;If applicable, screen out encounters that are not demographic rejects
.I ((SCREEN=2)!(SCREEN=3)) Q:'$$REJ4DEMO^SCDXUTL3(XMITPTR)
.;Get pointer to encounter's patient
.S TMP=$$PAT4XMIT(XMITPTR)
.S DFN=+$P(TMP,"^",1)
.S NAME=$P(TMP,"^",2)
.;Couldn't find patient - ignore
.Q:('DFN)
.;Increment patient count
.S:('$D(@OUTARR@("DFN",DFN))) PATCNT=PATCNT+1
.;Store patient & encounter in output array
.S @OUTARR@("DFN",DFN,XMITPTR)=NAME
.;Increment encounter counts
.S TMP=$G(@OUTARR@("NAME",NAME))
.S @OUTARR@("NAME",NAME)=DFN_"^"_(1+$P(TMP,"^",2))
.S ENCCNT=ENCCNT+1
.;Print dots ?
.I (DOTS) W:('(ENCCNT#DOTS)) "."
Q PATCNT_"^"_ENCCNT
;
XMIT4DFN(DFN,OUTARR) ;Return list of entries in TRANSMITTED OUTPATIENT
; ENCOUNTER file (#409.73) for a given patient
;
;Input : DFN - Pointer to entry in PATIENT file (#2)
; OUTARR - Array to store output in (full global reference)
; Defaults to ^TMP("SCDX",$J)
;Output : X - Number of entries in TRANSMITTED OUTPATIENT ENCOUNTER
; file (#409.73) that were found
; If entries are found, OUTARR() will be in the format
; OUTARR(DFN,XMITPTR) = ""
; Where XMITPTR = Pointer to entry in TRANSMITTED OUTPATIENT
; ENCOUNTER file (#409.73)
;Notes : It is the responsibility of the calling program to
; initialize (ie KILL) the output array
;
;Check input
S DFN=+$G(DFN)
Q:('$D(^DPT(DFN,0))) 0
S OUTARR=$G(OUTARR)
S:(OUTARR="") OUTARR="^TMP(""SCDX"","_$J_")"
;Declare variables
N ENCPTR,DELPTR,XMITPTR,COUNT
S COUNT=0
;Find all entries in the OUTPATIENT ENCOUNTER file (#409.68) that
;pertain to the given patient
S ENCPTR=""
F S ENCPTR=+$O(^SCE("C",DFN,ENCPTR)) Q:('ENCPTR) D
.;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file
.S XMITPTR=+$O(^SD(409.73,"AENC",ENCPTR,0))
.Q:('XMITPTR)
.;Store pointer in output array an increment counter
.S @OUTARR@(DFN,XMITPTR)=""
.S COUNT=COUNT+1
;Find all entries in DELETED OUTPATIENT ENCOUNTER file (#409.74) that
;pertain to the given patient
S DELPTR=""
F S DELPTR=+$O(^SD(409.74,"PAT",DFN,DELPTR)) Q:('DELPTR) D
.;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file
.S XMITPTR=+$O(^SD(409.73,"ADEL",DELPTR,0))
.Q:('XMITPTR)
.;Store pointer in output array an increment counter
.S @OUTARR@(DFN,XMITPTR)=""
.S COUNT=COUNT+1
Q COUNT
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCDXUTL4 7305 printed Dec 13, 2024@02:39:42 Page 2
SCDXUTL4 ;ALB/JRP - ACRP ERROR CODE UTILITIES;08-OCT-1996
+1 ;;5.3;Scheduling;**68**;AUG 13, 1993
PAT4XMIT(XMITPTR) ;Return patient associated to entry in TRANSMITTED
+1 ; OUTPATIENT ENCOUNTER file (#409.73)
+2 ;
+3 ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
+4 ; ENCOUNTER file (#409.73)
+5 ;Output : DFN^Name - Patient that is associated to the encounter
+6 ; DFN = Pointer to PATIENT file (#2)
+7 ; Name = Patient's name
+8 ; 0 - Error/bad input
+9 ;Notes : This call follows the link from the TRANSMITTED OUTPATIENT
+10 ; ENCOUNTER file (#409.73) to the OUTPATIENT ENCOUNTER file
+11 ; (#409.68) [or DELETED OUTPATIENT ENCOUNTER file (#409.74)]
+12 ; to the PATIENT file (#2)
+13 ;
+14 ;Check input
+15 SET XMITPTR=+$GET(XMITPTR)
+16 if ('$DATA(^SD(409.73,XMITPTR,0)))
QUIT 0
+17 ;Declare variables
+18 NEW DFN,DELPTR,ENCPTR,NODE,NAME
+19 SET DFN=0
+20 ;Determine if entry in transmit file is for a deleted encounter or
+21 ; an existing encounter
+22 SET NODE=$GET(^SD(409.73,XMITPTR,0))
+23 SET ENCPTR=+$PIECE(NODE,"^",2)
+24 SET DELPTR=+$PIECE(NODE,"^",3)
+25 if (('ENCPTR)&('DELPTR))
QUIT 0
+26 ;Existing encounter
+27 IF (ENCPTR)
Begin DoDot:1
+28 ;Follow pointer to OUTPATIENT ENCOUNTER file
+29 SET NODE=$GET(^SCE(ENCPTR,0))
+30 ;Get pointer to PATIENT file
+31 SET DFN=+$PIECE(NODE,"^",2)
End DoDot:1
+32 ;Deleted encounter
+33 IF (DELPTR)
Begin DoDot:1
+34 ;Follow pointer to DELETED OUTPATIENT ENCOUNTER file
+35 SET NODE=$GET(^SD(409.74,DELPTR,0))
+36 ;Get pointer to PATIENT file
+37 SET DFN=+$PIECE(NODE,"^",2)
End DoDot:1
+38 ;Bad pointer to PATIENT file
+39 if ('$DATA(^DPT(DFN,0)))
QUIT 0
+40 ;Get patient's name
+41 SET NODE=$GET(^DPT(DFN,0))
+42 SET NAME=$PIECE(NODE,"^",1)
+43 ;No name on file
+44 if (NAME="")
SET NAME="NAME NOT ON FILE (#"_DFN_")"
+45 ;Done
+46 QUIT DFN_"^"_NAME
+47 ;
PAT4ERR(PTRERR) ;Return patient associated to entry in TRANSMITTED OUTPATIENT
+1 ; ENCOUNTER ERROR file (#409.75)
+2 ;
+3 ;Input : PTRERR - Pointer to entry in TRANSMITTED OUTPATIENT
+4 ; ENCOUNTER ERROR file (#409.75)
+5 ;Output : DFN^Name - Patient that is associated to the error
+6 ; DFN = Pointer to PATIENT file (#2)
+7 ; Name = Patient's name
+8 ; 0 - Error/bad input
+9 ;Notes : This call follows the link from the TRANSMITTED OUTPATIENT
+10 ; ENCOUNTER ERROR file (#409.75) to the TRANSMITTED OUTPATIENT
+11 ; ENCOUNTER file (#409.73) to the OUTPATIENT ENCOUNTER file
+12 ; (#409.68) [or DELETED OUTPATIENT ENCOUNTER file (#409.74)]
+13 ; to the PATIENT file (#2)
+14 ;
+15 ;Check input
+16 SET PTRERR=+$GET(PTRERR)
+17 if ('$DATA(^SD(409.75,PTRERR,0)))
QUIT 0
+18 ;Declare variables
+19 NEW NODE,XMITPTR
+20 ;Get pointer to TRANSMITTED OUTPATIENT ENCOUNTER file
+21 SET NODE=$GET(^SD(409.75,PTRERR,0))
+22 SET XMITPTR=+$PIECE(NODE,"^",1)
+23 if ('XMITPTR)
QUIT 0
+24 ;Return patient info
+25 QUIT $$PAT4XMIT(XMITPTR)
+26 ;
GETREJ(OUTARR,SCREEN,DOTS) ;Return list of all patients/encounters in the
+1 ; TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73) that were rejected
+2 ;
+3 ;Input : OUTARR - Array to store output in (full global reference)
+4 ; Defaults to ^TMP("SCDX",$J)
+5 ; SCREEN - Flag denoting if entries should be screen
+6 ; 0 = Don't apply any screens (default)
+7 ; 1 = Screen out entries that are marked for [re]xmit
+8 ; 2 = Only return entries that are demographic rejects
+9 ; 3 = Apply screen #1 & #2
+10 ; DOTS - Flag denoting if dots (.) should be printed
+11 ; 0 = Don't print dots whild building list (default)
+12 ; N = Print 1 dot for every N encounters found
+13 ;Output : PATCNT ^ ENCCNT
+14 ; PATS = Number of patients that were found
+15 ; COUNT = Number of entries in TRANSMITTED OUTPATIENT
+16 ; ENCOUNTER file (#409.73) that were found
+17 ; If entries are found, OUTARR() will be in the format
+18 ; OUTARR("NAME",NAME) = DFN ^ REJ
+19 ; OUTARR("DFN",DFN,XMITPTR) = NAME
+20 ; Where NAME = Patient's name
+21 ; DFN = Pointer to entry in PATIENT file (#2)
+22 ; REJ = Total number of encounters rejected for patient
+23 ; XMITPTR = Pointer to entry in TRANSMITTED OUTPATIENT
+24 ; ENCOUNTER file (#409.73)
+25 ;Notes : It is the responsibility of the calling program to
+26 ; initialize (ie KILL) the output array
+27 ;
+28 ;Check input
+29 SET OUTARR=$GET(OUTARR)
+30 if (OUTARR="")
SET OUTARR="^TMP(""SCDX"","_$JOB_")"
+31 SET SCREEN=+$GET(SCREEN)
+32 SET DOTS=+$GET(DOTS)
+33 if (DOTS<0)
SET DOTS=0
+34 ;Declare variables
+35 NEW DFN,XMITPTR,PATCNT,ENCCNT,NAME,TMP,MARKED
+36 SET PATCNT=0
+37 SET ENCCNT=0
+38 ;Loop through all encounters that have been rejected
+39 SET XMITPTR=""
+40 FOR
SET XMITPTR=+$ORDER(^SD(409.75,"B",XMITPTR))
if ('XMITPTR)
QUIT
Begin DoDot:1
+41 ;If applicable, screen out encounters marked for [re]transmission
+42 IF ((SCREEN=1)!(SCREEN=3))
Begin DoDot:2
+43 SET TMP=$GET(^SD(409.73,XMITPTR,0))
+44 SET MARKED=+$PIECE(TMP,"^",4)
End DoDot:2
if (MARKED)
QUIT
+45 ;If applicable, screen out encounters that are not demographic rejects
+46 IF ((SCREEN=2)!(SCREEN=3))
if '$$REJ4DEMO^SCDXUTL3(XMITPTR)
QUIT
+47 ;Get pointer to encounter's patient
+48 SET TMP=$$PAT4XMIT(XMITPTR)
+49 SET DFN=+$PIECE(TMP,"^",1)
+50 SET NAME=$PIECE(TMP,"^",2)
+51 ;Couldn't find patient - ignore
+52 if ('DFN)
QUIT
+53 ;Increment patient count
+54 if ('$DATA(@OUTARR@("DFN",DFN)))
SET PATCNT=PATCNT+1
+55 ;Store patient & encounter in output array
+56 SET @OUTARR@("DFN",DFN,XMITPTR)=NAME
+57 ;Increment encounter counts
+58 SET TMP=$GET(@OUTARR@("NAME",NAME))
+59 SET @OUTARR@("NAME",NAME)=DFN_"^"_(1+$PIECE(TMP,"^",2))
+60 SET ENCCNT=ENCCNT+1
+61 ;Print dots ?
+62 IF (DOTS)
if ('(ENCCNT#DOTS))
WRITE "."
End DoDot:1
+63 QUIT PATCNT_"^"_ENCCNT
+64 ;
XMIT4DFN(DFN,OUTARR) ;Return list of entries in TRANSMITTED OUTPATIENT
+1 ; ENCOUNTER file (#409.73) for a given patient
+2 ;
+3 ;Input : DFN - Pointer to entry in PATIENT file (#2)
+4 ; OUTARR - Array to store output in (full global reference)
+5 ; Defaults to ^TMP("SCDX",$J)
+6 ;Output : X - Number of entries in TRANSMITTED OUTPATIENT ENCOUNTER
+7 ; file (#409.73) that were found
+8 ; If entries are found, OUTARR() will be in the format
+9 ; OUTARR(DFN,XMITPTR) = ""
+10 ; Where XMITPTR = Pointer to entry in TRANSMITTED OUTPATIENT
+11 ; ENCOUNTER file (#409.73)
+12 ;Notes : It is the responsibility of the calling program to
+13 ; initialize (ie KILL) the output array
+14 ;
+15 ;Check input
+16 SET DFN=+$GET(DFN)
+17 if ('$DATA(^DPT(DFN,0)))
QUIT 0
+18 SET OUTARR=$GET(OUTARR)
+19 if (OUTARR="")
SET OUTARR="^TMP(""SCDX"","_$JOB_")"
+20 ;Declare variables
+21 NEW ENCPTR,DELPTR,XMITPTR,COUNT
+22 SET COUNT=0
+23 ;Find all entries in the OUTPATIENT ENCOUNTER file (#409.68) that
+24 ;pertain to the given patient
+25 SET ENCPTR=""
+26 FOR
SET ENCPTR=+$ORDER(^SCE("C",DFN,ENCPTR))
if ('ENCPTR)
QUIT
Begin DoDot:1
+27 ;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file
+28 SET XMITPTR=+$ORDER(^SD(409.73,"AENC",ENCPTR,0))
+29 if ('XMITPTR)
QUIT
+30 ;Store pointer in output array an increment counter
+31 SET @OUTARR@(DFN,XMITPTR)=""
+32 SET COUNT=COUNT+1
End DoDot:1
+33 ;Find all entries in DELETED OUTPATIENT ENCOUNTER file (#409.74) that
+34 ;pertain to the given patient
+35 SET DELPTR=""
+36 FOR
SET DELPTR=+$ORDER(^SD(409.74,"PAT",DFN,DELPTR))
if ('DELPTR)
QUIT
Begin DoDot:1
+37 ;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file
+38 SET XMITPTR=+$ORDER(^SD(409.73,"ADEL",DELPTR,0))
+39 if ('XMITPTR)
QUIT
+40 ;Store pointer in output array an increment counter
+41 SET @OUTARR@(DFN,XMITPTR)=""
+42 SET COUNT=COUNT+1
End DoDot:1
+43 QUIT COUNT