Ignore:
Timestamp:
Jun 26, 2012, 8:01:30 PM (12 years ago)
Author:
Sam Habiel
Message:

Refactoring cont.
Many changes in BSDX08. Extensive changes in BSDX31. Creation of BSDXAPI1 as continuation of BSDXAPI.
BSDXUT1 now has UTs for BSDX31. Transactions now gone from BSDX08 and BSDX31.
BSDX08 needs more tests at failure points. BSDX31 still needs analysis for transaction failure and
code for rollback points, plus tests for that.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Scheduling/trunk/m/BSDX08.m

    r1460 r1461  
    1 BSDX08  ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/25/12 6:17pm
     1BSDX08  ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS ; 6/26/12 10:49am
    22        ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
    33        ;
     
    66        ; Change History
    77        ; 3101022 UJO/SMH v1.42
    8         ;  - Transaction now restartable. Thanks to
    9         ;   --> Zach Gonzalez and Rick Marshall for fix.
    10         ;  - Extra TROLLBACK in Lock Statement when lock fails.
    11         ;   --> Removed--Rollback is already in ERR tag.
    12         ;  - Added new statements to old SD code in AVUPDT to obviate
    13         ;   --> need to restore variables in transaction
    14         ;  - Refactored this chunk of code. Don't really know whether it
    15         ;   --> worked in the first place. Waiting for bug report to know.
     8        ;  - Transaction work. As of v 1.7, all work here has been superceded
     9        ;  - Refactoring of AVUPDT - never tested though.
    1610        ;  - Refactored all of APPDEL.
    1711        ;
     
    1913        ;  - Added ability to remove checked in appointments. Added a couple
    2014        ;    of units tests for that under UT2.
    21         ;  - Minor reformatting because of how KIDS adds tabs.
     15        ;
     16        ; 3120625 VEN/SMH v1.7
     17        ;  - Transactions removed. Code refactored to work w/o txns.
    2218        ;
    2319        ; Error Reference:
     
    3127        ;  -8^BSDX08: Unable to find associated PIMS appointment for this patient
    3228        ;  -9^BSDX08: BSDXAPI returned an error: (error)
     29        ;  -10^BSDX08: $$BSDXCAN failed (Fileman filing error)
    3330        ;  -100~BSDX08 Error: (Mumps Error)
    3431        ;
     
    7673        ;
    7774        ;;;test for error inside transaction. See if %ZTER works
    78         I $G(BSDXDIE) S X=1/0
     75        I $G(BSDXDIE1) N X S X=1/0
    7976        ;
    8077        ; Check appointment ID and whether it exists
     
    9087        ; Check the resource ID and whether it exists
    9188        N BSDXSC1 S BSDXSC1=$P(BSDXNOD,U,7) ;RESOURCEID
    92         ; If the resouce id doesn't exist...
     89        ; If the resource id doesn't exist...
    9390        I BSDXSC1="" D ERR(BSDXI,"-4~BSDX08: Cancelled appointment does not have a Resouce ID") QUIT
    9491        I '$D(^BSDXRES(BSDXSC1,0)) D ERR(BSDXI,"-5~BSDX08: Resouce ID does not exist in BSDX RESOURCE") QUIT
    9592        ;
    96         ; BSDXAPPT First; todo: check for error
    97         D BSDXCAN(BSDXAPTID)  ; Add a cancellation date in BSDX APPOINTMENT
    98         ;
    99         ; Process PIMS issues second:
    100         ; cancel appt in "S" nodes in file 2 and 44, then update Legacy PIMS Availability
     93        ;
     94        ; Check if PIMS will let us cancel the appointment using $$CANCELCK^BSDXAPI
    10195        ; Get zero node of resouce
    10296        N BSDXNOD S BSDXNOD=^BSDXRES(BSDXSC1,0)
    10397        ; Get Hosp location
    10498        N BSDXLOC S BSDXLOC=$P(BSDXNOD,U,4)
    105         ; Error indicator for Hosp Location filing for getting out of routine
     99        ; Error indicator
    106100        N BSDXERR S BSDXERR=0
    107         ; For BSDXC
    108         N BSDXC
    109         ; Only file in 2/44 if there is an associated hospital location
    110         I BSDXLOC D  QUIT:BSDXERR
     101        ;
     102        N BSDXC ; Array to pass to BSDXAPI
     103        ;
     104        I BSDXLOC D
    111105        . S BSDXC("PAT")=BSDXPATID
    112106        . S BSDXC("CLN")=BSDXLOC
     
    120114        . ;
    121115        . S BSDXERR=$$CANCELCK^BSDXAPI(.BSDXC) ; 0 or 1^error message
    122         . I BSDXERR D ERR(BSDXI,"-9^BSDX08: BSDXAPI returned an error: "_$P(BSDXERR,U,2)) QUIT
     116        ; If error, quit. No need to rollback as no changes took place.
     117        I BSDXERR D ERR(BSDXI,"-9~BSDX08: BSDXAPI reports that "_$P(BSDXERR,U,2)) QUIT
     118        ;
     119        I $G(BSDXDIE2) N X S X=1/0
     120        ;
     121        ; Now cancel the appointment for real
     122        ; BSDXAPPT First; no need for rollback if error occured.
     123        N BSDXERR S BSDXERR=$$BSDXCAN(BSDXAPTID)  ; Add a cancellation date in BSDX APPOINTMENT
     124        I BSDXERR D ERR(BSDXI,"$$BSDXCAN failed (Fileman filing error): "_$P(BSDXERR,U,2)) QUIT
     125        ;
     126        ; Then PIMS:
     127        ; cancel appt in "S" nodes in file 2 and 44, then update Legacy PIMS Availability
     128        ; If error happens, must rollback ^BSDXAPPT
     129        I BSDXLOC D  QUIT:BSDXERR
     130        . N BSDXLEN S BSDXLEN=$$APPLEN^BSDXAPI(BSDXPATID,BSDXLOC,BSDXSTART) ; appt length
     131        . S BSDXERR=$$CANCEL^BSDXAPI(.BSDXC) ; Cancel through BSDXAPI
     132        . ; Rollback BSDXAPPT if error occurs
     133        . ; TODO: If an M error occurs in BSDXAPI, ETRAP gets called, ^BSDXTMP is
     134        . ;       populated, then the output of $$CANCEL is the output of ETRAP.
     135        . ;       Then, we see that BSDXERR is true, and we do another write,
     136        . ;       which deletes the information we had in ^BSDXTMP. What to do???
     137        . I BSDXERR D ERR(BSDXI,"-9^BSDX08: BSDXAPI returned an error: "_$P(BSDXERR,U,2)),ROLLBACK(BSDXAPTID)  QUIT
    123138        . ;
    124         . N BSDXLEN S BSDXLEN=$$APPLEN^BSDXAPI(BSDXPATID,BSDXLOC,BSDXSTART)
    125         . ;
    126         . ; Cancel through BSDXAPI
    127         . S BSDXERR=$$CANCEL^BSDXAPI(.BSDXC)
    128         . I BSDXERR=1 D ERR(BSDXI,"-9^BSDX08: BSDXAPI returned an error: "_$P(BSDXZ,U,2)) QUIT
    129         . ; Update Legacy PIMS clinic Availability
     139        . ; Update Legacy PIMS clinic Availability ; no failure expected here.
    130140        . D AVUPDT(BSDXLOC,BSDXSTART,BSDXLEN)
    131141        ;
     
    138148        Q
    139149        ;
    140 ROLLBACK(BSDXAPTID)
    141150AVUPDT(BSDXSCD,BSDXSTART,BSDXLEN)       ;Update Legacy PIMS Clinic availability
    142151        ;See SDCNP0
     
    185194        Q
    186195        ;
    187 BSDXCAN(BSDXAPTID)      ;
    188         ;Cancel BSDX APPOINTMENT entry
    189         N %DT,X,BSDXDATE,Y,BSDXIENS,BSDXFDA,BSDXMSG
    190         S %DT="XT",X="NOW" D ^%DT ; X ^DD("DD")
    191         S BSDXDATE=Y
     196BSDXCAN(BSDXAPTID)      ; $$; Private; Cancel BSDX APPOINTMENT entry
     197        ; Input: Appt IEN in ^BSDXAPPT
     198        ; Output: 0 for success and 1^Msg for failure
     199        N BSDXDATE,BSDXIENS,BSDXFDA,BSDXMSG
     200        S BSDXDATE=$$NOW^XLFDT()
    192201        S BSDXIENS=BSDXAPTID_","
    193202        S BSDXFDA(9002018.4,BSDXIENS,.12)=BSDXDATE
    194         K BSDXMSG
    195203        D FILE^DIE("","BSDXFDA","BSDXMSG")
    196         Q
     204        I $D(BSDXMSG) Q 1_U_BSDXMSG("DIERR",1,"TEXT",1)
     205        QUIT 0
     206        ;
     207ROLLBACK(BSDXAPTID)  ; Proc; Private; Rollback cancellation
     208        ; Input same as $$BSDXCAN
     209        N BSDXIENS S BSDXIENS=BSDXAPTID_","
     210        N BSDXFDA S BSDXFDA(9002018.4,BSDXIENS,.12)="@"
     211        N BSDXMSG
     212        D FILE^DIE("","BSDXFDA","BSDXMSG")
     213        ;I $D(BSDXMSG)  ; Not sure what to do. We are already handling an error.
     214        QUIT
    197215        ;
    198216CANEVT(BSDXPAT,BSDXSTART,BSDXSC)        ;EP Called by BSDX CANCEL APPOINTMENT event
     
    248266        D ^%ZTER
    249267        S $EC=""  ; Clear Error
     268        ; Roll back BSDXAPPT;
     269        ; TODO: What if a Mumps error happens in fileman in BSDXAPI? The Scheduling files can potentially be out of sync
     270        D:$G(BSDXAPTID) ROLLBACK(BSDXAPTID)
    250271        ; Log error message and send to client
    251272        I '$D(BSDXI) N BSDXI S BSDXI=0
    252273        D ERR(BSDXI,"-100~BSDX08 Error: "_$G(%ZTERZE))
    253         QUIT
     274        Q:$Q 1_U_"-100~Mumps Error" Q
    254275        ;
    255276        ;;;NB: This is code that is unused in both original and port.
Note: See TracChangeset for help on using the changeset viewer.