[1460] | 1 | BSDX26 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 6/25/12 4:29pm
|
---|
[1472] | 2 | ;;1.7T1;BSDX;;Jul 06, 2012;Build 18
|
---|
[1460] | 3 | ; Licensed under LGPL
|
---|
| 4 | ; Change History:
|
---|
| 5 | ; 3101023 - UJO/SMH - Addition of restartable transaction; relocation of tx.
|
---|
| 6 | ; 3101205 - UJO/SMH - Extensive refactoring.
|
---|
| 7 | ; 3120625 - VEN/SMH - Removal of Transactions, reloation of UTs to BSDXUT1
|
---|
| 8 | ;
|
---|
| 9 | ; Error Reference:
|
---|
| 10 | ; -1: Appt ID is not a number
|
---|
| 11 | ; -2: Appt IEN is not in ^BSDXAPPT
|
---|
| 12 | ; -3: FM Failure to file WP field in ^BSDXAPPT
|
---|
| 13 | ; -4: BSDXAPI reports failure to change note field in ^SC
|
---|
| 14 | ;
|
---|
[1041] | 15 | EDITAPTD(BSDXY,BSDXAPTID,BSDXNOTE) ;EP
|
---|
[1460] | 16 | ;Entry point for debugging
|
---|
| 17 | ;
|
---|
| 18 | ;D DEBUG^%Serenji("EDITAPT^BSDX26(.BSDXY,BSDXAPTID,BSDXNOTE)")
|
---|
| 19 | Q
|
---|
[1041] | 20 | EDITAPT(BSDXY,BSDXAPTID,BSDXNOTE) ;EP Edit appointment (only note text can be edited)
|
---|
[1460] | 21 | ; Called by RPC: BSDX EDIT APPOINTMENT
|
---|
| 22 | ;
|
---|
| 23 | ; Edits Appointment Text in BSDX APPOINTMENT file & Hosp Location (44) file
|
---|
| 24 | ;
|
---|
| 25 | ; Parameters:
|
---|
| 26 | ; - BSDXY: Global Return (RPC must be set to Global Array)
|
---|
| 27 | ; - BSDXAPTID: Appointment IEN in BSDX APPOINTMENT
|
---|
| 28 | ; - BSDXNOTE: New note
|
---|
| 29 | ;
|
---|
| 30 | ; Return:
|
---|
| 31 | ; ADO.net Recordset having 1 field: ERRORID
|
---|
| 32 | ; If Okay: -1; otherwise, positive integer with message
|
---|
| 33 | ;
|
---|
| 34 | ; Return Array; set Return and clear array
|
---|
| 35 | S BSDXY=$NA(^BSDXTMP($J))
|
---|
| 36 | K ^BSDXTMP($J)
|
---|
| 37 | ; ET
|
---|
| 38 | N $ET S $ET="G ETRAP^BSDX26"
|
---|
| 39 | ; Set up basic DUZ variables
|
---|
| 40 | D ^XBKVAR
|
---|
| 41 | ; Counter
|
---|
| 42 | N BSDXI S BSDXI=0
|
---|
| 43 | ; Header Node
|
---|
| 44 | S ^BSDXTMP($J,BSDXI)="T00100ERRORID"_$C(30)
|
---|
| 45 | ;
|
---|
| 46 | ;;;test for error. See if %ZTER works
|
---|
| 47 | I $G(BSDXDIE) S X=1/0
|
---|
| 48 | ;
|
---|
| 49 | ; Validate Appointment ID
|
---|
| 50 | I '+BSDXAPTID D ERR(BSDXI,"-1~BSDX26: Invalid Appointment ID") QUIT
|
---|
| 51 | I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(BSDXI,"-2~BSDX26: Invalid Appointment ID") QUIT
|
---|
| 52 | ;
|
---|
| 53 | ; Put the WP in decendant fields from the root to file as a WP field
|
---|
| 54 | S BSDXNOTE(.5)=BSDXNOTE,BSDXNOTE=""
|
---|
| 55 | I $D(BSDXNOTE(0)) S BSDXNOTE(.5)=BSDXNOTE(0) K BSDXNOTE(0)
|
---|
| 56 | ;
|
---|
| 57 | N BSDXMSG ; Message in case of error in filing.
|
---|
| 58 | ;
|
---|
| 59 | ; Save Before State in case we need it for rollback
|
---|
| 60 | K ^TMP($J)
|
---|
| 61 | M ^TMP($J,"BEFORE","BSDXAPPT")=^BSDXAPPT(BSDXAPTID)
|
---|
| 62 | ;
|
---|
| 63 | I $D(BSDXNOTE(.5)) D
|
---|
| 64 | . D WP^DIE(9002018.4,BSDXAPTID_",",1,"","BSDXNOTE","BSDXMSG")
|
---|
| 65 | ;
|
---|
| 66 | ; Error handling. No need for rollback since nothing else changed.
|
---|
| 67 | I $D(BSDXMSG) D ERR(BSDXI,"-3~BSDX26: Fileman failure to file data into 9002018.4") QUIT
|
---|
| 68 | ;
|
---|
| 69 | ; Now file in file 44:
|
---|
| 70 | N PTIEN S PTIEN=$$GET1^DIQ(9002018.4,BSDXAPTID,".05","I") ; Patient IEN
|
---|
| 71 | N HLIEN S HLIEN=$$GET1^DIQ(9002018.4,BSDXAPTID,".07:.04","I") ; HL Location IEN pointed to by Resource ID
|
---|
| 72 | N DATE S DATE=+^BSDXAPPT(BSDXAPTID,0) ; Date of APPT
|
---|
| 73 | N BSDXRES S BSDXRES=0 ; Result
|
---|
| 74 | ; Update Note only if we have a linked hospital location.
|
---|
| 75 | I HLIEN S BSDXRES=$$UPDATENT^BSDXAPI(PTIEN,HLIEN,DATE,BSDXNOTE(.5))
|
---|
| 76 | ; If we get an error (denoted by -1 in BSDXRES), return error to client
|
---|
| 77 | ; AND restore the original note
|
---|
| 78 | I BSDXRES<0 D ERR(BSDXI,"-4~BSDX26: BSDXAPI reports an error: "_BSDXRES),ROLLBACK(BSDXAPTID) QUIT
|
---|
| 79 | ;
|
---|
| 80 | ;Return Recordset indicating success
|
---|
| 81 | S BSDXI=BSDXI+1
|
---|
| 82 | S ^BSDXTMP($J,BSDXI)="-1"_$C(30)
|
---|
| 83 | S BSDXI=BSDXI+1
|
---|
| 84 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
| 85 | ;
|
---|
| 86 | K ^TMP($J) ; Done; remove TMP data
|
---|
| 87 | QUIT
|
---|
| 88 | ;
|
---|
[1472] | 89 | ROLLBACK(BSDXAPTID) ; Rollback note to original in ^BSDXAPPT
|
---|
[1460] | 90 | M ^BSDXAPPT(BSDXAPTID)=^TMP($J,"BEFORE","BSDXAPPT")
|
---|
| 91 | K ^TMP($J)
|
---|
| 92 | QUIT
|
---|
| 93 | ;
|
---|
[1041] | 94 | ERR(BSDXI,BSDXERR) ;Error processing
|
---|
[1460] | 95 | S BSDXI=BSDXI+1
|
---|
| 96 | S BSDXERR=$TR(BSDXERR,"^","~")
|
---|
| 97 | S ^BSDXTMP($J,BSDXI)=BSDXERR_$C(30)
|
---|
| 98 | S BSDXI=BSDXI+1
|
---|
| 99 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
| 100 | QUIT
|
---|
| 101 | ;
|
---|
[1041] | 102 | ETRAP ;EP Error trap entry
|
---|
[1460] | 103 | N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
|
---|
| 104 | D ^%ZTER
|
---|
| 105 | S $EC=""
|
---|
| 106 | I '$D(BSDXI) N BSDXI S BSDXI=0
|
---|
| 107 | D ERR(BSDXI,"-100~BSDX26 Error: "_$G(%ZTERZE))
|
---|
| 108 | QUIT
|
---|