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

SCDXUTL4.m

Go to the documentation of this file.
  1. SCDXUTL4 ;ALB/JRP - ACRP ERROR CODE UTILITIES;08-OCT-1996
  1. ;;5.3;Scheduling;**68**;AUG 13, 1993
  1. PAT4XMIT(XMITPTR) ;Return patient associated to entry in TRANSMITTED
  1. ; OUTPATIENT ENCOUNTER file (#409.73)
  1. ;
  1. ;Input : XMITPTR - Pointer to entry in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73)
  1. ;Output : DFN^Name - Patient that is associated to the encounter
  1. ; DFN = Pointer to PATIENT file (#2)
  1. ; Name = Patient's name
  1. ; 0 - Error/bad input
  1. ;Notes : This call follows the link from the TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73) to the OUTPATIENT ENCOUNTER file
  1. ; (#409.68) [or DELETED OUTPATIENT ENCOUNTER file (#409.74)]
  1. ; to the PATIENT file (#2)
  1. ;
  1. ;Check input
  1. S XMITPTR=+$G(XMITPTR)
  1. Q:('$D(^SD(409.73,XMITPTR,0))) 0
  1. ;Declare variables
  1. N DFN,DELPTR,ENCPTR,NODE,NAME
  1. S DFN=0
  1. ;Determine if entry in transmit file is for a deleted encounter or
  1. ; an existing encounter
  1. S NODE=$G(^SD(409.73,XMITPTR,0))
  1. S ENCPTR=+$P(NODE,"^",2)
  1. S DELPTR=+$P(NODE,"^",3)
  1. Q:(('ENCPTR)&('DELPTR)) 0
  1. ;Existing encounter
  1. I (ENCPTR) D
  1. .;Follow pointer to OUTPATIENT ENCOUNTER file
  1. .S NODE=$G(^SCE(ENCPTR,0))
  1. .;Get pointer to PATIENT file
  1. .S DFN=+$P(NODE,"^",2)
  1. ;Deleted encounter
  1. I (DELPTR) D
  1. .;Follow pointer to DELETED OUTPATIENT ENCOUNTER file
  1. .S NODE=$G(^SD(409.74,DELPTR,0))
  1. .;Get pointer to PATIENT file
  1. .S DFN=+$P(NODE,"^",2)
  1. ;Bad pointer to PATIENT file
  1. Q:('$D(^DPT(DFN,0))) 0
  1. ;Get patient's name
  1. S NODE=$G(^DPT(DFN,0))
  1. S NAME=$P(NODE,"^",1)
  1. ;No name on file
  1. S:(NAME="") NAME="NAME NOT ON FILE (#"_DFN_")"
  1. ;Done
  1. Q DFN_"^"_NAME
  1. ;
  1. PAT4ERR(PTRERR) ;Return patient associated to entry in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER ERROR file (#409.75)
  1. ;
  1. ;Input : PTRERR - Pointer to entry in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER ERROR file (#409.75)
  1. ;Output : DFN^Name - Patient that is associated to the error
  1. ; DFN = Pointer to PATIENT file (#2)
  1. ; Name = Patient's name
  1. ; 0 - Error/bad input
  1. ;Notes : This call follows the link from the TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER ERROR file (#409.75) to the TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73) to the OUTPATIENT ENCOUNTER file
  1. ; (#409.68) [or DELETED OUTPATIENT ENCOUNTER file (#409.74)]
  1. ; to the PATIENT file (#2)
  1. ;
  1. ;Check input
  1. S PTRERR=+$G(PTRERR)
  1. Q:('$D(^SD(409.75,PTRERR,0))) 0
  1. ;Declare variables
  1. N NODE,XMITPTR
  1. ;Get pointer to TRANSMITTED OUTPATIENT ENCOUNTER file
  1. S NODE=$G(^SD(409.75,PTRERR,0))
  1. S XMITPTR=+$P(NODE,"^",1)
  1. Q:('XMITPTR) 0
  1. ;Return patient info
  1. Q $$PAT4XMIT(XMITPTR)
  1. ;
  1. GETREJ(OUTARR,SCREEN,DOTS) ;Return list of all patients/encounters in the
  1. ; TRANSMITTED OUTPATIENT ENCOUNTER file (#409.73) that were rejected
  1. ;
  1. ;Input : OUTARR - Array to store output in (full global reference)
  1. ; Defaults to ^TMP("SCDX",$J)
  1. ; SCREEN - Flag denoting if entries should be screen
  1. ; 0 = Don't apply any screens (default)
  1. ; 1 = Screen out entries that are marked for [re]xmit
  1. ; 2 = Only return entries that are demographic rejects
  1. ; 3 = Apply screen #1 & #2
  1. ; DOTS - Flag denoting if dots (.) should be printed
  1. ; 0 = Don't print dots whild building list (default)
  1. ; N = Print 1 dot for every N encounters found
  1. ;Output : PATCNT ^ ENCCNT
  1. ; PATS = Number of patients that were found
  1. ; COUNT = Number of entries in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73) that were found
  1. ; If entries are found, OUTARR() will be in the format
  1. ; OUTARR("NAME",NAME) = DFN ^ REJ
  1. ; OUTARR("DFN",DFN,XMITPTR) = NAME
  1. ; Where NAME = Patient's name
  1. ; DFN = Pointer to entry in PATIENT file (#2)
  1. ; REJ = Total number of encounters rejected for patient
  1. ; XMITPTR = Pointer to entry in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73)
  1. ;Notes : It is the responsibility of the calling program to
  1. ; initialize (ie KILL) the output array
  1. ;
  1. ;Check input
  1. S OUTARR=$G(OUTARR)
  1. S:(OUTARR="") OUTARR="^TMP(""SCDX"","_$J_")"
  1. S SCREEN=+$G(SCREEN)
  1. S DOTS=+$G(DOTS)
  1. S:(DOTS<0) DOTS=0
  1. ;Declare variables
  1. N DFN,XMITPTR,PATCNT,ENCCNT,NAME,TMP,MARKED
  1. S PATCNT=0
  1. S ENCCNT=0
  1. ;Loop through all encounters that have been rejected
  1. S XMITPTR=""
  1. F S XMITPTR=+$O(^SD(409.75,"B",XMITPTR)) Q:('XMITPTR) D
  1. .;If applicable, screen out encounters marked for [re]transmission
  1. .I ((SCREEN=1)!(SCREEN=3)) D Q:(MARKED)
  1. ..S TMP=$G(^SD(409.73,XMITPTR,0))
  1. ..S MARKED=+$P(TMP,"^",4)
  1. .;If applicable, screen out encounters that are not demographic rejects
  1. .I ((SCREEN=2)!(SCREEN=3)) Q:'$$REJ4DEMO^SCDXUTL3(XMITPTR)
  1. .;Get pointer to encounter's patient
  1. .S TMP=$$PAT4XMIT(XMITPTR)
  1. .S DFN=+$P(TMP,"^",1)
  1. .S NAME=$P(TMP,"^",2)
  1. .;Couldn't find patient - ignore
  1. .Q:('DFN)
  1. .;Increment patient count
  1. .S:('$D(@OUTARR@("DFN",DFN))) PATCNT=PATCNT+1
  1. .;Store patient & encounter in output array
  1. .S @OUTARR@("DFN",DFN,XMITPTR)=NAME
  1. .;Increment encounter counts
  1. .S TMP=$G(@OUTARR@("NAME",NAME))
  1. .S @OUTARR@("NAME",NAME)=DFN_"^"_(1+$P(TMP,"^",2))
  1. .S ENCCNT=ENCCNT+1
  1. .;Print dots ?
  1. .I (DOTS) W:('(ENCCNT#DOTS)) "."
  1. Q PATCNT_"^"_ENCCNT
  1. ;
  1. XMIT4DFN(DFN,OUTARR) ;Return list of entries in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73) for a given patient
  1. ;
  1. ;Input : DFN - Pointer to entry in PATIENT file (#2)
  1. ; OUTARR - Array to store output in (full global reference)
  1. ; Defaults to ^TMP("SCDX",$J)
  1. ;Output : X - Number of entries in TRANSMITTED OUTPATIENT ENCOUNTER
  1. ; file (#409.73) that were found
  1. ; If entries are found, OUTARR() will be in the format
  1. ; OUTARR(DFN,XMITPTR) = ""
  1. ; Where XMITPTR = Pointer to entry in TRANSMITTED OUTPATIENT
  1. ; ENCOUNTER file (#409.73)
  1. ;Notes : It is the responsibility of the calling program to
  1. ; initialize (ie KILL) the output array
  1. ;
  1. ;Check input
  1. S DFN=+$G(DFN)
  1. Q:('$D(^DPT(DFN,0))) 0
  1. S OUTARR=$G(OUTARR)
  1. S:(OUTARR="") OUTARR="^TMP(""SCDX"","_$J_")"
  1. ;Declare variables
  1. N ENCPTR,DELPTR,XMITPTR,COUNT
  1. S COUNT=0
  1. ;Find all entries in the OUTPATIENT ENCOUNTER file (#409.68) that
  1. ;pertain to the given patient
  1. S ENCPTR=""
  1. F S ENCPTR=+$O(^SCE("C",DFN,ENCPTR)) Q:('ENCPTR) D
  1. .;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file
  1. .S XMITPTR=+$O(^SD(409.73,"AENC",ENCPTR,0))
  1. .Q:('XMITPTR)
  1. .;Store pointer in output array an increment counter
  1. .S @OUTARR@(DFN,XMITPTR)=""
  1. .S COUNT=COUNT+1
  1. ;Find all entries in DELETED OUTPATIENT ENCOUNTER file (#409.74) that
  1. ;pertain to the given patient
  1. S DELPTR=""
  1. F S DELPTR=+$O(^SD(409.74,"PAT",DFN,DELPTR)) Q:('DELPTR) D
  1. .;Find entry in TRANSMITTED OUTPATIENT ENCOUNTER file
  1. .S XMITPTR=+$O(^SD(409.73,"ADEL",DELPTR,0))
  1. .Q:('XMITPTR)
  1. .;Store pointer in output array an increment counter
  1. .S @OUTARR@(DFN,XMITPTR)=""
  1. .S COUNT=COUNT+1
  1. Q COUNT