source: Scheduling/trunk/m/BSDXAPI.m@ 1080

Last change on this file since 1080 was 1080, checked in by Sam Habiel, 14 years ago

Final checkin. Completed ability to be able to remove appointments that have been checked in. Also, fixed not being able to make an appointment at midnight issue.

File size: 14.8 KB
Line 
1BSDXAPI ; IHS/ANMC/LJF - SCHEDULING APIs ; 1/25/11 1:00pm
2 ;;1.42;BSDX;;Dec 07, 2010;Build 7
3 ;Orignal routine is BSDAPI by IHS/LJF, HMW, and MAW
4 ;local mods (many) by WV/SMH
5 ;Move to BSDX namespace as BSDXAPI from BSDAPI by WV/SMH
6 ; Change History:
7 ; 2010-11-5: (1.42)
8 ; - Fixed errors having to do uncanceling patient appointments if it was a patient cancelled appointment.
9 ; - Use new style Fileman API for storing appointments in file 44 in $$MAKE due to problems with legacy API.
10 ; 2010-11-12: (1.42)
11 ; - Changed ="C" to ["C" in SCIEN. Cancelled appointments can be "PC" as well.
12 ; 2010-12-5 (1.42)
13 ; Added an entry point to update the patient note in file 44.
14 ; 2010-12-6 (1.42)
15 ; MAKE1 incorrectly put info field in BSDR("INFO") rather than BSDR("OI")
16 ; 2010-12-8 (1.42)
17 ; Removed restriction on max appt length. Even though this restriction
18 ; exists in fileman (120 minutes), PIMS ignores it. Therefore, I
19 ; will ignore it here too.
20 ; 2011-01-25 (v.1.5)
21 ; Added entry point $$RMCI to remove checked in appointments.
22 ; In $$CANCEL, if the appointment is checked in, delete check-in rather than
23 ; spitting an error message to the user saying 'Delete the check-in'
24 ; Changed all lines that look like this:
25 ; I $G(BSDR("ADT"))'?7N1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
26 ; to:
27 ; I $G(BSDR("ADT"))'?7N.1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
28 ; to allow for date at midnight which does not have a dot at the end.
29 ;
30 ;
31MAKE1(DFN,CLIN,TYP,DATE,LEN,INFO) ; Simplified PEP w/ parameters for $$MAKE - making appointment
32 ; Call like this for DFN 23435 having an appointment at Hospital Location 33
33 ; have 3 (scheduled) or 4 (walkin) appt at Dec 20, 2009 @ 10:11:59 for 30 minutes appt
34 ; for Baby foxes hallucinations.
35 ; S RESULT=$$MAKE1^BSDXAPI(23435,33,(3 or 4),3091220.221159,30,"I see Baby foxes")
36 S BSDR("PAT")=DFN ;DFN
37 S BSDR("CLN")=CLIN ;Hosp Loc IEN
38 S BSDR("TYP")=TYP ;3 sched or 4 walkin
39 S BSDR("ADT")=DATE ;Appointment date in FM format
40 S BSDR("LEN")=LEN ;Appt len upto 240 (min)
41 S BSDR("OI")=INFO ;Reason for appt - up to 150 char
42 S BSDR("USR")=DUZ ;Person who made appt - current user
43 Q $$MAKE(.BSDR)
44 ;
45MAKE(BSDR) ;PEP; call to store appt made
46 ;
47 ; Make call using: S ERR=$$MAKE^BSDXAPI(.ARRAY)
48 ;
49 ; Input Array -
50 ; BSDR("PAT") = ien of patient in file 2
51 ; BSDR("CLN") = ien of clinic in file 44
52 ; BSDR("TYP") = 3 for scheduled appts, 4 for walkins
53 ; BSDR("ADT") = appointment date and time
54 ; BSDR("LEN") = appointment length in minutes (5-120)
55 ; BSDR("OI") = reason for appt - up to 150 characters
56 ; BSDR("USR") = user who made appt
57 ;
58 ;Output: error status and message
59 ; = 0 or null: everything okay
60 ; = 1^message: error and reason
61 ;
62 I '$D(^DPT(+$G(BSDR("PAT")),0)) Q 1_U_"Patient not on file: "_$G(BSDR("PAT"))
63 I '$D(^SC(+$G(BSDR("CLN")),0)) Q 1_U_"Clinic not on file: "_$G(BSDR("CLN"))
64 I ($G(BSDR("TYP"))<3)!($G(BSDR("TYP"))>4) Q 1_U_"Appt Type error: "_$G(BSDR("TYP"))
65 I $G(BSDR("ADT")) S BSDR("ADT")=+$E(BSDR("ADT"),1,12) ;remove seconds
66 I $G(BSDR("ADT"))'?7N.1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
67 ;
68 ;I ($G(BSDR("LEN"))<5)!($G(BSDR("LEN"))>240) Q 1_U_"Appt Length error: "_$G(BSDR("LEN")) ; v 1.42 - no check on length is done anymore. see top comments for details.
69 I '$D(^VA(200,+$G(BSDR("USR")),0)) Q 1_U_"User Who Made Appt Error: "_$G(BSDR("USR"))
70 I $D(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0)),$P(^(0),U,2)'["C" Q 1_U_"Patient "_BSDR("PAT")_" already has appt at "_BSDR("ADT")
71 ;
72 NEW DIC,DA,Y,X,DD,DO,DLAYGO
73 ;
74 I $D(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0)),$P(^(0),U,2)["C" D
75 . ; "un-cancel" existing appt in file 2
76 . N BSDXFDA,BSDXIENS,BSDXMSG
77 . S BSDXIENS=BSDR("ADT")_","_BSDR("PAT")_","
78 . S BSDXFDA(2.98,BSDXIENS,".01")=BSDR("CLN")
79 . S BSDXFDA(2.98,BSDXIENS,"3")=""
80 . S BSDXFDA(2.98,BSDXIENS,"9")=BSDR("TYP")
81 . S BSDXFDA(2.98,BSDXIENS,"9.5")=9
82 . S BSDXFDA(2.98,BSDXIENS,"14")=""
83 . S BSDXFDA(2.98,BSDXIENS,"15")=""
84 . S BSDXFDA(2.98,BSDXIENS,"16")=""
85 . S BSDXFDA(2.98,BSDXIENS,"19")=""
86 . S BSDXFDA(2.98,BSDXIENS,"20")=$$NOW^XLFDT
87 . D FILE^DIE("","BSDXFDA","BSDXMSG")
88 . N BSDXTEMP S BSDXTEMP=$G(BSDXMSG)
89 E D I $G(BSDXERR(1)) Q 1_U_"FileMan add to DPT error: Patient="_BSDR("PAT")_" Appt="_BSDR("ADT")
90 . N BSDXFDA,BSDXIENS,BSDXMSG
91 . S BSDXIENS="?+2,"_BSDR("PAT")_","
92 . S BSDXIENS(2)=BSDR("ADT")
93 . S BSDXFDA(2.98,BSDXIENS,.01)=BSDR("CLN")
94 . S BSDXFDA(2.98,BSDXIENS,"9")=BSDR("TYP")
95 . S BSDXFDA(2.98,BSDXIENS,"9.5")=9
96 . S BSDXFDA(2.98,BSDXIENS,"20")=$$NOW^XLFDT
97 . D UPDATE^DIE("","BSDXFDA","BSDXIENS","BSDXERR(1)")
98 ; add appt to file 44
99 K DIC,DA,X,Y,DLAYGO,DD,DO
100 I '$D(^SC(BSDR("CLN"),"S",0)) S ^SC(BSDR("CLN"),"S",0)="^44.001DA^^"
101 I '$D(^SC(BSDR("CLN"),"S",BSDR("ADT"),0)) D I Y<1 Q 1_U_"Error adding date to file 44: Clinic="_BSDR("CLN")_" Date="_BSDR("ADT")
102 . S DIC="^SC("_BSDR("CLN")_",""S"",",DA(1)=BSDR("CLN"),(X,DINUM)=BSDR("ADT")
103 . S DIC("P")="44.001DA",DIC(0)="L",DLAYGO=44.001
104 . S Y=1 I '$D(@(DIC_X_")")) D FILE^DICN
105 ;
106 ; Sep 28 2010: Changed old style API to new style API. Keep for reference //smh
107 ;K DIC,DA,X,Y,DLAYGO,DD,DO,DINUM
108 ;S DIC="^SC("_BSDR("CLN")_",""S"","_BSDR("ADT")_",1,"
109 ;S DA(2)=BSDR("CLN"),DA(1)=BSDR("ADT"),X=BSDR("PAT")
110 ;S DIC("DR")="1///"_BSDR("LEN")_";3///"_$E($G(BSDR("OI")),1,150)_";7///`"_BSDR("USR")_";8///"_$P($$NOW^XLFDT,".")
111 ;S DIC("P")="44.003PA",DIC(0)="L",DLAYGO=44.003
112 ;D FILE^DICN
113 ;
114 N BSDXIENS S BSDXIENS="?+1,"_BSDR("ADT")_","_BSDR("CLN")_","
115 N BSDXFDA
116 S BSDXFDA(44.003,BSDXIENS,.01)=BSDR("PAT")
117 S BSDXFDA(44.003,BSDXIENS,1)=BSDR("LEN")
118 S BSDXFDA(44.003,BSDXIENS,3)=$E($G(BSDR("OI")),1,150)
119 S BSDXFDA(44.003,BSDXIENS,7)=BSDR("USR")
120 S BSDXFDA(44.003,BSDXIENS,8)=$P($$NOW^XLFDT,".")
121 N BSDXERR
122 D UPDATE^DIE("","BSDXFDA","","BSDXERR")
123 ;
124 I $D(BSDXERR) Q 1_U_"Error adding appt to file 44: Clinic="_BSDR("CLN")_" Date="_BSDR("ADT")_" Patient="_BSDR("PAT")_" Error: "_BSDXERR("DIERR",1,"TEXT",1)
125 ;
126 ; call event driver
127 NEW DFN,SDT,SDCL,SDDA,SDMODE
128 S DFN=BSDR("PAT"),SDT=BSDR("ADT"),SDCL=BSDR("CLN"),SDMODE=2
129 S SDDA=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
130 D MAKE^SDAMEVT(DFN,SDT,SDCL,SDDA,SDMODE)
131 Q 0
132 ;
133CHECKIN1(DFN,CLIN,APDATE) ; Simplified PEP w/ parameters for $$CHECKIN - Checking in
134 ; Call like this for DFN 23435 checking in now at Hospital Location 33
135 ; for appt at Dec 20, 2009 @ 10:11:59
136 ; S RESULT=$$CHECKIN1^BSDXAPI(23435,33,3091220.221159)
137 S BSDR("PAT")=DFN ;DFN
138 S BSDR("CLN")=CLIN ;Hosp Loc IEN
139 S BSDR("ADT")=APDATE ;Appt Date
140 S BSDR("CDT")=$$NOW^XLFDT ;Check-in date defaults to now
141 S BSDR("USR")=DUZ ;Check-in user defaults to current
142 Q $$CHECKIN(.BSDR)
143 ;
144CHECKIN(BSDR) ;EP; call to add checkin info to appt; IHS/ITSC/LJF 12/23/2004 PATCH 1002
145 ;
146 ; Make call by using: S ERR=$$CHECKIN^BSDXAPI(.ARRAY)
147 ;
148 ; Input array -
149 ; BSDR("PAT") = ien of patient in file 2
150 ; BSDR("CLN") = ien of clinic in file 44
151 ; BSDR("ADT") = appt date/time
152 ; BSDR("CDT") = checkin date/time
153 ; BSDR("USR") = checkin user
154 ;
155 ; Output value -
156 ; = 0 means everything worked
157 ; = 1^message means error with reason message
158 ;
159 I '$D(^DPT(+$G(BSDR("PAT")),0)) Q 1_U_"Patient not on file: "_$G(BSDR("PAT"))
160 I '$D(^SC(+$G(BSDR("CLN")),0)) Q 1_U_"Clinic not on file: "_$G(BSDR("CLN"))
161 I $G(BSDR("ADT")) S BSDR("ADT")=+$E(BSDR("ADT"),1,12) ;remove seconds
162 I $G(BSDR("ADT"))'?7N.1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
163 I $G(BSDR("CDT")) S BSDR("CDT")=+$E(BSDR("CDT"),1,12) ;remove seconds
164 I $G(BSDR("CDT"))'?7N.1".".4N Q 1_U_"Checkin Date/Time error: "_$G(BSDR("CDT"))
165 I '$D(^VA(200,+$G(BSDR("USR")),0)) Q 1_U_"User Who Made Appt Error: "_$G(BSDR("USR"))
166 ;
167 ; find ien for appt in file 44
168 NEW IEN,DIE,DA,DR
169 S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
170 I 'IEN Q 1_U_"Error trying to find appointment for checkin: Patient="_BSDR("PAT")_" Clinic="_BSDR("CLN")_" Appt="_BSDR("ADT")
171 ;
172 ; remember before status
173 NEW SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL
174 S DFN=BSDR("PAT"),SDT=BSDR("ADT"),SDCL=BSDR("CLN"),SDMODE=2,SDDA=IEN
175 S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
176 D BEFORE^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
177 ;
178 ; set checkin
179 S DIE="^SC("_BSDR("CLN")_",""S"","_BSDR("ADT")_",1,"
180 S DA(2)=BSDR("CLN"),DA(1)=BSDR("ADT"),DA=IEN
181 S DR="309///"_BSDR("CDT")_";302///`"_BSDR("USR")_";305///"_$$NOW^XLFDT
182 D ^DIE
183 ;
184 ; set after status
185 S SDDA=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
186 S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
187 D AFTER^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
188 ;
189 ; call event driver
190 D EVT^SDAMEVT(.SDATA,4,SDMODE,SDCIHDL)
191 Q 0
192 ;
193CANCEL1(DFN,CLIN,TYP,APDATE,REASON,INFO) ; PEP w/ parameters for $$CANCEL - cancelling appointment
194 ; Call like this for DFN 23435 cancelling an appointment at Hospital Location 33,
195 ; cancellation initiated by patient ("PC" rather than clinic "C"),
196 ; cancelling appt at Dec 20, 2009 @ 10:11:59 because of reason 1 in file 409.2 IEN (weather)
197 ; because foxes come out during bad weather.
198 ; S RESULT=$$CANCEL1^BSDXAPI(23435,33,"PC",3091220.221159,1,"Afraid of foxes")
199 S BSDR("PAT")=DFN
200 S BSDR("CLN")=CLIN
201 S BSDR("TYP")=TYP
202 S BSDR("ADT")=APDATE
203 S BSDR("CDT")=$$NOW^XLFDT
204 S BSDR("USR")=DUZ
205 S BSDR("CR")=REASON
206 S BSDR("NOT")=INFO
207 Q $$CANCEL(.BSDR)
208 ;
209CANCEL(BSDR) ;PEP; called to cancel appt
210 ;
211 ; Make call using: S ERR=$$CANCEL^BSDXAPI(.ARRAY)
212 ;
213 ; Input Array -
214 ; BSDR("PAT") = ien of patient in file 2
215 ; BSDR("CLN") = ien of clinic in file 44
216 ; BSDR("TYP") = C for canceled by clinic; PC for patient canceled
217 ; BSDR("ADT") = appointment date and time
218 ; BSDR("CDT") = cancel date and time
219 ; BSDR("USR") = user who canceled appt
220 ; BSDR("CR") = cancel reason - pointer to file 409.2
221 ; BSDR("NOT") = cancel remarks - optional notes to 160 characters
222 ;
223 ;Output: error status and message
224 ; = 0 or null: everything okay
225 ; = 1^message: error and reason
226 ;
227 I '$D(^DPT(+$G(BSDR("PAT")),0)) Q 1_U_"Patient not on file: "_$G(BSDR("PAT"))
228 I '$D(^SC(+$G(BSDR("CLN")),0)) Q 1_U_"Clinic not on file: "_$G(BSDR("CLN"))
229 I ($G(BSDR("TYP"))'="C"),($G(BSDR("TYP"))'="PC") Q 1_U_"Cancel Status error: "_$G(BSDR("TYP"))
230 I $G(BSDR("ADT")) S BSDR("ADT")=+$E(BSDR("ADT"),1,12) ;remove seconds
231 I $G(BSDR("ADT"))'?7N.1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
232 I $G(BSDR("CDT")) S BSDR("CDT")=+$E(BSDR("CDT"),1,12) ;remove seconds
233 I $G(BSDR("CDT"))'?7N.1".".4N Q 1_U_"Cancel Date/Time error: "_$G(BSDR("CDT"))
234 I '$D(^VA(200,+$G(BSDR("USR")),0)) Q 1_U_"User Who Canceled Appt Error: "_$G(BSDR("USR"))
235 I '$D(^SD(409.2,+$G(BSDR("CR")))) Q 1_U_"Cancel Reason error: "_$G(BSDR("CR"))
236 ;
237 NEW IEN,DIE,DA,DR
238 S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
239 I 'IEN Q 1_U_"Error trying to find appointment for cancel: Patient="_BSDR("PAT")_" Clinic="_BSDR("CLN")_" Appt="_BSDR("ADT")
240 ;
241 ; BSDX 1.5 3110125
242 ; UJO/SMH - Add ability to remove check-in if the patient is checked in
243 ; I $$CI(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"),IEN) Q 1_U_"Patient already checked in; cannot cancel until checkin deleted: Patient="_BSDR("PAT")_" Clinic="_BSDR("CLN")_" Appt="_BSDR("ADT")
244 ; Remove check-in if the patient is checked in.
245 N BSDXRESULT S BSDXRESULT=0 ; Result; should be zero if success; -1 + message if failure
246 I $$CI(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"),IEN) SET BSDXRESULT=$$RMCI(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
247 I BSDXRESULT Q BSDXRESULT
248 ;
249 ; remember before status
250 NEW SDATA,DFN,SDT,SDCL,SDDA,SDCPHDL
251 S DFN=BSDR("PAT"),SDT=BSDR("ADT"),SDCL=BSDR("CLN"),SDMODE=2,SDDA=IEN
252 S SDCPHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
253 D BEFORE^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCPHDL)
254 ;
255 ; get user who made appt and date appt made from ^SC
256 ; because data in ^SC will be deleted
257 NEW USER,DATE
258 S USER=$P($G(^SC(SDCL,"S",SDT,1,IEN,0)),U,6)
259 S DATE=$P($G(^SC(SDCL,"S",SDT,1,IEN,0)),U,7)
260 ;
261 ; update file 2 info
262 NEW DIE,DA,DR
263 S DIE="^DPT("_DFN_",""S"",",DA(1)=DFN,DA=SDT
264 S DR="3///"_BSDR("TYP")_";14///`"_BSDR("USR")_";15///"_BSDR("CDT")_";16///`"_BSDR("CR")_";19///`"_USER_";20///"_DATE
265 S:$G(BSDR("NOT"))]"" DR=DR_";17///"_$E(BSDR("NOT"),1,160)
266 D ^DIE
267 ;
268 ; delete data in ^SC
269 NEW DIK,DA
270 S DIK="^SC("_BSDR("CLN")_",""S"","_BSDR("ADT")_",1,"
271 S DA(2)=BSDR("CLN"),DA(1)=BSDR("ADT"),DA=IEN
272 D ^DIK
273 ;
274 ; call event driver
275 D CANCEL^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDMODE,SDCPHDL)
276 Q 0
277 ;
278CI(PAT,CLINIC,DATE,SDIEN) ;PEP; -- returns 1 if appt already checked-in
279 NEW X
280 S X=$G(SDIEN) ;ien sent in call
281 I 'X S X=$$SCIEN(PAT,CLINIC,DATE) I 'X Q 0
282 S X=$P($G(^SC(CLINIC,"S",DATE,1,X,"C")),U)
283 Q $S(X:1,1:0)
284 ;
285RMCI(PAT,CLINIC,DATE) ;PEP; -- Remove Check-in; $$
286 ; PAT = DFN
287 ; CLINIC = SC IEN
288 ; DATE = FM Date/Time of Appointment
289 ;
290 ; Returns:
291 ; 0 if okay
292 ; -1 if failure
293 ;
294 ; Call like this: $$RMCI(233,33,3110102.1130)
295 ;
296 ; Move my variables into the ones used by SDAPIs (just a convenience)
297 NEW SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL
298 S DFN=PAT,SDT=DATE,SDCL=CLINIC,SDMODE=2,SDDA=$$SCIEN(DFN,SDCL,SDT)
299 ;
300 I SDDA<1 QUIT 0 ; Appt cancelled; cancelled appts rm'ed from file 44
301 ;
302 ; remember before status
303 S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
304 D BEFORE^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
305 ;
306 ; remove check-in using filer.
307 N BSDXIENS S BSDXIENS=SDDA_","_DATE_","_CLINIC_","
308 S BSDXFDA(44.003,BSDXIENS,309)="@" ; CHECKED-IN
309 S BSDXFDA(44.003,BSDXIENS,302)="@" ; CHECK IN USER
310 S BSDXFDA(44.003,BSDXIENS,305)="@" ; CHECK IN ENTERED
311 N BSDXERR
312 D FILE^DIE("","BSDXFDA","BSDXERR")
313 I $D(BSDXERR) QUIT "-1~Can't file for Pat "_PAT_" in Clinic "_CLINIC_" at "_DATE_". Fileman reported an error: "_BSDXERR("DIERR",1,"TEXT",1)
314 ;
315 ; set after status
316 S SDDA=$$SCIEN(DFN,SDCL,SDT)
317 S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
318 D AFTER^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
319 ;
320 ; call event driver
321 D EVT^SDAMEVT(.SDATA,4,SDMODE,SDCIHDL)
322 QUIT 0
323 ;
324SCIEN(PAT,CLINIC,DATE) ;PEP; returns ien for appt in ^SC
325 NEW X,IEN
326 S X=0 F S X=$O(^SC(CLINIC,"S",DATE,1,X)) Q:'X Q:$G(IEN) D
327 . Q:$P($G(^SC(CLINIC,"S",DATE,1,X,0)),U,9)["C" ;cancelled
328 . I +$G(^SC(CLINIC,"S",DATE,1,X,0))=PAT S IEN=X
329 Q $G(IEN)
330 ;
331APPTYP(PAT,DATE) ;PEP; -- returns type of appt (scheduled or walk-in)
332 NEW X S X=$P($G(^DPT(PAT,"S",DATE,0)),U,7)
333 Q $S(X=3:"SCHED",X=4:"WALK-IN",1:"??")
334 ;
335CO(PAT,CLINIC,DATE,SDIEN) ;PEP; -- returns 1 if appt already checked-out
336 NEW X
337 S X=$G(SDIEN) ;ien sent in call
338 I 'X S X=$$SCIEN(PAT,CLINIC,DATE) I 'X Q 0
339 S X=$P($G(^SC(CLINIC,"S",DATE,1,X,"C")),U,3)
340 Q $S(X:1,1:0)
341 ;
342UPDATENOTE(PAT,CLINIC,DATE,NOTE) ; PEP; Update Note in ^SC for patient's appointment @ DATE
343 ; PAT = DFN
344 ; CLINIC = SC IEN
345 ; DATE = FM Date/Time of Appointment
346 ;
347 ; Returns:
348 ; 0 if okay
349 ; -1 if failure
350 N SCIEN S SCIEN=$$SCIEN(PAT,CLINIC,DATE) ; ien of appt in ^SC
351 I SCIEN<1 QUIT 0 ; Appt cancelled; cancelled appts rm'ed from file 44
352 N BSDXIENS S BSDXIENS=SCIEN_","_DATE_","_CLINIC_","
353 S BSDXFDA(44.003,BSDXIENS,3)=$E(NOTE,1,150)
354 N BSDXERR
355 D FILE^DIE("","BSDXFDA","BSDXERR")
356 I $D(BSDXERR) QUIT "-1~Can't file for Pat "_PAT_" in Clinic "_CLINIC_" at "_DATE_". Fileman reported an error: "_BSDXERR("DIERR",1,"TEXT",1)
357 QUIT 0
Note: See TracBrowser for help on using the repository browser.