SDWLROF ;;IOFO BAY PINES/TEH - WAIT LIST OVERDUE REPORT 1;06/12/2002 ; 29 Aug 2002 2:54 PM
;;5.3;scheduling;**263,414,1015**;AUG 13 1993;Build 21
;
;
;******************************************************************
; CHANGE LOG
;
; DATE PATCH DESCRIPTION
; ---- ----- -----------
;
;
;
;
EN D INIT
I $$S^%ZTLOAD G END
D SORT
I $$S^%ZTLOAD G END
D PRINT
I $$S^%ZTLOAD G END
K ^TMP("SDWLQOF",$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=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)="",^TMP("SDWLQOF",$J,SDWLIN)=0
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("SDWLROF",$J)
S SDWLDA=0,SDWLCNT=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
.;-Check for Date Range Compliance
.I $P(SDWLX,U,16)'<DT,$P(SDWLX,U,16)'=DT S SDWLERR=2
.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
.I SDWLCT2'="ALL" D
..I '$D(SDWLCT2(SDWLTYPE)) S SDWLERR=3
.I SDWLTYP="" S SDWLERR=4
.I $P(SDWLX,U,17)["C" S SDWLERR=6
.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 ^TMP("SDWLROF",$J,+$P(SDWLX,U,3),SDWLTYPE,SDWLSCC,SDWLDA)=""
..S SDWLCNT=SDWLCNT+1,^TMP("SDWLROF",$J,+$P(SDWLX,U,3))=SDWLCNT
Q
PRINT ;Print Report
D HD S SDWLCNT=0 I '$D(^TMP("SDWLROF",$J)) W !!,?80-$L("*** No Patient Records to Report ***")\2,"*** No Patient Records to Report ***" Q
S SDWLA="" F S SDWLA=$O(^TMP("SDWLROF",$J,SDWLA)) G END:$$S^%ZTLOAD Q:SDWLA="" D Q:$D(DUOUT)
.D LINE W !!,"Institution: " S X=$$EXTERNAL^DILFD(409.3,2,,SDWLA) W X I '$G(^TMP("SDWLROF",$J,SDWLA)) W !!,"*** No Patient Records to Report ***"
.S SDWLB="" F S SDWLB=$O(^TMP("SDWLROF",$J,SDWLA,SDWLB)) Q:SDWLB="" D Q:$D(DUOUT)
..W !!,"Clinic/Service: " S X=$$EXTERNAL^DILFD(409.3,SDWLTXP,,SDWLB) W X,! Q:$D(DUOUT)
..S SDWLC="" F S SDWLC=$O(^TMP("SDWLROF",$J,SDWLA,SDWLB,SDWLC)) Q:SDWLC="" D Q:$D(DUOUT)
...S SDWLD="" F S SDWLD=$O(^TMP("SDWLROF",$J,SDWLA,SDWLB,SDWLC,SDWLD)) Q:SDWLD="" D Q:$D(DUOUT)
....S (DFN,SDWLDFN)=$P($G(^SDWL(409.3,SDWLD,0)),U,1) D 1^VADPT,DEM^VADPT,ELIG^VADPT,ADD^VADPT
....S SDWLELIG=$P(VAEL(1),U,2)
....S SDWLNAM=VADM(1),SDWLSSN=VA("BID")
....S SDWLDEAD=1
....S SDWLAPTD=$P(^SDWL(409.3,SDWLD,0),U,16),SDWLCOM=$P(^SDWL(409.3,SDWLD,0),U,18)
....S SDWLRBY=$P(^SDWL(409.3,SDWLD,0),U,12),SDWLRPV=$P(^SDWL(409.3,SDWLD,0),U,13)
....S SDWLPH=$G(VAPA(8))
....I SDWLAPTD'="" S Y=SDWLAPTD D DD^%DT S SDWLAPTD=Y
....W !!,SDWLNAM
....W ?35,SDWLSSN I SDWLAPTD'="" W ?50,"Desired Date: ",SDWLAPTD
....W !,"Primary Eligibility: ",SDWLELIG
....W !,"Comments: ",SDWLCOM,!
....I SDWLRBY W !,"Requested by: ",$$EXTERNAL^DILFD(409.3,11,,SDWLRBY)
....I SDWLRPV W ?35,"Requesting Provider: " S X=$$EXTERNAL^DILFD(409.3,12,,SDWLRPV) W X
....W !,"Telephone (Home): ",$P(SDWLPH,U,1) I $P(SDWLPH,U,2) W !,?10,"(Work): ",$P(SDWLPH,U,2)
....W !,"*****"
....I $D(SDWLSPT) S DIR(0)="E" D ^DIR I X["^" S DUOUT=1 Q
....I '$D(SDWLSPT),'$D(DUOUT),$Y>(IOSL-5) D HD
....K VAEL,VADM,VA,VAPA
W !!,"** End of Report **"
Q
LINE ;Draw Line
W !,"_______________________________________________________________________________"
Q
HD ;Header
W:$D(IOF) @IOF W !,SDWLDTP,?80-$L("Appt Wait List Overdue Report")\2,"Appt Wait List Overdue Report"
S Y=DT D DD^%DT S SDWLPD=Y W ?57,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(SDWLCT2,U,2)
W !?26,"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
END K SDWL,SDWLA,SDWLAPTD,SDWLB,SDWLBD,SDWLBDT,SDWLC,SDWLCAT,SDWLCNT,SDWLCOM,SDWLCT1,SDWLCT2,SDWLCTX,SDWLD
K SDLWDA,SDLWDEAD,SDWLDFN,SDWLE,SDWLEDT,SDWLELIG,SDWLERR,SDWLF,SDWLFD,SDWLI,SDWLIN,SDWLINS,SDWLINST
K SDWLNAM,SDWLPD,SDWLPG,SDWLPH,SDWLPROM,SDWLRBY,SDWLPRV,SDWLSCC,SDWLSPT,SDWLSSN,SDWLTAG,SDLTK,SDWLTXP
K SDWLTYP,SDWLTYPE,SDWLX,CT1,CT2,DATE,I,INS,OPEN,FORM
Q
SDWLROF ;;IOFO BAY PINES/TEH - WAIT LIST OVERDUE REPORT 1;06/12/2002 ; 29 Aug 2002 2:54 PM
+1 ;;5.3;scheduling;**263,414,1015**;AUG 13 1993;Build 21
+2 ;
+3 ;
+4 ;******************************************************************
+5 ; CHANGE LOG
+6 ;
+7 ; DATE PATCH DESCRIPTION
+8 ; ---- ----- -----------
+9 ;
+10 ;
+11 ;
+12 ;
EN DO INIT
+1 IF $$S^%ZTLOAD
GOTO END
+2 DO SORT
+3 IF $$S^%ZTLOAD
GOTO END
+4 DO PRINT
+5 IF $$S^%ZTLOAD
GOTO END
+6 KILL ^TMP("SDWLQOF",$JOB)
+7 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=INS
+7 SET SDWLPG=0
+8 IF $DATA(ZTSAVE)
Begin DoDot:1
+9 FOR SDWLI="CT1","CT2","FORM","INS"
SET SDWL="SDWL"_SDWLI
SET @SDWL=$GET(ZTSAVE(SDWLI))
End DoDot:1
+10 IF SDWLINS="ALL"
SET SDWLIN("ALL")=""
+11 SET SDWLTXP=$PIECE(SDWLCT1,U,3)
SET SDWLF=$PIECE(SDWLCT1,U,2)
+12 IF SDWLINS'="ALL"
FOR SDWLI=1:1
SET SDWLIN=$PIECE($PIECE(SDWLINS,";",SDWLI),U,1)
IF SDWLIN=""
QUIT
SET SDWLIN(SDWLIN)=""
SET ^TMP("SDWLQOF",$JOB,SDWLIN)=0
+13 IF SDWLCT2'="ALL"
FOR SDWLI=1:1
SET SDWLCL=$PIECE($PIECE(SDWLCT2,";",SDWLI),U,1)
IF SDWLCL=""
QUIT
SET SDWLCT2(SDWLCL)=""
+14 DO NOW^%DTC
SET Y=%
DO DD^%DT
SET SDWLDTP=Y
+15 QUIT
SORT ;Sort Records
+1 KILL ^TMP("SDWLROF",$JOB)
+2 SET SDWLDA=0
SET SDWLCNT=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
End DoDot:2
+7 ;-Check for Date Range Compliance
+8 IF $PIECE(SDWLX,U,16)'<DT
IF $PIECE(SDWLX,U,16)'=DT
SET SDWLERR=2
+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 IF SDWLCT2'="ALL"
Begin DoDot:2
+11 IF '$DATA(SDWLCT2(SDWLTYPE))
SET SDWLERR=3
End DoDot:2
+12 IF SDWLTYP=""
SET SDWLERR=4
+13 IF $PIECE(SDWLX,U,17)["C"
SET SDWLERR=6
+14 IF SDWLERR
QUIT
Begin DoDot:2
+15 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
+16 SET ^TMP("SDWLROF",$JOB,+$PIECE(SDWLX,U,3),SDWLTYPE,SDWLSCC,SDWLDA)=""
+17 SET SDWLCNT=SDWLCNT+1
SET ^TMP("SDWLROF",$JOB,+$PIECE(SDWLX,U,3))=SDWLCNT
End DoDot:2
End DoDot:1
+18 QUIT
PRINT ;Print Report
+1 DO HD
SET SDWLCNT=0
IF '$DATA(^TMP("SDWLROF",$JOB))
WRITE !!,?80-$LENGTH("*** No Patient Records to Report ***")\2,"*** No Patient Records to Report ***"
QUIT
+2 SET SDWLA=""
FOR
SET SDWLA=$ORDER(^TMP("SDWLROF",$JOB,SDWLA))
IF $$S^%ZTLOAD
GOTO END
IF SDWLA=""
QUIT
Begin DoDot:1
+3 DO LINE
WRITE !!,"Institution: "
SET X=$$EXTERNAL^DILFD(409.3,2,,SDWLA)
WRITE X
IF '$GET(^TMP("SDWLROF",$JOB,SDWLA))
WRITE !!,"*** No Patient Records to Report ***"
+4 SET SDWLB=""
FOR
SET SDWLB=$ORDER(^TMP("SDWLROF",$JOB,SDWLA,SDWLB))
IF SDWLB=""
QUIT
Begin DoDot:2
+5 WRITE !!,"Clinic/Service: "
SET X=$$EXTERNAL^DILFD(409.3,SDWLTXP,,SDWLB)
WRITE X,!
IF $DATA(DUOUT)
QUIT
+6 SET SDWLC=""
FOR
SET SDWLC=$ORDER(^TMP("SDWLROF",$JOB,SDWLA,SDWLB,SDWLC))
IF SDWLC=""
QUIT
Begin DoDot:3
+7 SET SDWLD=""
FOR
SET SDWLD=$ORDER(^TMP("SDWLROF",$JOB,SDWLA,SDWLB,SDWLC,SDWLD))
IF SDWLD=""
QUIT
Begin DoDot:4
+8 SET (DFN,SDWLDFN)=$PIECE($GET(^SDWL(409.3,SDWLD,0)),U,1)
DO 1^VADPT
DO DEM^VADPT
DO ELIG^VADPT
DO ADD^VADPT
+9 SET SDWLELIG=$PIECE(VAEL(1),U,2)
+10 SET SDWLNAM=VADM(1)
SET SDWLSSN=VA("BID")
+11 SET SDWLDEAD=1
+12 SET SDWLAPTD=$PIECE(^SDWL(409.3,SDWLD,0),U,16)
SET SDWLCOM=$PIECE(^SDWL(409.3,SDWLD,0),U,18)
+13 SET SDWLRBY=$PIECE(^SDWL(409.3,SDWLD,0),U,12)
SET SDWLRPV=$PIECE(^SDWL(409.3,SDWLD,0),U,13)
+14 SET SDWLPH=$GET(VAPA(8))
+15 IF SDWLAPTD'=""
SET Y=SDWLAPTD
DO DD^%DT
SET SDWLAPTD=Y
+16 WRITE !!,SDWLNAM
+17 WRITE ?35,SDWLSSN
IF SDWLAPTD'=""
WRITE ?50,"Desired Date: ",SDWLAPTD
+18 WRITE !,"Primary Eligibility: ",SDWLELIG
+19 WRITE !,"Comments: ",SDWLCOM,!
+20 IF SDWLRBY
WRITE !,"Requested by: ",$$EXTERNAL^DILFD(409.3,11,,SDWLRBY)
+21 IF SDWLRPV
WRITE ?35,"Requesting Provider: "
SET X=$$EXTERNAL^DILFD(409.3,12,,SDWLRPV)
WRITE X
+22 WRITE !,"Telephone (Home): ",$PIECE(SDWLPH,U,1)
IF $PIECE(SDWLPH,U,2)
WRITE !,?10,"(Work): ",$PIECE(SDWLPH,U,2)
+23 WRITE !,"*****"
+24 IF $DATA(SDWLSPT)
SET DIR(0)="E"
DO ^DIR
IF X["^"
SET DUOUT=1
QUIT
+25 IF '$DATA(SDWLSPT)
IF '$DATA(DUOUT)
IF $Y>(IOSL-5)
DO HD
+26 KILL VAEL,VADM,VA,VAPA
End DoDot:4
IF $DATA(DUOUT)
QUIT
End DoDot:3
IF $DATA(DUOUT)
QUIT
End DoDot:2
IF $DATA(DUOUT)
QUIT
End DoDot:1
IF $DATA(DUOUT)
QUIT
+27 WRITE !!,"** End of Report **"
+28 QUIT
LINE ;Draw Line
+1 WRITE !,"_______________________________________________________________________________"
+2 QUIT
HD ;Header
+1 IF $DATA(IOF)
WRITE @IOF
WRITE !,SDWLDTP,?80-$LENGTH("Appt Wait List Overdue Report")\2,"Appt Wait List Overdue Report"
+2 SET Y=DT
DO DD^%DT
SET SDWLPD=Y
WRITE ?57,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(SDWLCT2,U,2)
+7 WRITE !?26,"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
END KILL SDWL,SDWLA,SDWLAPTD,SDWLB,SDWLBD,SDWLBDT,SDWLC,SDWLCAT,SDWLCNT,SDWLCOM,SDWLCT1,SDWLCT2,SDWLCTX,SDWLD
+1 KILL SDLWDA,SDLWDEAD,SDWLDFN,SDWLE,SDWLEDT,SDWLELIG,SDWLERR,SDWLF,SDWLFD,SDWLI,SDWLIN,SDWLINS,SDWLINST
+2 KILL SDWLNAM,SDWLPD,SDWLPG,SDWLPH,SDWLPROM,SDWLRBY,SDWLPRV,SDWLSCC,SDWLSPT,SDWLSSN,SDWLTAG,SDLTK,SDWLTXP
+3 KILL SDWLTYP,SDWLTYPE,SDWLX,CT1,CT2,DATE,I,INS,OPEN,FORM
+4 QUIT