Changeset 1076


Ignore:
Timestamp:
Jan 24, 2011, 9:21:52 AM (14 years ago)
Author:
Sam Habiel
Message:

Updates to M routines to support deletion of check-in

Location:
Scheduling/trunk/m
Files:
2 edited

Legend:

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

    r1041 r1076  
    11BSDX08  ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 12/6/10 12:35pm
    22        ;;1.42;BSDX;;Dec 07, 2010
    3            ;
    4            ; Original by HMW. New Written by Sam Habiel. Licensed under LGPL.
    5            ;
    6            ; Change History
    7            ; 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.
    16            ;  - Refactored all of APPDEL.
    17            ;
    18            ; Error Reference:
    19            ;  -1~BSDX08: Appt record is locked. Please contact technical support.
    20            ;  -2~BSDX08: Invalid Appointment ID
     3        ;
     4        ; Original by HMW. New Written by Sam Habiel. Licensed under LGPL.
     5        ;
     6        ; Change History
     7        ; 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.
     16        ;  - Refactored all of APPDEL.
     17        ;
     18        ; Error Reference:
     19        ;  -1~BSDX08: Appt record is locked. Please contact technical support.
     20        ;  -2~BSDX08: Invalid Appointment ID
    2121        ;  -3~BSDX08: Invalid Appointment ID
    22            ;  -4~BSDX08: Cancelled appointment does not have a Resouce ID 
    23            ;  -5~BSDX08: Resouce ID does not exist in BSDX RESOURCE
    24            ;  -6~BSDX08: Invalid Hosp Location stored in Database
    25            ;  -7~BSDX08: Patient does not have an appointment in PIMS Clinic
    26            ;  -8^BSDX08: Unable to find associated PIMS appointment for this patient
    27            ;  -9^BSDX08: BSDXAPI returned an error: (error)
    28            ;  -100~BSDX08 Error: (Mumps Error)
     22        ;  -4~BSDX08: Cancelled appointment does not have a Resouce ID 
     23        ;  -5~BSDX08: Resouce ID does not exist in BSDX RESOURCE
     24        ;  -6~BSDX08: Invalid Hosp Location stored in Database
     25        ;  -7~BSDX08: Patient does not have an appointment in PIMS Clinic
     26        ;  -8^BSDX08: Unable to find associated PIMS appointment for this patient
     27        ;  -9^BSDX08: BSDXAPI returned an error: (error)
     28        ;  -100~BSDX08 Error: (Mumps Error)
    2929        ;
    3030APPDELD(BSDXY,BSDXAPTID,BSDXTYP,BSDXCR,BSDXNOT) ;EP
     
    3434        ;
    3535UT      ; Unit Tests
    36            ; Test 1: Make normal appointment and cancel it. See if every thing works
    37            N ZZZ
    38            D APPADD^BSDX07(.ZZZ,3110123.2,3110123.3,4,"Dr Office",10,"Sam's Note",1)
    39            S APPID=+$P(^BSDXTMP($J,1),U)
    40            D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
    41            I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1"
    42            I $O(^SC(2,"S",3110123.2,1,0))]"" W "Error in Cancellation-2"
    43            I $P(^DPT(4,"S",3110123.2,0),U,2)'="PC" W "Error in Cancellation-3"
    44            I ^DPT(4,"S",3110123.2,"R")'="Sam's Cancel Note" W "Error in Cancellation-4"
    45            ;
    46            ; Test 2: Check for -1
    47            ; Make appt
    48            D APPADD^BSDX07(.ZZZ,3110125.2,3110125.3,4,"Dr Office",10,"Sam's Note",1)
    49            ; Lock the node in another job
    50            S APPID=+$P(^BSDXTMP($J,1),U)
    51            ; W "Lock ^BSDXAPPT("_APPID_") in another session. You have 10 seconds." H 10
    52            D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
    53            ;
    54            ; Test 3: Check for -100
    55            S bsdxdie=1
    56            D APPADD^BSDX07(.ZZZ,3110126.2,3110126.3,4,"Dr Office",10,"Sam's Note",1)
    57            S APPID=+$P(^BSDXTMP($J,1),U)
    58            D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
    59            I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100",!
    60            K bsdxdie
    61            ;
    62            ; Test 4: Restartable transaction
    63            S bsdxrestart=1
    64            D APPADD^BSDX07(.ZZZ,3110128.2,3110128.3,4,"Dr Office",10,"Sam's Note",1)
    65            S APPID=+$P(^BSDXTMP($J,1),U)
    66            D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
    67            I $P(^DPT(4,"S",3110128.2,0),U,2)'="PC" W "Error in Restartable Transaction",!
    68            ;
    69            ; Test 5: for invalid Appointment ID (-2 and -3)
    70            D APPDEL^BSDX08(.ZZZ,0,"PC",1,"Reasons")
    71            I $P(^BSDXTMP($J,1),"~")'=-2 W "Error in -2",!
    72            D APPDEL^BSDX08(.ZZZ,999999,"PC",1,"Reasons")
    73            I $P(^BSDXTMP($J,1),"~")'=-3 W "Error in -3",!
    74            QUIT
     36        ; Test 1: Make normal appointment and cancel it. See if every thing works
     37        N ZZZ
     38        D APPADD^BSDX07(.ZZZ,3110123.2,3110123.3,4,"Dr Office",10,"Sam's Note",1)
     39        S APPID=+$P(^BSDXTMP($J,1),U)
     40        D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
     41        I $P(^BSDXAPPT(APPID,0),U,12)'>0 W "Error in Cancellation-1"
     42        I $O(^SC(2,"S",3110123.2,1,0))]"" W "Error in Cancellation-2"
     43        I $P(^DPT(4,"S",3110123.2,0),U,2)'="PC" W "Error in Cancellation-3"
     44        I ^DPT(4,"S",3110123.2,"R")'="Sam's Cancel Note" W "Error in Cancellation-4"
     45        ;
     46        ; Test 2: Check for -1
     47        ; Make appt
     48        D APPADD^BSDX07(.ZZZ,3110125.2,3110125.3,4,"Dr Office",10,"Sam's Note",1)
     49        ; Lock the node in another job
     50        S APPID=+$P(^BSDXTMP($J,1),U)
     51        ; W "Lock ^BSDXAPPT("_APPID_") in another session. You have 10 seconds." H 10
     52        D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Sam's Cancel Note")
     53        ;
     54        ; Test 3: Check for -100
     55        S bsdxdie=1
     56        D APPADD^BSDX07(.ZZZ,3110126.2,3110126.3,4,"Dr Office",10,"Sam's Note",1)
     57        S APPID=+$P(^BSDXTMP($J,1),U)
     58        D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
     59        I $P(^BSDXTMP($J,1),"~")'=-100 W "Error in -100",!
     60        K bsdxdie
     61        ;
     62        ; Test 4: Restartable transaction
     63        S bsdxrestart=1
     64        D APPADD^BSDX07(.ZZZ,3110128.2,3110128.3,4,"Dr Office",10,"Sam's Note",1)
     65        S APPID=+$P(^BSDXTMP($J,1),U)
     66        D APPDEL^BSDX08(.ZZZ,APPID,"PC",1,"Reasons")
     67        I $P(^DPT(4,"S",3110128.2,0),U,2)'="PC" W "Error in Restartable Transaction",!
     68        ;
     69        ; Test 5: for invalid Appointment ID (-2 and -3)
     70        D APPDEL^BSDX08(.ZZZ,0,"PC",1,"Reasons")
     71        I $P(^BSDXTMP($J,1),"~")'=-2 W "Error in -2",!
     72        D APPDEL^BSDX08(.ZZZ,999999,"PC",1,"Reasons")
     73        I $P(^BSDXTMP($J,1),"~")'=-3 W "Error in -3",!
     74        ;
     75        ; Test 6: for Cancelling walkin and checked-in appointments.
     76        S BSDXSTART=$E($$NOW^XLFDT,1,12),BSDXEND=BSDXSTART+.0001
     77        D APPADD^BSDX07(.ZZZ,BSDXSTART,BSDXEND,4,"Dr Office",10,"Sam's Note",1)
     78        S APPID=+$P(^BSDXTMP($J,1),U)
     79        B
     80        D CHECKIN^BSDX25(.ZZZ,APPID,$$NOW^XLFDT)
     81        B
     82        D APPDEL^BSDX08(.ZZZ,APPID,"PC",10,"Cancel Note")
     83        QUIT
    7584           ; Lock the node in another job for testing.
    7685UTL(APPID)      L +^BSDXAPPT(APPID) HANG 10 QUIT
  • Scheduling/trunk/m/BSDXAPI.m

    r1041 r1076  
    55        ;Move to BSDX namespace as BSDXAPI from BSDAPI by WV/SMH
    66        ; Change History:
    7            ; 2010-11-5:
     7        ; 2010-11-5:
    88        ; - Fixed errors having to do uncanceling patient appointments if it was a patient cancelled appointment.
    99        ; - Use new style Fileman API for storing appointments in file 44 in $$MAKE due to problems with legacy API.
    10            ; 2010-11-12:
    11            ; - Changed ="C" to ["C" in SCIEN. Cancelled appointments can be "PC" as well.
    12            ; 2010-12-5
    13            ; Added an entry point to update the patient note in file 44.
    14            ; 2010-12-6
    15            ; MAKE1 incorrectly put info field in BSDR("INFO") rather than BSDR("OI")
    16            ; 2010-12-8
    17            ; Removed restriction on max appt length. Even though this restriction
    18            ; exists in fileman (120 minutes), PIMS ignores it. Therefore, I
    19            ; will ignore it here too.
     10        ; 2010-11-12:
     11        ; - Changed ="C" to ["C" in SCIEN. Cancelled appointments can be "PC" as well.
     12        ; 2010-12-5
     13        ; Added an entry point to update the patient note in file 44.
     14        ; 2010-12-6
     15        ; MAKE1 incorrectly put info field in BSDR("INFO") rather than BSDR("OI")
     16        ; 2010-12-8
     17        ; Removed restriction on max appt length. Even though this restriction
     18        ; exists in fileman (120 minutes), PIMS ignores it. Therefore, I
     19        ; will ignore it here too.
    2020        ;
    2121MAKE1(DFN,CLIN,TYP,DATE,LEN,INFO)       ; Simplified PEP w/ parameters for $$MAKE - making appointment
     
    267267        Q $S(X:1,1:0)
    268268        ;
     269RMCI(PAT,CLINIC,DATE)           ;PEP; -- Remove Check-in; $$
     270        ; PAT = DFN
     271        ; CLINIC = SC IEN
     272        ; DATE = FM Date/Time of Appointment
     273        ;
     274        ; Returns:
     275        ; 0 if okay
     276        ; -1 if failure
     277        ;
     278        ; remember before status
     279        NEW SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL
     280        S DFN=PAT,SDT=DATE,SDCL=CLINIC,SDMODE=2,SDDA=$$SCIEN(DFN,SDCL,SDT)
     281        ;
     282        I SDDA<1 QUIT 0    ; Appt cancelled; cancelled appts rm'ed from file 44
     283        ;
     284        S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
     285        D BEFORE^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
     286        ;
     287        ; remove check-in using filer.
     288        N BSDXIENS S BSDXIENS=SDDA_","_DATE_","_CLINIC_","
     289        S BSDXFDA(44.003,BSDXIENS,309)="@"      ; CHECKED-IN
     290        S BSDXFDA(44.003,BSDXIENS,302)="@"      ; CHECK IN USER
     291        S BSDXFDA(44.003,BSDXIENS,305)="@"      ; CHECK IN ENTERED
     292        N BSDXERR
     293        D FILE^DIE("","BSDXFDA","BSDXERR")
     294        I $D(BSDXERR) QUIT "-1~Can't file for Pat "_PAT_" in Clinic "_CLINIC_" at "_DATE_". Fileman reported an error: "_BSDXERR("DIERR",1,"TEXT",1)
     295        ;
     296        ; set after status
     297        S SDDA=$$SCIEN(DFN,SDCL,SDT)
     298        S SDCIHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
     299        D AFTER^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCIHDL)
     300        ;
     301        ; call event driver
     302        D EVT^SDAMEVT(.SDATA,4,SDMODE,SDCIHDL)
     303        QUIT 0
     304        ;
    269305SCIEN(PAT,CLINIC,DATE)  ;PEP; returns ien for appt in ^SC
    270306        NEW X,IEN
Note: See TracChangeset for help on using the changeset viewer.