Changeset 1462 for Scheduling/trunk/m


Ignore:
Timestamp:
Jun 27, 2012, 7:45:33 PM (13 years ago)
Author:
Sam Habiel
Message:

Done refactoring BSDX31 plus all Unit Tests

Location:
Scheduling/trunk/m
Files:
4 edited

Legend:

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

    r1461 r1462  
    1 BSDX31   ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 6/26/12 4:35pm
     1BSDX31   ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 6/27/12 4:57pm
    22        ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
    33        ; Licensed under LGPL
     
    1010        ;                       - Made BSDXNOS extrinsic.
    1111        ;                       - Moved Unit Tests to BSDXUT1
     12        ;                       - BSDXNOS deletes no-show rather than file 0 for
     13        ;                         undoing a no show
    1214        ;
    1315        ; Error Reference:
     
    8587        N BSDXRESNOD S BSDXRESNOD=^BSDXRES(BSDXRES,0)
    8688        N BSDXLOC S BSDXLOC=$P(BSDXRESNOD,U,4) ;HOSPITAL LOCATION
    87         I '$D(^SC(BSDXLOC,0)) S BSDXLOC="" ; Unlink it if it doesn't exist
    88         ; I can go and then delete it from BSDXLOC like Mailman code which tries
    89         ; to be too helpful... but I will postpone that until this is need it.
    90         ;
    91         ; Edit BSDX APPOINTMENT entry
    92         N BSDXMSG S BSDXMSG=$$BSDXNOS(BSDXAPTID,BSDXNS)  ;Edit BSDX APPOINTMENT entry NOSHOW field
     89        I BSDXLOC,'$D(^SC(BSDXLOC,0)) S BSDXLOC="" ; Unlink it if it doesn't exist
     90        ; I can go and then delete it from ^BSDXRES like Mailman code which tries
     91        ; to be too helpful... but I will postpone that until this is a need.
     92        ;
     93        ; Check if it's okay to no-show patient.
     94        N BSDXERR S BSDXERR=0 ; Error variable
     95        I BSDXLOC S BSDXERR=$$NOSHOWCK^BSDXAPI1(BSDXPATID,BSDXLOC,BSDXSTART,BSDXNS)
     96        I BSDXERR D ERR(-5,"BSDX31: "_$P(BSDXERR,U,2)) QUIT
     97        ;
     98        ; Simulated Error
     99        I $G(BSDXSIMERR1) D ERR(-4,"BSDX31: Simulated Error") QUIT
     100        ; Edit BSDX APPOINTMENT entry No-show field
     101        ; Failure Analysis: If we fail here, no rollback needed, as this is the 1st
     102        ; call
     103        N BSDXMSG S BSDXMSG=$$BSDXNOS(BSDXAPTID,BSDXNS)
    93104        I BSDXMSG D ERR(-4,"BSDX31: "_$P(BSDXMSG,U,2)) QUIT
    94105        ;
    95106        ; Edit File 2 "S" node entry
    96         N BSDXERR ; Error variable
     107        ; Failure Analysis: If we fail here, we need to rollback the BSDX
     108        ; Apptointment Entry
     109        N BSDXERR S BSDXERR=0 ; Error variable
    97110        ; If HL exist, (resource is linked to PIMS), file no show in File 2
    98111        I BSDXLOC S BSDXERR=$$NOSHOW^BSDXAPI1(BSDXPATID,BSDXLOC,BSDXSTART,BSDXNS)
    99         I BSDXERR D ERR(-5,"BSDX31: "_$P(BSDXERR,U,2)) QUIT
    100         ;
     112        I BSDXERR D  QUIT
     113        . D ERR(-5,"BSDX31: "_$P(BSDXERR,U,2))
     114        . N % S %=$$BSDXNOS(BSDXAPTID,'BSDXNS) ; no error checking for filer
     115        ;
     116        ; Return data in ADO.net table
    101117        S BSDXI=BSDXI+1
    102118        S ^BSDXTMP($J,BSDXI)="1^"_$C(30) ; 1 means everything okay
     
    106122        ;
    107123BSDXNOS(BSDXAPTID,BSDXNS) ; $$ Private; File/unfile noshow in ^BSDXAPPT
     124        ; in v1.7 I delete the no-show value rather than file zero
    108125        N BSDXFDA,BSDXIENS,BSDXMSG
     126        N BSDXVALUE ; What to file: 1 or delete it.
     127        I BSDXNS S BSDXVALUE=1
     128        E  S BSDXVALUE="@"
    109129        S BSDXIENS=BSDXAPTID_","
    110         S BSDXFDA(9002018.4,BSDXIENS,.1)=BSDXNS ;NOSHOW
     130        S BSDXFDA(9002018.4,BSDXIENS,.1)=BSDXVALUE ;NOSHOW 1 or 0
    111131        D FILE^DIE("","BSDXFDA","BSDXMSG")
    112132        QUIT:$D(BSDXMSG) -1_U_BSDXMSG("DIERR",1,"TEXT",1)
     
    157177        ;
    158178ERR(BSDXERID,ERRTXT)       ;Error processing
     179        ; If last line is $C(31), we are done. No more errors to send to client.
     180        I ^BSDXTMP($J,$O(^BSDXTMP($J," "),-1))=$C(31) QUIT
    159181        S BSDXI=BSDXI+1
    160182        S ERRTXT=$TR(ERRTXT,"^","~")
     
    166188ETRAP     ;EP Error trap entry
    167189        N $ET S $ET="D ^%ZTER HALT"  ; Emergency Error Trap
    168         I $G(BSDXAPTID),$D(BSDXNS) N % S %=$$BSDXNOS(BSDXAPTID,'BSDXNS) ; Reverse No-Show status (whatever it was)
    169190        D ^%ZTER
    170191        S $EC="" ; Clear Error
     192        I $G(BSDXAPTID),$D(BSDXNS) N % S %=$$BSDXNOS(BSDXAPTID,'BSDXNS) ; Reverse No-Show status (whatever it was)
    171193        ; Send to client
    172194        I '$D(BSDXI) N BSDXI S BSDXI=0
    173195        D ERR(-100,"BSDX31 Error: "_$G(%ZTERZE))
    174         QUIT
     196        Q:$Q 100_U_"Mumps Error" Q
    175197        ;
    176198IMHERE(BSDXRES) ;EP
  • Scheduling/trunk/m/BSDXAPI1.m

    r1461 r1462  
    1 BSDXAPI1 ; VEN/SMH - SCHEDULING APIs - Continued!!! ; 6/26/12 4:32pm
     1BSDXAPI1 ; VEN/SMH - SCHEDULING APIs - Continued!!! ; 6/27/12 4:45pm
    22        ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
    33        ; Licensed under LGPL 
     
    77        ; CLINIC = SC IEN
    88        ; DATE = FM Date/Time of Appointment
    9         ; NSFLAG = truthy value to add no-show, or falsy to remove
    10         ; -1^error for failure, 0 for success
     9        ; NSFLAG = truthy value to add no-show, or falsy to remove (use 1 or 0 pls!)
     10        ; 1^error for failure, 0 for success
    1111        ; Code follows EN1^SDN
     12        ;
     13        ; Check for failure conditions first before doing this. No globals set here
    1214        N NOSHOWCK S NOSHOWCK=$$NOSHOWCK(PAT,CLINIC,DATE,NSFLAG)
    1315        I NOSHOWCK Q NOSHOWCK
    1416        ;
     17        ; Set up Protocol Driver
    1518        N SDNSHDL,SDDA S SDNSHDL=$$HANDLE^SDAMEVT(1) S SDDA=$$SCIEN^BSDXAPI(PAT,CLINIC,DATE)
    1619        N SDATA
    17         D BEFORE^SDAMEVT(.SDATA,PAT,DATE,CLINIC,SDDA,SDNSHDL)
     20        D BEFORE^SDAMEVT(.SDATA,PAT,DATE,CLINIC,SDDA,SDNSHDL) ; Only ^TMP set here.
     21        ;
     22        ; Simulated Errors
     23        Q:$D(BSDXSIMERR2) 1_U_"Simulated Error"
     24        ;
     25        ; Edit the ^DPT( "S" node entry - Noshow or undo noshow
     26        ; Failure analysis: if we fail here, we presume no change happened in
     27        ; ^DPT(DA,"S", and so we just have to roll back ^BSDXAPPT
    1828        N BSDXIENS S BSDXIENS=DATE_","_PAT_","
    1929        N BSDXFDA
     
    2939        D FILE^DIE("","BSDXFDA","BSDXMSG")
    3040        Q:$D(BSDXMSG) 1_U_"Fileman edit to DPT error: Patient="_PAT_" Appt="_DATE_" Error="_BSDXMSG("DIERR",1,"TEXT",1)
     41        ;
     42        ; This M error trigger tests if ^BSDXAPPT rolls back.
     43        ; I won't try to roll back ^DPT(,"S"
     44        ; The M error is caused here, so if I try to rollback, I can cause another
     45        ; error. Infinite Errors then.
     46        I $D(BSDXSIMERR3) N X S X=1/0
     47        ;
     48        ; Run the event driver
    3149        D NOSHOW^SDAMEVT(.SDATA,PAT,DATE,CLINIC,SDDA,0,SDNSHDL)
    3250        Q 0
     51        ;
    3352NOSHOWCK(PAT,CLINIC,DATE,NSFLAG) ; $$ PEP; No-show Check
    34         ; pars are the same as above
     53        ; TODO: Not all appointments can be no showed.
     54        ; Check the code in SDAMN
     55        ; S SDSTB=$$STATUS^SDAM1(DFN,SDT,SDCL,$G(^DPT(DFN,"S",SDT,0))) ; before status 
     56        ; Q:'$$CHK ; Checks $D(^SD(409.63,"ANS",1,+SDSTB))
    3557        QUIT 0
  • Scheduling/trunk/m/BSDXUT.m

    r1461 r1462  
    1 BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/26/12 11:06am
     1BSDXUT ; VEN/SMH - Unit Tests for Scheduling GUI ; 6/27/12 4:18pm
    22        ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
    33        ; Licensed under LGPL
     
    207207        D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
    208208        D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
    209         I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10 in Unlinked Section",!
     209        I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10 in Unlinked Section (existing bug)",!
    210210        ;
    211211        ; Test that ROLLBACK^BSDX07 occurs properly in various places
  • Scheduling/trunk/m/BSDXUT1.m

    r1461 r1462  
    1 BSDXUT1 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/26/12 4:36pm
     1BSDXUT1 ; VEN/SMH - Unit Tests for Scheduling GUI - cont. ; 6/27/12 4:59pm
    22        ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
    33        ;
     
    227227        ; Test 2: Undo NOSHOW
    228228        D NOSHOW^BSDX31(.ZZZ,APPID,0)
    229         I $P(^BSDXAPPT(APPID,0),U,10)'="0" W "ERROR T2",!
     229        I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T2",!
    230230        I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="" W "ERROR T2",!
    231231        ; Test 3: -1
     
    243243        I $P(^BSDXTMP($J,1),U)'=-100 W "ERROR T6",!
    244244        K BSDXDIE
    245         ; Test 7: Restartable transaction
    246         N BSDXRESTART S BSDXRESTART=1
    247         D NOSHOW^BSDX31(.ZZZ,APPID,1)
    248         I $P(^BSDXAPPT(APPID,0),U,10)'=1 W "ERROR T7",!
     245        ;
     246        ; Test 9
     247        ; Error Simulations
     248        ; Get start and end times
     249        N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
     250        N APPTTIME S APPTTIME=$P(TIMES,U)
     251        N ENDTIME S ENDTIME=$P(TIMES,U,2)
     252        ;
     253        ; This tests if we fail without filing anything
     254        N ZZZ,DFN
     255        S DFN=3
     256        D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
     257        N APPID S APPID=+$P(^BSDXTMP($J,1),U)
     258        N BSDXSIMERR1 S BSDXSIMERR1=1
     259        D NOSHOW^BSDX31(.ZZZ,APPID,1)
     260        I $P(^BSDXTMP($J,1),U)'=-4 W "ERROR T9.1",!
     261        I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T9.2",!
     262        I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="" W "ERROR T9.3",!
     263        K BSDXSIMERR1
     264        ;
     265        ; This tests if we fail inside BSDXAPI and have to rollback ^BSDXAPPT
     266        N BSDXSIMERR2 S BSDXSIMERR2=1
     267        D NOSHOW^BSDX31(.ZZZ,APPID,1)
     268        I $P(^BSDXTMP($J,1),U)'=-5 W "ERROR T9.4",!
     269        I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T9.5",!
     270        I $P(^DPT(DFN,"S",APPTTIME,0),U,2)'="" W "ERROR T9.6",!
     271        K BSDXSIMERR2
     272        ;
     273        ; This test a mumps error in BSDXAPI
     274        N BSDXSIMERR3 S BSDXSIMERR3=1
     275        D NOSHOW^BSDX31(.ZZZ,APPID,1)
     276        I +$P(^BSDXTMP($J,1),U)'=-100 W "ERROR T9.7",!
     277        I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T9.8",!
     278        K BSDXSIMERR3
     279        ;
     280        ; Test 7: Restartable transaction ; Retired
     281        ;
     282        ; Test 8: UTs for an unlinked resource (not linked to PIMS)
     283        N RESNAM S RESNAM="UTCLINICUL" ; Unlinked Clinic
     284        N RESIEN
     285        D
     286        . N $ET S $ET="D ^%ZTER B"
     287        . S RESIEN=$$UTCRRES^BSDXUT(RESNAM)
     288        . I RESIEN<0 S $EC=",U1," ; not supposed to happen - hard crash if so
     289        ;
     290        ; Get start and end times
     291        N TIMES S TIMES=$$TIMES^BSDXUT ; appt time^end time
     292        N APPTTIME S APPTTIME=$P(TIMES,U)
     293        N ENDTIME S ENDTIME=$P(TIMES,U,2)
     294        ;
     295        ; Make appt
     296        N ZZZ,DFN
     297        S DFN=3
     298        D APPADD^BSDX07(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
     299        N APPID S APPID=+$P(^BSDXTMP($J,1),U)
     300        ; Test 1: Sanity Check
     301        D NOSHOW^BSDX31(.ZZZ,APPID,1)
     302        I $P(^BSDXAPPT(APPID,0),U,10)'=1 W "ERROR T8.1",!
     303        ; Test 2: Undo NOSHOW
     304        D NOSHOW^BSDX31(.ZZZ,APPID,0)
     305        I $P(^BSDXAPPT(APPID,0),U,10)'="" W "ERROR T8.2",!
     306        ; Test 3: Put it back on...
     307        D NOSHOW^BSDX31(.ZZZ,APPID,1)
     308        I $P(^BSDXAPPT(APPID,0),U,10)'=1 W "ERROR T8.3",!
     309        ;
     310        ;
    249311        QUIT
Note: See TracChangeset for help on using the changeset viewer.