Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDAMOWP

SDAMOWP.m

Go to the documentation of this file.
SDAMOWP ;ALB/CAW - Appointment Waiting Time Print Routine ; 12/1/91
 ;;5.3;Scheduling;**12**;Aug 13, 1993
 ;
PRINT ; -- print arrays
 ; var defined:
 ;   SDSUB2 := top level sort after Division (clinic,stop cd,patient)
 ;   SDSUB3 := next level sort
 ;
 U IO N SDQUIT,SDDIV,SDROU,SDCLN,SDPAT,SDSTP,SDNO,LEVEL1
 S (SDQUIT,SDDIV,SDCLN,SDPAT,SDATE,SDSTP)=""
 I $O(^TMP("SDWAIT",$J,SDDIV))="" S LEVEL1=0,SDNO=1 D HDR^SDAMOWP1 D  G PRINTQ
 .W !!?5,"No appointments to report."
 .D:$E(IOST,1,2)="C-" PAUSE^VALM1
 ;
 F  S SDDIV=$O(^TMP("SDWAIT",$J,SDDIV)) Q:SDDIV=""!(SDQUIT)  D SORT(SDDIV,SDSORT) G:SDQUIT PRINTQ
 D PAUSE G:SDQUIT PRINTQ
 S SDDIV=0 D HDRD^SDAMOWP1 W !,SDASH D HDRT^SDAMOWP1() D
 .F  S SDDIV=$O(^TMP("SDWTTOTD",$J,SDDIV)) Q:SDDIV=""!(SDQUIT)  D TOT^SDAMOWP1("DIV",$P($G(^DG(40.8,SDDIV,0)),U),SDDIV) W !,SDASH
 .D TOT^SDAMOWP1("GRAND","TOTAL"),LEGEND^SDAMOWP1
PRINTQ Q
 ;
SORT(DIV,SORT) ; sort
 ;
 Q:SDSEL=2&(SORT=5)
 S (LEVEL1,LEVEL2,LEVEL3,LEVEL4)=0
 I SDSEL=2 D TOTP^SDAMOWP1(SORT,DIV,LEVEL1) G SORTQ
 I SORT=5 S LEVEL1=$O(^TMP("SDWAIT",$J,DIV,LEVEL1)) D HDR^SDAMOWP1 S LEVEL1=""
 F  S LEVEL1=$O(^TMP("SDWAIT",$J,DIV,LEVEL1)) Q:LEVEL1=""!(SDQUIT)  D:SORT'=5 HDR^SDAMOWP1  D
 .F  S LEVEL2=$O(^TMP("SDWAIT",$J,DIV,LEVEL1,LEVEL2)) Q:LEVEL2=""!(SDQUIT)   D
 ..F  S LEVEL3=$O(^TMP("SDWAIT",$J,DIV,LEVEL1,LEVEL2,LEVEL3)) Q:LEVEL3=""!(SDQUIT)  D
 ...I SORT=3!(SORT=4) F  S LEVEL4=$O(^TMP("SDWAIT",$J,DIV,LEVEL1,LEVEL2,LEVEL3,LEVEL4)) Q:LEVEL4=""!(SDQUIT)  D SET(SORT,LEVEL1,LEVEL2,LEVEL3,LEVEL4),CHECK S SDATA=^TMP("SDWAIT",$J,DIV,LEVEL1,LEVEL2,LEVEL3,LEVEL4) Q:'$$PRT
 ...Q:SORT=3!(SORT=4)
 ...S SDATA=^(LEVEL3) D SET(SORT,LEVEL1,LEVEL2,LEVEL3,LEVEL4),CHECK Q:SDQUIT  Q:'$$PRT
 .Q:SDQUIT
 .I SORT'=5 N TOTAL,TOTAL1,TOTAL2,TOTAL3,TOTAL4 D
 ..S TOTAL=$G(^TMP("SDWTTOT",$J,DIV,LEVEL1,"PRIM")),TOTAL1=$P(TOTAL,U,1),TOTAL2=$P(TOTAL,U,2),TOTAL3=$P(TOTAL,U,3),TOTAL4=$P(TOTAL,U,4)
 ..D TOT
 .I SORT'=5 D PAUSE Q:SDQUIT
 I SDSORT=5&(SDSEL=1) N TOTAL,TOTAL1,TOTAL2,TOTAL3,TOTAL4 D
 .S TOTAL=$G(^TMP("SDWTTOTD",$J,SDDIV,"DIV")),TOTAL1=$P(TOTAL,U,1),TOTAL2=$P(TOTAL,U,2),TOTAL3=$P(TOTAL,U,3),TOTAL4=$P(TOTAL,U,4)
 .D TOT
