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