ONCOU0A ;WISC/MLH - ONCOLOGY PATIENT FILE UTILITIES - Fix follow ups for expired patients ;6/21/93 09:18
;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
;
FIXFOR(ONCOWRT) ; correct erroneous 'foreign resident' status for exp pats
; ONCOWRT defined if output desired
N ONCOLVL S ONCOLVL="^TMP(""ONCOFIXFOR"","_$$INITSYA_")" ; level of ^TMP for SYA
N ONCOKP,ONCOKF,ONCOKC S (ONCOKP,ONCOKF,ONCOKC)=0 ; counts
N ONCOPI S ONCOPI=0 ; patient file index
FOR ONCOKP=0:1 S ONCOPI=$O(^ONCO(160,ONCOPI)) Q:ONCOPI'=+ONCOPI D
. N ONCOFI S ONCOFI=0 ; follow-up sub-file index
. FOR S ONCOFI=$O(^ONCO(160,ONCOPI,"F",ONCOFI)) Q:ONCOFI'=+ONCOFI S ONCOKF=ONCOKF+1,ONCOKC=ONCOKC+$$CHKSTAT(ONCOPI,ONCOFI,ONCOLVL,ONCOWRT)
. Q
;END FOR
;
N ONCORES S ONCORES=ONCOKP_U_ONCOKF_U_ONCOKC ; results array
I $D(ONCOWRT) D WRT(ONCORES)
QUIT
;
INITSYA() ; find level of ^TMP on which to put SYA and initialize
N ONCOI S ONCOI=$P($G(^TMP("ONCOFIXFOR",0)),U,3)+1,$P(^(0),U,3)=ONCOI
Q ONCOI
;
CHKSTAT(ONCOP,ONCOF,ONCOLVL,ONCOWRT) ; look at follow-up record for patient ONCOP, follow-up ONCOF
; if we need to change and ONCOLVL defined, back up on ^TMP("ONCOFIXFOR",ONCOLVL)
; ONCOWRT is defined if we want dots for the user
N ONCOX S ONCOX=$G(^ONCO(160,ONCOP,"F",ONCOF,0)) ; onco pat rec
N ONCOCHG S ONCOCHG=0 ; change flag
IF $P(ONCOX,U,2)=0,$P(ONCOX,U,6)=8 D ; exp pat, foreign resident --> hit!
. S ONCOSYA=$P($G(@ONCOLVL@(0)),U,3)+1,$P(@ONCOLVL@(0),U,3)=ONCOSYA,@ONCOLVL@(ONCOSYA,0)=ONCOP_":"_ONCOF_":"_ONCOX ; save old data
. ;
. ; correct follow-up method
. N DIE,DA S DIE="^ONCO(160,"_ONCOP_",""F"",",DA(1)=ONCOP,DA=ONCOF,DR="6///9"
. D ^DIE
. ;
. I $D(ONCOWRT),$R(40)=0 W "."
. S ONCOCHG=1
. Q
;END IF
;
Q ONCOCHG
;
WRT(ONCORES) ; output results array
N ONCOI F ONCOI=1:1:3 S ONCORES(ONCOI)=$P(ONCORES,U,ONCOI)
W !!,"Oncology patients processed: ",?35,$J(ONCORES(1),6),!,"Follow-ups processed: ",?35,$J(ONCORES(2),6),!,"Follow-ups corrected: ",?35,$J(ONCORES(3),6),!!
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HONCOU0A 2094 printed Nov 22, 2024@17:36:08 Page 2
ONCOU0A ;WISC/MLH - ONCOLOGY PATIENT FILE UTILITIES - Fix follow ups for expired patients ;6/21/93 09:18
+1 ;;2.2;ONCOLOGY;**1**;Jul 31, 2013;Build 8
+2 ;
FIXFOR(ONCOWRT) ; correct erroneous 'foreign resident' status for exp pats
+1 ; ONCOWRT defined if output desired
+2 ; level of ^TMP for SYA
NEW ONCOLVL
SET ONCOLVL="^TMP(""ONCOFIXFOR"","_$$INITSYA_")"
+3 ; counts
NEW ONCOKP,ONCOKF,ONCOKC
SET (ONCOKP,ONCOKF,ONCOKC)=0
+4 ; patient file index
NEW ONCOPI
SET ONCOPI=0
+5 FOR ONCOKP=0:1
SET ONCOPI=$ORDER(^ONCO(160,ONCOPI))
if ONCOPI'=+ONCOPI
QUIT
Begin DoDot:1
+6 ; follow-up sub-file index
NEW ONCOFI
SET ONCOFI=0
+7 FOR
SET ONCOFI=$ORDER(^ONCO(160,ONCOPI,"F",ONCOFI))
if ONCOFI'=+ONCOFI
QUIT
SET ONCOKF=ONCOKF+1
SET ONCOKC=ONCOKC+$$CHKSTAT(ONCOPI,ONCOFI,ONCOLVL,ONCOWRT)
+8 QUIT
End DoDot:1
+9 ;END FOR
+10 ;
+11 ; results array
NEW ONCORES
SET ONCORES=ONCOKP_U_ONCOKF_U_ONCOKC
+12 IF $DATA(ONCOWRT)
DO WRT(ONCORES)
+13 QUIT
+14 ;
INITSYA() ; find level of ^TMP on which to put SYA and initialize
+1 NEW ONCOI
SET ONCOI=$PIECE($GET(^TMP("ONCOFIXFOR",0)),U,3)+1
SET $PIECE(^(0),U,3)=ONCOI
+2 QUIT ONCOI
+3 ;
CHKSTAT(ONCOP,ONCOF,ONCOLVL,ONCOWRT) ; look at follow-up record for patient ONCOP, follow-up ONCOF
+1 ; if we need to change and ONCOLVL defined, back up on ^TMP("ONCOFIXFOR",ONCOLVL)
+2 ; ONCOWRT is defined if we want dots for the user
+3 ; onco pat rec
NEW ONCOX
SET ONCOX=$GET(^ONCO(160,ONCOP,"F",ONCOF,0))
+4 ; change flag
NEW ONCOCHG
SET ONCOCHG=0
+5 ; exp pat, foreign resident --> hit!
IF $PIECE(ONCOX,U,2)=0
IF $PIECE(ONCOX,U,6)=8
Begin DoDot:1
+6 ; save old data
SET ONCOSYA=$PIECE($GET(@ONCOLVL@(0)),U,3)+1
SET $PIECE(@ONCOLVL@(0),U,3)=ONCOSYA
SET @ONCOLVL@(ONCOSYA,0)=ONCOP_":"_ONCOF_":"_ONCOX
+7 ;
+8 ; correct follow-up method
+9 NEW DIE,DA
SET DIE="^ONCO(160,"_ONCOP_",""F"","
SET DA(1)=ONCOP
SET DA=ONCOF
SET DR="6///9"
+10 DO ^DIE
+11 ;
+12 IF $DATA(ONCOWRT)
IF $RANDOM(40)=0
WRITE "."
+13 SET ONCOCHG=1
+14 QUIT
End DoDot:1
+15 ;END IF
+16 ;
+17 QUIT ONCOCHG
+18 ;
WRT(ONCORES) ; output results array
+1 NEW ONCOI
FOR ONCOI=1:1:3
SET ONCORES(ONCOI)=$PIECE(ONCORES,U,ONCOI)
+2 WRITE !!,"Oncology patients processed: ",?35,$JUSTIFY(ONCORES(1),6),!,"Follow-ups processed: ",?35,$JUSTIFY(ONCORES(2),6),!,"Follow-ups corrected: ",?35,$JUSTIFY(ONCORES(3),6),!!
+3 QUIT