SDWLRPS2 ;;IOFO BAY PINES/TEH - WAIT LIST REPORT FORMAT 1-SUMMARY;06/12/2002 ; 20 Aug 2002 2:10 PM
;;5.3;scheduling;**263,412**;AUG 13 1993
;
;
;******************************************************************
; CHANGE LOG
;
; DATE PATCH DESCRIPTION
; ---- ----- -----------
;
;
;
;
EN ;
D INIT
I $$S^%ZTLOAD G END
D HD
D SORT
I $$S^%ZTLOAD G END
D PRT G:POP END ;SD*5.3*412 added for early exit
I $$S^%ZTLOAD G END
D PRT1
K ^TMP("SDWLRPS2",$J)
Q
INIT ;Initialize variables
;
I $D(CT1) S SDWLCT1=CT1
I $D(CT2) S SDWLCT2=CT2
I $D(DATE) S SDWLDATE=DATE
I $D(FORM) S SDWLFORM=FORM
I $D(INS) S (SDWLINS,SDWLINST)=INS
I $D(OPEN) S SDWLOPEN=OPEN
S SDWLPG=0
I $D(ZTSAVE) D
.F SDWLI="CT1","CT2","FORM","INS","OPEN" S SDWL="SDWL"_SDWLI,@SDWL=$G(ZTSAVE(SDWLI))
I SDWLINS="ALL" S SDWLIN("ALL")=""
S SDWLINST=SDWLINS
S SDWLTXP=$P(SDWLCT1,U,3)
I SDWLINS'="ALL" F SDWLI=1:1 S SDWLIN=$P($P(SDWLINS,";",SDWLI),U,1) Q:SDWLIN="" S SDWLIN(SDWLIN)="",^TMP("SDWLRPS2",$J,"D",1,SDWLIN)=0,^TMP("SDWLRPS2",$J,"D",2,SDWLIN)=0
I SDWLCT2'="ALL" F SDWLI=1:1 S SDWLCL=$P($P(SDWLCT2,";",SDWLI),U,1) Q:SDWLCL="" S SDWLCT2(SDWLCL)=""
S SDWLSCX=$S($P(SDWLCT1,U,1)="T":5,1:6)
D NOW^%DTC S Y=% D DD^%DT S SDWLDTP=Y
N POP S POP=0 ;SD*5.3*412
Q
SORT ;Sort Records
S SDWLCNT=0
S SDWLDA=0 F S SDWLDA=$O(^SDWL(409.3,SDWLDA)) Q:SDWLDA<1 D
.S SDWLX=$G(^SDWL(409.3,SDWLDA,0)),SDWLERR=0,SDWLDFN=+SDWLX
.;-Check for Institution Sort
.I SDWLINS'="ALL" D
..I '$D(SDWLIN(+$P(SDWLX,U,3))) S SDWLERR=1 Q
.S SDWLAPDT=$P(SDWLX,U,16),SDWLOPDT=$P(SDWLX,U,2) S X1=DT,X2=SDWLOPDT D ^%DTC S SDWLDWT=+X I SDWLDWT<0 S SDWLDWT=0
.S SDWLTYP=$P(SDWLCT1,U,1),SDWLTYPE=$S(SDWLTYP="T":$P(SDWLX,U,6),1:$P(SDWLX,U,7)) I SDWLTYPE="" S SDWLERR=7 Q
.S SDWLF=$P(SDWLCT1,U,2)
.I SDWLCT2'="ALL" D
..I '$D(SDWLCT2(SDWLTYPE)) S SDWLERR=3
.I SDWLTYP="" S SDWLERR=4 Q
.I $P(SDWLX,U,17)'[SDWLOPEN S SDWLERR=6 Q
.Q:SDWLERR D
..S SDWLSCC=2 D ELIG^VADPT I $D(VAEL(3)) S SDWLSCN=$P(VAEL(3),U,2) I SDWLSCN>49 S SDWLSCC=1
..S:'$D(^TMP("SDWLRPS2",$J,"A",+$P(SDWLX,U,3),SDWLTYPE)) ^(SDWLTYPE)=0
..S ^TMP("SDWLRPS2",$J,"A",+$P(SDWLX,U,3),SDWLTYPE)=^(SDWLTYPE)+1
..S:'$D(^TMP("SDWLRPS2",$J,"B",+$P(SDWLX,U,3),SDWLTYPE,SDWLDFN)) ^(SDWLDFN)=0 S ^TMP("SDWLRPS2",$J,"B",+$P(SDWLX,U,3),SDWLTYPE,SDWLDFN)=^(SDWLDFN)+1
..S:'$D(^TMP("SDWLRPS2",$J,"C",SDWLSCC,+$P(SDWLX,U,3),SDWLTYPE)) ^TMP("SDWLRPS2",$J,"C",SDWLSCC,+$P(SDWLX,U,3),SDWLTYPE)=0
..S ^TMP("SDWLRPS2",$J,"C",SDWLSCC,+$P(SDWLX,U,3),SDWLTYPE)=^(SDWLTYPE)+1
..S ^TMP("SDWLRPS2",$J,"D",SDWLSCC,+$P(SDWLX,U,3),SDWLTYPE,99999999-SDWLDWT,SDWLDA)=""
..S SDWLCNT=SDWLCNT+1,^TMP("SDWLRPS2",$J,"D",SDWLSCC,+$P(SDWLX,U,3))=SDWLCNT
Q
PRT ;
S SDWLIN=0 F S SDWLIN=$O(^TMP("SDWLRPS2",$J,"A",SDWLIN)) Q:SDWLIN="" W !,"Institution: ",$$GET1^DIQ(4,SDWLIN_",",".01"),! D Q:POP ;SD*5.3*412
.D PRA
Q
PRA ;
S SDWLSC=0,(SDWLX,SDWLXT)=0 F S SDWLSC=$O(^TMP("SDWLRPS2",$J,"A",SDWLIN,SDWLSC)) Q:SDWLSC="" D Q:POP ;SD*5.3*412 added Quit to Exit
.I '$D(SDWLSCX) S SDWLSCX=0
.S SDWLX=$G(^TMP("SDWLRPS2",$J,"A",SDWLIN,SDWLSC)),SDWLXT=SDWLXT+SDWLX W !,$$EXTERNAL^DILFD(409.3,SDWLSCX,,SDWLSC),?30,SDWLX
.S SDWLXTT=0,SDWLDFNX=0 F S SDWLDFNX=$O(^TMP("SDWLRPS2",$J,"B",SDWLIN,SDWLSC,SDWLDFNX)) Q:SDWLDFNX="" S SDWLXTT=SDWLXTT+1
W !,?21,"Total #: ",SDWLXT
I $D(SDWLSPT) D SCR Q:POP D HD,HD1 ;SD*5.3*412 added Quit
Q
PRT1 ;
N DFN
S SDWLSCC=0 F S SDWLSCC=$O(^TMP("SDWLRPS2",$J,"D",SDWLSCC)) Q:SDWLSCC="" Q:$$S^%ZTLOAD D Q:POP ;SD*5.3*412 added Quit for early exit
.W !,"******* ",SDWLSCC," *******",!
.S SDWLINS=0 F S SDWLINS=$O(^TMP("SDWLRPS2",$J,"D",SDWLSCC,SDWLINS)) Q:SDWLINS="" D Q:POP W ! ;SD*5.3*412 added Quit
..W !,$P($G(^DIC(4,SDWLINS,0)),U,1),! I '$G(^TMP("SDWLRPS2",$J,"D",SDWLSCC,SDWLINS)) W !,"*** No Patient Records to Report ***" D:$D(SDWLSPT) SCR Q:POP D HD,HD1 Q ;SD*5.3*412 added first Quit
..S SDWLSC=0 F S SDWLSC=$O(^TMP("SDWLRPS2",$J,"D",SDWLSCC,SDWLINS,SDWLSC)) Q:SDWLSC="" D Q:POP ;SD*5.3*412 added Quit
...S SDWLWT="" F S SDWLWT=$O(^TMP("SDWLRPS2",$J,"D",SDWLSCC,SDWLINS,SDWLSC,SDWLWT)) Q:SDWLWT="" D Q:POP ;SD*5.3*412 added Quit
....S SDWLDA=0 F S SDWLDA=$O(^TMP("SDWLRPS2",$J,"D",SDWLSCC,SDWLINS,SDWLSC,SDWLWT,SDWLDA)) Q:SDWLDA="" D Q:POP ;SD*5.3*412 added Quit
.....S X=$G(^SDWL(409.3,SDWLDA,0)),SDWLODT=$P(X,U,2),SDWLDDT=$P(X,U,16) S DFN=+X D Q:POP ;SD*5.3*412 added Quit
......D DEM^VADPT,1^VADPT
......W !,VA("BID"),?6,$E(VADM(1),1,25) W ?32,$E(SDWLODT,4,5),"/",$E(SDWLODT,6,7),"/",($E(SDWLODT,1,3)+1700)
......W ?47,$J(99999999-SDWLWT,5)
......D:$D(SDWLSPT) SCR Q:POP D HD,HD1 ;SD*5.3*412 added Quit
.W !
LINE ;Draw Line
W !,"_______________________________________________________________________________"
Q
SCR W ! S DIR(0)="E" D ^DIR S:X="^" POP=1 ; SD*5.3*412
Q
HD ;Header
W:$D(IOF) @IOF W !,SDWLDTP,?80-$L("PCMM ASSIGNMENT Wait List Report")\2,"PCMM ASSIGNMENT Wait List Report"
S SDWLPG=SDWLPG+1 W ?72,"Page: ",SDWLPG
W !!,?30,"Institution: " D
.F I=1:1 S X=$P(SDWLINST,";",I) Q:X="" W:I>1 ! W ?45,$$GET1^DIQ(4,X_",",".01")
S X=$P(SDWLCT2,U,2)
W !?27,"Report Category: ",$S($P(SDWLCT1,U,1)="T":"TEAM",1:"POSITION") I X="ALL" W " ALL"
I X'="ALL" D
.F I=1:1 S X=$P($P(SDWLCT2,";",I),"^",2) Q:X="" W !,?45,X
S X=$G(SDWLOPEN) W !,?36,"Status: ",$S(SDWLOPEN="O":"Open",1:"All")
S X=$G(SDWLFORM) W !,?28,"Output Format: ",$S(SDWLFORM="S":"Summary",1:"Detailed")
Q
HD1 ;
W !!,"Name",?30,"Date Entered",?45,"# of Days Waiting",!!
Q
END K X1,X2,CT1,CT2,DATE,I,INS,OPEN,FORM
K ^TMP("SDWLRPS2",$J)
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDWLRPS2 5800 printed Dec 13, 2024@03:03:18 Page 2
SDWLRPS2 ;;IOFO BAY PINES/TEH - WAIT LIST REPORT FORMAT 1-SUMMARY;06/12/2002 ; 20 Aug 2002 2:10 PM
+1 ;;5.3;scheduling;**263,412**;AUG 13 1993
+2 ;
+3 ;
+4 ;******************************************************************
+5 ; CHANGE LOG
+6 ;
+7 ; DATE PATCH DESCRIPTION
+8 ; ---- ----- -----------
+9 ;
+10 ;
+11 ;
+12 ;
EN ;
+1 DO INIT
+2 IF $$S^%ZTLOAD
GOTO END
+3 DO HD
+4 DO SORT
+5 IF $$S^%ZTLOAD
GOTO END
+6 ;SD*5.3*412 added for early exit
DO PRT
if POP
GOTO END
+7 IF $$S^%ZTLOAD
GOTO END
+8 DO PRT1
+9 KILL ^TMP("SDWLRPS2",$JOB)
+10 QUIT
INIT ;Initialize variables
+1 ;
+2 IF $DATA(CT1)
SET SDWLCT1=CT1
+3 IF $DATA(CT2)
SET SDWLCT2=CT2
+4 IF $DATA(DATE)
SET SDWLDATE=DATE
+5 IF $DATA(FORM)
SET SDWLFORM=FORM
+6 IF $DATA(INS)
SET (SDWLINS,SDWLINST)=INS
+7 IF $DATA(OPEN)
SET SDWLOPEN=OPEN
+8 SET SDWLPG=0
+9 IF $DATA(ZTSAVE)
Begin DoDot:1
+10 FOR SDWLI="CT1","CT2","FORM","INS","OPEN"
SET SDWL="SDWL"_SDWLI
SET @SDWL=$GET(ZTSAVE(SDWLI))
End DoDot:1
+11 IF SDWLINS="ALL"
SET SDWLIN("ALL")=""
+12 SET SDWLINST=SDWLINS
+13 SET SDWLTXP=$PIECE(SDWLCT1,U,3)
+14 IF SDWLINS'="ALL"
FOR SDWLI=1:1
SET SDWLIN=$PIECE($PIECE(SDWLINS,";",SDWLI),U,1)
if SDWLIN=""
QUIT
SET SDWLIN(SDWLIN)=""
SET ^TMP("SDWLRPS2",$JOB,"D",1,SDWLIN)=0
SET ^TMP("SDWLRPS2",$JOB,"D",2,SDWLIN)=0
+15 IF SDWLCT2'="ALL"
FOR SDWLI=1:1
SET SDWLCL=$PIECE($PIECE(SDWLCT2,";",SDWLI),U,1)
if SDWLCL=""
QUIT
SET SDWLCT2(SDWLCL)=""
+16 SET SDWLSCX=$SELECT($PIECE(SDWLCT1,U,1)="T":5,1:6)
+17 DO NOW^%DTC
SET Y=%
DO DD^%DT
SET SDWLDTP=Y
+18 ;SD*5.3*412
NEW POP
SET POP=0
+19 QUIT
SORT ;Sort Records
+1 SET SDWLCNT=0
+2 SET SDWLDA=0
FOR
SET SDWLDA=$ORDER(^SDWL(409.3,SDWLDA))
if SDWLDA<1
QUIT
Begin DoDot:1
+3 SET SDWLX=$GET(^SDWL(409.3,SDWLDA,0))
SET SDWLERR=0
SET SDWLDFN=+SDWLX
+4 ;-Check for Institution Sort
+5 IF SDWLINS'="ALL"
Begin DoDot:2
+6 IF '$DATA(SDWLIN(+$PIECE(SDWLX,U,3)))
SET SDWLERR=1
QUIT
End DoDot:2
+7 SET SDWLAPDT=$PIECE(SDWLX,U,16)
SET SDWLOPDT=$PIECE(SDWLX,U,2)
SET X1=DT
SET X2=SDWLOPDT
DO ^%DTC
SET SDWLDWT=+X
IF SDWLDWT<0
SET SDWLDWT=0
+8 SET SDWLTYP=$PIECE(SDWLCT1,U,1)
SET SDWLTYPE=$SELECT(SDWLTYP="T":$PIECE(SDWLX,U,6),1:$PIECE(SDWLX,U,7))
IF SDWLTYPE=""
SET SDWLERR=7
QUIT
+9 SET SDWLF=$PIECE(SDWLCT1,U,2)
+10 IF SDWLCT2'="ALL"
Begin DoDot:2
+11 IF '$DATA(SDWLCT2(SDWLTYPE))
SET SDWLERR=3
End DoDot:2
+12 IF SDWLTYP=""
SET SDWLERR=4
QUIT
+13 IF $PIECE(SDWLX,U,17)'[SDWLOPEN
SET SDWLERR=6
QUIT
+14 if SDWLERR
QUIT
Begin DoDot:2
+15 SET SDWLSCC=2
DO ELIG^VADPT
IF $DATA(VAEL(3))
SET SDWLSCN=$PIECE(VAEL(3),U,2)
IF SDWLSCN>49
SET SDWLSCC=1
+16 if '$DATA(^TMP("SDWLRPS2",$JOB,"A",+$PIECE(SDWLX,U,3),SDWLTYPE))
SET ^(SDWLTYPE)=0
+17 SET ^TMP("SDWLRPS2",$JOB,"A",+$PIECE(SDWLX,U,3),SDWLTYPE)=^(SDWLTYPE)+1
+18 if '$DATA(^TMP("SDWLRPS2",$JOB,"B",+$PIECE(SDWLX,U,3),SDWLTYPE,SDWLDFN))
SET ^(SDWLDFN)=0
SET ^TMP("SDWLRPS2",$JOB,"B",+$PIECE(SDWLX,U,3),SDWLTYPE,SDWLDFN)=^(SDWLDFN)+1
+19 if '$DATA(^TMP("SDWLRPS2",$JOB,"C",SDWLSCC,+$PIECE(SDWLX,U,3),SDWLTYPE))
SET ^TMP("SDWLRPS2",$JOB,"C",SDWLSCC,+$PIECE(SDWLX,U,3),SDWLTYPE)=0
+20 SET ^TMP("SDWLRPS2",$JOB,"C",SDWLSCC,+$PIECE(SDWLX,U,3),SDWLTYPE)=^(SDWLTYPE)+1
+21 SET ^TMP("SDWLRPS2",$JOB,"D",SDWLSCC,+$PIECE(SDWLX,U,3),SDWLTYPE,99999999-SDWLDWT,SDWLDA)=""
+22 SET SDWLCNT=SDWLCNT+1
SET ^TMP("SDWLRPS2",$JOB,"D",SDWLSCC,+$PIECE(SDWLX,U,3))=SDWLCNT
End DoDot:2
End DoDot:1
+23 QUIT
PRT ;
+1 ;SD*5.3*412
SET SDWLIN=0
FOR
SET SDWLIN=$ORDER(^TMP("SDWLRPS2",$JOB,"A",SDWLIN))
if SDWLIN=""
QUIT
WRITE !,"Institution: ",$$GET1^DIQ(4,SDWLIN_",",".01"),!
Begin DoDot:1
+2 DO PRA
End DoDot:1
if POP
QUIT
+3 QUIT
PRA ;
+1 ;SD*5.3*412 added Quit to Exit
SET SDWLSC=0
SET (SDWLX,SDWLXT)=0
FOR
SET SDWLSC=$ORDER(^TMP("SDWLRPS2",$JOB,"A",SDWLIN,SDWLSC))
if SDWLSC=""
QUIT
Begin DoDot:1
+2 IF '$DATA(SDWLSCX)
SET SDWLSCX=0
+3 SET SDWLX=$GET(^TMP("SDWLRPS2",$JOB,"A",SDWLIN,SDWLSC))
SET SDWLXT=SDWLXT+SDWLX
WRITE !,$$EXTERNAL^DILFD(409.3,SDWLSCX,,SDWLSC),?30,SDWLX
+4 SET SDWLXTT=0
SET SDWLDFNX=0
FOR
SET SDWLDFNX=$ORDER(^TMP("SDWLRPS2",$JOB,"B",SDWLIN,SDWLSC,SDWLDFNX))
if SDWLDFNX=""
QUIT
SET SDWLXTT=SDWLXTT+1
End DoDot:1
if POP
QUIT
+5 WRITE !,?21,"Total #: ",SDWLXT
+6 ;SD*5.3*412 added Quit
IF $DATA(SDWLSPT)
DO SCR
if POP
QUIT
DO HD
DO HD1
+7 QUIT
PRT1 ;
+1 NEW DFN
+2 ;SD*5.3*412 added Quit for early exit
SET SDWLSCC=0
FOR
SET SDWLSCC=$ORDER(^TMP("SDWLRPS2",$JOB,"D",SDWLSCC))
if SDWLSCC=""
QUIT
if $$S^%ZTLOAD
QUIT
Begin DoDot:1
+3 WRITE !,"******* ",SDWLSCC," *******",!
+4 ;SD*5.3*412 added Quit
SET SDWLINS=0
FOR
SET SDWLINS=$ORDER(^TMP("SDWLRPS2",$JOB,"D",SDWLSCC,SDWLINS))
if SDWLINS=""
QUIT
Begin DoDot:2
+5 ;SD*5.3*412 added first Quit
WRITE !,$PIECE($GET(^DIC(4,SDWLINS,0)),U,1),!
IF '$GET(^TMP("SDWLRPS2",$JOB,"D",SDWLSCC,SDWLINS))
WRITE !,"*** No Patient Records to Report ***"
if $DATA(SDWLSPT)
DO SCR
if POP
QUIT
DO HD
DO HD1
QUIT
+6 ;SD*5.3*412 added Quit
SET SDWLSC=0
FOR
SET SDWLSC=$ORDER(^TMP("SDWLRPS2",$JOB,"D",SDWLSCC,SDWLINS,SDWLSC))
if SDWLSC=""
QUIT
Begin DoDot:3
+7 ;SD*5.3*412 added Quit
SET SDWLWT=""
FOR
SET SDWLWT=$ORDER(^TMP("SDWLRPS2",$JOB,"D",SDWLSCC,SDWLINS,SDWLSC,SDWLWT))
if SDWLWT=""
QUIT
Begin DoDot:4
+8 ;SD*5.3*412 added Quit
SET SDWLDA=0
FOR
SET SDWLDA=$ORDER(^TMP("SDWLRPS2",$JOB,"D",SDWLSCC,SDWLINS,SDWLSC,SDWLWT,SDWLDA))
if SDWLDA=""
QUIT
Begin DoDot:5
+9 ;SD*5.3*412 added Quit
SET X=$GET(^SDWL(409.3,SDWLDA,0))
SET SDWLODT=$PIECE(X,U,2)
SET SDWLDDT=$PIECE(X,U,16)
SET DFN=+X
Begin DoDot:6
+10 DO DEM^VADPT
DO 1^VADPT
+11 WRITE !,VA("BID"),?6,$EXTRACT(VADM(1),1,25)
WRITE ?32,$EXTRACT(SDWLODT,4,5),"/",$EXTRACT(SDWLODT,6,7),"/",($EXTRACT(SDWLODT,1,3)+1700)
+12 WRITE ?47,$JUSTIFY(99999999-SDWLWT,5)
+13 ;SD*5.3*412 added Quit
if $DATA(SDWLSPT)
DO SCR
if POP
QUIT
DO HD
DO HD1
End DoDot:6
if POP
QUIT
End DoDot:5
if POP
QUIT
End DoDot:4
if POP
QUIT
End DoDot:3
if POP
QUIT
End DoDot:2
if POP
QUIT
WRITE !
+14 WRITE !
End DoDot:1
if POP
QUIT
LINE ;Draw Line
+1 WRITE !,"_______________________________________________________________________________"
+2 QUIT
SCR ; SD*5.3*412
WRITE !
SET DIR(0)="E"
DO ^DIR
if X="^"
SET POP=1
+1 QUIT
HD ;Header
+1 if $DATA(IOF)
WRITE @IOF
WRITE !,SDWLDTP,?80-$LENGTH("PCMM ASSIGNMENT Wait List Report")\2,"PCMM ASSIGNMENT Wait List Report"
+2 SET SDWLPG=SDWLPG+1
WRITE ?72,"Page: ",SDWLPG
+3 WRITE !!,?30,"Institution: "
Begin DoDot:1
+4 FOR I=1:1
SET X=$PIECE(SDWLINST,";",I)
if X=""
QUIT
if I>1
WRITE !
WRITE ?45,$$GET1^DIQ(4,X_",",".01")
End DoDot:1
+5 SET X=$PIECE(SDWLCT2,U,2)
+6 WRITE !?27,"Report Category: ",$SELECT($PIECE(SDWLCT1,U,1)="T":"TEAM",1:"POSITION")
IF X="ALL"
WRITE " ALL"
+7 IF X'="ALL"
Begin DoDot:1
+8 FOR I=1:1
SET X=$PIECE($PIECE(SDWLCT2,";",I),"^",2)
if X=""
QUIT
WRITE !,?45,X
End DoDot:1
+9 SET X=$GET(SDWLOPEN)
WRITE !,?36,"Status: ",$SELECT(SDWLOPEN="O":"Open",1:"All")
+10 SET X=$GET(SDWLFORM)
WRITE !,?28,"Output Format: ",$SELECT(SDWLFORM="S":"Summary",1:"Detailed")
+11 QUIT
HD1 ;
+1 WRITE !!,"Name",?30,"Date Entered",?45,"# of Days Waiting",!!
+2 QUIT
END KILL X1,X2,CT1,CT2,DATE,I,INS,OPEN,FORM
+1 KILL ^TMP("SDWLRPS2",$JOB)
+2 QUIT