Changeset 1456


Ignore:
Timestamp:
Jun 22, 2012, 7:18:41 PM (12 years ago)
Author:
Sam Habiel
Message:

forgot BSDXAPI

File:
1 edited

Legend:

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

    r1452 r1456  
    1 BSDXAPI ; IHS/ANMC/LJF & VW/SMH - SCHEDULING APIs ; 6/20/12 12:40pm
     1BSDXAPI ; IHS/ANMC/LJF & VW/SMH - SCHEDULING APIs ; 6/22/12 4:25pm
    22        ;;1.7T1;BSDX;;Aug 31, 2011;Build 18
    33        ; Licensed under LGPL 
     
    292292        ;   = 1^message:  error and reason
    293293        ;
     294        N BSDXCANCK S BSDXCANCK=$$CANCELCK(.BSDR)
     295        I BSDXCANCK Q BSDXCANCK
     296        ;
     297        ; BSDX 1.5 3110125
     298        ; UJO/SMH - Add ability to remove check-in if the patient is checked in
     299        ; I $$CI(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"),IEN) Q 1_U_"Patient already checked in; cannot cancel until checkin deleted: Patient="_BSDR("PAT")_" Clinic="_BSDR("CLN")_" Appt="_BSDR("ADT")
     300        ; Remove check-in if the patient is checked in.
     301        N BSDXRESULT S BSDXRESULT=0 ; Result; should be zero if success; -1 + message if failure
     302        NEW IEN S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
     303        I $$CI(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"),IEN) SET BSDXRESULT=$$RMCI(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
     304        I BSDXRESULT Q BSDXRESULT
     305        ; NB: Failure point 1: we fail here nothing has happened yet
     306        ;
     307        ; remember before status
     308        NEW SDATA,DFN,SDT,SDCL,SDDA,SDCPHDL
     309        S DFN=BSDR("PAT"),SDT=BSDR("ADT"),SDCL=BSDR("CLN"),SDMODE=2,SDDA=IEN
     310        S SDCPHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
     311        D BEFORE^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCPHDL)
     312        ; NB: Here only globals are set. Nothing else.
     313        ;
     314        ; get user who made appt and date appt made from ^SC
     315        ;    because data in ^SC will be deleted
     316        NEW USER,DATE
     317        S USER=$P($G(^SC(SDCL,"S",SDT,1,IEN,0)),U,6)
     318        S DATE=$P($G(^SC(SDCL,"S",SDT,1,IEN,0)),U,7)
     319        ;
     320        ; update file 2 info
     321        NEW DIE,DA,DR
     322        S DIE="^DPT("_DFN_",""S"",",DA(1)=DFN,DA=SDT
     323        S DR="3///"_BSDR("TYP")_";14///`"_BSDR("USR")_";15///"_BSDR("CDT")_";16///`"_BSDR("CR")_";19///`"_USER_";20///"_DATE
     324        S:$G(BSDR("NOT"))]"" DR=DR_";17///"_$E(BSDR("NOT"),1,160)
     325        D ^DIE
     326        ; Failure point 2: If we fail here, it means that the check-in was removed;
     327        ; but the appointment wasn't cancelled.
     328        ; To roll back, we should restore the check-in. However, I would rather not
     329        ; do that. This code will only fail if there's something wrong in the DB.
     330        ; (deleted field for example). If I try to restore the check-in, I just
     331        ; may excercerbate the problem.
     332        ;
     333        ; delete data in ^SC
     334        NEW DIK,DA
     335        S DIK="^SC("_BSDR("CLN")_",""S"","_BSDR("ADT")_",1,"
     336        S DA(2)=BSDR("CLN"),DA(1)=BSDR("ADT"),DA=IEN
     337        D ^DIK
     338        ; Failure point 3: If we fail here, we need to restore the cancel date,
     339        ; and possibly, the check-in.
     340        ;
     341        ; call event driver
     342        D CANCEL^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDMODE,SDCPHDL)
     343        Q 0
     344        ;
     345CANCELCK(BSDR) ; $$ PEP; Okay to Cancel Appointment?
     346        ; Input: .BSDR array as documented in $$CANCEL
     347        ; Output: 0 or 1^Error message
    294348        I '$D(^DPT(+$G(BSDR("PAT")),0)) Q 1_U_"Patient not on file: "_$G(BSDR("PAT"))
    295349        I '$D(^SC(+$G(BSDR("CLN")),0)) Q 1_U_"Clinic not on file: "_$G(BSDR("CLN"))
     
    302356        I '$D(^SD(409.2,+$G(BSDR("CR")))) Q 1_U_"Cancel Reason error: "_$G(BSDR("CR"))
    303357        ;
    304         NEW IEN,DIE,DA,DR
    305         S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
     358        NEW IEN S IEN=$$SCIEN(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
    306359        I 'IEN Q 1_U_"Error trying to find appointment for cancel: Patient="_BSDR("PAT")_" Clinic="_BSDR("CLN")_" Appt="_BSDR("ADT")
    307         ;
    308         ; BSDX 1.5 3110125
    309         ; UJO/SMH - Add ability to remove check-in if the patient is checked in
    310         ; I $$CI(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"),IEN) Q 1_U_"Patient already checked in; cannot cancel until checkin deleted: Patient="_BSDR("PAT")_" Clinic="_BSDR("CLN")_" Appt="_BSDR("ADT")
    311         ; Remove check-in if the patient is checked in.
    312         N BSDXRESULT S BSDXRESULT=0 ; Result; should be zero if success; -1 + message if failure
    313         I $$CI(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"),IEN) SET BSDXRESULT=$$RMCI(BSDR("PAT"),BSDR("CLN"),BSDR("ADT"))
    314         I BSDXRESULT Q BSDXRESULT
    315         ;
    316         ; remember before status
    317         NEW SDATA,DFN,SDT,SDCL,SDDA,SDCPHDL
    318         S DFN=BSDR("PAT"),SDT=BSDR("ADT"),SDCL=BSDR("CLN"),SDMODE=2,SDDA=IEN
    319         S SDCPHDL=$$HANDLE^SDAMEVT(1),SDATA=SDDA_U_DFN_U_SDT_U_SDCL
    320         D BEFORE^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDCPHDL)
    321         ;
    322         ; get user who made appt and date appt made from ^SC
    323         ;    because data in ^SC will be deleted
    324         NEW USER,DATE
    325         S USER=$P($G(^SC(SDCL,"S",SDT,1,IEN,0)),U,6)
    326         S DATE=$P($G(^SC(SDCL,"S",SDT,1,IEN,0)),U,7)
    327         ;
    328         ; update file 2 info
    329         NEW DIE,DA,DR
    330         S DIE="^DPT("_DFN_",""S"",",DA(1)=DFN,DA=SDT
    331         S DR="3///"_BSDR("TYP")_";14///`"_BSDR("USR")_";15///"_BSDR("CDT")_";16///`"_BSDR("CR")_";19///`"_USER_";20///"_DATE
    332         S:$G(BSDR("NOT"))]"" DR=DR_";17///"_$E(BSDR("NOT"),1,160)
    333         D ^DIE
    334         ;
    335         ; delete data in ^SC
    336         NEW DIK,DA
    337         S DIK="^SC("_BSDR("CLN")_",""S"","_BSDR("ADT")_",1,"
    338         S DA(2)=BSDR("CLN"),DA(1)=BSDR("ADT"),DA=IEN
    339         D ^DIK
    340         ;
    341         ; call event driver
    342         D CANCEL^SDAMEVT(.SDATA,DFN,SDT,SDCL,SDDA,SDMODE,SDCPHDL)
    343         Q 0
    344         ;
     360        Q 0
    345361CI(PAT,CLINIC,DATE,SDIEN)       ;PEP; -- returns 1 if appt already checked-in
    346362        NEW X
     
    396412        Q $G(IEN)
    397413        ;
     414APPLEN(PAT,CLINIC,DATE) ; $$ PEP; returns an appointment's length
     415        ; Get either the appointment length or zero
     416        ; TODO: Test
     417        N SCIEN S SCIEN=$$SCIEN(PAT,CLINIC,DATE)
     418        Q:SCIEN $P(^SC(CLINIC,"S",DATE,1,SCIEN,0),U,2)
     419        Q 0
    398420APPTYP(PAT,DATE)        ;PEP; -- returns type of appt (scheduled or walk-in)
    399421        NEW X S X=$P($G(^DPT(PAT,"S",DATE,0)),U,7)
Note: See TracChangeset for help on using the changeset viewer.