1 | SDM0 ;SF/GFT - MAKE APPOINTMENT ; 11 Jun 2001 5:20 PM
|
---|
2 | ;;5.3;Scheduling;**140,167,206,186,223,237,241,384,334**;Aug 13, 1993
|
---|
3 | I $D(SDXXX) S SDOK=1 Q
|
---|
4 | N SDSRTY,SDDATE,SDSDATE,SDSRFU,SDDMAX,SDONCE
|
---|
5 | ;Prompt for scheduling request type
|
---|
6 | M N SDHX,SDXF,SDXD
|
---|
7 | Q:'$$SRTY(.SDSRTY) S:SDSRTY SDDATE=DT
|
---|
8 | ;Calculate appointment follow-up indicator
|
---|
9 | S SDSRFU=$$PTFU(DFN,SC)
|
---|
10 | ;Determine maximum days for scheduling
|
---|
11 | S SDMAX(1)=$P($G(^SC(+SC,"SDP")),U,2) S:'SDMAX(1) SDMAX(1)=365
|
---|
12 | S (SDMAX,SDDMAX)=$$FMADD^XLFDT(DT,SDMAX(1))
|
---|
13 | ;Prompt for desired date
|
---|
14 | Q:'$$DDATE(.SDDATE,SDSRTY,.SDMAX)
|
---|
15 | ;If date and time, schedule appt. directly
|
---|
16 | W ! I SDDATE#1 S SDSDATE=SDDATE,SDDATE=SDDATE\1 G ^SDM1
|
---|
17 | S (X,Y)=SDDATE K SDHX
|
---|
18 | ;Find first available after specified date
|
---|
19 | I X="F"!(X="f") D SUP,DT1 G NEXT
|
---|
20 | ;Find next available appointment
|
---|
21 | I SDSRTY,SDDATE D SUP S SDSTRTDT=SDDATE D OVR^SDMULT0 G NEXT
|
---|
22 | ;
|
---|
23 | EN S:$L(X)=1 X=$TR(X,"tnN","TTT") S:X="NOW" X="T" I X?.A!(+X=X),X<13,X'?1"T".E S X=X_" 1"
|
---|
24 | D Q:Y<1
|
---|
25 | .N %DT
|
---|
26 | .S %DT="T" D ^%DT
|
---|
27 | .I Y<1 W !!,"Unable to evaluate date value """_X_""".",!
|
---|
28 | .Q
|
---|
29 | S:$S($D(DUZ)'[0:1,1:0) ^DISV(DUZ_U_+SC)=Y
|
---|
30 | DISP S IOF=$S('$D(IOF):"!#",IOF']"":"!#",1:IOF) W @IOF S SDSOH=$S('$D(^SC(+SC,"SL")):0,$P(^("SL"),"^",8)']"":0,1:1),SDAV=0
|
---|
31 | I $D(SDINA),Y'<SDINA,SDRE>Y!('SDRE) S SDHY=Y,Y=SDINA D DTS^SDUTL W !,*7,"Clinic is inactive ",$S(SDRE:"from ",1:"as of "),Y S Y=SDRE D:Y DTS^SDUTL W $S(SDRE:" to "_Y,1:"") S Y=SDHY K SDHY D PAUSE^VALM1 Q:'SDRE
|
---|
32 | S:Y#100=0 Y=Y+1 S X=Y D D:$E(X,4,5) S (SDX,X1)=X,X2=1 D C^%DTC S X=SDX K SDX G:SDAV ^SDM1 Q
|
---|
33 | ;
|
---|
34 | NEXT D SET I $S('$D(FND):1,'FND:1,1:0) D G EN
|
---|
35 | .K ^DISV($S($D(DUZ)'[0:DUZ,1:0)_U_+SC)
|
---|
36 | .I '$O(^SC(+SC,"ST",SDDATE-1)) S (X,Y)=SDDATE Q
|
---|
37 | .W $C(7),!?6,"No open slots found in the date range "
|
---|
38 | .W $$FMTE^XLFDT(SDDATE)," to ",$$FMTE^XLFDT(SDDMAX),"!",!
|
---|
39 | .H 3 S (X,Y)=SDDATE
|
---|
40 | .Q
|
---|
41 | S (X,Y)=SDAPP K SDXXX G DISP
|
---|
42 | D W #!?36,$P(SC,U,2) S:$O(^SC(+SC,"T",0))>X X=+$O(^(0)) D DOW S I=Y+32,D=Y S SDXF=0 D WM I SDXF D WMH
|
---|
43 | X1 S X1=X\100_$P("31^28^31^30^31^30^31^31^30^31^30^31",U,+$E(X,4,5)) ;28
|
---|
44 | W I '$D(^SC(+SC,"ST",X,1)) S Y=D#7 G L:'$D(J(Y)),H:$D(^HOLIDAY(X))&('SDSOH) S SS=+$O(^SC(+SC,"T"_Y,X)) G L:SS'>0,L:^(SS,1)="" S ^SC(+SC,"ST",$P(X,"."),1)=$E($P($T(DAY),U,Y+2),1,2)_" "_$E(X,6,7)_$J("",SI+SI-6)_^(1),^(0)=$P(X,".")
|
---|
45 | S SDHX=X,SDAV=1 D:X>SM WM I SDXF<2 D WMH
|
---|
46 | I $D(^SC(+SC,"ST",X,1)),^(1)["["!(^(1)["CANCELLED")!($D(^HOLIDAY(X))) W !,$E(^SC(+SC,"ST",X,1),1,80) S:'$D(^HOLIDAY(X))&('SDAV) SDAV=1
|
---|
47 | I $Y>18 W ! Q
|
---|
48 | L S X=X+1,D=D+1
|
---|
49 | I $D(SDINA),X>SDINA,SDRE>X!('SDRE) D:'SDAV NOAV S SDHY=Y,Y=SDINA D DTS^SDUTL W !,*7,?8,"Clinic is inactive ",$S(SDRE:"from ",1:"as of "),Y S Y=SDRE D:Y DTS^SDUTL W $S(SDRE:" to "_Y,1:"") S Y=SDHY K SDHY Q:'SDRE D DIFF
|
---|
50 | G W:X'>X1 S X2=X-X1 D C^%DTC
|
---|
51 | I $D(SDINA),X>SDINA,SDRE>X!('SDRE) D:'SDAV NOAV S SDHY=Y,Y=SDINA D DTS^SDUTL W !,*7,?8,"Clinic is inactive ",$S(SDRE:"from ",1:"as of "),Y S Y=SDRE D:Y DTS^SDUTL W $S(SDRE:" to "_Y,1:"") S Y=SDHY K SDHY Q:'SDRE
|
---|
52 | G X1:D<I W ! D:'SDAV MNTH Q
|
---|
53 | ;
|
---|
54 | NOAV W !,"No availability found between date chosen and inactivate date!" Q
|
---|
55 | H S ^SC(+SC,"ST",X,1)=" "_$E(X,6,7)_" "_$P(^(X,0),U,2),^(0)=X G W
|
---|
56 | ;
|
---|
57 | WM W !?36 S Y=$E(X,1,5)_"00",SM=$S($E(X,4,5)[12:$E(X,1,3)+1_"01",1:$E(X,1,3)_$E(X,4,5)+1)_"00"
|
---|
58 | S SDXF=SDXF+1 I $E(X,6,7)>20 D
|
---|
59 | . S SDXD=$O(^SC(+SC,"ST",X-1)) Q:SDXD=""
|
---|
60 | . I $E(SDXD,4,5)'=$E(X,4,5) S SDXF=0
|
---|
61 | D:SDXF DT
|
---|
62 | Q
|
---|
63 | WMH ;Write month heading lines
|
---|
64 | W !!," TIME",?SI+SI-1 F Y=STARTDAY:1:65\(SI+SI)+STARTDAY W $E("|"_$S('Y:0,1:(Y-1#12+1))_" ",1,SI+SI)
|
---|
65 | W !," DATE",?SI+SI-1,"|" K J F Y=0:1:6 I $D(^SC(+SC,"T"_Y)) S J(Y)=""
|
---|
66 | F Y=1:1:65\(SI+SI) W $J("|",SI+SI)
|
---|
67 | S SDXF=2
|
---|
68 | Q
|
---|
69 | DT W $$FMTE^XLFDT(Y) Q
|
---|
70 | ;
|
---|
71 | DOW S Y=$$DOW^XLFDT(X,1) Q
|
---|
72 | ;
|
---|
73 | DAY ;;^SUN^MON^TUES^WEDNES^THURS^FRI^SATUR
|
---|
74 | MORDIS I '$D(SDHX) W *7," ??" G ADT^SDM1
|
---|
75 | S SDXF=0,X1=SDHX,X2=1 D C^%DTC
|
---|
76 | MORD2 I $D(SDINA),SDINA'>X,SDRE>X!('SDRE) S SDHY=$S($D(Y):Y,1:""),Y=SDINA D DTS^SDUTL W *7,!,"Clinic is inactivated as of ",Y S Y=SDHY K SDHY G ADT^SDM1
|
---|
77 | G EN
|
---|
78 | INPAT S SDI=$O(^DGPM("ATID1",DFN,9999999-X)) I SDI>0 D I1
|
---|
79 | S:'$D(SDINP) SDINP="" K SDI,SDI1 Q
|
---|
80 | I1 F SDI1=0:0 S SDI1=$O(^DGPM("ATID1",DFN,SDI,SDI1)) Q:SDI1'>0 I $D(^DGPM(SDI1,0)) S SDX=^(0) I $S($P(SDX,U,17)']"":1,+^DGPM($P(SDX,U,17),0)>X!(+^DGPM($P(SDX,U,17),0)=0):1,1:0) S SDINP="I" Q
|
---|
81 | Q
|
---|
82 | ;
|
---|
83 | SUP ;Set up variables for availability search
|
---|
84 | S SDNEXT=1,SDCT=1,G1=+SC,SDC(1)=SC,FND=0,SDAV=0 K SDC1
|
---|
85 | D SAVE S IOP=$S($D(ION):ION,1:"HOME") D ^%ZIS K IOP
|
---|
86 | Q
|
---|
87 | ;
|
---|
88 | SET S I1="" F I=0:0 S I1=$O(SDZ(I1)) Q:I1']"" S @I1=SDZ(I1)
|
---|
89 | K SDZ Q
|
---|
90 | SAVE K SDZ F I="SDDIF","STR","SC","DFN","SL","SI","HSI","SB" S Z="SDZ("_""""_I_""")" S:$D(@I) @Z=@I
|
---|
91 | Q
|
---|
92 | MNTH W !," *** No availability found for one full calendar month",!," Search stopped at " S Y=X D DTS^SDUTL W Y," ***",! Q
|
---|
93 | DIFF S X1=SDRE,X2=X D ^%DTC S D=D+X,X=SDRE,X1=X\100_28 Q
|
---|
94 | ;
|
---|
95 | SRTY(SDSRTY) ;Prompt for scheduling request type
|
---|
96 | ;Input: SDSRTY=variable to return user response (pass by reference)
|
---|
97 | ;Output: '1' if successful, '0' otherwise
|
---|
98 | ;
|
---|
99 | I $G(DFN)<1 S SDSRTY="M" Q 1 ;patient not defined
|
---|
100 | I $G(SDMM)=1 S SDSRTY="M" Q 1 ;multiple appointment booking
|
---|
101 | N DIR,DTOUT,DUOUT
|
---|
102 | S DIR(0)="Y"
|
---|
103 | S DIR("A")="IS THIS A 'NEXT AVAILABLE' APPOINTMENT REQUEST"
|
---|
104 | S DIR("?")="Answer 'yes' if scheduling to the next available appointment is desired."
|
---|
105 | W ! D ^DIR I $D(DTOUT)!$D(DUOUT) Q 0
|
---|
106 | S SDSRTY=Y,SDSRTY(0)=$$TXRT^SDM1A(.SDSRTY) Q 1
|
---|
107 | ;
|
---|
108 | PTFU(DFN,SC) ;Determine if this is a follow-up (return to clinic within 24 months)
|
---|
109 | ;Input: DFN=patient ifn
|
---|
110 | ;Input: SC=clinic ifn
|
---|
111 | ;Output: '1' if seen within 24 months, '0' otherwise
|
---|
112 | ;
|
---|
113 | Q:'DFN!'SC 0 ;variable check
|
---|
114 | N SDBDT,SDT,SDX,SDY,SDZ,SDCP,SDCP1,SC0,SDENC,SDCT
|
---|
115 | ;set up variables
|
---|
116 | S SDBDT=(DT-20000)+.24,SDT=DT_.999999,(SDCT,SDY)=0
|
---|
117 | S SC0=$G(^SC(+SC,0)),SDX=$$CPAIR^SCRPW71(SC0,.SDCP) ;get credit pair for this clinic
|
---|
118 | ;Iterate through encounters
|
---|
119 | W !!,"Calculating follow-up status"
|
---|
120 | F S SDT=$O(^SCE("ADFN",DFN,SDT),-1) Q:SDT<SDBDT!SDY D
|
---|
121 | .S SDENC=0 F S SDENC=$O(^SCE("ADFN",DFN,SDT,SDENC)) Q:'SDENC!SDY D
|
---|
122 | ..S SDENC0=$G(^SCE(SDENC,0)) ;get encounter node
|
---|
123 | ..Q:$P(SDENC0,U,6) ;parent encounters only
|
---|
124 | ..S SDX=$P(SDENC0,U,4) Q:'SDX ;get clinic
|
---|
125 | ..S SC0=$G(^SC(SDX,0))
|
---|
126 | ..S SDX=$$CPAIR^SCRPW71(SC0,.SDCP1) ;get credit pair for encounter
|
---|
127 | ..S SDY=SDCP=SDCP1 ;compare credit pairs
|
---|
128 | ..S SDCT=SDCT+1 W:SDCT#10=0 "."
|
---|
129 | ..Q
|
---|
130 | .Q
|
---|
131 | Q SDY
|
---|
132 | ;
|
---|
133 | DDATE(SDDATE,SDSRTY,SDMAX) ;Desired date selection
|
---|
134 | ;Input: SDDATE=variable to return date selection (pass by reference)
|
---|
135 | ;Input: SDSRTY=variable to return request type
|
---|
136 | ;Input: SDMAX=variable to return max. days to sched. (pass by ref.)
|
---|
137 | ;Output: '1' for success, otherwise '0'
|
---|
138 | ;
|
---|
139 | Q:SDSRTY 1
|
---|
140 | W !!?2,"Select one of the following:",!
|
---|
141 | W !?5,"'F'",?20,"for First available following a specified date"
|
---|
142 | W !?5,"Date",?20,"(or date computation such as 'T+2M') for a desired date"
|
---|
143 | I DFN>0 W !?5,"Date/time",?20,"to schedule a specific appointment"
|
---|
144 | W !?5,"'?'",?20,"for detailed help"
|
---|
145 | DASK N DIR,X,Y,SDX,DTOUT,DUOUT
|
---|
146 | ;
|
---|
147 | ;BP OIFO/TEH PATCH SD*5.3*384
|
---|
148 | ;
|
---|
149 | S DIR(0)="F^1:30"
|
---|
150 | S DIR("A")="ENTER THE DATE DESIRED FOR THIS APPOINTMENT"
|
---|
151 | S DIR("?",1)=" Enter the date that is desired for this appointment."
|
---|
152 | S DIR("?",2)=""
|
---|
153 | S DIR("?",3)=" You may enter 'F' to find the first available slot after a specifed date."
|
---|
154 | S DIR("?",4)=" You will be prompted for begin and end dates for this search."
|
---|
155 | S DIR("?",5)=""
|
---|
156 | S DIR("?",6)=" A date may be entered to begin the display of clinic availability at the"
|
---|
157 | I DFN<1 S DIR("?")=" requested date."
|
---|
158 | I DFN>0 D
|
---|
159 | .S DIR("?",7)=" requested date."
|
---|
160 | .S DIR("?",8)=""
|
---|
161 | .S DIR("?",9)=" The entry of a date/time will result in the scheduling of an appointment at"
|
---|
162 | .S DIR("?")=" that time, if possible."
|
---|
163 | .Q
|
---|
164 | W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) 0
|
---|
165 | I Y=" " S SDX=$G(^DISV(DUZ_U_+SC)) I SDX?7N S (X,Y)=SDX
|
---|
166 | I $L(Y)=1,"fF"[Y D Q 1
|
---|
167 | .W " First available"
|
---|
168 | .S (SDDATE,SDSRTY)=$TR(Y,"f","F")
|
---|
169 | .Q
|
---|
170 | N %DT,SDX,SDI
|
---|
171 | S SDX="N^n^NOW^now^Now" F SDI=1:1:5 S:X=$P(SDX,U,SDI) X="T"
|
---|
172 | S %DT="EFT" D ^%DT
|
---|
173 | G:Y<1 DASK S SDDATE=Y
|
---|
174 | I DFN<1 S SDDATE=SDDATE\1
|
---|
175 | I DFN>0,Y'<DT,(Y\1)>SDMAX D G DASK
|
---|
176 | .W !,$C(7)
|
---|
177 | .W "Scheduling cannot be more than ",SDMAX(1)," days in the future"
|
---|
178 | .Q
|
---|
179 | Q 1
|
---|
180 | ;
|
---|
181 | 1 S SDNEXT="",SDCT=0 G RD^SDMULT
|
---|
182 | DT1 S FND=0,%DT(0)=-SDMAX,%DT="AEF",%DT("A")=" START SEARCH FOR NEXT AVAILABLE FROM WHAT DATE: " D ^%DT K %DT G:"^"[X 1:$S('$D(SDNEXT):1,'SDNEXT:1,1:0),END^SDMULT0 G:Y<0 DT S (SDDATE,SDSTRTDT)=+Y
|
---|
183 | LIM W !," ENTER LATEST DATE TO CHECK FOR 1ST AVAILABLE SLOT: " S Y=SDMAX D DT^DIQ R "// ",X:DTIME G:X["^"!'($T) END^SDMULT0 I X']"" G OVR^SDMULT0
|
---|
184 | I X?.E1"?" W !," The latest date for future bookings for ",$P(SDC(1),"^",2)," is: " S Y=SDMAX D DTS^SDUTL W Y,!," If you enter a date here, it must be less than this date to further limit the",!," search" G LIM
|
---|
185 | S %DT="EF",%DT(0)=-SDMAX D ^%DT K %DT G:Y<0!(Y<SDSTRTDT) LIM S:Y>0 (SDDMAX,SDMAX)=+Y
|
---|
186 | G OVR^SDMULT0
|
---|