SDWLROS ;IOFO BAY PINES/TEH - WAIT LIST OVERDUE REPORT-SUMMARY ;1/5/16 9:25am
;;5.3;scheduling;**263,414,645**;AUG 13 1993;Build 7
;
;
;******************************************************************
; CHANGE LOG
;
; DATE PATCH DESCRIPTION
; ---- ----- -----------
;
;
;
;
EN ;
D INIT
I $$S^%ZTLOAD G END
D HD
D SORT
I $$S^%ZTLOAD G END
D PRT
I $$S^%ZTLOAD G END
D PRT1
K ^TMP("SDWLROS",$J)
Q
INIT ;Initialize variables
;
I $D(CT1) S SDWLCT1=CT1
I $D(CT2) S SDWLCT2=CT2
I $D(FORM) S SDWLFORM=FORM
I $D(INS) S SDWLINS=INS
S SDWLPG=0
I $D(ZTSAVE) D
.F SDWLI="CT1","CT2","FORM","INS" S SDWL="SDWL"_SDWLI,@SDWL=$G(ZTSAVE(SDWLI))
I SDWLINS="ALL" S SDWLIN("ALL")=""
S SDWLTXP=$P(SDWLCT1,U,3),SDWLF=$P(SDWLCT1,U,2)
I SDWLINS'="ALL" F SDWLI=1:1 S SDWLIN=$P($P(SDWLINS,";",SDWLI),U,1) Q:SDWLIN="" S SDWLIN(SDWLIN)=""
I SDWLCT2'="ALL" F SDWLI=1:1 S SDWLCL=$P($P(SDWLCT2,";",SDWLI),U,1) Q:SDWLCL="" S SDWLCT2(SDWLCL)=""
D NOW^%DTC S Y=% D DD^%DT S SDWLDTP=Y
Q
SORT ;Sort Records
K ^TMP("SDWLROS",$J)
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 I 'SDWLDFN Q
.;-Check for Institution Sort
.I SDWLINS'="ALL" D
..I '$D(SDWLIN(+$P(SDWLX,U,3))) S SDWLERR=1 Q
.I $P(SDWLX,U,16)'<DT,$P(SDWLX,U,16)'=DT S SDWLERR=2
.S SDWLAPDT=$P(SDWLX,U,16),SDWLOPDT=$P(SDWLX,U,2) S X1=DT,X2=SDWLAPDT D ^%DTC S SDWLDWT=+X
.S SDWLTYP=$P(SDWLCT1,U,1),SDWLTYPE=$S(SDWLTYP="C":+$P(SDWLX,U,9),1:+$P(SDWLX,U,8)) I SDWLTYPE=""!('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)["C" S SDWLERR=6 Q
.Q:SDWLERR D
..S SDWLSCC=2,DFN=SDWLDFN D ELIG^VADPT I $D(VAEL(3)) S SDWLSCN=$P(VAEL(3),U,2) I SDWLSCN>49 S SDWLSCC=1
..S:'$D(^TMP("SDWLROS",$J,"A",+$P(SDWLX,U,3),SDWLTYPE)) ^(SDWLTYPE)=0
..S ^TMP("SDWLROS",$J,"A",+$P(SDWLX,U,3),SDWLTYPE)=^(SDWLTYPE)+1
..S:'$D(^TMP("SDWLROS",$J,"B",+$P(SDWLX,U,3),SDWLTYPE,SDWLDFN)) ^(SDWLDFN)=0 S ^TMP("SDWLROS",$J,"B",+$P(SDWLX,U,3),SDWLTYPE,SDWLDFN)=^(SDWLDFN)+1
..S:'$D(^TMP("SDWLROS",$J,"C",SDWLSCC,+$P(SDWLX,U,3),SDWLTYPE)) ^TMP("SDWLROS",$J,"C",SDWLSCC,+$P(SDWLX,U,3),SDWLTYPE)=0
..S ^TMP("SDWLROS",$J,"C",SDWLSCC,+$P(SDWLX,U,3),SDWLTYPE)=^(SDWLTYPE)+1
..S ^TMP("SDWLROS",$J,"D",SDWLSCC,+$P(SDWLX,U,3),SDWLTYPE,SDWLDWT,SDWLDA)=""
Q
PRT ;
S SDWLIN=0 F S SDWLIN=$O(^TMP("SDWLROS",$J,"A",SDWLIN)) Q:SDWLIN="" W !,"Institution: ",$P($G(^DIC(4,SDWLIN,0)),U,1),! D
.D PRA
Q
PRA ;
S SDWLSC=0,(SDWLX,SDWLXT,SDWLXTT)=0 F S SDWLSC=$O(^TMP("SDWLROS",$J,"A",SDWLIN,SDWLSC)) Q:SDWLSC="" D
.S SDWLX=$G(^TMP("SDWLROS",$J,"A",SDWLIN,SDWLSC)),SDWLXT=SDWLXT+SDWLX W !,$$EXTERNAL^DILFD(SDWLF,.01,,$P(^SDWL(SDWLF,SDWLSC,0),U,1)),?30,SDWLX
.S SDWLDFNX=0 F S SDWLDFNX=$O(^TMP("SDWLROS",$J,"B",SDWLIN,SDWLSC,SDWLDFNX)) Q:SDWLDFNX="" S SDWLXTT=SDWLXTT+1
W !,?20,"Total #: ",SDWLXT
;W !,?4,"Total # Unique Patients: ",SDWLXTT,!!
I $D(SDWLSPT),$Y>IOSL S DIR(0)="E" D ^DIR I X="^" Q
Q
PRT1 ;
D HD,HD1
S SDWLSCC=0 F S SDWLSCC=$O(^TMP("SDWLROS",$J,"D",SDWLSCC)) Q:SDWLSCC="" Q:$$S^%ZTLOAD D I $D(DUOUT) Q
.W !,"******* ",SDWLSCC," *******",!
.S SDWLINS=0 F S SDWLINS=$O(^TMP("SDWLROS",$J,"D",SDWLSCC,SDWLINS)) Q:SDWLINS="" D W ! I $D(DUOUT) Q
..W !,$P($G(^DIC(4,SDWLINS,0)),U,1),!
..S SDWLSC=0 F S SDWLSC=$O(^TMP("SDWLROS",$J,"D",SDWLSCC,SDWLINS,SDWLSC)) Q:SDWLSC="" D I $D(DUOUT) Q
...W !,$$EXTERNAL^DILFD(SDWLF,.01,,$P(^SDWL(SDWLF,SDWLSC,0),U,1))
...S SDWLWT="" F S SDWLWT=$O(^TMP("SDWLROS",$J,"D",SDWLSCC,SDWLINS,SDWLSC,SDWLWT)) Q:SDWLWT="" D I $D(DUOUT) Q
....S SDWLDA=0 F S SDWLDA=$O(^TMP("SDWLROS",$J,"D",SDWLSCC,SDWLINS,SDWLSC,SDWLWT,SDWLDA)) Q:SDWLDA="" D I $D(DUOUT) Q
.....S X=$G(^SDWL(409.3,SDWLDA,0)),SDWLODT=$P(X,U,2),SDWLDDT=$P(X,U,16) D
......S DFN=+X D 1^VADPT,DEM^VADPT
......W !,VA("BID"),?6,$E(VADM(1),1,25),?32,$E(SDWLODT,4,5),"/",$E(SDWLODT,6,7),"/",($E(SDWLODT,1,3)+1700)
......W ?47,$E(SDWLDDT,4,5),"/",$E(SDWLDDT,6,7),"/",($E(SDWLDDT,1,3)+1700),?60,$J(SDWLWT,5) K VA,VADM
......I $D(SDWLSPT),$Y>(IOSL+3) S DIR(0)="E" D ^DIR I X="^" S DUOUT=1 Q
......I $Y>(IOSL+3) D HD,HD1
.W !
Q
LINE ;Draw Line
W !,"_______________________________________________________________________________"
Q
HD ;Header
W:$D(IOF) @IOF W !,SDWLDTP,?80-$L("Appointment Wait List Overdue Report")\2,"Appointment Wait List Overdue Report"
S Y=DT D DD^%DT S SDWLPD=Y W ?59,SDWLPD S SDWLPG=SDWLPG+1 W ?72,"Page: ",SDWLPG
W !!,?30,"Institution: " I SDWLINS="ALL" D
.W ?45,SDWLINS
F I=1:1 S X=$P($P(SDWLINS,";",I),"^",2) Q:X="" W:I>1 ! W ?45,X
S X=$P(SDWLCT1,U,1)
W !?27,"Report Category: ",$S($P(SDWLCT1,U,1)="C":"CLINIC",1:"SPECIALTY") I X="ALL" W " ALL"
I X'="ALL" D
.F I=1:1 S X=$P($P(SDWLCT2,";",I),"^",2) Q:X="" W !,?45,$$EXTERNAL^DILFD(SDWLF,.01,,X)
S X=$G(SDWLFORM) W !,?28,"Output Format: ",$S(SDWLFORM="S":"Summary",1:"Detailed")
Q
HD1 ;
; SD*5.3*645 - changed 'Date Desired' to 'CID/PD' due to space limit
;W !!,"Name",?30,"Date Entered",?45,"Date Desired",?60,"# of Days Waiting",!!
W !!,"Name",?30,"Date Entered",?47,"CID/PD",?60,"# of Days Waiting",!!
Q
END K X1,X2,SDWLAPDT,CT,CT1,CT2,I,OPEN,INS,FORM,VADM Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDWLROS 5477 printed Dec 13, 2024@03:03:12 Page 2
SDWLROS ;IOFO BAY PINES/TEH - WAIT LIST OVERDUE REPORT-SUMMARY ;1/5/16 9:25am
+1 ;;5.3;scheduling;**263,414,645**;AUG 13 1993;Build 7
+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 DO PRT
+7 IF $$S^%ZTLOAD
GOTO END
+8 DO PRT1
+9 KILL ^TMP("SDWLROS",$JOB)
+10 QUIT
INIT ;Initialize variables
+1 ;
+2 IF $DATA(CT1)
SET SDWLCT1=CT1
+3 IF $DATA(CT2)
SET SDWLCT2=CT2
+4 IF $DATA(FORM)
SET SDWLFORM=FORM
+5 IF $DATA(INS)
SET SDWLINS=INS
+6 SET SDWLPG=0
+7 IF $DATA(ZTSAVE)
Begin DoDot:1
+8 FOR SDWLI="CT1","CT2","FORM","INS"
SET SDWL="SDWL"_SDWLI
SET @SDWL=$GET(ZTSAVE(SDWLI))
End DoDot:1
+9 IF SDWLINS="ALL"
SET SDWLIN("ALL")=""
+10 SET SDWLTXP=$PIECE(SDWLCT1,U,3)
SET SDWLF=$PIECE(SDWLCT1,U,2)
+11 IF SDWLINS'="ALL"
FOR SDWLI=1:1
SET SDWLIN=$PIECE($PIECE(SDWLINS,";",SDWLI),U,1)
if SDWLIN=""
QUIT
SET SDWLIN(SDWLIN)=""
+12 IF SDWLCT2'="ALL"
FOR SDWLI=1:1
SET SDWLCL=$PIECE($PIECE(SDWLCT2,";",SDWLI),U,1)
if SDWLCL=""
QUIT
SET SDWLCT2(SDWLCL)=""
+13 DO NOW^%DTC
SET Y=%
DO DD^%DT
SET SDWLDTP=Y
+14 QUIT
SORT ;Sort Records
+1 KILL ^TMP("SDWLROS",$JOB)
+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
IF 'SDWLDFN
QUIT
+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 IF $PIECE(SDWLX,U,16)'<DT
IF $PIECE(SDWLX,U,16)'=DT
SET SDWLERR=2
+8 SET SDWLAPDT=$PIECE(SDWLX,U,16)
SET SDWLOPDT=$PIECE(SDWLX,U,2)
SET X1=DT
SET X2=SDWLAPDT
DO ^%DTC
SET SDWLDWT=+X
+9 SET SDWLTYP=$PIECE(SDWLCT1,U,1)
SET SDWLTYPE=$SELECT(SDWLTYP="C":+$PIECE(SDWLX,U,9),1:+$PIECE(SDWLX,U,8))
IF SDWLTYPE=""!('SDWLTYPE)
SET SDWLERR=7
QUIT
+10 SET SDWLF=$PIECE(SDWLCT1,U,2)
+11 IF SDWLCT2'="ALL"
Begin DoDot:2
+12 IF '$DATA(SDWLCT2(SDWLTYPE))
SET SDWLERR=3
End DoDot:2
+13 IF SDWLTYP=""
SET SDWLERR=4
QUIT
+14 IF $PIECE(SDWLX,U,17)["C"
SET SDWLERR=6
QUIT
+15 if SDWLERR
QUIT
Begin DoDot:2
+16 SET SDWLSCC=2
SET DFN=SDWLDFN
DO ELIG^VADPT
IF $DATA(VAEL(3))
SET SDWLSCN=$PIECE(VAEL(3),U,2)
IF SDWLSCN>49
SET SDWLSCC=1
+17 if '$DATA(^TMP("SDWLROS",$JOB,"A",+$PIECE(SDWLX,U,3),SDWLTYPE))
SET ^(SDWLTYPE)=0
+18 SET ^TMP("SDWLROS",$JOB,"A",+$PIECE(SDWLX,U,3),SDWLTYPE)=^(SDWLTYPE)+1
+19 if '$DATA(^TMP("SDWLROS",$JOB,"B",+$PIECE(SDWLX,U,3),SDWLTYPE,SDWLDFN))
SET ^(SDWLDFN)=0
SET ^TMP("SDWLROS",$JOB,"B",+$PIECE(SDWLX,U,3),SDWLTYPE,SDWLDFN)=^(SDWLDFN)+1
+20 if '$DATA(^TMP("SDWLROS",$JOB,"C",SDWLSCC,+$PIECE(SDWLX,U,3),SDWLTYPE))
SET ^TMP("SDWLROS",$JOB,"C",SDWLSCC,+$PIECE(SDWLX,U,3),SDWLTYPE)=0
+21 SET ^TMP("SDWLROS",$JOB,"C",SDWLSCC,+$PIECE(SDWLX,U,3),SDWLTYPE)=^(SDWLTYPE)+1
+22 SET ^TMP("SDWLROS",$JOB,"D",SDWLSCC,+$PIECE(SDWLX,U,3),SDWLTYPE,SDWLDWT,SDWLDA)=""
End DoDot:2
End DoDot:1
+23 QUIT
PRT ;
+1 SET SDWLIN=0
FOR
SET SDWLIN=$ORDER(^TMP("SDWLROS",$JOB,"A",SDWLIN))
if SDWLIN=""
QUIT
WRITE !,"Institution: ",$PIECE($GET(^DIC(4,SDWLIN,0)),U,1),!
Begin DoDot:1
+2 DO PRA
End DoDot:1
+3 QUIT
PRA ;
+1 SET SDWLSC=0
SET (SDWLX,SDWLXT,SDWLXTT)=0
FOR
SET SDWLSC=$ORDER(^TMP("SDWLROS",$JOB,"A",SDWLIN,SDWLSC))
if SDWLSC=""
QUIT
Begin DoDot:1
+2 SET SDWLX=$GET(^TMP("SDWLROS",$JOB,"A",SDWLIN,SDWLSC))
SET SDWLXT=SDWLXT+SDWLX
WRITE !,$$EXTERNAL^DILFD(SDWLF,.01,,$PIECE(^SDWL(SDWLF,SDWLSC,0),U,1)),?30,SDWLX
+3 SET SDWLDFNX=0
FOR
SET SDWLDFNX=$ORDER(^TMP("SDWLROS",$JOB,"B",SDWLIN,SDWLSC,SDWLDFNX))
if SDWLDFNX=""
QUIT
SET SDWLXTT=SDWLXTT+1
End DoDot:1
+4 WRITE !,?20,"Total #: ",SDWLXT
+5 ;W !,?4,"Total # Unique Patients: ",SDWLXTT,!!
+6 IF $DATA(SDWLSPT)
IF $Y>IOSL
SET DIR(0)="E"
DO ^DIR
IF X="^"
QUIT
+7 QUIT
PRT1 ;
+1 DO HD
DO HD1
+2 SET SDWLSCC=0
FOR
SET SDWLSCC=$ORDER(^TMP("SDWLROS",$JOB,"D",SDWLSCC))
if SDWLSCC=""
QUIT
if $$S^%ZTLOAD
QUIT
Begin DoDot:1
+3 WRITE !,"******* ",SDWLSCC," *******",!
+4 SET SDWLINS=0
FOR
SET SDWLINS=$ORDER(^TMP("SDWLROS",$JOB,"D",SDWLSCC,SDWLINS))
if SDWLINS=""
QUIT
Begin DoDot:2
+5 WRITE !,$PIECE($GET(^DIC(4,SDWLINS,0)),U,1),!
+6 SET SDWLSC=0
FOR
SET SDWLSC=$ORDER(^TMP("SDWLROS",$JOB,"D",SDWLSCC,SDWLINS,SDWLSC))
if SDWLSC=""
QUIT
Begin DoDot:3
+7 WRITE !,$$EXTERNAL^DILFD(SDWLF,.01,,$PIECE(^SDWL(SDWLF,SDWLSC,0),U,1))
+8 SET SDWLWT=""
FOR
SET SDWLWT=$ORDER(^TMP("SDWLROS",$JOB,"D",SDWLSCC,SDWLINS,SDWLSC,SDWLWT))
if SDWLWT=""
QUIT
Begin DoDot:4
+9 SET SDWLDA=0
FOR
SET SDWLDA=$ORDER(^TMP("SDWLROS",$JOB,"D",SDWLSCC,SDWLINS,SDWLSC,SDWLWT,SDWLDA))
if SDWLDA=""
QUIT
Begin DoDot:5
+10 SET X=$GET(^SDWL(409.3,SDWLDA,0))
SET SDWLODT=$PIECE(X,U,2)
SET SDWLDDT=$PIECE(X,U,16)
Begin DoDot:6
+11 SET DFN=+X
DO 1^VADPT
DO DEM^VADPT
+12 WRITE !,VA("BID"),?6,$EXTRACT(VADM(1),1,25),?32,$EXTRACT(SDWLODT,4,5),"/",$EXTRACT(SDWLODT,6,7),"/",($EXTRACT(SDWLODT,1,3)+1700)
+13 WRITE ?47,$EXTRACT(SDWLDDT,4,5),"/",$EXTRACT(SDWLDDT,6,7),"/",($EXTRACT(SDWLDDT,1,3)+1700),?60,$JUSTIFY(SDWLWT,5)
KILL VA,VADM
+14 IF $DATA(SDWLSPT)
IF $Y>(IOSL+3)
SET DIR(0)="E"
DO ^DIR
IF X="^"
SET DUOUT=1
QUIT
+15 IF $Y>(IOSL+3)
DO HD
DO HD1
End DoDot:6
End DoDot:5
IF $DATA(DUOUT)
QUIT
End DoDot:4
IF $DATA(DUOUT)
QUIT
End DoDot:3
IF $DATA(DUOUT)
QUIT
End DoDot:2
WRITE !
IF $DATA(DUOUT)
QUIT
+16 WRITE !
End DoDot:1
IF $DATA(DUOUT)
QUIT
+17 QUIT
LINE ;Draw Line
+1 WRITE !,"_______________________________________________________________________________"
+2 QUIT
HD ;Header
+1 if $DATA(IOF)
WRITE @IOF
WRITE !,SDWLDTP,?80-$LENGTH("Appointment Wait List Overdue Report")\2,"Appointment Wait List Overdue Report"
+2 SET Y=DT
DO DD^%DT
SET SDWLPD=Y
WRITE ?59,SDWLPD
SET SDWLPG=SDWLPG+1
WRITE ?72,"Page: ",SDWLPG
+3 WRITE !!,?30,"Institution: "
IF SDWLINS="ALL"
Begin DoDot:1
+4 WRITE ?45,SDWLINS
End DoDot:1
+5 FOR I=1:1
SET X=$PIECE($PIECE(SDWLINS,";",I),"^",2)
if X=""
QUIT
if I>1
WRITE !
WRITE ?45,X
+6 SET X=$PIECE(SDWLCT1,U,1)
+7 WRITE !?27,"Report Category: ",$SELECT($PIECE(SDWLCT1,U,1)="C":"CLINIC",1:"SPECIALTY")
IF X="ALL"
WRITE " ALL"
+8 IF X'="ALL"
Begin DoDot:1
+9 FOR I=1:1
SET X=$PIECE($PIECE(SDWLCT2,";",I),"^",2)
if X=""
QUIT
WRITE !,?45,$$EXTERNAL^DILFD(SDWLF,.01,,X)
End DoDot:1
+10 SET X=$GET(SDWLFORM)
WRITE !,?28,"Output Format: ",$SELECT(SDWLFORM="S":"Summary",1:"Detailed")
+11 QUIT
HD1 ;
+1 ; SD*5.3*645 - changed 'Date Desired' to 'CID/PD' due to space limit
+2 ;W !!,"Name",?30,"Date Entered",?45,"Date Desired",?60,"# of Days Waiting",!!
+3 WRITE !!,"Name",?30,"Date Entered",?47,"CID/PD",?60,"# of Days Waiting",!!
+4 QUIT
END KILL X1,X2,SDWLAPDT,CT,CT1,CT2,I,OPEN,INS,FORM,VADM
QUIT