Ignore:
Timestamp:
Jul 9, 2012, 7:43:46 PM (12 years ago)
Author:
Sam Habiel
Message:

Added/fixed the following:

  • Unit Tests for running everything through PIMS
  • Checks for end of message for error handling ((31))
  • All routines previously using transactions use locks now
File:
1 edited

Legend:

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

    r1472 r1479  
    1 BSDX07  ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS  ; 7/5/12 12:57pm
     1BSDX07  ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS  ; 7/9/12 4:02pm
    22        ;;1.7T1;BSDX;;Jul 06, 2012;Build 18
    33        ; Licensed under LGPL
     
    3232        Q
    3333        ;
    34 APPADD(BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID,BSDXRADEXAM) ;EP
     34APPADD(BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID,BSDXRADEXAM) ;Private EP
    3535        ;
    3636        ;Called by RPC: BSDX ADD NEW APPOINTMENT
     
    5858        ; AppointmentID and ErrorNumber
    5959        ;
    60         ; NB: Specifying BSDXLEN and BSDXEND is redundant. For future programmers
     60        ; TODO: Specifying BSDXLEN and BSDXEND is redundant. For future programmers
    6161        ; to sort out. Needs changes on client.
    6262        ;
     
    6666        ; Deal with optional arguments
    6767        S BSDXRADEXAM=$G(BSDXRADEXAM)
    68            ;
     68        ;
    6969        ; Return Array; set Return and clear array
    7070        S BSDXY=$NA(^BSDXTMP($J))
    7171        K ^BSDXTMP($J)
    72            ;
     72        ;
    7373        ; $ET
    7474        N $ET S $ET="G ETRAP^BSDX07"
     
    8080        ; It's not expected that the error will ever happen as no filing
    8181        ; is supposed to take 5 seconds.
    82         L +^BSDXAPPT(BSDXPATID):5 I '$T D ERR(BSDXI,"-1~Patient record is locked. Please contact technical support.") Q
     82        L +^BSDXPAT(BSDXPATID):5 I '$T D ERR(BSDXI,"-1~Patient record is locked. Please contact technical support.") Q
    8383        ;
    8484        ; Header Node
     
    9292        N BSDXERR S BSDXERR=0
    9393        ;
    94         ;;;test for error inside transaction. See if %ZTER works
    95         I $G(BSDXDIE) S X=1/0
     94        ;;;test for error. See if %ZTER works
     95        I $G(BSDXDIE) N X S X=1/0
    9696        ;;;test
    9797        ;
     
    132132        ; Now, check if PIMS has any issues with us making the appt using MAKECK
    133133        N BSDXSCD S BSDXSCD=$P(BSDXRNOD,U,4)  ; Hosp Location IEN
    134         N BSDXERR ; Variable to hold value of $$MAKE and $$MAKECK
     134        N BSDXERR S BSDXERR=0 ; Variable to hold value of $$MAKE and $$MAKECK
    135135        N BSDXC ; Array to send to MAKE and MAKECK APIs
    136136        ; Only if we have a valid Hosp Location
    137         I +BSDXSCD,$D(^SC(BSDXSCD,0)) D  I +BSDXERR D ERR(BSDXI,"-10~BSDX07 Error: MAKECK^BSDXAPI returned error code: "_BSDXERR) Q  ; no need for roll back
     137        I +BSDXSCD,$D(^SC(BSDXSCD,0)) D
    138138        . S BSDXC("PAT")=BSDXPATID
    139139        . S BSDXC("CLN")=BSDXSCD
     
    147147        . S BSDXC("USR")=DUZ
    148148        . S BSDXERR=$$MAKECK^BSDXAPI(.BSDXC)
     149        I BSDXERR D ERR(BSDXI,"-10~BSDX07 Error: MAKECK^BSDXAPI returned error code: "_BSDXERR) Q  ; no need for roll back
    149150        ;
    150151        ; Done with all checks, let's make appointment in BSDX APPOINTMENT
     
    160161        ; Only if we have a valid Hosp Loc can we make an appointment in 2/44
    161162        ; Use BSDXC array from before.
    162         ; NB: $$MAKE itself calls $$MAKECK to check again for being okay.
    163         I +BSDXSCD,$D(^SC(BSDXSCD,0)) D  I +BSDXERR D ERR(BSDXI,"-10~BSDX07 Error: MAKE^BSDXAPI returned error code: "_BSDXERR),ROLLBACK(BSDXAPPTID,.BSDXC) Q
    164         . S BSDXERR=$$MAKE^BSDXAPI(.BSDXC)
     163        ; FYI: $$MAKE itself calls $$MAKECK to check again for being okay.
     164        ; If an error happens here, we roll back both ^BSDXAPPT and 2/44 by deleting
     165        N BSDXERR S BSDXERR=0 ; Variable to hold value of $$MAKE and $$MAKECK
     166        I +BSDXSCD,$D(^SC(BSDXSCD,0)) S BSDXERR=$$MAKE^BSDXAPI(.BSDXC)
     167        I BSDXERR D ERR(BSDXI,"-10~BSDX07 Error: MAKE^BSDXAPI returned error code: "_BSDXERR),ROLLBACK(BSDXAPPTID,.BSDXC) Q
     168        ;
     169        ; Unlock
     170        L -^BSDXPAT(BSDXPATID)
    165171        ;
    166172        ;Return Recordset
    167         L -^BSDXAPPT(BSDXPATID)
    168173        S BSDXI=BSDXI+1
    169174        S ^BSDXTMP($J,BSDXI)=BSDXAPPTID_"^"_$C(30)
     
    179184        ;Returns ien in BSDXAPPT or 0 if failed
    180185        ;Create entry in BSDX APPOINTMENT
    181         N BSDXAPPTID
     186        N BSDXAPPTID,BSDXFDA
    182187        S BSDXFDA(9002018.4,"+1,",.01)=BSDXSTART
    183188        S BSDXFDA(9002018.4,"+1,",.02)=BSDXEND
     
    208213        ;BSDXSCDA=IEN for ^SC(BSDXSC,"S",BSDXSTART,1,BSDXSCDA). Use to get Length & Note
    209214        ;
    210         N BSDXNOD,BSDXLEN,BSDXAPPTID,BSDXNODP,BSDXWKIN,BSDXRES
     215        N BSDXNOD,BSDXLEN,BSDXAPPTID,BSDXNODP,BSDXWKIN,BSDXRES,BSDXNOTE,BSDXEND
    211216        Q:+$G(BSDXNOEV)
    212217        I $D(^BSDXRES("ALOC",BSDXSC)) S BSDXRES=$O(^BSDXRES("ALOC",BSDXSC,0))
     
    243248        ; Appointment ID to remove from ^BSDXAPPT
    244249        ; BSDXC array (see array format in $$MAKE^BSDXAPI)
    245         ; NB: I am not sure whether I want to do $G to protect against undefs?
    246         ; I send the variables to this EP from the Symbol Table in ETRAP
     250        N %
    247251        D BSDXDEL^BSDX07(BSDXAPPTID)
    248252        S:$D(BSDXC) %=$$UNMAKE^BSDXAPI(.BSDXC) ; rtn value always 0
     
    257261        ;
    258262ERR(BSDXI,BSDXERR)       ;Error processing - different from error trap.
     263        ; Unlock first
     264        L -^BSDXPAT(BSDXPATID)
     265        ; If last line is $C(31), we are done. No more errors to send to client.
     266        I ^BSDXTMP($J,$O(^BSDXTMP($J," "),-1))=$C(31) QUIT
    259267        S BSDXI=BSDXI+1
    260268        S BSDXERR=$TR(BSDXERR,"^","~")
     
    262270        S BSDXI=BSDXI+1
    263271        S ^BSDXTMP($J,BSDXI)=$C(31)
    264         L -^BSDXAPPT(BSDXPATID)
    265272        Q
    266273        ;
     
    268275        N $ET S $ET="D ^%ZTER HALT"  ; Emergency Error Trap
    269276        D ^%ZTER
    270         S $EC=""  ; Clear Error
     277        ;
    271278        I +$G(BSDXAPPTID) D ROLLBACK(BSDXAPPTID,.BSDXC) ; Rollback if BSDXAPPTID exists
     279        ;
    272280        ; Log error message and send to client
    273281        I '$D(BSDXI) N BSDXI S BSDXI=0
Note: See TracChangeset for help on using the changeset viewer.