SORTQ Q
PRT() ; -- print appt
 ;  return: continue processing [ 1|yes   0|no ]
 ; ^TMP("SDWAIT") nodes setup:
 ;SDCLIN^SDSTOP^SDDAY^SDDIV^DFN^SDCHKIN^SDCHKOUT^SDWTTIME^SDOTTIME^SDTTTIME
 ;   1      2      3     4    5     6       7        8         9     10
 ;
 N Y,VA,SDREQ,SDVAR,SDTIME
 S DFN=$P(SDATA,U,5) D PID^VADPT6
 W !,$E($P($G(^DPT(DFN,0)),U,1),1,17),?20,VA("BID"),?26,$S("^3^4^5^"[(U_SDSORT_U):$E(SDCLN,1,20),1:"")
 W ?46,$E($$FDTTM^VALM1($P(SDATA,U,6)),1,14),?62,$E($$FDTTM^VALM1(SDATE),1,14),?78,$$HRS($P(SDATA,U,8))
 W ?92,$E($$FDTTM^VALM1($P(SDATA,U,7)),1,14),?109,$$HRS($P(SDATA,U,9)),?120,$$HRS($P(SDATA,U,10))
 S Y=1
PRTQ Q Y
 ;
CHECK ; check to see if header should be printed
 I 'SDPAGE D HDR^SDAMOWP1 Q
 I $E(IOST,1,2)="C-",($Y+6)>IOSL D PAUSE^VALM1 D:Y HDR^SDAMOWP1 I 'Y S SDQUIT=1 Q
 I ($Y+6)>IOSL D HDR^SDAMOWP1
 Q
 ;
PAUSE ; pause for CRT
 ;
 I $E(IOST,1,2)="C-" D PAUSE^VALM1 I 'Y S SDQUIT=1
 Q
 ;
SET(SORT,LEVEL1,LEVEL2,LEVEL3,LEVEL4) ;
 I SORT=1 S SDCLN=LEVEL1,SDPAT=LEVEL2,SDATE=LEVEL3
 I SORT=2 S SDCLN=LEVEL1,SDATE=LEVEL2,SDPAT=LEVEL3
 I SORT=3 S SDSTP=LEVEL1,SDCLN=LEVEL2,SDPAT=LEVEL3,SDATE=LEVEL4
 I SORT=4 S SDSTP=LEVEL1,SDPAT=LEVEL2,SDCLN=LEVEL3,SDATE=LEVEL4
 I SORT=5 S SDPAT=LEVEL1,SDATE=LEVEL2,SDCLN=LEVEL3
 Q
 ;
TOT ; Totals Print
 ;
 W !,SDASH1,!,?62,"Total:",?78,$$HRS(TOTAL2),?109,$$HRS(TOTAL3),?120,$$HRS(TOTAL4),!,?60,"Average:",?78,$$HRS($P((TOTAL2/TOTAL1),".")),?109,$$HRS($P((TOTAL3/TOTAL1),".")),?120,$$HRS($P((TOTAL4/TOTAL1),".")) D LEGEND^SDAMOWP1
TOTQ Q
 ;
HRS(MIN) ;Convert minutes to hours
 ;
 N HRS,HRS1
 S HRS=MIN/60,HRS1=$P(HRS,"."),MIN=MIN-(HRS1*60)
 Q $S(HRS1:HRS1_"hr ",1:"")_MIN_"min"