SCRPW77 ;BP-CIOFO/KEITH,ESW - Clinic Appointment Availability Extract (cont.) ;1/5/16 12:25pm
;;5.3;Scheduling;**223,241,291,645**;AUG 13, 1993;Build 7
;
ACCRUE ;Accrue counts and averages to division and division/credit pair totals
F S SDCL=$O(^TMP("SDXNAVA",$J,SDCL)) Q:'SDCL D
.S SC0=$G(^SC(SDCL,0)) Q:'$L(SC0) Q:'$$CPAIR^SCRPW71(SC0,.SDCP)
.S SDIV=$$DIV^SCRPW71(SC0) Q:'$L(SDIV)
.Q:'$D(^TMP("SD",$J,SDIV,SDCP,SDCL))
.S:'$D(^TMP("SDNAVA",$J,SDIV,SDCP)) ^TMP("SDNAVA",$J,SDIV,SDCP)=""
.I SDMD S:'$D(^TMP("SDNAVA",$J,0,SDCP)) ^TMP("SDNAVA",$J,0,SDCP)=""
.S SDX=$P(^TMP("SDXNAVA",$J,SDCL),U,1,8)
.S $P(SDX,U,9)=$G(^TMP("SDYNAVA",$J,SDCL))
.S $P(SDX,U,38)=$P(^TMP("SDXNAVA",$J,SDCL),U,9,10)
.S SDAVE=$$AVE(SDX),^TMP("SDNAVA",$J,SDIV,SDCP,SDCL)=SDAVE
.S:$$AVE2(SDCL,.SDAVE2) ^TMP("SDNAVB",$J,SDIV,SDCP,SDCL)=SDAVE2
.I SDMD S ^TMP("SDNAVA",$J,0,SDCP,SDCL)=SDAVE
.F SDI=1:1:18 S $P(^TMP("SDNAVA",$J,SDIV),U,SDI)=$P($G(^TMP("SDNAVA",$J,SDIV)),U,SDI)+$P(SDX,U,SDI)
.F SDI=19:1:39 S $P(^TMP("SDZNAVA",$J,SDIV),U,SDI)=$P($G(^TMP("SDZNAVA",$J,SDIV)),U,SDI)+$P(SDX,U,SDI)
.I SDMD D
..F SDI=1:1:18 S $P(^TMP("SDNAVA",$J,0),U,SDI)=$P($G(^TMP("SDNAVA",$J,0)),U,SDI)+$P(SDX,U,SDI)
..F SDI=19:1:39 S $P(^TMP("SDZNAVA",$J,0),U,SDI)=$P($G(^TMP("SDNZAVA",$J,0)),U,SDI)+$P(SDX,U,SDI)
..Q
.F SDI=1:1:18 S $P(^TMP("SDNAVA",$J,SDIV,SDCP),U,SDI)=$P(^TMP("SDNAVA",$J,SDIV,SDCP),U,SDI)+$P(SDX,U,SDI)
.F SDI=19:1:39 S $P(^TMP("SDZNAVA",$J,SDIV,SDCP),U,SDI)=$P($G(^TMP("SDZNAVA",$J,SDIV,SDCP)),U,SDI)+$P(SDX,U,SDI)
.I SDMD D
..F SDI=1:1:18 S $P(^TMP("SDNAVA",$J,0,SDCP),U,SDI)=$P(^TMP("SDNAVA",$J,0,SDCP),U,SDI)+$P(SDX,U,SDI)
..F SDI=19:1:39 S $P(^TMP("SDZNAVA",$J,0,SDCP),U,SDI)=$P($G(^TMP("SDZNAVA",$J,0,SDCP)),U,SDI)+$P(SDX,U,SDI)
..Q
.S SDT=0 F S SDT=$O(^TMP("SDXNAVA",$J,SDCL,SDT)) Q:SDOUT!'SDT D
..S SDX=$P(^TMP("SDXNAVA",$J,SDCL,SDT),U,1,8)
..S $P(SDX,U,9)=$G(^TMP("SDYNAVA",$J,SDCL,SDT))
..S $P(SDX,U,38)=$P(^TMP("SDXNAVA",$J,SDCL,SDT),U,9,10)
..S ^TMP("SDNAVA",$J,SDIV,SDCP,SDCL,SDT)=$$AVE(SDX)
..Q
.Q
S SDIV="" F S SDIV=$O(^TMP("SDNAVA",$J,SDIV)) Q:'$L(SDIV) D
.S SDX=^TMP("SDNAVA",$J,SDIV)_U_$P($G(^TMP("SDZNAVA",$J,SDIV)),U,19,39)
.S ^TMP("SDNAVA",$J,SDIV)=$$AVE(SDX)
.S SDCP=0 F S SDCP=$O(^TMP("SDNAVA",$J,SDIV,SDCP)) Q:'SDCP D
..S SDX=^TMP("SDNAVA",$J,SDIV,SDCP)_U_$P($G(^TMP("SDZNAVA",$J,SDIV,SDCP)),U,19,39)
..S ^TMP("SDNAVA",$J,SDIV,SDCP)=$$AVE(SDX)
..Q
.Q
K ^TMP("SDWNAVA",$J),^TMP("SDXNAVA",$J),^TMP("SDYNAVA",$J),^TMP("SDZNAVA",$J)
Q
;
AVE(SDX) ;Calculate averages
;Input: SDX=string of appointment totals and total waiting time
;Output: string of appointment totals and average waiting time
N SDI,SDY,SDZ
F SDI=2:2:22,24:3:36 D
.S SDY=+$P(SDX,U,(SDI-1)),$P(SDX,U,(SDI-1))=SDY
.S $P(SDX,U,SDI)=$FN($S(SDY=0:0,1:$P(SDX,U,SDI)/SDY),"",1)
.Q:SDI<24
.S $P(SDX,U,SDI+1)=$FN($S(SDY=0:0,1:$P(SDX,U,SDI+1)/SDY),"",1)
.Q
S SDY=$P(SDX,U)+$P(SDX,U,5),SDZ=+$P(SDX,U,38)*100
S $P(SDX,U,38)=$FN($S(SDY=0:0,1:(SDZ/SDY)),"",1)
S SDY=$P(SDX,U,3)+$P(SDX,U,7),SDZ=+$P(SDX,U,39)*100
S $P(SDX,U,39)=$FN($S(SDY=0:0,1:(SDZ/SDY)),"",1)
Q SDX
;
AVE2(SDCL,SDAVE2) ;Format additional fields
;Input: SDCL=clinic ifn
;Input: SDAVE2=variable to return values (pass by reference)
N SDX,SDY,SDI
S SDAVE2=$G(^TMP("SDWNAVA",$J,SDCL))
Q:'$L(SDAVE2) 0
S SDY=+$P(SDAVE2,U,8)
F SDI=1:1:4 D
.S SDX=$P(SDAVE2,U,SDI)*100
.S $P(SDAVE2,U,SDI)=$FN($S(SDY=0:0,1:(SDX/SDY)),"",1)
.Q
Q 1
;
STOP ;Check for stop task request
S:$D(ZTQUEUED) (SDOUT,ZTSTOP)=$S($$S^%ZTLOAD:1,1:0) Q
;
OUT4 ;Output patient list
N SDY,SDI,SDPNAME,DFN,SDADT
I '$O(^TMP("SDPLIST",$J,SC,0)) D Q
.S SDY="No appointments scheduled during this date range were found."
.W !!?(IOM-$L(SDY)\2),SDY Q
S SDI=0 F S SDI=$O(^TMP("SDPLIST",$J,SC,SDI)) Q:SDOUT!'SDI D
.S SDPNAME=""
.F S SDPNAME=$O(^TMP("SDPLIST",$J,SC,SDI,SDPNAME)) Q:SDOUT!(SDPNAME="") D
..S DFN=0
..F S DFN=$O(^TMP("SDPLIST",$J,SC,SDI,SDPNAME,DFN)) Q:SDOUT!(DFN="") D
...S SDADT=0
...F S SDADT=$O(^TMP("SDPLIST",$J,SC,SDI,SDPNAME,DFN,SDADT)) Q:SDOUT!'SDADT D
....S SDATA=^TMP("SDPLIST",$J,SC,SDI,SDPNAME,DFN,SDADT)
....I 'SDXM,$Y>(IOSL-SDFLEN) D FOOTER(SDREPORT),HDR^SCRPW76(1,SDREPORT,SDIV,SDCP,SC)
....Q:SDOUT
....W !,$$DTX(SDI),?13,$E(SDPNAME,1,23),?38,$P(SDATA,U)
....W ?50,$$DTX(SDADT),?69,$$SRTY($P(SDATA,U,2))
....W ?98,$P(SDATA,U,3),?102,$$DTX($P(SDATA,U,4))
....W ?115,$S($P(SDATA,U,5)=0:"NO",$P(SDATA,U,5)=1:"YES",1:"")
....W ?120,$J($P(SDATA,U,7),5,0),?127,$J($P(SDATA,U,6),5,0)
....Q
...Q
..Q
.Q
Q:SDOUT D FOOTER(SDREPORT)
Q
OUT5(DFN,SC) ;Output patient list
N SDY,SDI,SDPNAME,SDADT
I '$O(^TMP("SDIPLST",$J,DFN,SC,0)) D Q
.S SDY="No appointments scheduled during this date range were found."
.W !!?(IOM-$L(SDY)\2),SDY Q
S SDI=0 F S SDI=$O(^TMP("SDIPLST",$J,DFN,SC,SDI)) Q:SDOUT!'SDI D
.S SDPNAME=""
.F S SDPNAME=$O(^TMP("SDIPLST",$J,DFN,SC,SDI,SDPNAME)) Q:SDOUT!(SDPNAME="") D
..S SDADT=0
..F S SDADT=$O(^TMP("SDIPLST",$J,DFN,SC,SDI,SDPNAME,SDADT)) Q:SDOUT!'SDADT D
...S SDATA=^TMP("SDIPLST",$J,DFN,SC,SDI,SDPNAME,SDADT)
...I 'SDXM,$Y>(IOSL-SDFLEN) D FOOTER(SDREPORT),HDR^SCRPW76(1,SDREPORT,SDIV,SDCP,SC)
...Q:SDOUT
...W !,$$DTXN(SDI),?11,$$SRTY($P(SDATA,U,2)),?31,$$DTXN($P(SDATA,U,4))
...W ?42,$$DTXN(SDADT),?52,$J($P(SDATA,U,7),5,0)
...W ?59,$J($P(SDATA,U,6),5,0),?69,$P(SDATA,U,3)
...W ?73,$S($P(SDATA,U,5)=0:"NO",$P(SDATA,U,5)=1:"YES",1:"")
...W ?79,$$DTXN($P(SDATA,U,8)),?96,$P(SDATA,U,9),?102,$P($$DTXN($P(SDATA,U,10)),"@")
...I +$P(SDATA,U,11)>0 N SDFN,SDARR,DR,DIQ,DIC,DA D W ?113,$G(SDARR(SDFN,DA,DR,"I"))
....S DR=".01",DIQ="SDARR(",DIQ(0)="I",DIC=200,SDFN=200,DA=$P(SDATA,U,11) D EN^DIQ1
...Q
..Q
.Q
Q:SDOUT D FOOTER(SDREPORT)
Q
;
SRTY(SDSRTY) ;Externalize scheduling request type
;Input: SDSRTY=internal value for request type
Q:'$L(SDSRTY) ""
Q:SDSRTY="N" "Next available"
Q:SDSRTY="C" "Not-next ava-C/R" ;Clinician Request
Q:SDSRTY="P" "Not-next ava-P/R" ;Patient Request
Q:SDSRTY="W" "Walk in appoint"
Q:SDSRTY="M" "Multi booking"
Q:SDSRTY="A" "Auto rebook"
Q "Not-next available"
;
DTX(Y) ;Externalize date
X ^DD("DD")
Q Y
;
DTXN(Y) ;External date formated to abbreviate
I +Y=0 S Y="" Q Y
X ^DD("DD")
N SDSTR S Y=$P(Y,",")_","_$E($P(Y,",",2),3,10)
I $L(Y)#2=0 S Y=$E(Y,1,3)_" "_$P(Y," ",2)
Q Y
;
;Input: SDREPORT=report element to print
N SDI,SDFL S SDFL=$S(SDREPORT=1:10,SDREPORT=2:8,SDREPORT=5:13,1:9)
I SDXM D Q
.D XMTX^SCRPW73(" ") S SDI=0
.F S SDI=$O(SDFOOT(SDREPORT,SDI)) Q:'SDI D XMTX^SCRPW73(SDFOOT(SDREPORT,SDI))
.Q
F SDI=1:1:80 Q:$Y>(IOSL-SDFL) W !
S SDI=0
F S SDI=$O(SDFOOT(SDREPORT,SDI)) Q:'SDI W !,SDFOOT(SDREPORT,SDI)
Q
;
;Input: SDTX=array to return text
I $G(SDREPORT(1)) D
.S SDTX(1,1)=SDLINE
.S SDTX(1,2)="NOTE: TYPE '0' represents appointments scheduled during the report time frame not indicated by the user or by calculation to be"
.S SDTX(1,3)="'next available' appointments. TYPE '1' represents appointments defined by the user as being 'next available' appointments. TYPE"
.S SDTX(1,4)="'2' represents appointments calculated to be 'next available' appointments. TYPE '3' represents appointments indicated both by the"
.S SDTX(1,5)="user and by calculation to be 'next available' appointments. WAIT TIME is the average number of days from the date an appointment"
.S SDTX(1,6)="was scheduled to the date it is to be performed. The '% NNA' and '% NA' columns reflect percentage of appointments scheduled within"
.S SDTX(1,7)="30 days for 'non-next available' appointments (types 0 & 2) and 'next available' appointments (types 1 & 3), respectively."
.S SDTX(1,8)=SDLINE Q
I $G(SDREPORT(2)) D
.S SDTX(2,1)=SDLINE
.; SD*5.3*645 - replaced 'desired date' with 'CID/Preferred Date' when presented to the user
.;S SDTX(2,2)="NOTE: The date range categories ('0-1', '2-7', '8-30', etc.) are based on the difference between the 'desired date' defined for the"
.S SDTX(2,2)="NOTE: The date range categories ('0-1', '2-7', '8-3, etc.) are based on the difference between the 'CID/Preferred Date' defined for the"
.S SDTX(2,3)="appointment and the date the appointment was performed. 'Wait Time' reflects the average of this difference for all appointments in"
.S SDTX(2,4)="each category. 'Follow up' status is determined by encounter activity to the same DSS ID credit pair as the appointment clinic"
.S SDTX(2,5)="within the previous 24 months."
.S SDTX(2,6)=SDLINE Q
I $G(SDREPORT(3)) D
.S SDTX(3,1)=SDLINE
.;SD*5.3*645 - replaced 'desired date' with 'CID/Preferred date' when presented to the user
.;S SDTX(3,2)="NOTE: The date range categories ('0-1', '2-7', '8-30', etc.) are based on the difference between the 'desired date' defined for the"
.S SDTX(3,2)="NOTE: The date range categories ('0-1', '2-7', '8-30, etc.) are based on the difference between the 'CID/Preferred Date' defined for the"
.S SDTX(3,3)="appointment and the date the appointment was performed. 'Wait Time1' reflects the average difference between the 'CID/Preferred Date' and"
.S SDTX(3,4)="the date the appointment was performed. 'Wait Time2' reflects the average difference between the transaction date (the date the"
.S SDTX(3,5)="appointment was entered by the Scheduling package user) and the date the appointment was performed. 'Non-follow up' status is"
.S SDTX(3,6)="determined by the absence of encounter activity to the same DSS ID credit pair as the appointment clinic in the previous 24 months."
.S SDTX(3,7)=SDLINE Q
I $G(SDREPORT(4)) D
.S SDTX(4,1)=SDLINE
.S SDTX(4,2)="NOTE: 'Next Ava. Ind.' Values--'0' = not indicated by the user or calculation to be a 'next available' appointment, '1' = defined"
.S SDTX(4,3)="by the user as a 'next available' appointment, '2' = indicated by calculation to be a 'next available' appointment, '3' = indicated"
.S SDTX(4,4)="by the user and by calculation to be a 'next available' appointment. 'Wait Time1' = the difference between the 'CID/Preferred Date' and"
.S SDTX(4,5)="the date of the appointment. 'Wait Time2' = the difference between the 'date scheduled' and the date of the appointment."
.S SDTX(4,6)=SDLINE Q
I $G(SDREPORT(5)) D FOOT^SCRPW78(.SDTX,SDLINE) Q
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSCRPW77 10448 printed Dec 13, 2024@02:44:09 Page 2
SCRPW77 ;BP-CIOFO/KEITH,ESW - Clinic Appointment Availability Extract (cont.) ;1/5/16 12:25pm
+1 ;;5.3;Scheduling;**223,241,291,645**;AUG 13, 1993;Build 7
+2 ;
ACCRUE ;Accrue counts and averages to division and division/credit pair totals
+1 FOR
SET SDCL=$ORDER(^TMP("SDXNAVA",$JOB,SDCL))
if 'SDCL
QUIT
Begin DoDot:1
+2 SET SC0=$GET(^SC(SDCL,0))
if '$LENGTH(SC0)
QUIT
if '$$CPAIR^SCRPW71(SC0,.SDCP)
QUIT
+3 SET SDIV=$$DIV^SCRPW71(SC0)
if '$LENGTH(SDIV)
QUIT
+4 if '$DATA(^TMP("SD",$JOB,SDIV,SDCP,SDCL))
QUIT
+5 if '$DATA(^TMP("SDNAVA",$JOB,SDIV,SDCP))
SET ^TMP("SDNAVA",$JOB,SDIV,SDCP)=""
+6 IF SDMD
if '$DATA(^TMP("SDNAVA",$JOB,0,SDCP))
SET ^TMP("SDNAVA",$JOB,0,SDCP)=""
+7 SET SDX=$PIECE(^TMP("SDXNAVA",$JOB,SDCL),U,1,8)
+8 SET $PIECE(SDX,U,9)=$GET(^TMP("SDYNAVA",$JOB,SDCL))
+9 SET $PIECE(SDX,U,38)=$PIECE(^TMP("SDXNAVA",$JOB,SDCL),U,9,10)
+10 SET SDAVE=$$AVE(SDX)
SET ^TMP("SDNAVA",$JOB,SDIV,SDCP,SDCL)=SDAVE
+11 if $$AVE2(SDCL,.SDAVE2)
SET ^TMP("SDNAVB",$JOB,SDIV,SDCP,SDCL)=SDAVE2
+12 IF SDMD
SET ^TMP("SDNAVA",$JOB,0,SDCP,SDCL)=SDAVE
+13 FOR SDI=1:1:18
SET $PIECE(^TMP("SDNAVA",$JOB,SDIV),U,SDI)=$PIECE($GET(^TMP("SDNAVA",$JOB,SDIV)),U,SDI)+$PIECE(SDX,U,SDI)
+14 FOR SDI=19:1:39
SET $PIECE(^TMP("SDZNAVA",$JOB,SDIV),U,SDI)=$PIECE($GET(^TMP("SDZNAVA",$JOB,SDIV)),U,SDI)+$PIECE(SDX,U,SDI)
+15 IF SDMD
Begin DoDot:2
+16 FOR SDI=1:1:18
SET $PIECE(^TMP("SDNAVA",$JOB,0),U,SDI)=$PIECE($GET(^TMP("SDNAVA",$JOB,0)),U,SDI)+$PIECE(SDX,U,SDI)
+17 FOR SDI=19:1:39
SET $PIECE(^TMP("SDZNAVA",$JOB,0),U,SDI)=$PIECE($GET(^TMP("SDNZAVA",$JOB,0)),U,SDI)+$PIECE(SDX,U,SDI)
+18 QUIT
End DoDot:2
+19 FOR SDI=1:1:18
SET $PIECE(^TMP("SDNAVA",$JOB,SDIV,SDCP),U,SDI)=$PIECE(^TMP("SDNAVA",$JOB,SDIV,SDCP),U,SDI)+$PIECE(SDX,U,SDI)
+20 FOR SDI=19:1:39
SET $PIECE(^TMP("SDZNAVA",$JOB,SDIV,SDCP),U,SDI)=$PIECE($GET(^TMP("SDZNAVA",$JOB,SDIV,SDCP)),U,SDI)+$PIECE(SDX,U,SDI)
+21 IF SDMD
Begin DoDot:2
+22 FOR SDI=1:1:18
SET $PIECE(^TMP("SDNAVA",$JOB,0,SDCP),U,SDI)=$PIECE(^TMP("SDNAVA",$JOB,0,SDCP),U,SDI)+$PIECE(SDX,U,SDI)
+23 FOR SDI=19:1:39
SET $PIECE(^TMP("SDZNAVA",$JOB,0,SDCP),U,SDI)=$PIECE($GET(^TMP("SDZNAVA",$JOB,0,SDCP)),U,SDI)+$PIECE(SDX,U,SDI)
+24 QUIT
End DoDot:2
+25 SET SDT=0
FOR
SET SDT=$ORDER(^TMP("SDXNAVA",$JOB,SDCL,SDT))
if SDOUT!'SDT
QUIT
Begin DoDot:2
+26 SET SDX=$PIECE(^TMP("SDXNAVA",$JOB,SDCL,SDT),U,1,8)
+27 SET $PIECE(SDX,U,9)=$GET(^TMP("SDYNAVA",$JOB,SDCL,SDT))
+28 SET $PIECE(SDX,U,38)=$PIECE(^TMP("SDXNAVA",$JOB,SDCL,SDT),U,9,10)
+29 SET ^TMP("SDNAVA",$JOB,SDIV,SDCP,SDCL,SDT)=$$AVE(SDX)
+30 QUIT
End DoDot:2
+31 QUIT
End DoDot:1
+32 SET SDIV=""
FOR
SET SDIV=$ORDER(^TMP("SDNAVA",$JOB,SDIV))
if '$LENGTH(SDIV)
QUIT
Begin DoDot:1
+33 SET SDX=^TMP("SDNAVA",$JOB,SDIV)_U_$PIECE($GET(^TMP("SDZNAVA",$JOB,SDIV)),U,19,39)
+34 SET ^TMP("SDNAVA",$JOB,SDIV)=$$AVE(SDX)
+35 SET SDCP=0
FOR
SET SDCP=$ORDER(^TMP("SDNAVA",$JOB,SDIV,SDCP))
if 'SDCP
QUIT
Begin DoDot:2
+36 SET SDX=^TMP("SDNAVA",$JOB,SDIV,SDCP)_U_$PIECE($GET(^TMP("SDZNAVA",$JOB,SDIV,SDCP)),U,19,39)
+37 SET ^TMP("SDNAVA",$JOB,SDIV,SDCP)=$$AVE(SDX)
+38 QUIT
End DoDot:2
+39 QUIT
End DoDot:1
+40 KILL ^TMP("SDWNAVA",$JOB),^TMP("SDXNAVA",$JOB),^TMP("SDYNAVA",$JOB),^TMP("SDZNAVA",$JOB)
+41 QUIT
+42 ;
AVE(SDX) ;Calculate averages
+1 ;Input: SDX=string of appointment totals and total waiting time
+2 ;Output: string of appointment totals and average waiting time
+3 NEW SDI,SDY,SDZ
+4 FOR SDI=2:2:22,24:3:36
Begin DoDot:1
+5 SET SDY=+$PIECE(SDX,U,(SDI-1))
SET $PIECE(SDX,U,(SDI-1))=SDY
+6 SET $PIECE(SDX,U,SDI)=$FNUMBER($SELECT(SDY=0:0,1:$PIECE(SDX,U,SDI)/SDY),"",1)
+7 if SDI<24
QUIT
+8 SET $PIECE(SDX,U,SDI+1)=$FNUMBER($SELECT(SDY=0:0,1:$PIECE(SDX,U,SDI+1)/SDY),"",1)
+9 QUIT
End DoDot:1
+10 SET SDY=$PIECE(SDX,U)+$PIECE(SDX,U,5)
SET SDZ=+$PIECE(SDX,U,38)*100
+11 SET $PIECE(SDX,U,38)=$FNUMBER($SELECT(SDY=0:0,1:(SDZ/SDY)),"",1)
+12 SET SDY=$PIECE(SDX,U,3)+$PIECE(SDX,U,7)
SET SDZ=+$PIECE(SDX,U,39)*100
+13 SET $PIECE(SDX,U,39)=$FNUMBER($SELECT(SDY=0:0,1:(SDZ/SDY)),"",1)
+14 QUIT SDX
+15 ;
AVE2(SDCL,SDAVE2) ;Format additional fields
+1 ;Input: SDCL=clinic ifn
+2 ;Input: SDAVE2=variable to return values (pass by reference)
+3 NEW SDX,SDY,SDI
+4 SET SDAVE2=$GET(^TMP("SDWNAVA",$JOB,SDCL))
+5 if '$LENGTH(SDAVE2)
QUIT 0
+6 SET SDY=+$PIECE(SDAVE2,U,8)
+7 FOR SDI=1:1:4
Begin DoDot:1
+8 SET SDX=$PIECE(SDAVE2,U,SDI)*100
+9 SET $PIECE(SDAVE2,U,SDI)=$FNUMBER($SELECT(SDY=0:0,1:(SDX/SDY)),"",1)
+10 QUIT
End DoDot:1
+11 QUIT 1
+12 ;
STOP ;Check for stop task request
+1 if $DATA(ZTQUEUED)
SET (SDOUT,ZTSTOP)=$SELECT($$S^%ZTLOAD:1,1:0)
QUIT
+2 ;
OUT4 ;Output patient list
+1 NEW SDY,SDI,SDPNAME,DFN,SDADT
+2 IF '$ORDER(^TMP("SDPLIST",$JOB,SC,0))
Begin DoDot:1
+3 SET SDY="No appointments scheduled during this date range were found."
+4 WRITE !!?(IOM-$LENGTH(SDY)\2),SDY
QUIT
End DoDot:1
QUIT
+5 SET SDI=0
FOR
SET SDI=$ORDER(^TMP("SDPLIST",$JOB,SC,SDI))
if SDOUT!'SDI
QUIT
Begin DoDot:1
+6 SET SDPNAME=""
+7 FOR
SET SDPNAME=$ORDER(^TMP("SDPLIST",$JOB,SC,SDI,SDPNAME))
if SDOUT!(SDPNAME="")
QUIT
Begin DoDot:2
+8 SET DFN=0
+9 FOR
SET DFN=$ORDER(^TMP("SDPLIST",$JOB,SC,SDI,SDPNAME,DFN))
if SDOUT!(DFN="")
QUIT
Begin DoDot:3
+10 SET SDADT=0
+11 FOR
SET SDADT=$ORDER(^TMP("SDPLIST",$JOB,SC,SDI,SDPNAME,DFN,SDADT))
if SDOUT!'SDADT
QUIT
Begin DoDot:4
+12 SET SDATA=^TMP("SDPLIST",$JOB,SC,SDI,SDPNAME,DFN,SDADT)
+13 IF 'SDXM
IF $Y>(IOSL-SDFLEN)
DO FOOTER(SDREPORT)
DO HDR^SCRPW76(1,SDREPORT,SDIV,SDCP,SC)
+14 if SDOUT
QUIT
+15 WRITE !,$$DTX(SDI),?13,$EXTRACT(SDPNAME,1,23),?38,$PIECE(SDATA,U)
+16 WRITE ?50,$$DTX(SDADT),?69,$$SRTY($PIECE(SDATA,U,2))
+17 WRITE ?98,$PIECE(SDATA,U,3),?102,$$DTX($PIECE(SDATA,U,4))
+18 WRITE ?115,$SELECT($PIECE(SDATA,U,5)=0:"NO",$PIECE(SDATA,U,5)=1:"YES",1:"")
+19 WRITE ?120,$JUSTIFY($PIECE(SDATA,U,7),5,0),?127,$JUSTIFY($PIECE(SDATA,U,6),5,0)
+20 QUIT
End DoDot:4
+21 QUIT
End DoDot:3
+22 QUIT
End DoDot:2
+23 QUIT
End DoDot:1
+24 if SDOUT
QUIT
DO FOOTER(SDREPORT)
+25 QUIT
OUT5(DFN,SC) ;Output patient list
+1 NEW SDY,SDI,SDPNAME,SDADT
+2 IF '$ORDER(^TMP("SDIPLST",$JOB,DFN,SC,0))
Begin DoDot:1
+3 SET SDY="No appointments scheduled during this date range were found."
+4 WRITE !!?(IOM-$LENGTH(SDY)\2),SDY
QUIT
End DoDot:1
QUIT
+5 SET SDI=0
FOR
SET SDI=$ORDER(^TMP("SDIPLST",$JOB,DFN,SC,SDI))
if SDOUT!'SDI
QUIT
Begin DoDot:1
+6 SET SDPNAME=""
+7 FOR
SET SDPNAME=$ORDER(^TMP("SDIPLST",$JOB,DFN,SC,SDI,SDPNAME))
if SDOUT!(SDPNAME="")
QUIT
Begin DoDot:2
+8 SET SDADT=0
+9 FOR
SET SDADT=$ORDER(^TMP("SDIPLST",$JOB,DFN,SC,SDI,SDPNAME,SDADT))
if SDOUT!'SDADT
QUIT
Begin DoDot:3
+10 SET SDATA=^TMP("SDIPLST",$JOB,DFN,SC,SDI,SDPNAME,SDADT)
+11 IF 'SDXM
IF $Y>(IOSL-SDFLEN)
DO FOOTER(SDREPORT)
DO HDR^SCRPW76(1,SDREPORT,SDIV,SDCP,SC)
+12 if SDOUT
QUIT
+13 WRITE !,$$DTXN(SDI),?11,$$SRTY($PIECE(SDATA,U,2)),?31,$$DTXN($PIECE(SDATA,U,4))
+14 WRITE ?42,$$DTXN(SDADT),?52,$JUSTIFY($PIECE(SDATA,U,7),5,0)
+15 WRITE ?59,$JUSTIFY($PIECE(SDATA,U,6),5,0),?69,$PIECE(SDATA,U,3)
+16 WRITE ?73,$SELECT($PIECE(SDATA,U,5)=0:"NO",$PIECE(SDATA,U,5)=1:"YES",1:"")
+17 WRITE ?79,$$DTXN($PIECE(SDATA,U,8)),?96,$PIECE(SDATA,U,9),?102,$PIECE($$DTXN($PIECE(SDATA,U,10)),"@")
+18 IF +$PIECE(SDATA,U,11)>0
NEW SDFN,SDARR,DR,DIQ,DIC,DA
Begin DoDot:4
+19 SET DR=".01"
SET DIQ="SDARR("
SET DIQ(0)="I"
SET DIC=200
SET SDFN=200
SET DA=$PIECE(SDATA,U,11)
DO EN^DIQ1
End DoDot:4
WRITE ?113,$GET(SDARR(SDFN,DA,DR,"I"))
+20 QUIT
End DoDot:3
+21 QUIT
End DoDot:2
+22 QUIT
End DoDot:1
+23 if SDOUT
QUIT
DO FOOTER(SDREPORT)
+24 QUIT
+25 ;
SRTY(SDSRTY) ;Externalize scheduling request type
+1 ;Input: SDSRTY=internal value for request type
+2 if '$LENGTH(SDSRTY)
QUIT ""
+3 if SDSRTY="N"
QUIT "Next available"
+4 ;Clinician Request
if SDSRTY="C"
QUIT "Not-next ava-C/R"
+5 ;Patient Request
if SDSRTY="P"
QUIT "Not-next ava-P/R"
+6 if SDSRTY="W"
QUIT "Walk in appoint"
+7 if SDSRTY="M"
QUIT "Multi booking"
+8 if SDSRTY="A"
QUIT "Auto rebook"
+9 QUIT "Not-next available"
+10 ;
DTX(Y) ;Externalize date
+1 XECUTE ^DD("DD")
+2 QUIT Y
+3 ;
DTXN(Y) ;External date formated to abbreviate
+1 IF +Y=0
SET Y=""
QUIT Y
+2 XECUTE ^DD("DD")
+3 NEW SDSTR
SET Y=$PIECE(Y,",")_","_$EXTRACT($PIECE(Y,",",2),3,10)
+4 IF $LENGTH(Y)#2=0
SET Y=$EXTRACT(Y,1,3)_" "_$PIECE(Y," ",2)
+5 QUIT Y
+6 ;
+1 ;Input: SDREPORT=report element to print
+2 NEW SDI,SDFL
SET SDFL=$SELECT(SDREPORT=1:10,SDREPORT=2:8,SDREPORT=5:13,1:9)
+3 IF SDXM
Begin DoDot:1
+4 DO XMTX^SCRPW73(" ")
SET SDI=0
+5 FOR
SET SDI=$ORDER(SDFOOT(SDREPORT,SDI))
if 'SDI
QUIT
DO XMTX^SCRPW73(SDFOOT(SDREPORT,SDI))
+6 QUIT
End DoDot:1
QUIT
+7 FOR SDI=1:1:80
if $Y>(IOSL-SDFL)
QUIT
WRITE !
+8 SET SDI=0
+9 FOR
SET SDI=$ORDER(SDFOOT(SDREPORT,SDI))
if 'SDI
QUIT
WRITE !,SDFOOT(SDREPORT,SDI)
+10 QUIT
+11 ;
+1 ;Input: SDTX=array to return text
+2 IF $GET(SDREPORT(1))
Begin DoDot:1
+3 SET SDTX(1,1)=SDLINE
+4 SET SDTX(1,2)="NOTE: TYPE '0' represents appointments scheduled during the report time frame not indicated by the user or by calculation to be"
+5 SET SDTX(1,3)="'next available' appointments. TYPE '1' represents appointments defined by the user as being 'next available' appointments. TYPE"
+6 SET SDTX(1,4)="'2' represents appointments calculated to be 'next available' appointments. TYPE '3' represents appointments indicated both by the"
+7 SET SDTX(1,5)="user and by calculation to be 'next available' appointments. WAIT TIME is the average number of days from the date an appointment"
+8 SET SDTX(1,6)="was scheduled to the date it is to be performed. The '% NNA' and '% NA' columns reflect percentage of appointments scheduled within"
+9 SET SDTX(1,7)="30 days for 'non-next available' appointments (types 0 & 2) and 'next available' appointments (types 1 & 3), respectively."
+10 SET SDTX(1,8)=SDLINE
QUIT
End DoDot:1
+11 IF $GET(SDREPORT(2))
Begin DoDot:1
+12 SET SDTX(2,1)=SDLINE
+13 ; SD*5.3*645 - replaced 'desired date' with 'CID/Preferred Date' when presented to the user
+14 ;S SDTX(2,2)="NOTE: The date range categories ('0-1', '2-7', '8-30', etc.) are based on the difference between the 'desired date' defined for the"
+15 SET SDTX(2,2)="NOTE: The date range categories ('0-1', '2-7', '8-3, etc.) are based on the difference between the 'CID/Preferred Date' defined for the"
+16 SET SDTX(2,3)="appointment and the date the appointment was performed. 'Wait Time' reflects the average of this difference for all appointments in"
+17 SET SDTX(2,4)="each category. 'Follow up' status is determined by encounter activity to the same DSS ID credit pair as the appointment clinic"
+18 SET SDTX(2,5)="within the previous 24 months."
+19 SET SDTX(2,6)=SDLINE
QUIT
End DoDot:1
+20 IF $GET(SDREPORT(3))
Begin DoDot:1
+21 SET SDTX(3,1)=SDLINE
+22 ;SD*5.3*645 - replaced 'desired date' with 'CID/Preferred date' when presented to the user
+23 ;S SDTX(3,2)="NOTE: The date range categories ('0-1', '2-7', '8-30', etc.) are based on the difference between the 'desired date' defined for the"
+24 SET SDTX(3,2)="NOTE: The date range categories ('0-1', '2-7', '8-30, etc.) are based on the difference between the 'CID/Preferred Date' defined for the"
+25 SET SDTX(3,3)="appointment and the date the appointment was performed. 'Wait Time1' reflects the average difference between the 'CID/Preferred Date' and"
+26 SET SDTX(3,4)="the date the appointment was performed. 'Wait Time2' reflects the average difference between the transaction date (the date the"
+27 SET SDTX(3,5)="appointment was entered by the Scheduling package user) and the date the appointment was performed. 'Non-follow up' status is"
+28 SET SDTX(3,6)="determined by the absence of encounter activity to the same DSS ID credit pair as the appointment clinic in the previous 24 months."
+29 SET SDTX(3,7)=SDLINE
QUIT
End DoDot:1
+30 IF $GET(SDREPORT(4))
Begin DoDot:1
+31 SET SDTX(4,1)=SDLINE
+32 SET SDTX(4,2)="NOTE: 'Next Ava. Ind.' Values--'0' = not indicated by the user or calculation to be a 'next available' appointment, '1' = defined"
+33 SET SDTX(4,3)="by the user as a 'next available' appointment, '2' = indicated by calculation to be a 'next available' appointment, '3' = indicated"
+34 SET SDTX(4,4)="by the user and by calculation to be a 'next available' appointment. 'Wait Time1' = the difference between the 'CID/Preferred Date' and"
+35 SET SDTX(4,5)="the date of the appointment. 'Wait Time2' = the difference between the 'date scheduled' and the date of the appointment."
+36 SET SDTX(4,6)=SDLINE
QUIT
End DoDot:1
+37 IF $GET(SDREPORT(5))
DO FOOT^SCRPW78(.SDTX,SDLINE)
QUIT
+38 QUIT