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