1 | BSDX07 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 1/26/11 11:29am
|
---|
2 | ;;1.5;BSDX;;Jan 25, 2011
|
---|
3 | ;
|
---|
4 | ; Change Log:
|
---|
5 | ; UJO/SMH
|
---|
6 | ; v1.3 July 13 2010 - Add support i18n - Dates input as FM dates, not US.
|
---|
7 | ; v1.42 Oct 22 2010 - Transaction now restartable by providing arguments
|
---|
8 | ; thanks to Rick Marshall and Zach Gonzalez at Oroville.
|
---|
9 | ; v1.42 Oct 30 2010 - Extensive refactoring.
|
---|
10 | ;
|
---|
11 | ; Error Reference:
|
---|
12 | ; -1: Patient Record is locked. This means something is wrong!!!!
|
---|
13 | ; -2: Start Time is not a valid Fileman date
|
---|
14 | ; -3: End Time is not a valid Fileman date
|
---|
15 | ; -4: End Time does not have time inside of it.
|
---|
16 | ; -5: BSDXPATID is not numeric
|
---|
17 | ; -6: Patient Does not exist in ^DPT
|
---|
18 | ; -7: Resource Name does not exist in B index of BSDX RESOURCE
|
---|
19 | ; -8: Resouce doesn't exist in ^BSDXRES
|
---|
20 | ; -9: Couldn't add appointment to BSDX APPOINTMENT
|
---|
21 | ; -10: Couldn't add appointment to files 2 and/or 44
|
---|
22 | ; -100: Mumps Error
|
---|
23 |
|
---|
24 | APPADDD(BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID) ;EP
|
---|
25 | ;Entry point for debugging
|
---|
26 | D DEBUG^%Serenji("APPADD^BSDX07(.BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID)")
|
---|
27 | Q
|
---|
28 | ;
|
---|
29 | UT ; Unit Tests
|
---|
30 | N ZZZ
|
---|
31 | ; Test for bad start date
|
---|
32 | D APPADD(.ZZZ,2100123,3100123.3,2,"Dr Office",30,"Sam's Note",1)
|
---|
33 | I +$P(^BSDXTMP($J,1),U,2)'=-2 W "Error in -2",!
|
---|
34 | ; Test for bad end date
|
---|
35 | D APPADD(.ZZZ,3100123,2100123.3,2,"Dr Office",30,"Sam's Note",1)
|
---|
36 | I +$P(^BSDXTMP($J,1),U,2)'=-3 W "Error in -3",!
|
---|
37 | ; Test for end date without time
|
---|
38 | D APPADD(.ZZZ,3100123.1,3100123,2,"Dr Office",30,"Sam's Note",1)
|
---|
39 | I +$P(^BSDXTMP($J,1),U,2)'=-4 W "Error in -4",!
|
---|
40 | ; Test for mumps error
|
---|
41 | S bsdxdie=1
|
---|
42 | D APPADD(.ZZZ,3100123.09,3100123.093,2,"Dr Office",30,"Sam's Note",1)
|
---|
43 | I +$P(^BSDXTMP($J,1),U,2)'=-100 W "Error in -100: M Error",!
|
---|
44 | K bsdxdie
|
---|
45 | ; Test for TRESTART
|
---|
46 | s bsdxrestart=1
|
---|
47 | D APPADD(.ZZZ,3100123.09,3100123.093,3,"Dr Office",30,"Sam's Note",1)
|
---|
48 | I +$P(^BSDXTMP($J,1),U,2)'=0&(+$P(^BSDXTMP($J,1),U,2)'=-10) W "Error in TRESTART",!
|
---|
49 | k bsdxrestart
|
---|
50 | ; Test for non-numeric patient
|
---|
51 | D APPADD(.ZZZ,3100123.09,3100123.093,"CAT,DOG","Dr Office",30,"Sam's Note",1)
|
---|
52 | I +$P(^BSDXTMP($J,1),U,2)'=-5 W "Error in -5",!
|
---|
53 | ; Test for a non-existent patient
|
---|
54 | D APPADD(.ZZZ,3100123.09,3100123.093,8989898989,"Dr Office",30,"Sam's Note",1)
|
---|
55 | I +$P(^BSDXTMP($J,1),U,2)'=-6 W "Error in -6",!
|
---|
56 | ; Test for a non-existent resource name
|
---|
57 | D APPADD(.ZZZ,3100123.09,3100123.093,3,"lkajsflkjsadf",30,"Sam's Note",1)
|
---|
58 | I +$P(^BSDXTMP($J,1),U,2)'=-7 W "Error in -7",!
|
---|
59 | ; Test for corrupted resource
|
---|
60 | ; Can't test for -8 since it requires DB corruption
|
---|
61 | ; Test for inability to add appointment to BSDX Appointment
|
---|
62 | ; Also requires something wrong in the DB
|
---|
63 | ; Test for inability to add appointment to 2,44
|
---|
64 | ; Test by creating a duplicate appointment
|
---|
65 | D APPADD(.ZZZ,3100123.09,3100123.093,3,"Dr Office",30,"Sam's Note",1)
|
---|
66 | D APPADD(.ZZZ,3100123.09,3100123.093,3,"Dr Office",30,"Sam's Note",1)
|
---|
67 | I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10",!
|
---|
68 | ; Test for normality:
|
---|
69 | D APPADD(.ZZZ,3110123.09,3110123.093,3,"Dr Office",30,"Sam's Note",1)
|
---|
70 | ; Does Appt exist?
|
---|
71 | N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
72 | I 'APPID W "Error Making Appt-1" QUIT
|
---|
73 | I +^BSDXAPPT(APPID,0)'=3110123.09 W "Error Making Appt-2"
|
---|
74 | I '$D(^DPT(3,"S",3110123.09)) W "Error Making Appt-3"
|
---|
75 | I '$D(^SC(2,"S",3110123.09)) W "Error Making Appt-4"
|
---|
76 | QUIT
|
---|
77 | ;
|
---|
78 | APPADD(BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID) ;EP
|
---|
79 | ;Called by RPC: BSDX ADD NEW APPOINTMENT
|
---|
80 | ;
|
---|
81 | ;Add new appointment to 3 files
|
---|
82 | ; - BSDX APPOINTMENT
|
---|
83 | ; - Hosp Location Appointment SubSubfile if Resource is linked to clinic
|
---|
84 | ; - Patient Appointment Subfile if Resource is linked to clinic
|
---|
85 | ;
|
---|
86 | ;Paramters:
|
---|
87 | ;BSDXY: Global Return (RPC must be set to Global Array)
|
---|
88 | ;BSDXSTART: FM Start Date
|
---|
89 | ;BSDXEND: FM End Date
|
---|
90 | ;BSDXPATID: Patient DFN
|
---|
91 | ;BSDXRES is ResourceName in BSDX RESOURCE file (not IEN)
|
---|
92 | ;BSDXLEN is the appointment duration in minutes
|
---|
93 | ;BSDXNOTE is the Appiontment Note
|
---|
94 | ;BSDXATID is used for 2 purposes:
|
---|
95 | ; if BSDXATID = "WALKIN" then BSDAPI is called to create a walkin appt.
|
---|
96 | ; if BSDXATID = a number, then it is the access type id (used for rebooking)
|
---|
97 | ;
|
---|
98 | ;Return:
|
---|
99 | ; ADO.net Recordset having fields:
|
---|
100 | ; AppointmentID and ErrorNumber
|
---|
101 | ;
|
---|
102 | ;Test lines:
|
---|
103 | ;BSDX ADD NEW APPOINTMENT^3091122.0930^3091122.1000^370^Dr Office^30^EXAM^WALKIN
|
---|
104 | ;
|
---|
105 | ; Return Array; set Return and clear array
|
---|
106 | S BSDXY=$NA(^BSDXTMP($J))
|
---|
107 | K ^BSDXTMP($J)
|
---|
108 | ; $ET
|
---|
109 | N $ET S $ET="G ETRAP^BSDX07"
|
---|
110 | ; Counter
|
---|
111 | N BSDXI S BSDXI=0
|
---|
112 | ; Lock BSDX node, only to synchronize access to the globals.
|
---|
113 | ; It's not expected that the error will ever happen as no filing
|
---|
114 | ; is supposed to take 5 seconds.
|
---|
115 | L +^BSDXAPPT(BSDXPATID):5 I '$T D ERR(BSDXI,"-1~Patient record is locked. Please contact technical support.") Q
|
---|
116 | ; Header Node
|
---|
117 | S ^BSDXTMP($J,BSDXI)="I00020APPOINTMENTID^T00100ERRORID"_$C(30)
|
---|
118 | ;Restartable Transaction; restore paramters when starting.
|
---|
119 | ; (Params restored are what's passed here + BSDXI)
|
---|
120 | TSTART (BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID,BSDXI):T="BSDX ADD NEW APPOINTMENT^BSDX07"
|
---|
121 | ;
|
---|
122 | ; Turn off SDAM APPT PROTOCOL BSDX Entries
|
---|
123 | N BSDXNOEV
|
---|
124 | S BSDXNOEV=1 ;Don't execute BSDX ADD APPOINTMENT protocol
|
---|
125 | ;
|
---|
126 | ; Set Error Message to be empty
|
---|
127 | N BSDXERR S BSDXERR=0
|
---|
128 | ;
|
---|
129 | ;;;test for error inside transaction. See if %ZTER works
|
---|
130 | I $G(bsdxdie) S X=1/0
|
---|
131 | ;;;test
|
---|
132 | ;;;test for TRESTART
|
---|
133 | I $G(bsdxrestart) K bsdxrestart TRESTART
|
---|
134 | ;;;test
|
---|
135 | ;
|
---|
136 | ; -- Start and End Date Processing --
|
---|
137 | ; If C# sends the dates with extra zeros, remove them
|
---|
138 | S BSDXSTART=+BSDXSTART,BSDXEND=+BSDXEND
|
---|
139 | ; Are the dates valid? Must be FM Dates > than 2010
|
---|
140 | I BSDXSTART'>3100000 D ERR(BSDXI,"-2~BSDX07 Error: Invalid Start Time") Q
|
---|
141 | I BSDXEND'>3100000 D ERR(BSDXI,"-3~BSDX07 Error: Invalid End Time") Q
|
---|
142 | ; If Ending date doesn't have a time, this is an error
|
---|
143 | I $L(BSDXEND,".")=1 D ERR(BSDXI,"-4~BSDX07 Error: Invalid End Time") Q
|
---|
144 | ; If the Start Date is greater than the end date, swap dates
|
---|
145 | N BSDXTMP
|
---|
146 | I BSDXSTART>BSDXEND S BSDXTMP=BSDXEND,BSDXEND=BSDXSTART,BSDXSTART=BSDXTMP
|
---|
147 | ;
|
---|
148 | ; Check if the patient exists:
|
---|
149 | ; - DFN valid number?
|
---|
150 | ; - Valid Patient in file 2?
|
---|
151 | I '+BSDXPATID D ERR(BSDXI,"-5~BSDX07 Error: Invalid Patient ID") Q
|
---|
152 | I '$D(^DPT(BSDXPATID,0)) D ERR(BSDXI,"-6~BSDX07 Error: Invalid Patient ID") Q
|
---|
153 | ;
|
---|
154 | ;Validate Resource entry
|
---|
155 | I '$D(^BSDXRES("B",BSDXRES)) D ERR(BSDXI,"-7~BSDX07 Error: Invalid Resource ID") Q
|
---|
156 | N BSDXRESD ; Resource IEN
|
---|
157 | S BSDXRESD=$O(^BSDXRES("B",BSDXRES,0))
|
---|
158 | N BSDXRNOD ; Resouce zero node
|
---|
159 | S BSDXRNOD=$G(^BSDXRES(BSDXRESD,0))
|
---|
160 | I BSDXRNOD="" D ERR(BSDXI,"-8~BSDX07 Error: invalid Resource entry.") Q
|
---|
161 | ;
|
---|
162 | ; Walk-in (Unscheduled) Appointment?
|
---|
163 | N BSDXWKIN S BSDXWKIN=0
|
---|
164 | I BSDXATID="WALKIN" S BSDXWKIN=1
|
---|
165 | ; Reset Access Type ID if it doesn't say "WALKIN" and isn't a number
|
---|
166 | I BSDXATID'?.N&(BSDXATID'="WALKIN") S BSDXATID=""
|
---|
167 | ;
|
---|
168 | ; Done with all checks, let's make appointment in BSDX APPOINTMENT
|
---|
169 | N BSDXAPPTID
|
---|
170 | S BSDXAPPTID=$$BSDXADD(BSDXSTART,BSDXEND,BSDXPATID,BSDXRESD,BSDXATID)
|
---|
171 | I 'BSDXAPPTID D ERR(BSDXI,"-9~BSDX07 Error: Unable to add appointment to BSDX APPOINTMENT file.") Q
|
---|
172 | I BSDXNOTE]"" D BSDXWP(BSDXAPPTID,BSDXNOTE)
|
---|
173 | ;
|
---|
174 | ; Then Create Subfiles in 2/44 Appointment
|
---|
175 | N BSDXSCD S BSDXSCD=$P(BSDXRNOD,U,4) ; Hosp Location IEN
|
---|
176 | ; Only if we have a valid Hosp Loc can we make an appointment
|
---|
177 | I +BSDXSCD,$D(^SC(BSDXSCD,0)) D I +BSDXERR D ERR(BSDXI,"-10~BSDX07 Error: MAKE^BSDXAPI returned error code: "_BSDXERR) Q
|
---|
178 | . N BSDXC
|
---|
179 | . S BSDXC("PAT")=BSDXPATID
|
---|
180 | . S BSDXC("CLN")=BSDXSCD
|
---|
181 | . S BSDXC("TYP")=3 ;3 for scheduled appts, 4 for walkins
|
---|
182 | . S:BSDXWKIN BSDXC("TYP")=4
|
---|
183 | . S BSDXC("ADT")=BSDXSTART
|
---|
184 | . S BSDXC("LEN")=BSDXLEN
|
---|
185 | . S BSDXC("OI")=$E($G(BSDXNOTE),1,150) ;File 44 has 150 character limit on OTHER field
|
---|
186 | . S BSDXC("OI")=$TR(BSDXC("OI"),";"," ") ;No semicolons allowed by MAKE^BSDXAPI
|
---|
187 | . S BSDXC("OI")=$$STRIP(BSDXC("OI")) ;Strip control characters from note
|
---|
188 | . S BSDXC("USR")=DUZ
|
---|
189 | . S BSDXERR=$$MAKE^BSDXAPI(.BSDXC)
|
---|
190 | . Q:BSDXERR
|
---|
191 | . ;Update RPMS Clinic availability
|
---|
192 | . D AVUPDT(BSDXSCD,BSDXSTART,BSDXLEN)
|
---|
193 | . Q
|
---|
194 | ;
|
---|
195 | ;Return Recordset
|
---|
196 | TCOMMIT
|
---|
197 | L -^BSDXAPPT(BSDXPATID)
|
---|
198 | S BSDXI=BSDXI+1
|
---|
199 | S ^BSDXTMP($J,BSDXI)=BSDXAPPTID_"^"_$C(30)
|
---|
200 | S BSDXI=BSDXI+1
|
---|
201 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
202 | Q
|
---|
203 | BSDXDEL(BSDXAPPTID) ;Deletes appointment BSDXAPPTID from BSDXAPPOINTMETN
|
---|
204 | N DA,DIK
|
---|
205 | S DIK="^BSDXAPPT(",DA=BSDXAPPTID
|
---|
206 | D ^DIK
|
---|
207 | Q
|
---|
208 | ;
|
---|
209 | STRIP(BSDXZ) ;Replace control characters with spaces
|
---|
210 | N BSDXI
|
---|
211 | F BSDXI=1:1:$L(BSDXZ) I (32>$A($E(BSDXZ,BSDXI))) S BSDXZ=$E(BSDXZ,1,BSDXI-1)_" "_$E(BSDXZ,BSDXI+1,999)
|
---|
212 | Q BSDXZ
|
---|
213 | ;
|
---|
214 | BSDXADD(BSDXSTART,BSDXEND,BSDXPATID,BSDXRESD,BSDXATID) ;ADD BSDX APPOINTMENT ENTRY
|
---|
215 | ;Returns ien in BSDXAPPT or 0 if failed
|
---|
216 | ;Create entry in BSDX APPOINTMENT
|
---|
217 | N BSDXAPPTID
|
---|
218 | S BSDXFDA(9002018.4,"+1,",.01)=BSDXSTART
|
---|
219 | S BSDXFDA(9002018.4,"+1,",.02)=BSDXEND
|
---|
220 | S BSDXFDA(9002018.4,"+1,",.05)=BSDXPATID
|
---|
221 | S BSDXFDA(9002018.4,"+1,",.07)=BSDXRESD
|
---|
222 | S BSDXFDA(9002018.4,"+1,",.08)=$G(DUZ)
|
---|
223 | S BSDXFDA(9002018.4,"+1,",.09)=$$NOW^XLFDT
|
---|
224 | S:BSDXATID="WALKIN" BSDXFDA(9002018.4,"+1,",.13)="y"
|
---|
225 | S:BSDXATID?.N BSDXFDA(9002018.4,"+1,",.06)=BSDXATID
|
---|
226 | N BSDXIEN,BSDXMSG
|
---|
227 | D UPDATE^DIE("","BSDXFDA","BSDXIEN","BSDXMSG")
|
---|
228 | S BSDXAPPTID=+$G(BSDXIEN(1))
|
---|
229 | Q BSDXAPPTID
|
---|
230 | ;
|
---|
231 | BSDXWP(BSDXAPPTID,BSDXNOTE) ;
|
---|
232 | ;Add WP field
|
---|
233 | I BSDXNOTE]"" S BSDXNOTE(.5)=BSDXNOTE,BSDXNOTE=""
|
---|
234 | I $D(BSDXNOTE(0)) S BSDXNOTE(.5)=BSDXNOTE(0) K BSDXNOTE(0)
|
---|
235 | I $D(BSDXNOTE(.5)) D
|
---|
236 | . D WP^DIE(9002018.4,BSDXAPPTID_",",1,"","BSDXNOTE","BSDXMSG")
|
---|
237 | Q
|
---|
238 | ;
|
---|
239 | ADDEVT(BSDXPATID,BSDXSTART,BSDXSC,BSDXSCDA) ;EP
|
---|
240 | ;Called by BSDX ADD APPOINTMENT protocol
|
---|
241 | ;BSDXSC=IEN of clinic in ^SC
|
---|
242 | ;BSDXSCDA=IEN for ^SC(BSDXSC,"S",BSDXSTART,1,BSDXSCDA). Use to get Length & Note
|
---|
243 | ;
|
---|
244 | N BSDXNOD,BSDXLEN,BSDXAPPTID,BSDXNODP,BSDXWKIN,BSDXRES
|
---|
245 | Q:+$G(BSDXNOEV)
|
---|
246 | I $D(^BSDXRES("ALOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ALOC",BSDXSC,0))
|
---|
247 | E I $D(^BSDXRES("ASSOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ASSOC",BSDXSC,0))
|
---|
248 | Q:'+$G(BSDXRES)
|
---|
249 | S BSDXNOD=$G(^SC(BSDXSC,"S",BSDXSTART,1,BSDXSCDA,0))
|
---|
250 | Q:BSDXNOD=""
|
---|
251 | S BSDXNODP=$G(^DPT(BSDXPATID,"S",BSDXSTART,0))
|
---|
252 | S BSDXWKIN=""
|
---|
253 | S:$P(BSDXNODP,U,7)=4 BSDXWKIN="WALKIN" ;Purpose of Visit field of DPT Appointment subfile
|
---|
254 | S BSDXLEN=$P(BSDXNOD,U,2)
|
---|
255 | Q:'+BSDXLEN
|
---|
256 | S BSDXEND=$$FMADD^XLFDT(BSDXSTART,0,0,BSDXLEN,0)
|
---|
257 | S BSDXAPPTID=$$BSDXADD(BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXWKIN)
|
---|
258 | Q:'+BSDXAPPTID
|
---|
259 | S BSDXNOTE=$P(BSDXNOD,U,4)
|
---|
260 | I BSDXNOTE]"" D BSDXWP(BSDXAPPTID,BSDXNOTE)
|
---|
261 | D ADDEVT3(BSDXRES)
|
---|
262 | Q
|
---|
263 | ;
|
---|
264 | ADDEVT3(BSDXRES) ;
|
---|
265 | ;Call RaiseEvent to notify GUI clients
|
---|
266 | N BSDXRESN
|
---|
267 | S BSDXRESN=$G(^BSDXRES(BSDXRES,0))
|
---|
268 | Q:BSDXRESN=""
|
---|
269 | S BSDXRESN=$P(BSDXRESN,"^")
|
---|
270 | ;D EVENT^BSDX23("SCHEDULE-"_BSDXRESN,"","","")
|
---|
271 | D EVENT^BMXMEVN("BSDX SCHEDULE",BSDXRESN)
|
---|
272 | Q
|
---|
273 | ;
|
---|
274 | ERR(BSDXI,BSDXERR) ;Error processing
|
---|
275 | S BSDXI=BSDXI+1
|
---|
276 | S BSDXERR=$TR(BSDXERR,"^","~")
|
---|
277 | I $TL>0 TROLLBACK
|
---|
278 | S ^BSDXTMP($J,BSDXI)="0^"_BSDXERR_$C(30)
|
---|
279 | S BSDXI=BSDXI+1
|
---|
280 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
281 | L -^BSDXAPPT(BSDXPATID)
|
---|
282 | Q
|
---|
283 | ;
|
---|
284 | ETRAP ;EP Error trap entry
|
---|
285 | N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
|
---|
286 | ; Rollback, otherwise ^XTER will be empty from future rollback
|
---|
287 | I $TL>0 TROLLBACK
|
---|
288 | D ^%ZTER
|
---|
289 | S $EC="" ; Clear Error
|
---|
290 | ; Log error message and send to client
|
---|
291 | I '$D(BSDXI) N BSDXI S BSDXI=0
|
---|
292 | D ERR(BSDXI,"-100~BSDX07 Error: "_$G(%ZTERZE))
|
---|
293 | Q
|
---|
294 | ;
|
---|
295 | DAY ;;^SUN^MON^TUES^WEDNES^THURS^FRI^SATUR
|
---|
296 | ;
|
---|
297 | DOW S %=$E(X,1,3),Y=$E(X,4,5),Y=Y>2&'(%#4)+$E("144025036146",Y)
|
---|
298 | F %=%:-1:281 S Y=%#4=1+1+Y
|
---|
299 | S Y=$E(X,6,7)+Y#7
|
---|
300 | Q
|
---|
301 | ;
|
---|
302 | AVUPDT(BSDXSCD,BSDXSTART,BSDXLEN) ;Update RPMS Clinic availability
|
---|
303 | ;SEE SDM1
|
---|
304 | N Y,DFN
|
---|
305 | N SL,STARTDAY,X,SC,SB,HSI,SI,STR,SDDIF,SDMAX,SDDATE,SDDMAX,SDSDATE,CCXN,MXOK,COV,SDPROG
|
---|
306 | N X1,SDEDT,X2,SD,SM,SS,S,SDLOCK,ST,I
|
---|
307 | S Y=BSDXSCD,DFN=BSDXPATID
|
---|
308 | S SL=$G(^SC(+Y,"SL")),X=$P(SL,U,3),STARTDAY=$S($L(X):X,1:8),SC=Y,SB=STARTDAY-1/100,X=$P(SL,U,6),HSI=$S(X=1:X,X:X,1:4),SI=$S(X="":4,X<3:4,X:X,1:4),STR="#@!$* XXWVUTSRQPONMLKJIHGFEDCBA0123456789jklmnopqrstuvwxyz",SDDIF=$S(HSI<3:8/HSI,1:2) K Y
|
---|
309 | ;Determine maximum days for scheduling
|
---|
310 | S SDMAX(1)=$P($G(^SC(+SC,"SDP")),U,2) S:'SDMAX(1) SDMAX(1)=365
|
---|
311 | S (SDMAX,SDDMAX)=$$FMADD^XLFDT(DT,SDMAX(1))
|
---|
312 | S SDDATE=BSDXSTART
|
---|
313 | S SDSDATE=SDDATE,SDDATE=SDDATE\1
|
---|
314 | 1 ;L Q:$D(SDXXX) S CCXN=0 K MXOK,COV,SDPROT Q:DFN<0 S SC=+SC
|
---|
315 | Q:$D(SDXXX) S CCXN=0 K MXOK,COV,SDPROT Q:DFN<0 S SC=+SC
|
---|
316 | S X1=DT,SDEDT=365 S:$D(^SC(SC,"SDP")) SDEDT=$P(^SC(SC,"SDP"),"^",2)
|
---|
317 | S X2=SDEDT D C^%DTC S SDEDT=X
|
---|
318 | S Y=BSDXSTART
|
---|
319 | EN1 S (X,SD)=Y,SM=0 D DOW
|
---|
320 | S I '$D(^SC(SC,"ST",$P(SD,"."),1)) S SS=+$O(^SC(+SC,"T"_Y,SD)) Q:SS'>0 Q:^(SS,1)="" S ^SC(+SC,"ST",$P(SD,"."),1)=$E($P($T(DAY),U,Y+2),1,2)_" "_$E(SD,6,7)_$J("",SI+SI-6)_^(1),^(0)=$P(SD,".")
|
---|
321 | S S=BSDXLEN
|
---|
322 | ;Check if BSDXLEN evenly divisible by appointment length
|
---|
323 | S RPMSL=$P(SL,U)
|
---|
324 | I BSDXLEN<RPMSL S BSDXLEN=RPMSL
|
---|
325 | I BSDXLEN#RPMSL'=0 D
|
---|
326 | . S BSDXINC=BSDXLEN\RPMSL
|
---|
327 | . S BSDXINC=BSDXINC+1
|
---|
328 | . S BSDXLEN=RPMSL*BSDXINC
|
---|
329 | S SL=S_U_$P(SL,U,2,99)
|
---|
330 | SC S SDLOCK=$S('$D(SDLOCK):1,1:SDLOCK+1) Q:SDLOCK>9
|
---|
331 | L +^SC(SC,"ST",$P(SD,"."),1):5 G:'$T SC
|
---|
332 | S SDLOCK=0,S=^SC(SC,"ST",$P(SD,"."),1)
|
---|
333 | S I=SD#1-SB*100,ST=I#1*SI\.6+($P(I,".")*SI),SS=SL*HSI/60*SDDIF+ST+ST
|
---|
334 | I (I<1!'$F(S,"["))&(S'["CAN") L -^SC(SC,"ST",$P(SD,"."),1) Q
|
---|
335 | I SM<7 S %=$F(S,"[",SS-1) S:'%!($P(SL,"^",6)<3) %=999 I $F(S,"]",SS)'<%!(SDDIF=2&$E(S,ST+ST+1,SS-1)["[") S SM=7
|
---|
336 | ;
|
---|
337 | SP I ST+ST>$L(S),$L(S)<80 S S=S_" " G SP
|
---|
338 | S SDNOT=1
|
---|
339 | S ABORT=0
|
---|
340 | F I=ST+ST:SDDIF:SS-SDDIF D Q:ABORT
|
---|
341 | . S ST=$E(S,I+1) S:ST="" ST=" "
|
---|
342 | . S Y=$E(STR,$F(STR,ST)-2)
|
---|
343 | . I S["CAN"!(ST="X"&($D(^SC(+SC,"ST",$P(SD,"."),"CAN")))) S ABORT=1 Q
|
---|
344 | . I Y="" S ABORT=1 Q
|
---|
345 | . S:Y'?1NL&(SM<6) SM=6 S ST=$E(S,I+2,999) S:ST="" ST=" " S S=$E(S,1,I)_Y_ST
|
---|
346 | . Q
|
---|
347 | S ^SC(SC,"ST",$P(SD,"."),1)=S
|
---|
348 | L -^SC(SC,"ST",$P(SD,"."),1)
|
---|
349 | Q
|
---|