[1466] | 1 | BSDXAPI ; IHS/ANMC/LJF & VW/SMH - SCHEDULING APIs ; 7/3/12 12:30pm
|
---|
[1451] | 2 | ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
|
---|
[1161] | 3 | ; Licensed under LGPL
|
---|
| 4 | ;
|
---|
[1466] | 5 | ; Orignal routine is BSDAPI by IHS/LJF, HMW, and MAW
|
---|
[1452] | 6 | ; mods (many) by WV/SMH
|
---|
[1466] | 7 | ; Move to BSDX namespace as BSDXAPI from BSDAPI by WV/SMH
|
---|
| 8 | ; Change history is located in BSDXAPI1 (to save space).
|
---|
[968] | 9 | ;
|
---|
| 10 | MAKE1(DFN,CLIN,TYP,DATE,LEN,INFO) ; Simplified PEP w/ parameters for $$MAKE - making appointment
|
---|
| 11 | ; Call like this for DFN 23435 having an appointment at Hospital Location 33
|
---|
| 12 | ; have 3 (scheduled) or 4 (walkin) appt at Dec 20, 2009 @ 10:11:59 for 30 minutes appt
|
---|
| 13 | ; for Baby foxes hallucinations.
|
---|
| 14 | ; S RESULT=$$MAKE1^BSDXAPI(23435,33,(3 or 4),3091220.221159,30,"I see Baby foxes")
|
---|
[1460] | 15 | N BSDR
|
---|
[968] | 16 | S BSDR("PAT")=DFN ;DFN
|
---|
| 17 | S BSDR("CLN")=CLIN ;Hosp Loc IEN
|
---|
| 18 | S BSDR("TYP")=TYP ;3 sched or 4 walkin
|
---|
| 19 | S BSDR("ADT")=DATE ;Appointment date in FM format
|
---|
| 20 | S BSDR("LEN")=LEN ;Appt len upto 240 (min)
|
---|
[1035] | 21 | S BSDR("OI")=INFO ;Reason for appt - up to 150 char
|
---|
[968] | 22 | S BSDR("USR")=DUZ ;Person who made appt - current user
|
---|
| 23 | Q $$MAKE(.BSDR)
|
---|
| 24 | ;
|
---|
| 25 | MAKE(BSDR) ;PEP; call to store appt made
|
---|
| 26 | ;
|
---|
| 27 | ; Make call using: S ERR=$$MAKE^BSDXAPI(.ARRAY)
|
---|
| 28 | ;
|
---|
| 29 | ; Input Array -
|
---|
| 30 | ; BSDR("PAT") = ien of patient in file 2
|
---|
| 31 | ; BSDR("CLN") = ien of clinic in file 44
|
---|
| 32 | ; BSDR("TYP") = 3 for scheduled appts, 4 for walkins
|
---|
| 33 | ; BSDR("ADT") = appointment date and time
|
---|
[1081] | 34 | ; BSDR("LEN") = appointment length in minutes (*1.42 limit removed)
|
---|
[968] | 35 | ; BSDR("OI") = reason for appt - up to 150 characters
|
---|
| 36 | ; BSDR("USR") = user who made appt
|
---|
| 37 | ;
|
---|
| 38 | ;Output: error status and message
|
---|
| 39 | ; = 0 or null: everything okay
|
---|
| 40 | ; = 1^message: error and reason
|
---|
| 41 | ;
|
---|
[1450] | 42 | N BSDXMKCK S BSDXMKCK=$$MAKECK(.BSDR) ; Check if we can make appointment
|
---|
| 43 | I BSDXMKCK Q BSDXMKCK ; If we can't, quit with the reason why.
|
---|
[968] | 44 | ;
|
---|
[1451] | 45 | ;Otherwise, we continue
|
---|
[968] | 46 | ;
|
---|
[1451] | 47 | N BSDXFDA,BSDXIENS,BSDXMSG ; FILE/UPDATE^DIE variables
|
---|
| 48 | ;
|
---|
[968] | 49 | I $D(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0)),$P(^(0),U,2)["C" D
|
---|
| 50 | . ; "un-cancel" existing appt in file 2
|
---|
| 51 | . S BSDXIENS=BSDR("ADT")_","_BSDR("PAT")_","
|
---|
| 52 | . S BSDXFDA(2.98,BSDXIENS,".01")=BSDR("CLN")
|
---|
| 53 | . S BSDXFDA(2.98,BSDXIENS,"3")=""
|
---|
| 54 | . S BSDXFDA(2.98,BSDXIENS,"9")=BSDR("TYP")
|
---|
| 55 | . S BSDXFDA(2.98,BSDXIENS,"9.5")=9
|
---|
| 56 | . S BSDXFDA(2.98,BSDXIENS,"14")=""
|
---|
| 57 | . S BSDXFDA(2.98,BSDXIENS,"15")=""
|
---|
| 58 | . S BSDXFDA(2.98,BSDXIENS,"16")=""
|
---|
[1452] | 59 | . S BSDXFDA(2.98,BSDXIENS,"17")="@" ; v 1.7; cancellation remarks were left over
|
---|
[968] | 60 | . S BSDXFDA(2.98,BSDXIENS,"19")=""
|
---|
| 61 | . S BSDXFDA(2.98,BSDXIENS,"20")=$$NOW^XLFDT
|
---|
| 62 | . D FILE^DIE("","BSDXFDA","BSDXMSG")
|
---|
[1451] | 63 | Q:$D(BSDXMSG) 1_U_"Fileman edit to DPT error: Patient="_BSDR("PAT")_" Appt="_BSDR("ADT")_" Error="_BSDXMSG("DIERR",1,"TEXT",1)
|
---|
| 64 | ;
|
---|
[1452] | 65 | Q:$G(BSDXSIMERR2) 1_U_$NA(BSDXSIMERR2) ; Unit Test line
|
---|
| 66 | ;
|
---|
[1451] | 67 | E D ; File new appointment/edit existing appointment in file 2
|
---|
[968] | 68 | . S BSDXIENS="?+2,"_BSDR("PAT")_","
|
---|
| 69 | . S BSDXIENS(2)=BSDR("ADT")
|
---|
| 70 | . S BSDXFDA(2.98,BSDXIENS,.01)=BSDR("CLN")
|
---|
| 71 | . S BSDXFDA(2.98,BSDXIENS,"9")=BSDR("TYP")
|
---|
| 72 | . S BSDXFDA(2.98,BSDXIENS,"9.5")=9
|
---|
| 73 | . S BSDXFDA(2.98,BSDXIENS,"20")=$$NOW^XLFDT
|
---|
[1451] | 74 | . D UPDATE^DIE("","BSDXFDA","BSDXIENS","BSDXMSG")
|
---|
| 75 | Q:$D(BSDXMSG) 1_U_"FileMan add to DPT error: Patient="_BSDR("PAT")_" Appt="_BSDR("ADT")_" Error="_BSDXMSG("DIERR",1,"TEXT",1)
|
---|
| 76 | ;
|
---|
[1452] | 77 | Q:$G(BSDXSIMERR3) 1_U_$NA(BSDXSIMERR3) ; Unit Test line
|
---|
| 78 | ;
|
---|
[1451] | 79 | ; add appt to file 44. This adds it to the FIRST subfile (Appointment)
|
---|
[1460] | 80 | N DIC,DA,Y,X,DD,DO,DLAYGO,DINUM
|
---|
[968] | 81 | I '$D(^SC(BSDR("CLN"),"S",0)) S ^SC(BSDR("CLN"),"S",0)="^44.001DA^^"
|
---|
| 82 | 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")
|
---|
| 83 | . S DIC="^SC("_BSDR("CLN")_",""S"",",DA(1)=BSDR("CLN"),(X,DINUM)=BSDR("ADT")
|
---|
| 84 | . S DIC("P")="44.001DA",DIC(0)="L",DLAYGO=44.001
|
---|
| 85 | . S Y=1 I '$D(@(DIC_X_")")) D FILE^DICN
|
---|
| 86 | ;
|
---|
[1452] | 87 | Q:$G(BSDXSIMERR4) 1_U_$NA(BSDXSIMERR4) ; Unit Test line
|
---|
| 88 | ;
|
---|
[1451] | 89 | ; add appt for file 44, second subfile (Appointment/Patient)
|
---|
[968] | 90 | ; Sep 28 2010: Changed old style API to new style API. Keep for reference //smh
|
---|
| 91 | ;K DIC,DA,X,Y,DLAYGO,DD,DO,DINUM
|
---|
| 92 | ;S DIC="^SC("_BSDR("CLN")_",""S"","_BSDR("ADT")_",1,"
|
---|
| 93 | ;S DA(2)=BSDR("CLN"),DA(1)=BSDR("ADT"),X=BSDR("PAT")
|
---|
| 94 | ;S DIC("DR")="1///"_BSDR("LEN")_";3///"_$E($G(BSDR("OI")),1,150)_";7///`"_BSDR("USR")_";8///"_$P($$NOW^XLFDT,".")
|
---|
| 95 | ;S DIC("P")="44.003PA",DIC(0)="L",DLAYGO=44.003
|
---|
| 96 | ;D FILE^DICN
|
---|
| 97 | ;
|
---|
| 98 | N BSDXIENS S BSDXIENS="?+1,"_BSDR("ADT")_","_BSDR("CLN")_","
|
---|
| 99 | N BSDXFDA
|
---|
| 100 | S BSDXFDA(44.003,BSDXIENS,.01)=BSDR("PAT")
|
---|
| 101 | S BSDXFDA(44.003,BSDXIENS,1)=BSDR("LEN")
|
---|
| 102 | S BSDXFDA(44.003,BSDXIENS,3)=$E($G(BSDR("OI")),1,150)
|
---|
| 103 | S BSDXFDA(44.003,BSDXIENS,7)=BSDR("USR")
|
---|
| 104 | S BSDXFDA(44.003,BSDXIENS,8)=$P($$NOW^XLFDT,".")
|
---|
| 105 | N BSDXERR
|
---|
| 106 | D UPDATE^DIE("","BSDXFDA","","BSDXERR")
|
---|
| 107 | ;
|
---|
| 108 | 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)
|
---|
| 109 | ;
|
---|
[1452] | 110 | ;Q:$G(BSDXSIMERR5) 1_U_$NA(BSDXSIMERR5) ; Unit Test line
|
---|
| 111 | S:$G(BSDXSIMERR5) X=1/0
|
---|
| 112 | ;
|
---|
[968] | 113 | ; call event driver
|
---|
| 114 | NEW DFN,SDT,SDCL,SDDA,SDMODE
|
---|
| 115 | S DFN=BSDR("PAT"),SDT=BSDR("ADT"),SDCL=BSDR("CLN"),SDMODE=2
|
---|
| 116 | S SDDA=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
|
---|
| 117 | D MAKE^SDAMEVT(DFN,SDT,SDCL,SDDA,SDMODE)
|
---|
| 118 | Q 0
|
---|
| 119 | ;
|
---|
[1450] | 120 | MAKECK(BSDR) ; $$ - Is it okay to make an appointment? ; PEP
|
---|
[1451] | 121 | ; Input: Same as $$MAKE
|
---|
| 122 | ; Output: 1^error or 0 for success
|
---|
| 123 | ; NB: This subroutine saves no data. Only checks whether it's okay.
|
---|
| 124 | ;
|
---|
[1450] | 125 | I '$D(^DPT(+$G(BSDR("PAT")),0)) Q 1_U_"Patient not on file: "_$G(BSDR("PAT"))
|
---|
| 126 | I '$D(^SC(+$G(BSDR("CLN")),0)) Q 1_U_"Clinic not on file: "_$G(BSDR("CLN"))
|
---|
| 127 | I ($G(BSDR("TYP"))<3)!($G(BSDR("TYP"))>4) Q 1_U_"Appt Type error: "_$G(BSDR("TYP"))
|
---|
| 128 | I $G(BSDR("ADT")) S BSDR("ADT")=+$E(BSDR("ADT"),1,12) ;remove seconds
|
---|
| 129 | I $G(BSDR("ADT"))'?7N.1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
|
---|
| 130 | ;
|
---|
[1451] | 131 | ; Appt Length check removed in v 1.5
|
---|
| 132 | ;
|
---|
[1450] | 133 | I '$D(^VA(200,+$G(BSDR("USR")),0)) Q 1_U_"User Who Made Appt Error: "_$G(BSDR("USR"))
|
---|
| 134 | ; More verbose error message in v1.5
|
---|
| 135 | ; Following block to give an error message to user if there is already an appointment for patient. More verbose than others.
|
---|
| 136 | N BSDXERR ; place to store error message
|
---|
| 137 | I $D(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0)),$P(^(0),U,2)'["C" DO QUIT BSDXERR ; If there's an appt in the "S" node of file 2 and it's not cancelled
|
---|
| 138 | . S BSDXERR=1_U_"Patient "_$P(^DPT(BSDR("PAT"),0),U)_" ("_BSDR("PAT")_") "
|
---|
| 139 | . S BSDXERR=BSDXERR_"already has appt at "_$$FMTE^XLFDT(BSDR("ADT"))
|
---|
| 140 | . N BSDXSCIEN S BSDXSCIEN=$P(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0),U) ; Clinic IEN in ^SC (0 piece of 0 node of "S" multiple in file 2)
|
---|
| 141 | . N BSDXSCNAM S BSDXSCNAM=$P(^SC(BSDXSCIEN,0),U) ; PIMS Name of Clinic
|
---|
| 142 | . S BSDXERR=BSDXERR_$C(13,10)_"PIMS clinic: "_BSDXSCNAM ; tell the user of the PIMS clinic
|
---|
| 143 | . I $D(^BSDXRES("ALOC",BSDXSCIEN)) DO ; if the Clinic is linked to a BSDX Resource (we find out using the index ALOC in the BSDX RESOURCE file)
|
---|
| 144 | . . N BSDXRESIEN S BSDXRESIEN=$O(^BSDXRES("ALOC",BSDXSCIEN,""))
|
---|
| 145 | . . QUIT:'BSDXRESIEN ; Safeguard if index is corrupt
|
---|
| 146 | . . N BSDXRESNAM S BSDXRESNAM=$P(^BSDXRES(BSDXRESIEN,0),U)
|
---|
| 147 | . . S BSDXERR=BSDXERR_$C(13,10)_"Scheduling GUI clinic: "_BSDXRESNAM ; tell the user of the BSDX clinic
|
---|
| 148 | Q 0
|
---|
[1451] | 149 | ;
|
---|
[1450] | 150 | UNMAKE(BSDR) ; Reverse Make - Private $$
|
---|
[1451] | 151 | ; Only used in Emergiencies where Fileman data filing fails.
|
---|
| 152 | ; If previous data exists, which caused an error, it's destroyed.
|
---|
| 153 | ; NB: ^DIK stops for nobody
|
---|
| 154 | ; Input: Same array as $$MAKE
|
---|
| 155 | ; Output: Always 0
|
---|
| 156 | NEW DIK,DA
|
---|
| 157 | S DIK="^DPT("_BSDR("PAT")_",""S"","
|
---|
[1452] | 158 | S DA(1)=BSDR("PAT"),DA=BSDR("ADT")
|
---|
[1451] | 159 | D ^DIK
|
---|
[1450] | 160 | ;
|
---|
[1451] | 161 | N IEN S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
|
---|
| 162 | I 'IEN QUIT 0
|
---|
| 163 | ;
|
---|
| 164 | NEW DIK,DA
|
---|
| 165 | S DIK="^SC("_BSDR("CLN")_",""S"","_BSDR("ADT")_",1,"
|
---|
| 166 | S DA(2)=BSDR("CLN"),DA(1)=BSDR("ADT"),DA=IEN
|
---|
| 167 | D ^DIK
|
---|
| 168 | QUIT 0
|
---|
| 169 | ;
|
---|
[968] | 170 | CHECKIN1(DFN,CLIN,APDATE) ; Simplified PEP w/ parameters for $$CHECKIN - Checking in
|
---|
| 171 | ; Call like this for DFN 23435 checking in now at Hospital Location 33
|
---|
| 172 | ; for appt at Dec 20, 2009 @ 10:11:59
|
---|
| 173 | ; S RESULT=$$CHECKIN1^BSDXAPI(23435,33,3091220.221159)
|
---|
[1460] | 174 | N BSDR
|
---|
[968] | 175 | S BSDR("PAT")=DFN ;DFN
|
---|
| 176 | S BSDR("CLN")=CLIN ;Hosp Loc IEN
|
---|
| 177 | S BSDR("ADT")=APDATE ;Appt Date
|
---|
| 178 | S BSDR("CDT")=$$NOW^XLFDT ;Check-in date defaults to now
|
---|
| 179 | S BSDR("USR")=DUZ ;Check-in user defaults to current
|
---|
| 180 | Q $$CHECKIN(.BSDR)
|
---|
| 181 | ;
|
---|
| 182 | CHECKIN(BSDR) ;EP; call to add checkin info to appt; IHS/ITSC/LJF 12/23/2004 PATCH 1002
|
---|
| 183 | ;
|
---|
| 184 | ; Make call by using: S ERR=$$CHECKIN^BSDXAPI(.ARRAY)
|
---|
| 185 | ;
|
---|
| 186 | ; Input array -
|
---|
| 187 | ; BSDR("PAT") = ien of patient in file 2
|
---|
| 188 | ; BSDR("CLN") = ien of clinic in file 44
|
---|
| 189 | ; BSDR("ADT") = appt date/time
|
---|
| 190 | ; BSDR("CDT") = checkin date/time
|
---|
| 191 | ; BSDR("USR") = checkin user
|
---|
| 192 | ;
|
---|
| 193 | ; Output value -
|
---|
| 194 | ; = 0 means everything worked
|
---|
| 195 | ; = 1^message means error with reason message
|
---|
| 196 | ;
|
---|
[1466] | 197 | I $G(BSDXDIE2) N X S X=1/0
|
---|
[968] | 198 | ;
|
---|
[1466] | 199 | N BSDXERR S BSDXERR=$$CHECKICK(.BSDR)
|
---|
| 200 | I BSDXERR Q BSDXERR
|
---|
| 201 | ;
|
---|
[968] | 202 | ; find ien for appt in file 44
|
---|
| 203 | NEW IEN,DIE,DA,DR
|
---|
| 204 | S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
|
---|
| 205 | ;
|
---|
| 206 | ; remember before status
|
---|
[1466] | 207 | ; Failure analysis: Only ^TMP global is set here.
|
---|
[1460] | 208 | NEW SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL,SDMODE
|
---|
[968] | 209 | S DFN=BSDR("PAT"),SDT=BSDR("ADT"),SDCL=BSDR("CLN"),SDMODE=2,SDDA=IEN
|
---|
| 210 | S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
|
---|
| 211 | D BEFORE^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
|
---|
| 212 | ;
|
---|
[1466] | 213 | ; set checkin; Old Code -- keep for ref VEN/SMH 3 Jul 2012
|
---|
| 214 | ; S DIE="^SC("_BSDR("CLN")_",""S"","_BSDR("ADT")_",1,"
|
---|
| 215 | ; S DA(2)=BSDR("CLN"),DA(1)=BSDR("ADT"),DA=IEN
|
---|
| 216 | ; S DR="309///"_BSDR("CDT")_";302///`"_BSDR("USR")_";305///"_$$NOW^XLFDT
|
---|
| 217 | ; D ^DIE
|
---|
[968] | 218 | ;
|
---|
[1466] | 219 | I $D(BSDXSIMERR3) Q 1_U_"Simulated Error"
|
---|
| 220 | ;
|
---|
| 221 | ; Failure analysis: If this fails, no other changes were made in this routine
|
---|
| 222 | N BSDXIENS S BSDXIENS=IEN_","_BSDR("ADT")_","_BSDR("CLN")_","
|
---|
| 223 | N BSDXFDA
|
---|
| 224 | S BSDXFDA(44.003,BSDXIENS,309)=BSDR("CDT")
|
---|
| 225 | S BSDXFDA(44.003,BSDXIENS,302)=BSDR("USR")
|
---|
| 226 | S BSDXFDA(44.003,BSDXIENS,305)=$$NOW^XLFDT()
|
---|
| 227 | N BSDXERR
|
---|
| 228 | D UPDATE^DIE("","BSDXFDA","BSDXERR")
|
---|
| 229 | ;
|
---|
| 230 | I $D(BSDXERR) Q 1_U_"Error checking in appointment to file 44. Error: "_BSDXERR("DIERR",1,"TEXT",1)
|
---|
| 231 | ;
|
---|
[968] | 232 | ; set after status
|
---|
| 233 | S SDDA=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
|
---|
| 234 | S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
|
---|
| 235 | D AFTER^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
|
---|
| 236 | ;
|
---|
[1466] | 237 | ; Point of no Return
|
---|
[968] | 238 | ; call event driver
|
---|
| 239 | D EVT^SDAMEVT(.SDATA,4,SDMODE,SDCIHDL)
|
---|
| 240 | Q 0
|
---|
| 241 | ;
|
---|
[1466] | 242 | CHECKIC1(DFN,CLIN,APDATE) ; Simplified PEP w/ parameters for $$CHECKICK -
|
---|
| 243 | ; Check-in Check
|
---|
| 244 | ; Call like this for DFN 23435 checking in now at Hospital Location 33
|
---|
| 245 | ; for appt at Dec 20, 2009 @ 10:11:59
|
---|
| 246 | ; S RESULT=$$CHECKIC1^BSDXAPI(23435,33,3091220.221159)
|
---|
| 247 | N BSDR
|
---|
| 248 | S BSDR("PAT")=DFN ;DFN
|
---|
| 249 | S BSDR("CLN")=CLIN ;Hosp Loc IEN
|
---|
| 250 | S BSDR("ADT")=APDATE ;Appt Date
|
---|
| 251 | S BSDR("CDT")=$$NOW^XLFDT ;Check-in date defaults to now
|
---|
| 252 | S BSDR("USR")=DUZ ;Check-in user defaults to current
|
---|
| 253 | Q $$CHECKICK(.BSDR)
|
---|
| 254 | ;
|
---|
| 255 | CHECKICK(BSDR) ; $$ PEP; - Is it okay to check-in patient?
|
---|
| 256 | ; Input: Same as $$CHECKIN
|
---|
| 257 | ; Output: 0 if okay or 1^message if error
|
---|
| 258 | ;
|
---|
| 259 | I $G(BSDXSIMERR2) Q 1_U_"Simulated Error"
|
---|
| 260 | ;
|
---|
| 261 | I '$D(^DPT(+$G(BSDR("PAT")),0)) Q 1_U_"Patient not on file: "_$G(BSDR("PAT"))
|
---|
| 262 | I '$D(^SC(+$G(BSDR("CLN")),0)) Q 1_U_"Clinic not on file: "_$G(BSDR("CLN"))
|
---|
| 263 | I $G(BSDR("ADT")) S BSDR("ADT")=+$E(BSDR("ADT"),1,12) ;remove seconds
|
---|
| 264 | I $G(BSDR("ADT"))'?7N.1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
|
---|
| 265 | I $G(BSDR("CDT")) S BSDR("CDT")=+$E(BSDR("CDT"),1,12) ;remove seconds
|
---|
| 266 | I $G(BSDR("CDT"))'?7N.1".".4N Q 1_U_"Checkin Date/Time error: "_$G(BSDR("CDT"))
|
---|
| 267 | I '$D(^VA(200,+$G(BSDR("USR")),0)) Q 1_U_"User Who Made Appt Error: "_$G(BSDR("USR"))
|
---|
| 268 | ;
|
---|
| 269 | ; find ien for appt in file 44
|
---|
| 270 | N IEN S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
|
---|
| 271 | I 'IEN Q 1_U_"Error trying to find appointment for checkin: Patient="_BSDR("PAT")_" Clinic="_BSDR("CLN")_" Appt="_BSDR("ADT")
|
---|
| 272 | Q 0
|
---|
| 273 | ;
|
---|
[968] | 274 | CANCEL1(DFN,CLIN,TYP,APDATE,REASON,INFO) ; PEP w/ parameters for $$CANCEL - cancelling appointment
|
---|
| 275 | ; Call like this for DFN 23435 cancelling an appointment at Hospital Location 33,
|
---|
| 276 | ; cancellation initiated by patient ("PC" rather than clinic "C"),
|
---|
| 277 | ; cancelling appt at Dec 20, 2009 @ 10:11:59 because of reason 1 in file 409.2 IEN (weather)
|
---|
| 278 | ; because foxes come out during bad weather.
|
---|
| 279 | ; S RESULT=$$CANCEL1^BSDXAPI(23435,33,"PC",3091220.221159,1,"Afraid of foxes")
|
---|
[1460] | 280 | N BSDR
|
---|
[968] | 281 | S BSDR("PAT")=DFN
|
---|
| 282 | S BSDR("CLN")=CLIN
|
---|
| 283 | S BSDR("TYP")=TYP
|
---|
| 284 | S BSDR("ADT")=APDATE
|
---|
| 285 | S BSDR("CDT")=$$NOW^XLFDT
|
---|
| 286 | S BSDR("USR")=DUZ
|
---|
| 287 | S BSDR("CR")=REASON
|
---|
| 288 | S BSDR("NOT")=INFO
|
---|
| 289 | Q $$CANCEL(.BSDR)
|
---|
| 290 | ;
|
---|
| 291 | CANCEL(BSDR) ;PEP; called to cancel appt
|
---|
| 292 | ;
|
---|
| 293 | ; Make call using: S ERR=$$CANCEL^BSDXAPI(.ARRAY)
|
---|
| 294 | ;
|
---|
| 295 | ; Input Array -
|
---|
| 296 | ; BSDR("PAT") = ien of patient in file 2
|
---|
| 297 | ; BSDR("CLN") = ien of clinic in file 44
|
---|
| 298 | ; BSDR("TYP") = C for canceled by clinic; PC for patient canceled
|
---|
| 299 | ; BSDR("ADT") = appointment date and time
|
---|
| 300 | ; BSDR("CDT") = cancel date and time
|
---|
| 301 | ; BSDR("USR") = user who canceled appt
|
---|
| 302 | ; BSDR("CR") = cancel reason - pointer to file 409.2
|
---|
| 303 | ; BSDR("NOT") = cancel remarks - optional notes to 160 characters
|
---|
| 304 | ;
|
---|
| 305 | ;Output: error status and message
|
---|
| 306 | ; = 0 or null: everything okay
|
---|
| 307 | ; = 1^message: error and reason
|
---|
| 308 | ;
|
---|
[1460] | 309 | ; Okay to Cancel? Call Cancel Check.
|
---|
[1456] | 310 | N BSDXCANCK S BSDXCANCK=$$CANCELCK(.BSDR)
|
---|
| 311 | I BSDXCANCK Q BSDXCANCK
|
---|
[968] | 312 | ;
|
---|
[1080] | 313 | ; BSDX 1.5 3110125
|
---|
| 314 | ; UJO/SMH - Add ability to remove check-in if the patient is checked in
|
---|
[1460] | 315 | ; VEN/SMH on 3120625/v1.7 - PIMS doesn't care if patient is already checked in
|
---|
| 316 | ; Lets you remove appointment anyways! Not like RPMS.
|
---|
| 317 | ; Plus... deleting checkin affects S node on 44, which is DELETED anyways!
|
---|
[968] | 318 | ;
|
---|
| 319 | ; remember before status
|
---|
[1460] | 320 | NEW SDATA,DFN,SDT,SDCL,SDDA,SDCPHDL,SDMODE
|
---|
[1461] | 321 | NEW IEN S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
|
---|
[968] | 322 | S DFN=BSDR("PAT"),SDT=BSDR("ADT"),SDCL=BSDR("CLN"),SDMODE=2,SDDA=IEN
|
---|
| 323 | S SDCPHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
|
---|
| 324 | D BEFORE^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCPHDL)
|
---|
[1460] | 325 | ; NB: Here only ^TMP globals are set with before values.
|
---|
[968] | 326 | ;
|
---|
| 327 | ; get user who made appt and date appt made from ^SC
|
---|
| 328 | ; because data in ^SC will be deleted
|
---|
| 329 | NEW USER,DATE
|
---|
| 330 | S USER=$P($G(^SC(SDCL,"S",SDT,1,IEN,0)),U,6)
|
---|
| 331 | S DATE=$P($G(^SC(SDCL,"S",SDT,1,IEN,0)),U,7)
|
---|
| 332 | ;
|
---|
[1461] | 333 | ; update file 2 info --old code; keep for reference
|
---|
[1460] | 334 | ;NEW DIE,DA,DR
|
---|
| 335 | ;S DIE="^DPT("_DFN_",""S"",",DA(1)=DFN,DA=SDT
|
---|
| 336 | ;S DR="3///"_BSDR("TYP")_";14///`"_BSDR("USR")_";15///"_BSDR("CDT")_";16///`"_BSDR("CR")_";19///`"_USER_";20///"_DATE
|
---|
| 337 | ;S:$G(BSDR("NOT"))]"" DR=DR_";17///"_$E(BSDR("NOT"),1,160)
|
---|
| 338 | ;D ^DIE
|
---|
| 339 | N BSDXIENS S BSDXIENS=SDT_","_DFN_","
|
---|
| 340 | N BSDXFDA
|
---|
| 341 | S BSDXFDA(2.98,BSDXIENS,3)=BSDR("TYP")
|
---|
| 342 | S BSDXFDA(2.98,BSDXIENS,14)=BSDR("USR")
|
---|
| 343 | S BSDXFDA(2.98,BSDXIENS,15)=BSDR("CDT")
|
---|
| 344 | S BSDXFDA(2.98,BSDXIENS,16)=BSDR("CR")
|
---|
| 345 | S BSDXFDA(2.98,BSDXIENS,19)=USER
|
---|
| 346 | S BSDXFDA(2.98,BSDXIENS,20)=DATE
|
---|
| 347 | S:$G(BSDR("NOT"))]"" BSDXFDA(2.98,BSDXIENS,17)=$E(BSDR("NOT"),1,160)
|
---|
| 348 | N BSDXERR
|
---|
| 349 | D FILE^DIE("","BSDXFDA","BSDXERR")
|
---|
| 350 | I $D(BSDXERR) Q 1_U_"Cannot cancel appointment in File 2"
|
---|
| 351 | ; Failure point 1: If we fail here, nothing has happened yet.
|
---|
| 352 | ; No rollback needed in ^BSDXAPPT
|
---|
[968] | 353 | ;
|
---|
[1460] | 354 | ; delete data in ^SC -- this does not (typically) fail. Fileman won't stop
|
---|
[968] | 355 | NEW DIK,DA
|
---|
| 356 | S DIK="^SC("_BSDR("CLN")_",""S"","_BSDR("ADT")_",1,"
|
---|
| 357 | S DA(2)=BSDR("CLN"),DA(1)=BSDR("ADT"),DA=IEN
|
---|
| 358 | D ^DIK
|
---|
[1460] | 359 | ; Failure point 2: not expected to happen here
|
---|
[968] | 360 | ;
|
---|
[1460] | 361 | ; call event driver -- point of no return
|
---|
[968] | 362 | D CANCEL^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDMODE,SDCPHDL)
|
---|
| 363 | Q 0
|
---|
| 364 | ;
|
---|
[1456] | 365 | CANCELCK(BSDR) ; $$ PEP; Okay to Cancel Appointment?
|
---|
| 366 | ; Input: .BSDR array as documented in $$CANCEL
|
---|
| 367 | ; Output: 0 or 1^Error message
|
---|
| 368 | I '$D(^DPT(+$G(BSDR("PAT")),0)) Q 1_U_"Patient not on file: "_$G(BSDR("PAT"))
|
---|
| 369 | I '$D(^SC(+$G(BSDR("CLN")),0)) Q 1_U_"Clinic not on file: "_$G(BSDR("CLN"))
|
---|
| 370 | I ($G(BSDR("TYP"))'="C"),($G(BSDR("TYP"))'="PC") Q 1_U_"Cancel Status error: "_$G(BSDR("TYP"))
|
---|
| 371 | I $G(BSDR("ADT")) S BSDR("ADT")=+$E(BSDR("ADT"),1,12) ;remove seconds
|
---|
| 372 | I $G(BSDR("ADT"))'?7N.1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
|
---|
| 373 | I $G(BSDR("CDT")) S BSDR("CDT")=+$E(BSDR("CDT"),1,12) ;remove seconds
|
---|
| 374 | I $G(BSDR("CDT"))'?7N.1".".4N Q 1_U_"Cancel Date/Time error: "_$G(BSDR("CDT"))
|
---|
| 375 | I '$D(^VA(200,+$G(BSDR("USR")),0)) Q 1_U_"User Who Canceled Appt Error: "_$G(BSDR("USR"))
|
---|
| 376 | I '$D(^SD(409.2,+$G(BSDR("CR")))) Q 1_U_"Cancel Reason error: "_$G(BSDR("CR"))
|
---|
| 377 | ;
|
---|
| 378 | NEW IEN S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
|
---|
| 379 | I 'IEN Q 1_U_"Error trying to find appointment for cancel: Patient="_BSDR("PAT")_" Clinic="_BSDR("CLN")_" Appt="_BSDR("ADT")
|
---|
| 380 | Q 0
|
---|
[968] | 381 | CI(PAT,CLINIC,DATE,SDIEN) ;PEP; -- returns 1 if appt already checked-in
|
---|
| 382 | NEW X
|
---|
| 383 | S X=$G(SDIEN) ;ien sent in call
|
---|
| 384 | I 'X S X=$$SCIEN(PAT,CLINIC,DATE) I 'X Q 0
|
---|
| 385 | S X=$P($G(^SC(CLINIC,"S",DATE,1,X,"C")),U)
|
---|
| 386 | Q $S(X:1,1:0)
|
---|
| 387 | ;
|
---|
| 388 | SCIEN(PAT,CLINIC,DATE) ;PEP; returns ien for appt in ^SC
|
---|
| 389 | NEW X,IEN
|
---|
| 390 | S X=0 F S X=$O(^SC(CLINIC,"S",DATE,1,X)) Q:'X Q:$G(IEN) D
|
---|
[1006] | 391 | . Q:$P($G(^SC(CLINIC,"S",DATE,1,X,0)),U,9)["C" ;cancelled
|
---|
[968] | 392 | . I +$G(^SC(CLINIC,"S",DATE,1,X,0))=PAT S IEN=X
|
---|
| 393 | Q $G(IEN)
|
---|
| 394 | ;
|
---|
[1456] | 395 | APPLEN(PAT,CLINIC,DATE) ; $$ PEP; returns an appointment's length
|
---|
| 396 | ; Get either the appointment length or zero
|
---|
| 397 | ; TODO: Test
|
---|
| 398 | N SCIEN S SCIEN=$$SCIEN(PAT,CLINIC,DATE)
|
---|
| 399 | Q:SCIEN $P(^SC(CLINIC,"S",DATE,1,SCIEN,0),U,2)
|
---|
| 400 | Q 0
|
---|
[968] | 401 | APPTYP(PAT,DATE) ;PEP; -- returns type of appt (scheduled or walk-in)
|
---|
| 402 | NEW X S X=$P($G(^DPT(PAT,"S",DATE,0)),U,7)
|
---|
| 403 | Q $S(X=3:"SCHED",X=4:"WALK-IN",1:"??")
|
---|
| 404 | ;
|
---|
| 405 | CO(PAT,CLINIC,DATE,SDIEN) ;PEP; -- returns 1 if appt already checked-out
|
---|
| 406 | NEW X
|
---|
| 407 | S X=$G(SDIEN) ;ien sent in call
|
---|
| 408 | I 'X S X=$$SCIEN(PAT,CLINIC,DATE) I 'X Q 0
|
---|
| 409 | S X=$P($G(^SC(CLINIC,"S",DATE,1,X,"C")),U,3)
|
---|
| 410 | Q $S(X:1,1:0)
|
---|
| 411 | ;
|
---|
[1450] | 412 | UPDATENT(PAT,CLINIC,DATE,NOTE) ; PEP; Update Note in ^SC for patient's appointment @ DATE
|
---|
[1080] | 413 | ; PAT = DFN
|
---|
| 414 | ; CLINIC = SC IEN
|
---|
| 415 | ; DATE = FM Date/Time of Appointment
|
---|
| 416 | ;
|
---|
| 417 | ; Returns:
|
---|
| 418 | ; 0 if okay
|
---|
| 419 | ; -1 if failure
|
---|
[1460] | 420 | ;
|
---|
| 421 | ; ERROR SIMULATION
|
---|
| 422 | I $G(BSDXSIMERR1) QUIT "-1~Simulated Error"
|
---|
| 423 | ;
|
---|
[1080] | 424 | N SCIEN S SCIEN=$$SCIEN(PAT,CLINIC,DATE) ; ien of appt in ^SC
|
---|
| 425 | I SCIEN<1 QUIT 0 ; Appt cancelled; cancelled appts rm'ed from file 44
|
---|
| 426 | N BSDXIENS S BSDXIENS=SCIEN_","_DATE_","_CLINIC_","
|
---|
[1460] | 427 | N BSDXFDA S BSDXFDA(44.003,BSDXIENS,3)=$E(NOTE,1,150)
|
---|
[1080] | 428 | N BSDXERR
|
---|
| 429 | D FILE^DIE("","BSDXFDA","BSDXERR")
|
---|
| 430 | 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)
|
---|
| 431 | QUIT 0
|
---|