[1452] | 1 | BSDX08 ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/20/12 3:52pm
|
---|
| 2 | ;;1.6;BSDX;;Aug 31, 2011;Build 18
|
---|
[1076] | 3 | ;
|
---|
| 4 | ; Original by HMW. New Written by Sam Habiel. Licensed under LGPL.
|
---|
| 5 | ;
|
---|
| 6 | ; Change History
|
---|
| 7 | ; 3101022 UJO/SMH v1.42
|
---|
| 8 | ; - Transaction now restartable. Thanks to
|
---|
| 9 | ; --> Zach Gonzalez and Rick Marshall for fix.
|
---|
| 10 | ; - Extra TROLLBACK in Lock Statement when lock fails.
|
---|
| 11 | ; --> Removed--Rollback is already in ERR tag.
|
---|
| 12 | ; - Added new statements to old SD code in AVUPDT to obviate
|
---|
| 13 | ; --> need to restore variables in transaction
|
---|
| 14 | ; - Refactored this chunk of code. Don't really know whether it
|
---|
| 15 | ; --> worked in the first place. Waiting for bug report to know.
|
---|
| 16 | ; - Refactored all of APPDEL.
|
---|
| 17 | ;
|
---|
[1080] | 18 | ; 3111125 UJO/SMH v1.5
|
---|
| 19 | ; - Added ability to remove checked in appointments. Added a couple
|
---|
| 20 | ; of units tests for that under UT2.
|
---|
| 21 | ; - Minor reformatting because of how KIDS adds tabs.
|
---|
| 22 | ;
|
---|
[1076] | 23 | ; Error Reference:
|
---|
| 24 | ; -1~BSDX08: Appt record is locked. Please contact technical support.
|
---|
| 25 | ; -2~BSDX08: Invalid Appointment ID
|
---|
[1007] | 26 | ; -3~BSDX08: Invalid Appointment ID
|
---|
[1076] | 27 | ; -4~BSDX08: Cancelled appointment does not have a Resouce ID
|
---|
| 28 | ; -5~BSDX08: Resouce ID does not exist in BSDX RESOURCE
|
---|
| 29 | ; -6~BSDX08: Invalid Hosp Location stored in Database
|
---|
| 30 | ; -7~BSDX08: Patient does not have an appointment in PIMS Clinic
|
---|
| 31 | ; -8^BSDX08: Unable to find associated PIMS appointment for this patient
|
---|
| 32 | ; -9^BSDX08: BSDXAPI returned an error: (error)
|
---|
| 33 | ; -100~BSDX08 Error: (Mumps Error)
|
---|
[614] | 34 | ;
|
---|
| 35 | APPDELD(BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT) ;EP
|
---|
| 36 | ;Entry point for debugging
|
---|
[1452] | 37 | ;D DEBUG^%Serenji("APPDEL^BSDX08(.BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT)")
|
---|
[614] | 38 | Q
|
---|
| 39 | ;
|
---|
[1041] | 40 | UT ; Unit Tests
|
---|
[1452] | 41 | N RESNAM S RESNAM="UTCLINIC"
|
---|
| 42 | N HLRESIENS ; holds output of UTCR^BSDX35 - HL IEN^Resource IEN
|
---|
| 43 | D
|
---|
| 44 | . N $ET S $ET="D ^%ZTER B"
|
---|
| 45 | . S HLRESIENS=$$UTCR^BSDX35(RESNAM)
|
---|
| 46 | . I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
|
---|
| 47 | ;
|
---|
| 48 | N HLIEN,RESIEN
|
---|
| 49 | S HLIEN=$P(HLRESIENS,U)
|
---|
| 50 | S RESIEN=$P(HLRESIENS,U,2)
|
---|
| 51 | ;
|
---|
| 52 | ; Get start and end times
|
---|
| 53 | N TIMES S TIMES=$$TIMES^BSDX35 ; appt time^end time
|
---|
| 54 | N APPTTIME S APPTTIME=$P(TIMES,U)
|
---|
| 55 | N ENDTIME S ENDTIME=$P(TIMES,U,2)
|
---|
| 56 | ;
|
---|
[1076] | 57 | ; Test 1: Make normal appointment and cancel it. See if every thing works
|
---|
[1452] | 58 | N ZZZ,DFN
|
---|
| 59 | S DFN=3
|
---|
| 60 | D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
|
---|
[1076] | 61 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
| 62 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
|
---|
| 63 | I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1"
|
---|
[1452] | 64 | I $O(^SC(2,"S",APPTTIME,1,0))]"" W "Error in Cancellation-2"
|
---|
| 65 | I $P(^DPT(4,"S",APPTTIME,0),U,2)'="PC" W "Error in Cancellation-3"
|
---|
[1076] | 66 | I ^DPT(4,"S",3110123.2,"R")'="Sam's Cancel Note" W "Error in Cancellation-4"
|
---|
| 67 | ;
|
---|
| 68 | ; Test 2: Check for -1
|
---|
| 69 | ; Make appt
|
---|
| 70 | D APPADD^BSDX07(.ZZZ,3110125.2,3110125.3,4,"Dr Office",10,"Sam's Note",1)
|
---|
| 71 | ; Lock the node in another job
|
---|
| 72 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
| 73 | ; W "Lock ^BSDXAPPT("_APPID_") in another session. You have 10 seconds." H 10
|
---|
| 74 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
|
---|
| 75 | ;
|
---|
| 76 | ; Test 3: Check for -100
|
---|
| 77 | S bsdxdie=1
|
---|
| 78 | D APPADD^BSDX07(.ZZZ,3110126.2,3110126.3,4,"Dr Office",10,"Sam's Note",1)
|
---|
| 79 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
| 80 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
|
---|
| 81 | I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100",!
|
---|
| 82 | K bsdxdie
|
---|
| 83 | ;
|
---|
| 84 | ; Test 4: Restartable transaction
|
---|
| 85 | S bsdxrestart=1
|
---|
| 86 | D APPADD^BSDX07(.ZZZ,3110128.2,3110128.3,4,"Dr Office",10,"Sam's Note",1)
|
---|
| 87 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
| 88 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
|
---|
| 89 | I $P(^DPT(4,"S",3110128.2,0),U,2)'="PC" W "Error in Restartable Transaction",!
|
---|
| 90 | ;
|
---|
| 91 | ; Test 5: for invalid Appointment ID (-2 and -3)
|
---|
| 92 | D APPDEL^BSDX08(.ZZZ,0,"PC",1,"Reasons")
|
---|
| 93 | I $P(^BSDXTMP($J,1),"~")'=-2 W "Error in -2",!
|
---|
| 94 | D APPDEL^BSDX08(.ZZZ,999999,"PC",1,"Reasons")
|
---|
| 95 | I $P(^BSDXTMP($J,1),"~")'=-3 W "Error in -3",!
|
---|
[1080] | 96 | UT2 ; More unit Tests
|
---|
[1076] | 97 | ;
|
---|
[1080] | 98 | ; Test 6: for Cancelling walkin and checked-in appointments
|
---|
[1076] | 99 | S BSDXSTART=$E($$NOW^XLFDT,1,12),BSDXEND=BSDXSTART+.0001
|
---|
[1080] | 100 | D APPADD^BSDX07(.ZZZ,BSDXSTART,BSDXEND,4,"Dr Office",10,"Sam's Note",1) ; Add appt
|
---|
[1076] | 101 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
[1080] | 102 | I APPID=0 W "Error in test 6",!
|
---|
| 103 | D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; check-in
|
---|
| 104 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; Delete appt
|
---|
| 105 | I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
|
---|
[1077] | 106 | ;
|
---|
[1080] | 107 | ; Test 7: for cancelling walkin and checked-in appointments
|
---|
[1077] | 108 | S BSDXSTART=$E($$NOW^XLFDT,1,12)+.0001,BSDXEND=BSDXSTART+.0001
|
---|
[1080] | 109 | D APPADD^BSDX07(.ZZZ,BSDXSTART,BSDXEND,4,"Dr Office",10,"Sam's Note",1) ; Add appt
|
---|
[1077] | 110 | S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
[1080] | 111 | I APPID=0 W "Error in test 6",!
|
---|
| 112 | D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT) ; Checkin
|
---|
[1077] | 113 | S BSDXRES=$O(^BSDXRES("B","Dr Office",""))
|
---|
| 114 | S BSDXCLN=$P(^BSDXRES(BSDXRES,0),U,4)
|
---|
[1080] | 115 | S BSDXRESULT=$$RMCI^BSDXAPI(4,BSDXCLN,BSDXSTART) ; remove checkin
|
---|
| 116 | D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note") ; delete appt
|
---|
| 117 | I $P(^BSDXTMP($J,1),$C(30))'="" W "Error in test 6",!
|
---|
[1076] | 118 | QUIT
|
---|
[614] | 119 | APPDEL(BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT) ;EP
|
---|
[1007] | 120 | ;Called by RPC: BSDX CANCEL APPOINTMENT
|
---|
| 121 | ;Cancels existing appointment in BSDX APPOINTMENT and 44/2 subfiles
|
---|
[1080] | 122 | ;Input Parameters:
|
---|
[1007] | 123 | ; - BSDXAPTID is entry number in BSDX APPOINTMENT file
|
---|
| 124 | ; - BSDXTYP is C for clinic-cancelled and PC for patient cancelled
|
---|
| 125 | ; - BSDXCR is pointer to CANCELLATION REASON File (409.2)
|
---|
| 126 | ; - BSDXNOT is user note
|
---|
[614] | 127 | ;
|
---|
[1080] | 128 | ; Returns error code in recordset field ERRORID. Empty string is success.
|
---|
| 129 | ; Returns Global Array. Must use this type in RPC.
|
---|
[614] | 130 | ;
|
---|
[1080] | 131 | ; Return Array: set Return and clear array
|
---|
[1007] | 132 | S BSDXY=$NA(^BSDXTMP($J))
|
---|
[1080] | 133 | K ^BSDXTMP($J)
|
---|
[1007] | 134 | ;
|
---|
[1080] | 135 | ; Set min DUZ vars if they don't exist
|
---|
| 136 | D ^XBKVAR
|
---|
[1007] | 137 | ;
|
---|
[1080] | 138 | ; $ET
|
---|
| 139 | N $ET S $ET="G ETRAP^BSDX08"
|
---|
| 140 | ;
|
---|
| 141 | ; Counter
|
---|
[1007] | 142 | N BSDXI S BSDXI=0
|
---|
[1080] | 143 | ; Header Node
|
---|
[1041] | 144 | S ^BSDXTMP($J,BSDXI)="T00100ERRORID"_$C(30)
|
---|
[1007] | 145 | ;
|
---|
[1080] | 146 | ; Lock BSDX node, only to synchronize access to the globals.
|
---|
| 147 | ; It's not expected that the error will ever happen as no filing
|
---|
| 148 | ; is supposed to take 5 seconds.
|
---|
| 149 | L +^BSDXAPPT(BSDXAPTID):5 I '$T D ERR(BSDXI,"-1~BSDX08: Appt record is locked. Please contact technical support.") Q
|
---|
[1007] | 150 | ;
|
---|
[1080] | 151 | ;Restartable Transaction; restore paramters when starting.
|
---|
| 152 | ; (Params restored are what's passed here + BSDXI)
|
---|
| 153 | TSTART (BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT,BSDXI):T="BSDX CANCEL APPOINTEMENT^BSDX08"
|
---|
[1007] | 154 | ;
|
---|
[1080] | 155 | ; Turn off SDAM APPT PROTOCOL BSDX Entries
|
---|
[614] | 156 | N BSDXNOEV
|
---|
| 157 | S BSDXNOEV=1 ;Don't execute BSDX CANCEL APPOINTMENT protocol
|
---|
| 158 | ;
|
---|
[1080] | 159 | ;;;test for error inside transaction. See if %ZTER works
|
---|
| 160 | I $G(bsdxdie) S X=1/0
|
---|
| 161 | ;;;test
|
---|
| 162 | ;;;test for TRESTART
|
---|
| 163 | I $G(bsdxrestart) K bsdxrestart TRESTART
|
---|
| 164 | ;;;test
|
---|
| 165 | ;
|
---|
| 166 | ; Check appointment ID and whether it exists
|
---|
| 167 | I '+BSDXAPTID D ERR(BSDXI,"-2~BSDX08: Invalid Appointment ID") Q
|
---|
[1007] | 168 | I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(BSDXI,"-3~BSDX08: Invalid Appointment ID") Q
|
---|
[614] | 169 | ;
|
---|
[1007] | 170 | ; Start Processing:
|
---|
[1080] | 171 | ; First, add cancellation date to appt entry in BSDX APPOINTMENT
|
---|
[1007] | 172 | N BSDXNOD S BSDXNOD=^BSDXAPPT(BSDXAPTID,0) ; BSDX Appt Node
|
---|
| 173 | N BSDXPATID S BSDXPATID=$P(BSDXNOD,U,5) ; Patient ID
|
---|
| 174 | N BSDXSTART S BSDXSTART=$P(BSDXNOD,U) ; Start Time
|
---|
| 175 | D BSDXCAN(BSDXAPTID) ; Add a cancellation date in BSDX APPOINTMENT
|
---|
[614] | 176 | ;
|
---|
[1080] | 177 | ; Second, cancel appt in "S" nodes in file 2 and 44, then update Legacy PIMS Availability
|
---|
[1007] | 178 | N BSDXSC1 S BSDXSC1=$P(BSDXNOD,U,7) ;RESOURCEID
|
---|
[1080] | 179 | ; If the resouce id doesn't exist...
|
---|
[1007] | 180 | I BSDXSC1="" D ERR(BSDXI,"-4~BSDX08: Cancelled appointment does not have a Resouce ID") QUIT
|
---|
[1080] | 181 | I '$D(^BSDXRES(BSDXSC1,0)) D ERR(BSDXI,"-5~BSDX08: Resouce ID does not exist in BSDX RESOURCE") QUIT
|
---|
[1007] | 182 | ; Get zero node of resouce
|
---|
[1080] | 183 | S BSDXNOD=^BSDXRES(BSDXSC1,0)
|
---|
| 184 | ; Get Hosp location
|
---|
[1007] | 185 | N BSDXLOC S BSDXLOC=$P(BSDXNOD,U,4)
|
---|
[1080] | 186 | ; Error indicator for Hosp Location filing for getting out of routine
|
---|
| 187 | N BSDXERR S BSDXERR=0
|
---|
| 188 | ; Only file in 2/44 if there is an associated hospital location
|
---|
| 189 | I BSDXLOC D QUIT:BSDXERR
|
---|
[1007] | 190 | . I '$D(^SC(BSDXLOC,0)) S BSDXERR=1 D ERR(BSDXI,"-6~BSDX08: Invalid Hosp Location stored in Database") QUIT
|
---|
[1080] | 191 | . ; Get the IEN of the appointment in the "S" node of ^SC
|
---|
| 192 | . N BSDXSCIEN
|
---|
[1007] | 193 | . S BSDXSCIEN=$$SCIEN^BSDXAPI(BSDXPATID,BSDXLOC,BSDXSTART)
|
---|
[1080] | 194 | . I BSDXSCIEN="" S BSDXERR=1 D ERR(BSDXI,"-7~BSDX08: Patient does not have an appointment in PIMS Clinic") QUIT
|
---|
[1007] | 195 | . ; Get the appointment node
|
---|
[1080] | 196 | . S BSDXNOD=$G(^SC(BSDXLOC,"S",BSDXSTART,1,BSDXSCIEN,0))
|
---|
[1007] | 197 | . I BSDXNOD="" S BSDXERR=1 D ERR(BSDXI,"-8^BSDX08: Unable to find associated PIMS appointment for this patient") QUIT
|
---|
| 198 | . N BSDXLEN S BSDXLEN=$P(BSDXNOD,U,2)
|
---|
| 199 | . ; Cancel through BSDXAPI
|
---|
[1080] | 200 | . N BSDXZ
|
---|
| 201 | . D APCAN(.BSDXZ,BSDXLOC,BSDXPATID,BSDXSTART)
|
---|
| 202 | . I +BSDXZ>0 S BSDXERR=1 D ERR(BSDXI,"-9^BSDX08: BSDXAPI returned an error: "_$P(BSDXZ,U,2)) QUIT
|
---|
[1007] | 203 | . ; Update Legacy PIMS clinic Availability
|
---|
[614] | 204 | . D AVUPDT(BSDXLOC,BSDXSTART,BSDXLEN)
|
---|
| 205 | ;
|
---|
| 206 | TCOMMIT
|
---|
[1007] | 207 | L -^BSDXAPPT(BSDXAPTID)
|
---|
[614] | 208 | S BSDXI=BSDXI+1
|
---|
| 209 | S ^BSDXTMP($J,BSDXI)=""_$C(30)
|
---|
| 210 | S BSDXI=BSDXI+1
|
---|
| 211 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
| 212 | Q
|
---|
| 213 | ;
|
---|
[1007] | 214 | AVUPDT(BSDXSCD,BSDXSTART,BSDXLEN) ;Update Legacy PIMS Clinic availability
|
---|
[614] | 215 | ;See SDCNP0
|
---|
[1007] | 216 | N SD,S ; Start Date
|
---|
[1080] | 217 | S (SD,S)=BSDXSTART
|
---|
| 218 | N I ; Clinic IEN in 44
|
---|
[614] | 219 | S I=BSDXSCD
|
---|
[1080] | 220 | ; if day has no schedule in legacy PIMS, forget about this update.
|
---|
[614] | 221 | Q:'$D(^SC(I,"ST",SD\1,1))
|
---|
[1080] | 222 | N SL ; Clinic characteristics node (length of appt, when appts start etc)
|
---|
[1007] | 223 | S SL=^SC(I,"SL")
|
---|
[1080] | 224 | N X ; Hour Clinic Display Begins
|
---|
| 225 | S X=$P(SL,U,3)
|
---|
| 226 | N STARTDAY ; When does the day start?
|
---|
| 227 | S STARTDAY=$S($L(X):X,1:8) ; If defined, use it; otherwise, 8am
|
---|
| 228 | N SB ; ?? Who knows? Day Start - 1 divided by 100.
|
---|
| 229 | S SB=STARTDAY-1/100
|
---|
| 230 | S X=$P(SL,U,6) ; Now X is Display increments per hour
|
---|
| 231 | N HSI ; Slots per hour, try 1
|
---|
| 232 | S HSI=$S(X:X,1:4) ; if defined, use it; otherwise, 4
|
---|
| 233 | N SI ; Slots per hour, try 2
|
---|
| 234 | S SI=$S(X="":4,X<3:4,X:X,1:4) ; If slots "", or less than 3, then 4
|
---|
| 235 | N STR ; ??
|
---|
| 236 | S STR="#@!$* XXWVUTSRQPONMLKJIHGFEDCBA0123456789jklmnopqrstuvwxyz"
|
---|
| 237 | N SDDIF ; Slots per hour diff??
|
---|
| 238 | S SDDIF=$S(HSI<3:8/HSI,1:2)
|
---|
[1007] | 239 | S SL=BSDXLEN ; Dammit, reusing variable; SL now Appt Length from GUI
|
---|
| 240 | S S=^SC(I,"ST",SD\1,1) ; reusing var again; S now Day Pattern from PIMS
|
---|
[1080] | 241 | N Y ; Hours since start of Date
|
---|
| 242 | S Y=SD#1-SB*100 ;SD#1=FM Time portion; -SB minus start of day; conv to hrs
|
---|
| 243 | N ST ; ??
|
---|
| 244 | ; Y#1 -> Minutes; *SI -> * Slots per hour; \.6 trunc min to hour
|
---|
| 245 | ; Y\1 -> Hours since start of day; * SI: * slots
|
---|
| 246 | S ST=Y#1*SI\.6+(Y\1*SI)
|
---|
| 247 | N SS ; how many slots are supposed to be taken by appointment
|
---|
| 248 | S SS=SL*HSI/60 ; (nb: try SL: 30 min; HSI: 4 slots)
|
---|
[1007] | 249 | N I
|
---|
[1080] | 250 | I Y'<1 D ; If Hours since start of Date is greater than 1
|
---|
| 251 | . ; loop through pattern. Tired of documenting.
|
---|
| 252 | . F I=ST+ST:SDDIF D Q:Y="" Q:SS'>0
|
---|
| 253 | . . S Y=$E(STR,$F(STR,$E(S,I+1))) Q:Y=""
|
---|
| 254 | . . S S=$E(S,1,I)_Y_$E(S,I+2,999)
|
---|
| 255 | . . S SS=SS-1
|
---|
| 256 | . . Q:SS'>0
|
---|
[1007] | 257 | S ^SC(BSDXSCD,"ST",SD\1,1)=S ; new pattern; global set
|
---|
[614] | 258 | Q
|
---|
| 259 | ;
|
---|
| 260 | APCAN(BSDXZ,BSDXLOC,BSDXDFN,BSDXSD) ;
|
---|
| 261 | ;Cancel appointment for patient BSDXDFN in clinic BSDXSC1
|
---|
| 262 | ;at time BSDXSD
|
---|
| 263 | N BSDXC,%H
|
---|
| 264 | S BSDXC("PAT")=BSDXPATID
|
---|
| 265 | S BSDXC("CLN")=BSDXLOC
|
---|
| 266 | S BSDXC("TYP")=BSDXTYP
|
---|
| 267 | S BSDXC("ADT")=BSDXSD
|
---|
| 268 | S %H=$H D YMD^%DTC
|
---|
| 269 | S BSDXC("CDT")=X+%
|
---|
| 270 | S BSDXC("NOT")=BSDXNOT
|
---|
[951] | 271 | S:'+$G(BSDXCR) BSDXCR=11 ;Other
|
---|
[614] | 272 | S BSDXC("CR")=BSDXCR
|
---|
| 273 | S BSDXC("USR")=DUZ
|
---|
| 274 | ;
|
---|
| 275 | S BSDXZ=$$CANCEL^BSDXAPI(.BSDXC)
|
---|
| 276 | Q
|
---|
| 277 | ;
|
---|
| 278 | BSDXCAN(BSDXAPTID) ;
|
---|
| 279 | ;Cancel BSDX APPOINTMENT entry
|
---|
| 280 | N %DT,X,BSDXDATE,Y,BSDXIENS,BSDXFDA,BSDXMSG
|
---|
| 281 | S %DT="XT",X="NOW" D ^%DT ; X ^DD("DD")
|
---|
| 282 | S BSDXDATE=Y
|
---|
| 283 | S BSDXIENS=BSDXAPTID_","
|
---|
| 284 | S BSDXFDA(9002018.4,BSDXIENS,.12)=BSDXDATE
|
---|
| 285 | K BSDXMSG
|
---|
| 286 | D FILE^DIE("","BSDXFDA","BSDXMSG")
|
---|
| 287 | Q
|
---|
| 288 | ;
|
---|
| 289 | CANEVT(BSDXPAT,BSDXSTART,BSDXSC) ;EP Called by BSDX CANCEL APPOINTMENT event
|
---|
| 290 | ;when appointments cancelled via PIMS interface.
|
---|
| 291 | ;Propagates cancellation to BSDXAPPT and raises refresh event to running GUI clients
|
---|
| 292 | N BSDXFOUND,BSDXRES
|
---|
| 293 | Q:+$G(BSDXNOEV)
|
---|
| 294 | Q:'+$G(BSDXSC)
|
---|
| 295 | S BSDXFOUND=0
|
---|
| 296 | I $D(^BSDXRES("ALOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ALOC",BSDXSC,0)) S BSDXFOUND=$$CANEVT1(BSDXRES,BSDXSTART,BSDXPAT)
|
---|
| 297 | I BSDXFOUND D CANEVT3(BSDXRES) Q
|
---|
| 298 | I $D(^BXDXRES("ASSOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ASSOC",BSDXSC,0)) S BSDXFOUND=$$CANEVT1(BSDXRES,BSDXSTART,BSDXPAT)
|
---|
| 299 | I BSDXFOUND D CANEVT3(BSDXRES)
|
---|
| 300 | Q
|
---|
| 301 | ;
|
---|
| 302 | CANEVT1(BSDXRES,BSDXSTART,BSDXPAT) ;
|
---|
| 303 | ;Get appointment id in BSDXAPT
|
---|
| 304 | ;If found, call BSDXCAN(BSDXAPPT) and return 1
|
---|
| 305 | ;else return 0
|
---|
| 306 | N BSDXFOUND,BSDXAPPT
|
---|
| 307 | S BSDXFOUND=0
|
---|
| 308 | Q:'+BSDXRES BSDXFOUND
|
---|
| 309 | Q:'$D(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART)) BSDXFOUND
|
---|
| 310 | S BSDXAPPT=0 F S BSDXAPPT=$O(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART,BSDXAPPT)) Q:'+BSDXAPPT D Q:BSDXFOUND
|
---|
| 311 | . S BSDXNOD=$G(^BSDXAPPT(BSDXAPPT,0)) Q:BSDXNOD=""
|
---|
| 312 | . I $P(BSDXNOD,U,5)=BSDXPAT,$P(BSDXNOD,U,12)="" S BSDXFOUND=1 Q
|
---|
| 313 | I BSDXFOUND,+$G(BSDXAPPT) D BSDXCAN(BSDXAPPT)
|
---|
| 314 | Q BSDXFOUND
|
---|
| 315 | ;
|
---|
| 316 | CANEVT3(BSDXRES) ;
|
---|
| 317 | ;Call RaiseEvent to notify GUI clients
|
---|
| 318 | ;
|
---|
| 319 | N BSDXRESN
|
---|
| 320 | S BSDXRESN=$G(^BSDXRES(BSDXRES,0))
|
---|
| 321 | Q:BSDXRESN=""
|
---|
| 322 | S BSDXRESN=$P(BSDXRESN,"^")
|
---|
| 323 | ;D EVENT^BSDX23("SCHEDULE-"_BSDXRESN,"","","")
|
---|
| 324 | D EVENT^BMXMEVN("BSDX SCHEDULE",BSDXRESN)
|
---|
| 325 | Q
|
---|
| 326 | ;
|
---|
| 327 | ERR(BSDXI,BSDXERR) ;Error processing
|
---|
| 328 | S BSDXI=BSDXI+1
|
---|
| 329 | S BSDXERR=$TR(BSDXERR,"^","~")
|
---|
[1007] | 330 | I $TL>0 TROLLBACK
|
---|
[614] | 331 | S ^BSDXTMP($J,BSDXI)=BSDXERR_$C(30)
|
---|
| 332 | S BSDXI=BSDXI+1
|
---|
| 333 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
[1007] | 334 | L -^BSDXAPPT(BSDXAPTID)
|
---|
| 335 | QUIT
|
---|
[614] | 336 | ;
|
---|
| 337 | ETRAP ;EP Error trap entry
|
---|
[1007] | 338 | N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
|
---|
[1080] | 339 | ; Rollback, otherwise ^XTER will be empty from future rollback
|
---|
| 340 | I $TL>0 TROLLBACK
|
---|
| 341 | D ^%ZTER
|
---|
| 342 | S $EC="" ; Clear Error
|
---|
[1007] | 343 | ; Log error message and send to client
|
---|
[1080] | 344 | I '$D(BSDXI) N BSDXI S BSDXI=0
|
---|
[1007] | 345 | D ERR(BSDXI,"-100~BSDX08 Error: "_$G(%ZTERZE))
|
---|
| 346 | QUIT
|
---|
[1080] | 347 | ;
|
---|
| 348 | ;;;NB: This is code that is unused in both original and port.
|
---|
| 349 | ; ; If not appt in the "S" node is found in ^SC then check associated RPMS Clinic Multiple
|
---|
| 350 | ; I BSDXSCIEN="" D I 'BSDXZ Q ;Q:BSDXZ
|
---|
[1007] | 351 | ; . S BSDXERR="BSDX08: Unable to find associated RPMS appointment for this patient. "
|
---|
| 352 | ; . S BSDXZ=1
|
---|
[1080] | 353 | ; . ; Check if there are associated RPMS clinics. (not currently used) Does the multiple exist? No, then quit
|
---|
[1007] | 354 | ; . I '$D(^BSDXRES(BSDXSC1,20)) S BSDXZ=0 QUIT
|
---|
[1080] | 355 | ; . ; Loop through the multiple. Get Location and then the ^SC "S" node IEN.
|
---|
[1007] | 356 | ; . N BSDX1 S BSDX1=0
|
---|
| 357 | ; . F S BSDX1=$O(^BSDXRES(BSDXSC1,20,BSDX1)) Q:'+BSDX1 Q:BSDXZ=0 D
|
---|
| 358 | ; . . Q:'$D(^BSDXRES(BSDXSC1,20,BSDX1,0))
|
---|
| 359 | ; . . S BSDXLOC=$P(^BSDXRES(BSDXSC1,20,BSDX1,0),U)
|
---|
[1080] | 360 | ; . . S BSDXSCIEN=$$SCIEN^BSDXAPI(BSDXPATID,BSDXLOC,BSDXSTART) I +BSDXSCIEN S BSDXZ=0 Q
|
---|