SDAMOW ;ALB/CAW - Waiting Time Report ; 12/1/91
;;5.3;Scheduling;**12,1015**;Aug 13, 1993;Build 21
;
EN ; main entry point
N DIC,SDBEG,SDEND,SDSEL,VAUTD,VAUTC,SDSORT,SDAMLIST
EN1 I '$$INIT G ENQ
I '$$RANGE G ENQ
I '$$SELECT G ENQ
I '$$SORT G ENQ
EN2 I '$$DIV G ENQ
I SDSORT=5 S (VAUTS,VAUTC)=1 G EN3
I SDSORT=1!(SDSORT=2) G ENQ:'$$CLINIC
I SDSORT=3!(SDSORT=4) G ENQ:'$$STOP
EN3 I '$$ASK G EN1
W !!,$$LINE("Device Selection")
W !!,"This output requires 132 columns.",!!
S %ZIS="PMQ" D ^%ZIS I POP G ENQ
I '$D(IO("Q")) D START^SDAMOW1 G ENQ
S Y=$$QUE
ENQ D:'$D(ZTQUEUED) ^%ZISC
K VAUTD,VAUTC,VAUTS Q
;
INIT() ; -- init vars
Q 1
;
RANGE() ; select date range
; input: none
; output: SDBEG := begin date
; SDEND := end date
; return: was selection made [ 1|yes 0|no]
;
W !!,$$LINE("Date Range Selection")
Q $$RANGE^SDAMQ(.SDBEG,.SDEND)
;
SELECT() ; -- get selection criteria
; input: none
; output: SDSEL := criteria selected
; return: was selection made [ 1|yes 0|no]
;
W !!,$$LINE("Type of Report Criteria")
S X="S^"
S X=X_"1:Full Report;"
S X=X_"2:Totals Only;"
S DIR(0)=X,DIR("A")="Which Report",DIR("B")="Totals Only"
D ^DIR K DIR S SDSEL=$S($D(DIRUT):0,1:+Y)
Q SDSEL>0
;
SORT() ; -- how to sort
; input: none
; output: SDSORT := sort selected
; return: was selection made [ 1|yes 0|no]
;
W !!,$$LINE("Sort Selection")
W !!,"Note: Top level sort will always be by Division."
S X="S^"
S X=X_"1:Clinic, then by Patient;"
S X=X_"2:Clinic, then by Appointment Date/Time;"
S X=X_"3:Stop Code, then by Clinic;"
S X=X_"4:Stop Code, then by Patient;"
S X=X_"5:Patient then by Appointment Date/Time;"
S DIR(0)=X,DIR("A")="Within Division Sort By",DIR("B")="Clinic, then by Patient"
D ^DIR K DIR S SDSORT=$S($D(DIRUT):0,1:+Y)
Q SDSORT>0
;
DIV() ; -- get division data
; input: none
; output: VAUTD := divs selected (VAUTD=1 for all)
; return: was selection made [ 1|yes 0|no]
;
W:$P($G(^DG(43,1,"GL")),U,2) !!,$$LINE("Division Selection")
D ASK2^SDDIV I Y<0 K VAUTD
Q $D(VAUTD)>0
;
CLINIC() ; -- get clinic data
; input: VAUTD := divisions selected
; output: VAUTC := clinic selected (VAUTC=1 for all)
; return: was selection made [ 1|yes 0|no]
;
W !!,$$LINE("Clinic Selection")
D CLINIC^SDAMO0
I Y<0 K VAUTC
CLINICQ Q $D(VAUTC)>0
;
STOP() ; -- get stop code data
; output: VAUTS := stop codes selected (VAUTS=1 for all)
; return: was selection made [ 1|yes 0|no]
;
W !!,$$LINE("Stop Codes Selection")
S DIC="^DIC(40.7,",VAUTSTR="stop code",VAUTVB="VAUTS",VAUTNI=2
D FIRST^VAUTOMA
I Y<0 K VAUTS
STOPQ Q $D(VAUTS)>0
;
;
LINE(STR) ; -- print line
; input: STR := text to insert
; output: none
; return: text to use
;
N X
S:STR]"" STR=" "_STR_" "
S $P(X,"_",(IOM/2)-($L(STR)/2))=""
Q X_STR_X
;
QUE() ; -- que job
; return: did job que [ 1|yes 0|no ]
;
K ZTSK,IO("Q")
S ZTDESC="Appointment Management Report",ZTRTN="START^SDAMOW1"
F X="VAUTD(","VAUTC(","SDSORT","SDSEL","SDBEG","SDEND","VAUTD","VAUTC","VAUTS","VAUTS(" S ZTSAVE(X)=""
D ^%ZTLOAD W:$D(ZTSK) " (Task: ",ZTSK,")"
Q $D(ZTSK)
;
ASK() ; -- ask if ok to use specs
; input: all selection variables
; output: none
; return: ok to continue [ 1|yes 0|no]
;
I '$$DISP^SDAMOW1 S Y=0 G ASKQ
S DIR(0)="Y",DIR("A")="Continue",DIR("B")="Yes" D ^DIR K DIR
ASKQ Q $S($D(DIRUT):0,1:Y)
SDAMOW ;ALB/CAW - Waiting Time Report ; 12/1/91
+1 ;;5.3;Scheduling;**12,1015**;Aug 13, 1993;Build 21
+2 ;
EN ; main entry point
+1 NEW DIC,SDBEG,SDEND,SDSEL,VAUTD,VAUTC,SDSORT,SDAMLIST
EN1 IF '$$INIT
GOTO ENQ
+1 IF '$$RANGE
GOTO ENQ
+2 IF '$$SELECT
GOTO ENQ
+3 IF '$$SORT
GOTO ENQ
EN2 IF '$$DIV
GOTO ENQ
+1 IF SDSORT=5
SET (VAUTS,VAUTC)=1
GOTO EN3
+2 IF SDSORT=1!(SDSORT=2)
IF '$$CLINIC
GOTO ENQ
+3 IF SDSORT=3!(SDSORT=4)
IF '$$STOP
GOTO ENQ
EN3 IF '$$ASK
GOTO EN1
+1 WRITE !!,$$LINE("Device Selection")
+2 WRITE !!,"This output requires 132 columns.",!!
+3 SET %ZIS="PMQ"
DO ^%ZIS
IF POP
GOTO ENQ
+4 IF '$DATA(IO("Q"))
DO START^SDAMOW1
GOTO ENQ
+5 SET Y=$$QUE
ENQ IF '$DATA(ZTQUEUED)
DO ^%ZISC
+1 KILL VAUTD,VAUTC,VAUTS
QUIT
+2 ;
INIT() ; -- init vars
+1 QUIT 1
+2 ;
RANGE() ; select date range
+1 ; input: none
+2 ; output: SDBEG := begin date
+3 ; SDEND := end date
+4 ; return: was selection made [ 1|yes 0|no]
+5 ;
+6 WRITE !!,$$LINE("Date Range Selection")
+7 QUIT $$RANGE^SDAMQ(.SDBEG,.SDEND)
+8 ;
SELECT() ; -- get selection criteria
+1 ; input: none
+2 ; output: SDSEL := criteria selected
+3 ; return: was selection made [ 1|yes 0|no]
+4 ;
+5 WRITE !!,$$LINE("Type of Report Criteria")
+6 SET X="S^"
+7 SET X=X_"1:Full Report;"
+8 SET X=X_"2:Totals Only;"
+9 SET DIR(0)=X
SET DIR("A")="Which Report"
SET DIR("B")="Totals Only"
+10 DO ^DIR
KILL DIR
SET SDSEL=$SELECT($DATA(DIRUT):0,1:+Y)
+11 QUIT SDSEL>0
+12 ;
SORT() ; -- how to sort
+1 ; input: none
+2 ; output: SDSORT := sort selected
+3 ; return: was selection made [ 1|yes 0|no]
+4 ;
+5 WRITE !!,$$LINE("Sort Selection")
+6 WRITE !!,"Note: Top level sort will always be by Division."
+7 SET X="S^"
+8 SET X=X_"1:Clinic, then by Patient;"
+9 SET X=X_"2:Clinic, then by Appointment Date/Time;"
+10 SET X=X_"3:Stop Code, then by Clinic;"
+11 SET X=X_"4:Stop Code, then by Patient;"
+12 SET X=X_"5:Patient then by Appointment Date/Time;"
+13 SET DIR(0)=X
SET DIR("A")="Within Division Sort By"
SET DIR("B")="Clinic, then by Patient"
+14 DO ^DIR
KILL DIR
SET SDSORT=$SELECT($DATA(DIRUT):0,1:+Y)
+15 QUIT SDSORT>0
+16 ;
DIV() ; -- get division data
+1 ; input: none
+2 ; output: VAUTD := divs selected (VAUTD=1 for all)
+3 ; return: was selection made [ 1|yes 0|no]
+4 ;
+5 IF $PIECE($GET(^DG(43,1,"GL")),U,2)
WRITE !!,$$LINE("Division Selection")
+6 DO ASK2^SDDIV
IF Y<0
KILL VAUTD
+7 QUIT $DATA(VAUTD)>0
+8 ;
CLINIC() ; -- get clinic data
+1 ; input: VAUTD := divisions selected
+2 ; output: VAUTC := clinic selected (VAUTC=1 for all)
+3 ; return: was selection made [ 1|yes 0|no]
+4 ;
+5 WRITE !!,$$LINE("Clinic Selection")
+6 DO CLINIC^SDAMO0
+7 IF Y<0
KILL VAUTC
CLINICQ QUIT $DATA(VAUTC)>0
+1 ;
STOP() ; -- get stop code data
+1 ; output: VAUTS := stop codes selected (VAUTS=1 for all)
+2 ; return: was selection made [ 1|yes 0|no]
+3 ;
+4 WRITE !!,$$LINE("Stop Codes Selection")
+5 SET DIC="^DIC(40.7,"
SET VAUTSTR="stop code"
SET VAUTVB="VAUTS"
SET VAUTNI=2
+6 DO FIRST^VAUTOMA
+7 IF Y<0
KILL VAUTS
STOPQ QUIT $DATA(VAUTS)>0
+1 ;
+2 ;
LINE(STR) ; -- print line
+1 ; input: STR := text to insert
+2 ; output: none
+3 ; return: text to use
+4 ;
+5 NEW X
+6 IF STR]""
SET STR=" "_STR_" "
+7 SET $PIECE(X,"_",(IOM/2)-($LENGTH(STR)/2))=""
+8 QUIT X_STR_X
+9 ;
QUE() ; -- que job
+1 ; return: did job que [ 1|yes 0|no ]
+2 ;
+3 KILL ZTSK,IO("Q")
+4 SET ZTDESC="Appointment Management Report"
SET ZTRTN="START^SDAMOW1"
+5 FOR X="VAUTD(","VAUTC(","SDSORT","SDSEL","SDBEG","SDEND","VAUTD","VAUTC","VAUTS","VAUTS("
SET ZTSAVE(X)=""
+6 DO ^%ZTLOAD
IF $DATA(ZTSK)
WRITE " (Task: ",ZTSK,")"
+7 QUIT $DATA(ZTSK)
+8 ;
ASK() ; -- ask if ok to use specs
+1 ; input: all selection variables
+2 ; output: none
+3 ; return: ok to continue [ 1|yes 0|no]
+4 ;
+5 IF '$$DISP^SDAMOW1
SET Y=0
GOTO ASKQ
+6 SET DIR(0)="Y"
SET DIR("A")="Continue"
SET DIR("B")="Yes"
DO ^DIR
KILL DIR
ASKQ QUIT $SELECT($DATA(DIRUT):0,1:Y)