- SDAMOWP1 ;ALB/CAW - Appointment Waiting Time Print Routine ; 12/1/91
- ;;5.3;Scheduling;**12,20**;Aug 13, 1993
- ;
- HDR ; -- print header
- ;
- N Y
- D HDRD
- ;
- I $D(SDNO) D NO G HDR1
- I SDSORT=1!(SDSORT=2) W !,?70," Clinic: ",$E(LEVEL1,1,23)
- I SDSORT=3!(SDSORT=4) W !,?70,"Stop Code: ",$E(LEVEL1,1,23)
- ;
- HDR1 W !,"Sorted By: ",$P($T(SORT1+SDSORT),";;",2)
- I SDSORT'=5,$D(^TMP("SDWTTOT",$J,+SDDIV,LEVEL1,"PRIM")) W ?70," Total: ",+^("PRIM")
- I SDSORT=5,$D(^TMP("SDWTTOTD",$J,+SDDIV,"DIV")) W ?70," Total: ",+^("DIV")
- ;
- W !,SDASH
- I SDSEL=1 W !,"Patient",?20,"ID",?26,$S("^3^4^5^"[(U_SDSORT_U):"Clinic",1:""),?46,"Check-In",?62,"Appointment",?78,"Elapsed",?92,"Check-Out",?109,"Elapsed",?120,"Total"
- I SDSEL=1 W !,?46,"Date/Time",?62,"Date/Time",?78,"Time",?92,"Date/Time",?109,"Time",?120,"Time",!,SDASH
- HDRQ Q
- ;
- HDRD ; Print header with dates
- ;
- W @IOF,"Appointment Waiting Time Report",?51,"Report Date: ",$P($$NOW^VALM1,":",1,2)
- S SDPAGE=SDPAGE+1 W ?108,"Page: ",SDPAGE
- W !,SDASH
- ;
- W !,"Dates : ",$$FDATE^VALM1(SDBEG)," to ",$$FDATE^VALM1(SDEND)
- I $D(SDNO) D NODIV G HDRDQ
- S SDDIVNAM=$E($S($D(^DG(40.8,+SDDIV,0)):$P(^(0),U),1:""),1,SDLEN)
- I SDDIVNAM'="" W ?70," Division: ",SDDIVNAM
- HDRDQ Q
- ;
- HDRT(SORT) ; Print header for totals
- ;
- N SRT S SRT=$G(SORT)
- W !,$S("^1^2^"[(U_SRT_U):"Clinic","^3^4^"[(U_SRT_U):"Stop Code",1:"Division"),?40,"Appointments",?56,"Total CI Time",?71,"Total CO Time",?86,"Average Pre",?101,"Average Post",?116,"Average Total"
- W !,?86,"Waiting Time",?101,"Waiting Time",?116,"Waiting Time"
- W !,SDASH
- Q
- TOT(WHAT,LEVEL1,DIV) ; Print totals
- ;
- N TOTAL,TOTAL1,TOTAL2,TOTAL3,TOTAL4
- I WHAT="PRIM" S TOTAL=$G(^TMP("SDWTTOT",$J,+DIV,LEVEL1,"PRIM"))
- I WHAT="DIV" S TOTAL=$G(^TMP("SDWTTOTD",$J,+DIV,"DIV"))
- I WHAT="GRAND" S TOTAL=$G(^TMP("SDWTTOTG",$J,"GRAND"))
- S TOTAL1=$P(TOTAL,U,1),TOTAL2=$P(TOTAL,U,2),TOTAL3=$P(TOTAL,U,3),TOTAL4=$P(TOTAL,U,4)
- W !,$G(LEVEL1)
- W ?40,TOTAL1
- W ?56,$$HRS^SDAMOWP(TOTAL2)
- W ?71,$$HRS^SDAMOWP(TOTAL3)
- W ?86,$$HRS^SDAMOWP($P((TOTAL2/TOTAL1),"."))
- W ?101,$$HRS^SDAMOWP($P((TOTAL3/TOTAL1),"."))
- W ?116,$$HRS^SDAMOWP($P((TOTAL4/TOTAL1),"."))
- TOTQ Q
- ;
- SORT1 ; -- hdr labels for sort
- ;;DIVISION, CLINIC, PATIENT
- ;;DIVISION, CLINIC, APPOINTMENT DATE/TIME
- ;;DIVISION, STOP CODE, CLINIC
- ;;DIVISION, STOP CODE, PATIENT
- ;;DIVISION, PATIENT, APPOINTMENT DATE/TIME
- ;;$$END
- Q
- ;
- TOTP(SORT,DIV,LEVEL1) ; Print totals
- ;
- D HDRD,HDRT(SORT)
- F S LEVEL1=$O(^TMP("SDWTTOT",$J,+DIV,LEVEL1)) Q:LEVEL1=""!(SDQUIT) D
- .D CHECK(SORT) Q:SDQUIT
- .D TOT("PRIM",LEVEL1,DIV)
- Q:SDQUIT
- W !,SDASH1
- D TOT("DIV","TOTAL",DIV),LEGEND
- D PAUSE^SDAMOWP
- Q
- ;
- CHECK(SORT) ; check to see if header should be printed
- I 'SDPAGE D HDRT(SORT) Q
- I $E(IOST,1,2)="C-",($Y+6)>IOSL D PAUSE^VALM1 I 'Y S SDQUIT=1 Q
- I ($Y+6)>IOSL W @IOF D HDRT(SORT)
- Q
- ;
- LEGEND ; Print legend on bottom
- ;
- W !!,?5,"o Check-In Date/Time - Time the patient first checks in at the clinic reception area."
- W !,?5,"o Appointment Date/Time - Time of the veteran's scheduled appointment."
- W !,?5,"o Elapsed Time(s) - 1. The elapsed period of time from the patient checking in at the clinic to the appointment time. "
- W !,?5," (Appointment time minus Check-In time)"
- W !,?5,"o 2. The elapsed period of time from the appointment time to the time the patient checks out."
- W !,?5," (Check-Out time minus Appointment Time)"
- W !,?5,"o Total Waiting Time - The elapsed period of time from the patient's check-in date/time to the time leaving the clinic"
- W !,?5," after service is completed. (Check-Out time minus Check-In time)"
- LEGENDQ Q
- ;
- NODIV ; Print divisions when no appts found
- ;
- N DIV S DIV="" W !,?70,"Division(s): "
- I VAUTD=1 W "All" G NODIVQ
- F S DIV=$O(VAUTD(DIV)) Q:DIV="" W ?83,VAUTD(DIV),!
- NODIVQ Q
- ;
- NO ; Print stop code or clinic when no appts found
- ;
- N SDWHAT S SDWHAT="" W !,?72,$S(SDSORT=1!(SDSORT=2):"Clinic(s): ",SDSORT=3!(SDSORT=4):"Stop Code(s): ",1:"")
- I SDSORT=1!(SDSORT=2),VAUTC=1 W "All" G NOQ
- I SDSORT=1!(SDSORT=2) F S SDWHAT=$O(VAUTC(SDWHAT)) Q:SDWHAT="" W ?83,VAUTC(SDWHAT),!
- I SDSORT=3!(SDSORT=4),VAUTS=1 W "All" G NOQ
- I SDSORT=3!(SDSORT=4) F S SDWHAT=$O(VAUTS(SDWHAT)) Q:SDWHAT="" W ?87,VAUTS(SDWHAT),!
- NOQ Q
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDAMOWP1 4395 printed Mar 13, 2025@21:53:03 Page 2
- SDAMOWP1 ;ALB/CAW - Appointment Waiting Time Print Routine ; 12/1/91
- +1 ;;5.3;Scheduling;**12,20**;Aug 13, 1993
- +2 ;
- HDR ; -- print header
- +1 ;
- +2 NEW Y
- +3 DO HDRD
- +4 ;
- +5 IF $DATA(SDNO)
- DO NO
- GOTO HDR1
- +6 IF SDSORT=1!(SDSORT=2)
- WRITE !,?70," Clinic: ",$EXTRACT(LEVEL1,1,23)
- +7 IF SDSORT=3!(SDSORT=4)
- WRITE !,?70,"Stop Code: ",$EXTRACT(LEVEL1,1,23)
- +8 ;
- HDR1 WRITE !,"Sorted By: ",$PIECE($TEXT(SORT1+SDSORT),";;",2)
- +1 IF SDSORT'=5
- IF $DATA(^TMP("SDWTTOT",$JOB,+SDDIV,LEVEL1,"PRIM"))
- WRITE ?70," Total: ",+^("PRIM")
- +2 IF SDSORT=5
- IF $DATA(^TMP("SDWTTOTD",$JOB,+SDDIV,"DIV"))
- WRITE ?70," Total: ",+^("DIV")
- +3 ;
- +4 WRITE !,SDASH
- +5 IF SDSEL=1
- WRITE !,"Patient",?20,"ID",?26,$SELECT("^3^4^5^"[(U_SDSORT_U):"Clinic",1:""),?46,"Check-In",?62,"Appointment",?78,"Elapsed",?92,"Check-Out",?109,"Elapsed",?120,"Total"
- +6 IF SDSEL=1
- WRITE !,?46,"Date/Time",?62,"Date/Time",?78,"Time",?92,"Date/Time",?109,"Time",?120,"Time",!,SDASH
- HDRQ QUIT
- +1 ;
- HDRD ; Print header with dates
- +1 ;
- +2 WRITE @IOF,"Appointment Waiting Time Report",?51,"Report Date: ",$PIECE($$NOW^VALM1,":",1,2)
- +3 SET SDPAGE=SDPAGE+1
- WRITE ?108,"Page: ",SDPAGE
- +4 WRITE !,SDASH
- +5 ;
- +6 WRITE !,"Dates : ",$$FDATE^VALM1(SDBEG)," to ",$$FDATE^VALM1(SDEND)
- +7 IF $DATA(SDNO)
- DO NODIV
- GOTO HDRDQ
- +8 SET SDDIVNAM=$EXTRACT($SELECT($DATA(^DG(40.8,+SDDIV,0)):$PIECE(^(0),U),1:""),1,SDLEN)
- +9 IF SDDIVNAM'=""
- WRITE ?70," Division: ",SDDIVNAM
- HDRDQ QUIT
- +1 ;
- HDRT(SORT) ; Print header for totals
- +1 ;
- +2 NEW SRT
- SET SRT=$GET(SORT)
- +3 WRITE !,$SELECT("^1^2^"[(U_SRT_U):"Clinic","^3^4^"[(U_SRT_U):"Stop Code",1:"Division"),?40,"Appointments",?56,"Total CI Time",?71,"Total CO Time",?86,"Average Pre",?101,"Average Post",?116,"Average Total"
- +4 WRITE !,?86,"Waiting Time",?101,"Waiting Time",?116,"Waiting Time"
- +5 WRITE !,SDASH
- +6 QUIT
- TOT(WHAT,LEVEL1,DIV) ; Print totals
- +1 ;
- +2 NEW TOTAL,TOTAL1,TOTAL2,TOTAL3,TOTAL4
- +3 IF WHAT="PRIM"
- SET TOTAL=$GET(^TMP("SDWTTOT",$JOB,+DIV,LEVEL1,"PRIM"))
- +4 IF WHAT="DIV"
- SET TOTAL=$GET(^TMP("SDWTTOTD",$JOB,+DIV,"DIV"))
- +5 IF WHAT="GRAND"
- SET TOTAL=$GET(^TMP("SDWTTOTG",$JOB,"GRAND"))
- +6 SET TOTAL1=$PIECE(TOTAL,U,1)
- SET TOTAL2=$PIECE(TOTAL,U,2)
- SET TOTAL3=$PIECE(TOTAL,U,3)
- SET TOTAL4=$PIECE(TOTAL,U,4)
- +7 WRITE !,$GET(LEVEL1)
- +8 WRITE ?40,TOTAL1
- +9 WRITE ?56,$$HRS^SDAMOWP(TOTAL2)
- +10 WRITE ?71,$$HRS^SDAMOWP(TOTAL3)
- +11 WRITE ?86,$$HRS^SDAMOWP($PIECE((TOTAL2/TOTAL1),"."))
- +12 WRITE ?101,$$HRS^SDAMOWP($PIECE((TOTAL3/TOTAL1),"."))
- +13 WRITE ?116,$$HRS^SDAMOWP($PIECE((TOTAL4/TOTAL1),"."))
- TOTQ QUIT
- +1 ;
- SORT1 ; -- hdr labels for sort
- +1 ;;DIVISION, CLINIC, PATIENT
- +2 ;;DIVISION, CLINIC, APPOINTMENT DATE/TIME
- +3 ;;DIVISION, STOP CODE, CLINIC
- +4 ;;DIVISION, STOP CODE, PATIENT
- +5 ;;DIVISION, PATIENT, APPOINTMENT DATE/TIME
- +6 ;;$$END
- +7 QUIT
- +8 ;
- TOTP(SORT,DIV,LEVEL1) ; Print totals
- +1 ;
- +2 DO HDRD
- DO HDRT(SORT)
- +3 FOR
- SET LEVEL1=$ORDER(^TMP("SDWTTOT",$JOB,+DIV,LEVEL1))
- if LEVEL1=""!(SDQUIT)
- QUIT
- Begin DoDot:1
- +4 DO CHECK(SORT)
- if SDQUIT
- QUIT
- +5 DO TOT("PRIM",LEVEL1,DIV)
- End DoDot:1
- +6 if SDQUIT
- QUIT
- +7 WRITE !,SDASH1
- +8 DO TOT("DIV","TOTAL",DIV)
- DO LEGEND
- +9 DO PAUSE^SDAMOWP
- +10 QUIT
- +11 ;
- CHECK(SORT) ; check to see if header should be printed
- +1 IF 'SDPAGE
- DO HDRT(SORT)
- QUIT
- +2 IF $EXTRACT(IOST,1,2)="C-"
- IF ($Y+6)>IOSL
- DO PAUSE^VALM1
- IF 'Y
- SET SDQUIT=1
- QUIT
- +3 IF ($Y+6)>IOSL
- WRITE @IOF
- DO HDRT(SORT)
- +4 QUIT
- +5 ;
- LEGEND ; Print legend on bottom
- +1 ;
- +2 WRITE !!,?5,"o Check-In Date/Time - Time the patient first checks in at the clinic reception area."
- +3 WRITE !,?5,"o Appointment Date/Time - Time of the veteran's scheduled appointment."
- +4 WRITE !,?5,"o Elapsed Time(s) - 1. The elapsed period of time from the patient checking in at the clinic to the appointment time. "
- +5 WRITE !,?5," (Appointment time minus Check-In time)"
- +6 WRITE !,?5,"o 2. The elapsed period of time from the appointment time to the time the patient checks out."
- +7 WRITE !,?5," (Check-Out time minus Appointment Time)"
- +8 WRITE !,?5,"o Total Waiting Time - The elapsed period of time from the patient's check-in date/time to the time leaving the clinic"
- +9 WRITE !,?5," after service is completed. (Check-Out time minus Check-In time)"
- LEGENDQ QUIT
- +1 ;
- NODIV ; Print divisions when no appts found
- +1 ;
- +2 NEW DIV
- SET DIV=""
- WRITE !,?70,"Division(s): "
- +3 IF VAUTD=1
- WRITE "All"
- GOTO NODIVQ
- +4 FOR
- SET DIV=$ORDER(VAUTD(DIV))
- if DIV=""
- QUIT
- WRITE ?83,VAUTD(DIV),!
- NODIVQ QUIT
- +1 ;
- NO ; Print stop code or clinic when no appts found
- +1 ;
- +2 NEW SDWHAT
- SET SDWHAT=""
- WRITE !,?72,$SELECT(SDSORT=1!(SDSORT=2):"Clinic(s): ",SDSORT=3!(SDSORT=4):"Stop Code(s): ",1:"")
- +3 IF SDSORT=1!(SDSORT=2)
- IF VAUTC=1
- WRITE "All"
- GOTO NOQ
- +4 IF SDSORT=1!(SDSORT=2)
- FOR
- SET SDWHAT=$ORDER(VAUTC(SDWHAT))
- if SDWHAT=""
- QUIT
- WRITE ?83,VAUTC(SDWHAT),!
- +5 IF SDSORT=3!(SDSORT=4)
- IF VAUTS=1
- WRITE "All"
- GOTO NOQ
- +6 IF SDSORT=3!(SDSORT=4)
- FOR
- SET SDWHAT=$ORDER(VAUTS(SDWHAT))
- if SDWHAT=""
- QUIT
- WRITE ?87,VAUTS(SDWHAT),!
- NOQ QUIT