[1041] | 1 | BSDX26 ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 12/6/10 12:38pm
|
---|
| 2 | ;;1.42;BSDX;;Dec 07, 2010
|
---|
| 3 | ; Change History:
|
---|
| 4 | ; 3101023 - UJO/SMH - Addition of restartable transaction; relocation of tx.
|
---|
| 5 | ; --> Thanks to Zach Gonzalez and Rick Marshall
|
---|
| 6 | ; 3101205 - UJO/SMH - Extensive refactoring.
|
---|
| 7 | ;
|
---|
| 8 | ; Error Reference:
|
---|
| 9 | ; -1: Appt ID is not a number
|
---|
| 10 | ; -2: Appt IEN is not in ^BSDXAPPT
|
---|
| 11 | ; -3: FM Failure to file WP field in ^BSDXAPPT
|
---|
| 12 | ;
|
---|
| 13 | EDITAPTD(BSDXY,BSDXAPTID,BSDXNOTE) ;EP
|
---|
| 14 | ;Entry point for debugging
|
---|
| 15 | ;
|
---|
| 16 | D DEBUG^%Serenji("EDITAPT^BSDX26(.BSDXY,BSDXAPTID,BSDXNOTE)")
|
---|
| 17 | Q
|
---|
| 18 | UT ; Unit Tests
|
---|
| 19 | ; Test 1: Make sure this damn thing works
|
---|
| 20 | N ZZZ
|
---|
| 21 | N %H S %H=$H
|
---|
| 22 | N NOTE S NOTE="New Note "_%H
|
---|
| 23 | D EDITAPT(.ZZZ,188,NOTE)
|
---|
| 24 | I ^BSDXAPPT(188,1,1,0)'=NOTE W "ERROR",! B
|
---|
| 25 | ; Test 2: Test Errors -1 and -2
|
---|
| 26 | N ZZZ
|
---|
| 27 | N NOTE S NOTE="Nothing important"
|
---|
| 28 | D EDITAPT(.ZZZ,"BLAHBLAH",NOTE)
|
---|
| 29 | I +^BSDXTMP($J,1)'=-1 W "ERROR IN -1",! B
|
---|
| 30 | D EDITAPT(.ZZZ,298734322,NOTE)
|
---|
| 31 | I +^BSDXTMP($J,1)'=-2 W "ERROR IN -2",! B
|
---|
| 32 | ; Test 4: M Error
|
---|
| 33 | N bsdxdie S bsdxdie=1
|
---|
| 34 | D EDITAPT(.ZZZ,188,NOTE)
|
---|
| 35 | I +^BSDXTMP($J,1)'=-100 W "ERROR IN -100",! B
|
---|
| 36 | k bsdxdie
|
---|
| 37 | ; Test 5: Trestart
|
---|
| 38 | N bsdxrestart S bsdxrestart=1
|
---|
| 39 | N %H S %H=$H
|
---|
| 40 | N NOTE S NOTE="New Note "_%H
|
---|
| 41 | D EDITAPT(.ZZZ,188,NOTE)
|
---|
| 42 | I ^BSDXAPPT(188,1,1,0)'=NOTE W "ERROR in TRESTART",! B
|
---|
| 43 | ; Test 6: for Hosp Location Update
|
---|
| 44 | N DATE S DATE=$$NOW^XLFDT()
|
---|
| 45 | S DATE=$E(DATE,1,12) ; Just get minutes b/c of HL file input transform
|
---|
| 46 | D APPADD^BSDX07(.ZZZ,DATE,DATE+.001,3,"Dr Office",30,"Old Note",1)
|
---|
| 47 | N APPID S APPID=+$P(^BSDXTMP($J,1),U)
|
---|
| 48 | D EDITAPT(.ZZZ,APPID,"New Note")
|
---|
| 49 | I ^BSDXAPPT(APTID,1,1,0)'="New Note" W "Error in HL Section",! B
|
---|
| 50 | I $P(^SC(2,"S",DATE,1,1,0),U,4)'="New Note" W "Error in HL Section",! B
|
---|
| 51 | QUIT
|
---|
| 52 | ;
|
---|
| 53 | EDITAPT(BSDXY,BSDXAPTID,BSDXNOTE) ;EP Edit appointment (only note text can be edited)
|
---|
| 54 | ; Called by RPC: BSDX EDIT APPOINTMENT
|
---|
| 55 | ;
|
---|
| 56 | ; Edits Appointment Text in BSDX APPOINTMENT file & Hosp Location (44) file
|
---|
| 57 | ;
|
---|
| 58 | ; Parameters:
|
---|
| 59 | ; - BSDXY: Global Return (RPC must be set to Global Array)
|
---|
| 60 | ; - BSDXAPTID: Appointment IEN in BSDX APPOINTMENT
|
---|
| 61 | ; - BSDXNOTE: New note
|
---|
| 62 | ;
|
---|
| 63 | ; Return:
|
---|
| 64 | ; ADO.net Recordset having 1 field: ERRORID
|
---|
| 65 | ; If Okay: -1; otherwise, positive integer with message
|
---|
| 66 | ;
|
---|
| 67 | ; Return Array; set Return and clear array
|
---|
| 68 | S BSDXY=$NA(^BSDXTMP($J))
|
---|
| 69 | K ^BSDXTMP($J)
|
---|
| 70 | ; ET
|
---|
| 71 | N $ET S $ET="G ETRAP^BSDX26"
|
---|
| 72 | ; Set up basic DUZ variables
|
---|
| 73 | D ^XBKVAR
|
---|
| 74 | ; Counter
|
---|
| 75 | N BSDXI S BSDXI=0
|
---|
| 76 | ; Header Node
|
---|
| 77 | S ^BSDXTMP($J,BSDXI)="T00100ERRORID"_$C(30)
|
---|
| 78 | ; Restartable txn for GT.M. Restored vars are Params + BSDXI.
|
---|
| 79 | TSTART (BSDXY,BSDXAPTID,BSDXNOTE,BSDXI):T="BSDX EDIT APPOINTMENT^BSDX26"
|
---|
| 80 | ;
|
---|
| 81 | ;;;test for error inside transaction. See if %ZTER works
|
---|
| 82 | I $G(bsdxdie) S X=1/0
|
---|
| 83 | ;;;test
|
---|
| 84 | ;;;test for TRESTART
|
---|
| 85 | I $G(bsdxrestart) K bsdxrestart TRESTART
|
---|
| 86 | ;;;test
|
---|
| 87 | ;
|
---|
| 88 | ; Validate Appointment ID
|
---|
| 89 | I '+BSDXAPTID D ERR(BSDXI,"-1~BSDX26: Invalid Appointment ID") QUIT
|
---|
| 90 | I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(BSDXI,"-2~BSDX26: Invalid Appointment ID") QUIT
|
---|
| 91 | ; Put the WP in decendant fields from the root to file as a WP field
|
---|
| 92 | S BSDXNOTE(.5)=BSDXNOTE,BSDXNOTE=""
|
---|
| 93 | I $D(BSDXNOTE(0)) S BSDXNOTE(.5)=BSDXNOTE(0) K BSDXNOTE(0)
|
---|
| 94 | N BSDXMSG ; Message in case of error in filing.
|
---|
| 95 | I $D(BSDXNOTE(.5)) D
|
---|
| 96 | . D WP^DIE(9002018.4,BSDXAPTID_",",1,"","BSDXNOTE","BSDXMSG")
|
---|
| 97 | I $D(BSDXMSG) D ERR(BSDXI,"-3~BSDX26: Fileman failure to file data into 9002018.4") QUIT
|
---|
| 98 | ;
|
---|
| 99 | ; Now file in file 44:
|
---|
| 100 | N PTIEN S PTIEN=$$GET1^DIQ(9002018.4,BSDXAPTID,".05","I") ; Patient IEN
|
---|
| 101 | N HLIEN S HLIEN=$$GET1^DIQ(9002018.4,BSDXAPTID,".07:.04","I") ; HL Location IEN pointed to by Resource ID
|
---|
| 102 | N DATE S DATE=+^BSDXAPPT(BSDXAPTID,0) ; Date of APPT
|
---|
| 103 | N BSDXRES S BSDXRES=0 ; Result
|
---|
| 104 | ; Update Note only if we have a linked hospital location.
|
---|
| 105 | I HLIEN S BSDXRES=$$UPDATENOTE^BSDXAPI(PTIEN,HLIEN,DATE,BSDXNOTE(.5))
|
---|
| 106 | ; If we get an error (denoted by -1 in BSDXRES), return error to client
|
---|
| 107 | I BSDXRES<0 D ERR(BSDXI,"-4~BSDX26: BSDXAPI reports an error: "_BSDXRES) QUIT
|
---|
| 108 | ;Return Recordset
|
---|
| 109 | TCOMMIT
|
---|
| 110 | S BSDXI=BSDXI+1
|
---|
| 111 | S ^BSDXTMP($J,BSDXI)="-1"_$C(30)
|
---|
| 112 | S BSDXI=BSDXI+1
|
---|
| 113 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
| 114 | QUIT
|
---|
| 115 | ;
|
---|
| 116 | ERR(BSDXI,BSDXERR) ;Error processing
|
---|
| 117 | S BSDXI=BSDXI+1
|
---|
| 118 | S BSDXERR=$TR(BSDXERR,"^","~")
|
---|
| 119 | I $TL>0 TROLLBACK
|
---|
| 120 | S ^BSDXTMP($J,BSDXI)=BSDXERR_$C(30)
|
---|
| 121 | S BSDXI=BSDXI+1
|
---|
| 122 | S ^BSDXTMP($J,BSDXI)=$C(31)
|
---|
| 123 | QUIT
|
---|
| 124 | ;
|
---|
| 125 | ETRAP ;EP Error trap entry
|
---|
| 126 | N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
|
---|
| 127 | I $TL>0 TROLLBACK
|
---|
| 128 | D ^%ZTER
|
---|
| 129 | S $EC=""
|
---|
| 130 | I '$D(BSDXI) N BSDXI S BSDXI=0
|
---|
| 131 | D ERR(BSDXI,"-100~BSDX26 Error: "_$G(%ZTERZE))
|
---|
| 132 | Q
|
---|