[1462] | 1 | BSDX31 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 6/27/12 4:57pm
|
---|
[1461] | 2 | ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
---|
| 3 | ; Licensed under LGPL
|
---|
| 4 | ; Change Log:
|
---|
| 5 | ; v1.42 3101023 WV/SMH - Change transaction to restartable.
|
---|
| 6 | ; v1.42 3101206 UJO/SMH - Extensive refactoring
|
---|
| 7 | ; v1.7 3120626 VEN/SMH - Removed transactions; extensive refactoring
|
---|
| 8 | ; - Moved APTNS (whatever it was) to BSDXAPI1
|
---|
| 9 | ; as $$NOSHOW
|
---|
| 10 | ; - Made BSDXNOS extrinsic.
|
---|
| 11 | ; - Moved Unit Tests to BSDXUT1
|
---|
[1462] | 12 | ; - BSDXNOS deletes no-show rather than file 0 for
|
---|
| 13 | ; undoing a no show
|
---|
[1461] | 14 | ;
|
---|
| 15 | ; Error Reference:
|
---|
| 16 | ; -1: zero or null Appt ID
|
---|
| 17 | ; -2: Invalid APPT ID (doesn't exist in ^BSDXAPPT)
|
---|
| 18 | ; -3: No-show flag is invalid
|
---|
| 19 | ; -4: Filing of No-show in ^BSDXAPPT failed
|
---|
| 20 | ; -5: Filing of No-show in ^DPT failed (BSDXAPI error)
|
---|
| 21 | ; -6: Invalid Resource ID
|
---|
| 22 | ; -100: M Error
|
---|
| 23 | ;
|
---|
| 24 | ;
|
---|
[1041] | 25 | NOSHOWD(BSDXY,BSDXAPTID,BSDXNS) ;EP
|
---|
[1461] | 26 | ;Entry point for debugging
|
---|
| 27 | ;
|
---|
| 28 | ; D DEBUG^%Serenji("NOSHOW^BSDX31(.BSDXY,BSDXAPTID,BSDXNS)")
|
---|
| 29 | Q
|
---|
| 30 | ;
|
---|
[1041] | 31 | NOSHOW(BSDXY,BSDXAPTID,BSDXNS) ;EP - No show a patient
|
---|
[1461] | 32 | ; Called by RPC: BSDX NOSHOW
|
---|
| 33 | ; Sets appointment noshow flag in BSDX APPOINTMENT file and "S" node in File 2
|
---|
| 34 | ;
|
---|
| 35 | ; Parameters:
|
---|
| 36 | ; BSDXY: Global Return
|
---|
| 37 | ; BSDXAPTID is entry number in BSDX APPOINTMENT file
|
---|
| 38 | ; BSDXNS = 1: NOSHOW, 0: CANCEL NOSHO
|
---|
| 39 | ;
|
---|
| 40 | ; Returns ADO.net record set with fields
|
---|
| 41 | ; - ERRORID; ERRORTEXT
|
---|
| 42 | ; ERRORID of 1 is okay
|
---|
| 43 | ; Anything else is an error.
|
---|
| 44 | ;
|
---|
| 45 | ; Return Array; set and clear
|
---|
| 46 | S BSDXY=$NA(^BSDXTMP($J))
|
---|
| 47 | K ^BSDXTMP($J)
|
---|
| 48 | ;
|
---|
| 49 | ; $ET
|
---|
| 50 | N $ET S $ET="G ETRAP^BSDX31"
|
---|
| 51 | ;
|
---|
| 52 | ; Basline vars
|
---|
| 53 | D ^XBKVAR ; Set up baseline variables (DUZ, DUZ(2)) if they don't exist
|
---|
| 54 | ;
|
---|
| 55 | ; Counter
|
---|
| 56 | N BSDXI S BSDXI=0
|
---|
| 57 | ;
|
---|
| 58 | ; Header Node
|
---|
| 59 | S ^BSDXTMP($J,BSDXI)="I00100ERRORID^T00030ERRORTEXT"_$C(30)
|
---|
| 60 | ;
|
---|
| 61 | ;;;test for error. See if %ZTER works
|
---|
| 62 | I $G(BSDXDIE) N X S X=1/0
|
---|
| 63 | ;;;TEST
|
---|
| 64 | ;
|
---|
| 65 | ; Turn off SDAM APPT PROTOCOL BSDX Entries
|
---|
| 66 | N BSDXNOEV S BSDXNOEV=1 ;Don't execute protocol
|
---|
| 67 | ;
|
---|
| 68 | ; Appointment ID check
|
---|
| 69 | I '+BSDXAPTID D ERR(-1,"BSDX31: Invalid Appointment ID") Q
|
---|
| 70 | I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(-2,"BSDX31: Invalid Appointment ID") Q
|
---|
| 71 | ;
|
---|
| 72 | ; Noshow value check - Must be 1 or 0
|
---|
| 73 | S BSDXNS=+BSDXNS
|
---|
| 74 | I BSDXNS'=1&(BSDXNS'=0) D ERR(-3,"BSDX31: Invalid No Show value") Q
|
---|
| 75 | ;
|
---|
| 76 | ; Get Some data
|
---|
| 77 | N BSDXNOD S BSDXNOD=^BSDXAPPT(BSDXAPTID,0) ; Node
|
---|
| 78 | N BSDXPATID S BSDXPATID=$P(BSDXNOD,U,5) ; DFN
|
---|
| 79 | N BSDXSTART S BSDXSTART=$P(BSDXNOD,U) ; Start Date/Time
|
---|
| 80 | N BSDXRES S BSDXRES=$P(BSDXNOD,U,7) ; Resource ID
|
---|
| 81 | ;
|
---|
| 82 | ; Check if Resource ID is missing or invalid
|
---|
| 83 | I BSDXRES="" D ERR(-6,"BSDX31: Invalid Resource") QUIT
|
---|
| 84 | I '$D(^BSDXRES(BSDXRES,0)) D ERR(-6,"BSDX31: Invalid Resource") QUIT
|
---|
| 85 | ;
|
---|
| 86 | ; Get the Hospital Location
|
---|
| 87 | N BSDXRESNOD S BSDXRESNOD=^BSDXRES(BSDXRES,0)
|
---|
| 88 | N BSDXLOC S BSDXLOC=$P(BSDXRESNOD,U,4) ;HOSPITAL LOCATION
|
---|
[1462] | 89 | I BSDXLOC,'$D(^SC(BSDXLOC,0)) S BSDXLOC="" ; Unlink it if it doesn't exist
|
---|
| 90 | ; I can go and then delete it from ^BSDXRES like Mailman code which tries
|
---|
| 91 | ; to be too helpful... but I will postpone that until this is a need.
|
---|
[1461] | 92 | ;
|
---|
[1462] | 93 | ; Check if it's okay to no-show patient.
|
---|
| 94 | N BSDXERR S BSDXERR=0 ; Error variable
|
---|
| 95 | I BSDXLOC S BSDXERR=$$NOSHOWCK^BSDXAPI1(BSDXPATID,BSDXLOC,BSDXSTART,BSDXNS)
|
---|
| 96 | I BSDXERR D ERR(-5,"BSDX31: "_$P(BSDXERR,U,2)) QUIT
|
---|
| 97 | ;
|
---|
| 98 | ; Simulated Error
|
---|
| 99 | I $G(BSDXSIMERR1) D ERR(-4,"BSDX31: Simulated Error") QUIT
|
---|
| 100 | ; Edit BSDX APPOINTMENT entry No-show field
|
---|
| 101 | ; Failure Analysis: If we fail here, no rollback needed, as this is the 1st
|
---|
| 102 | ; call
|
---|
| 103 | N BSDXMSG S BSDXMSG=$$BSDXNOS(BSDXAPTID,BSDXNS)
|
---|
[1461] | 104 | I BSDXMSG D ERR(-4,"BSDX31: "_$P(BSDXMSG,U,2)) QUIT
|
---|
| 105 | ;
|
---|
| 106 | ; Edit File 2 "S" node entry
|
---|
[1462] | 107 | ; Failure Analysis: If we fail here, we need to rollback the BSDX
|
---|
| 108 | ; Apptointment Entry
|
---|
| 109 | N BSDXERR S BSDXERR=0 ; Error variable
|
---|
[1461] | 110 | ; If HL exist, (resource is linked to PIMS), file no show in File 2
|
---|
| 111 | I BSDXLOC S BSDXERR=$$NOSHOW^BSDXAPI1(BSDXPATID,BSDXLOC,BSDXSTART,BSDXNS)
|
---|
[1462] | 112 | I BSDXERR D QUIT
|
---|
| 113 | . D ERR(-5,"BSDX31: "_$P(BSDXERR,U,2))
|
---|
| 114 | . N % S %=$$BSDXNOS(BSDXAPTID,'BSDXNS) ; no error checking for filer
|
---|
[1461] | 115 | ;
|
---|
[1462] | 116 | ; Return data in ADO.net table
|
---|
[1461] | 117 | S BSDXI=BSDXI+1
|
---|
| 118 | S ^BSDXTMP($J,BSDXI)="1^"_$C(30) ; 1 means everything okay
|
---|
| 119 | S BSDXI=BSDXI+1
|
---|
| 120 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
| 121 | QUIT
|
---|
| 122 | ;
|
---|
| 123 | BSDXNOS(BSDXAPTID,BSDXNS) ; $$ Private; File/unfile noshow in ^BSDXAPPT
|
---|
[1462] | 124 | ; in v1.7 I delete the no-show value rather than file zero
|
---|
[1461] | 125 | N BSDXFDA,BSDXIENS,BSDXMSG
|
---|
[1462] | 126 | N BSDXVALUE ; What to file: 1 or delete it.
|
---|
| 127 | I BSDXNS S BSDXVALUE=1
|
---|
| 128 | E S BSDXVALUE="@"
|
---|
[1461] | 129 | S BSDXIENS=BSDXAPTID_","
|
---|
[1462] | 130 | S BSDXFDA(9002018.4,BSDXIENS,.1)=BSDXVALUE ;NOSHOW 1 or 0
|
---|
[1461] | 131 | D FILE^DIE("","BSDXFDA","BSDXMSG")
|
---|
| 132 | QUIT:$D(BSDXMSG) -1_U_BSDXMSG("DIERR",1,"TEXT",1)
|
---|
| 133 | QUIT 0
|
---|
| 134 | ;
|
---|
[1041] | 135 | NOSEVT(BSDXPAT,BSDXSTART,BSDXSC) ;EP Called by BSDX NOSHOW APPOINTMENT event
|
---|
[1461] | 136 | ;when appointments NOSHOW via PIMS interface.
|
---|
| 137 | ;Propagates NOSHOW to BSDXAPPT and raises refresh event to running GUI clients
|
---|
| 138 | ;
|
---|
| 139 | Q:+$G(BSDXNOEV)
|
---|
| 140 | Q:'+$G(BSDXSC)
|
---|
| 141 | Q:$G(SDATA("AFTER","STATUS"))["AUTO RE-BOOK"
|
---|
| 142 | N BSDXSTAT,BSDXFOUND,BSDXRES
|
---|
| 143 | S BSDXSTAT=1
|
---|
| 144 | S:$G(SDATA("BEFORE","STATUS"))["NO-SHOW" BSDXSTAT=0
|
---|
| 145 | S BSDXFOUND=0
|
---|
| 146 | I $D(^BSDXRES("ALOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ALOC",BSDXSC,0)) S BSDXFOUND=$$NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
|
---|
| 147 | I BSDXFOUND D NOSEVT3(BSDXRES) Q
|
---|
| 148 | I $D(^BXDXRES("ASSOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ASSOC",BSDXSC,0)) S BSDXFOUND=$$NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT)
|
---|
| 149 | I BSDXFOUND D NOSEVT3(BSDXRES)
|
---|
| 150 | Q
|
---|
| 151 | ;
|
---|
[1041] | 152 | NOSEVT1(BSDXRES,BSDXSTART,BSDXPAT,BSDXSTAT) ;
|
---|
[1461] | 153 | ;Get appointment id in BSDXAPT
|
---|
| 154 | ;If found, call BSDXNOS(BSDXAPPT) and return 1
|
---|
| 155 | ;else return 0
|
---|
| 156 | N BSDXFOUND,BSDXAPPT,BSDXNOD
|
---|
| 157 | S BSDXFOUND=0
|
---|
| 158 | Q:'+$G(BSDXRES) BSDXFOUND
|
---|
| 159 | Q:'$D(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART)) BSDXFOUND
|
---|
| 160 | S BSDXAPPT=0 F S BSDXAPPT=$O(^BSDXAPPT("ARSRC",BSDXRES,BSDXSTART,BSDXAPPT)) Q:'+BSDXAPPT D Q:BSDXFOUND
|
---|
| 161 | . S BSDXNOD=$G(^BSDXAPPT(BSDXAPPT,0)) Q:BSDXNOD=""
|
---|
| 162 | . I $P(BSDXNOD,U,5)=BSDXPAT,$P(BSDXNOD,U,12)="" S BSDXFOUND=1 Q
|
---|
| 163 | I BSDXFOUND,+$G(BSDXAPPT) N BSDXMSG S BSDXMSG=$$BSDXNOS(BSDXAPPT,BSDXSTAT)
|
---|
| 164 | I BSDXMSG D ^%ZTER ; Last ditch error handling. This is supposed to be silently called from the protocol file.
|
---|
| 165 | Q BSDXFOUND
|
---|
| 166 | ;
|
---|
[1041] | 167 | NOSEVT3(BSDXRES) ;
|
---|
[1461] | 168 | ;Call RaiseEvent to notify GUI clients
|
---|
| 169 | ;
|
---|
| 170 | N BSDXRESN
|
---|
| 171 | S BSDXRESN=$G(^BSDXRES(BSDXRES,0))
|
---|
| 172 | Q:BSDXRESN=""
|
---|
| 173 | S BSDXRESN=$P(BSDXRESN,"^")
|
---|
| 174 | D EVENT^BMXMEVN("BSDX SCHEDULE",BSDXRESN)
|
---|
| 175 | Q
|
---|
| 176 | ;
|
---|
| 177 | ;
|
---|
[1041] | 178 | ERR(BSDXERID,ERRTXT) ;Error processing
|
---|
[1462] | 179 | ; If last line is $C(31), we are done. No more errors to send to client.
|
---|
| 180 | I ^BSDXTMP($J,$O(^BSDXTMP($J," "),-1))=$C(31) QUIT
|
---|
[1461] | 181 | S BSDXI=BSDXI+1
|
---|
| 182 | S ERRTXT=$TR(ERRTXT,"^","~")
|
---|
| 183 | S ^BSDXTMP($J,BSDXI)=BSDXERID_"^"_ERRTXT_$C(30)
|
---|
| 184 | S BSDXI=BSDXI+1
|
---|
| 185 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
| 186 | QUIT
|
---|
| 187 | ;
|
---|
[1041] | 188 | ETRAP ;EP Error trap entry
|
---|
[1461] | 189 | N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
|
---|
| 190 | D ^%ZTER
|
---|
| 191 | S $EC="" ; Clear Error
|
---|
[1462] | 192 | I $G(BSDXAPTID),$D(BSDXNS) N % S %=$$BSDXNOS(BSDXAPTID,'BSDXNS) ; Reverse No-Show status (whatever it was)
|
---|
[1461] | 193 | ; Send to client
|
---|
| 194 | I '$D(BSDXI) N BSDXI S BSDXI=0
|
---|
| 195 | D ERR(-100,"BSDX31 Error: "_$G(%ZTERZE))
|
---|
[1462] | 196 | Q:$Q 100_U_"Mumps Error" Q
|
---|
[1461] | 197 | ;
|
---|
[1041] | 198 | IMHERE(BSDXRES) ;EP
|
---|
[1461] | 199 | ;Entry point for BSDX IM HERE remote procedure
|
---|
| 200 | S BSDXRES=1
|
---|
| 201 | Q
|
---|
| 202 | ;
|
---|