Ignore:
Timestamp:
Jun 21, 2012, 7:24:56 PM (12 years ago)
Author:
Sam Habiel
Message:

Moved Unit Tests and UT Set-up to BSDXUT, started refactoring BSDX08.

File:
1 edited

Legend:

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

    r1452 r1454  
    1 BSDX07  ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS  ; 6/20/12 3:28pm
     1BSDX07  ; VW/UJO/SMH - WINDOWS SCHEDULING RPCS  ; 6/21/12 3:54pm
    22        ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
    33        ; Licensed under LGPL
     
    77        ; v1.3 July 13 2010 - Add support i18n - Dates input as FM dates, not US.
    88        ; v1.42 Oct 22 2010 - Transaction now restartable by providing arguments
    9         ;   thanks to Rick Marshall and Zach Gonzalez at Oroville.
    109        ; v1.42 Oct 30 2010 - Extensive refactoring.
    1110        ; v1.5  Mar 15 2011 - End time does not have to have time anymore.
     
    3231        Q
    3332        ;
    34 UT      ; Unit Tests - Assumes you have Patients with DFNs 1,2 and 3
    35         ; Set-up - Create Clinics
    36         N RESNAM S RESNAM="UTCLINIC"
    37         N HLRESIENS ; holds output of UTCR^BSDX35 - HL IEN^Resource IEN
    38         D
    39         . N $ET S $ET="D ^%ZTER B"
    40         . S HLRESIENS=$$UTCR^BSDX35(RESNAM)
    41         . I HLRESIENS<0 S $EC=",U1," ; not supposed to happen - hard crash if so
    42         ;
    43         N HLIEN,RESIEN
    44         S HLIEN=$P(HLRESIENS,U)
    45         S RESIEN=$P(HLRESIENS,U,2)
    46         ;
    47         ; Get start and end times
    48         N TIMES S TIMES=$$TIMES^BSDX35 ; appt time^end time
    49         N APPTTIME S APPTTIME=$P(TIMES,U)
    50         N ENDTIME S ENDTIME=$P(TIMES,U,2)
    51         ;
    52         N ZZZ,DFN
    53         ; Test for normality:
    54         S DFN=3
    55         D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
    56         ; Does Appt exist?
    57         N APPID S APPID=+$P(^BSDXTMP($J,1),U)
    58         I 'APPID W "Error Making Appt-1" QUIT
    59         I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-2"
    60         I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-3"
    61         I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-4"
    62         ;
    63         ; Do it again for a different patient
    64         S DFN=2
    65         D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
    66         N APPID S APPID=+$P(^BSDXTMP($J,1),U)
    67         I 'APPID W "Error Making Appt-5" QUIT
    68         I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-6"
    69         I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-7"
    70         I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-8"
    71         ;
    72         ; Again for a different patient (4)
    73         S DFN=4
    74         D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
    75         N APPID S APPID=+$P(^BSDXTMP($J,1),U)
    76         I 'APPID W "Error Making Appt-9" QUIT
    77         I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-10"
    78         I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-11"
    79         I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-12"
    80         ;
    81         ; Delete appointment set for Patient 4 (made above)
    82         N BSDX,DFN
    83         S DFN=4
    84         S BSDX("PAT")=DFN
    85         S BSDX("CLN")=HLIEN
    86         S BSDX("ADT")=APPTTIME
    87         D ROLLBACK(APPID,.BSDX)
    88         I +$G(^BSDXAPPT(APPID,0)) W "Error in deleting appointment-1",!
    89         I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-2",!
    90         I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-3",!
    91         ;
    92         ; Again for a different patient (5)
    93         S DFN=5
    94         D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
    95         N APPID S APPID=+$P(^BSDXTMP($J,1),U)
    96         I 'APPID W "Error Making Appt-13" QUIT
    97         I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-14"
    98         I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-15"
    99         I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-16"
    100         ; Now cancel that appointment
    101         D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
    102         ; Now make it again
    103         D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
    104         N APPID S APPID=+$P(^BSDXTMP($J,1),U)
    105         I 'APPID W "Error Making Appt-17" QUIT
    106         I +^BSDXAPPT(APPID,0)'=APPTTIME W "Error Making Appt-18"
    107         I '$D(^DPT(DFN,"S",APPTTIME)) W "Error Making Appt-19"
    108         I '$$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error Making Appt-20"
    109         ;
    110         ; Delete appointment set for Patient 1 (not made)... needs to not crash
    111         D
    112         . N $ET S $ET="D ^%ZTER S $EC="""" W ""Failure to del non-existent appt"",!"
    113         . N BSDX
    114         . S BSDX("PAT")=1
    115         . S BSDX("CLN")=HLIEN
    116         . S BSDX("ADT")=APPTTIME
    117         . D ROLLBACK(APPID,.BSDX)
    118         ;
    119         ; Test for bad start date
    120         D APPADD(.ZZZ,2100123,3100123.3,2,RESNAM,30,"Sam's Note",1)
    121         I +$P(^BSDXTMP($J,1),U,2)'=-2 W "Error in -2",!
    122         ; Test for bad end date
    123         D APPADD(.ZZZ,3100123,2100123.3,2,RESNAM,30,"Sam's Note",1)
    124         I +$P(^BSDXTMP($J,1),U,2)'=-3 W "Error in -3",!
    125         ; Test for end date without time - obsolete
    126         ; D APPADD(.ZZZ,3100123.1,3100123,2,RESNAM,30,"Sam's Note",1)
    127         ; I +$P(^BSDXTMP($J,1),U,2)'=-4 W "Error in -4",!
    128         ; Test for mumps error
    129         S BSDXDIE=1
    130         D APPADD(.ZZZ,APPTTIME,ENDTIME,1,RESNAM,30,"Sam's Note",1)
    131         I +$P(^BSDXTMP($J,1),U,2)'=-100 W "Error in -100: M Error",!
    132         K BSDXDIE
    133         ; Test for TRESTART -- retired in v 1.7
    134         ; S BSDXRESTART=1
    135         ; D APPADD(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
    136         ; I +$P(^BSDXTMP($J,1),U,2)'=0&(+$P(^BSDXTMP($J,1),U,2)'=-10) W "Error in TRESTART",!
    137         ; K BSDXRESTART
    138         ; Test for non-numeric patient
    139         D APPADD(.ZZZ,APPTTIME,ENDTIME,"CAT,DOG",RESNAM,30,"Sam's Note",1)
    140         I +$P(^BSDXTMP($J,1),U,2)'=-5 W "Error in -5",!
    141         ; Test for a non-existent patient
    142         D APPADD(.ZZZ,APPTTIME,ENDTIME,8989898989,RESNAM,30,"Sam's Note",1)
    143         I +$P(^BSDXTMP($J,1),U,2)'=-6 W "Error in -6",!
    144         ; Test for a non-existent resource name
    145         D APPADD(.ZZZ,APPTTIME,ENDTIME,3,"lkajsflkjsadf",30,"Sam's Note",1)
    146         I +$P(^BSDXTMP($J,1),U,2)'=-7 W "Error in -7",!
    147         ; Test for corrupted resource
    148         ; Can't test for -8 since it requires DB corruption
    149         ; Test for inability to add appointment to BSDX Appointment (-9)
    150         ; Also requires something wrong in the DB
    151         ; Test for inability to add appointment to 2,44
    152         ; Test by creating a duplicate appointment
    153         ; Get start and end times
    154         N TIMES S TIMES=$$TIMES^BSDX35 ; appt time^end time
    155         N APPTTIME S APPTTIME=$P(TIMES,U)
    156         N ENDTIME S ENDTIME=$P(TIMES,U,2)
    157         D APPADD(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
    158         D APPADD(.ZZZ,APPTTIME,ENDTIME,3,RESNAM,30,"Sam's Note",1)
    159         I +$P(^BSDXTMP($J,1),U,2)'=-10 W "Error in -10",!
    160         ;
    161         ; Test that rollback occurs properly in various places
    162         N TIMES S TIMES=$$TIMES^BSDX35 ; appt time^end time
    163         N APPTTIME S APPTTIME=$P(TIMES,U)
    164         N ENDTIME S ENDTIME=$P(TIMES,U,2)
    165         S DFN=4
    166         N BSDXSIMERR1 S BSDXSIMERR1=1
    167         D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
    168         N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
    169         I +APPID W "Error in deleting appointment-4",!
    170         I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-5",!
    171         I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-6",!
    172         ;
    173         K BSDXSIMERR1
    174         N BSDXSIMERR2 S BSDXSIMERR2=1
    175         D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
    176         N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
    177         I +APPID W "Error in deleting appointment-7",!
    178         I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-8",!
    179         I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-9",!
    180         ;
    181         K BSDXSIMERR2
    182         N BSDXSIMERR4 S BSDXSIMERR4=1
    183         D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
    184         N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
    185         I +APPID W "Error in deleting appointment-16",!
    186         I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-17",!
    187         I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-18",!
    188         ;
    189         K BSDXSIMERR4
    190         N BSDXSIMERR5 S BSDXSIMERR5=1
    191         D APPADD(.ZZZ,APPTTIME,ENDTIME,DFN,RESNAM,30,"Sam's Note",1)
    192         N APPID S APPID=$O(^BSDXAPPT("B",APPTTIME,""))
    193         I +APPID W "Error in deleting appointment-19",!
    194         I $D(^DPT(DFN,"S",APPTTIME)) W "Error in deleting appointment-20",!
    195         I $$SCIEN^BSDXAPI(DFN,HLIEN,APPTTIME) W "Error in deleting appointment-21",!
    196         QUIT
    197         ;
    19833APPADD(BSDXY,BSDXSTART,BSDXEND,BSDXPATID,BSDXRES,BSDXLEN,BSDXNOTE,BSDXATID,BSDXRADEXAM) ;EP
    19934        ;
     
    299134        N BSDXC ; Array to send to MAKE and MAKECK APIs
    300135        ; Only if we have a valid Hosp Location
    301         I +BSDXSCD,$D(^SC(BSDXSCD,0)) D
     136        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
    302137        . S BSDXC("PAT")=BSDXPATID
    303138        . S BSDXC("CLN")=BSDXSCD
     
    311146        . S BSDXC("USR")=DUZ
    312147        . S BSDXERR=$$MAKECK^BSDXAPI(.BSDXC)
    313         I +BSDXERR D ERR(BSDXI,"-10~BSDX07 Error: MAKECK^BSDXAPI returned error code: "_BSDXERR) Q  ; no need for roll back
    314148        ;
    315149        ; Done with all checks, let's make appointment in BSDX APPOINTMENT
Note: See TracChangeset for help on using the changeset viewer.