Ignore:
Timestamp:
Jun 18, 2012, 8:08:50 PM (12 years ago)
Author:
Sam Habiel
Message:

more changes

File:
1 edited

Legend:

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

    r1187 r1450  
    1 BSDXAPI ; IHS/ANMC/LJF & VW/SMH - SCHEDULING APIs ; 4/28/11 10:30am
    2         ;;1.6T2;BSDX;;May 16, 2011;Build 7
     1BSDXAPI ; IHS/ANMC/LJF & VW/SMH - SCHEDULING APIs ; 6/18/12 5:31pm
     2        ;;1.6;BSDX;;Aug 31, 2011;Build 18
    33        ; Licensed under LGPL 
    44        ;
     
    3232        ; More user friendly message if patient already has appointment in $$MAKE:
    3333        ;  Spits out pt name and user friendly date.
    34         ; 
     34    ; 2012-06-18 (v 1.7)
     35        ; Removing transacions. Means that code SHOULD NOT fail. Took all checks
     36    ;  out for making an appointment to MAKECK. We call this first to make sure
     37    ; that the appointment is okay to make before committing to make it.
    3538        ;
    3639MAKE1(DFN,CLIN,TYP,DATE,LEN,INFO)       ; Simplified PEP w/ parameters for $$MAKE - making appointment
     
    6568        ;   = 1^message:  error and reason
    6669        ;
    67         I '$D(^DPT(+$G(BSDR("PAT")),0)) Q 1_U_"Patient not on file: "_$G(BSDR("PAT"))
    68         I '$D(^SC(+$G(BSDR("CLN")),0)) Q 1_U_"Clinic not on file: "_$G(BSDR("CLN"))
    69         I ($G(BSDR("TYP"))<3)!($G(BSDR("TYP"))>4) Q 1_U_"Appt Type error: "_$G(BSDR("TYP"))
    70         I $G(BSDR("ADT")) S BSDR("ADT")=+$E(BSDR("ADT"),1,12)  ;remove seconds
    71         I $G(BSDR("ADT"))'?7N.1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
    72         ;
    73         ;I ($G(BSDR("LEN"))<5)!($G(BSDR("LEN"))>240) Q 1_U_"Appt Length error: "_$G(BSDR("LEN")) ; v 1.42 - no check on length is done anymore. see top comments for details.
    74         I '$D(^VA(200,+$G(BSDR("USR")),0)) Q 1_U_"User Who Made Appt Error: "_$G(BSDR("USR"))
    75         ;I $D(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0)),$P(^(0),U,2)'["C" Q 1_U_"Patient "_BSDR("PAT")_" already has appt at "_BSDR("ADT") ; v.1.5 more user friendly err msg
    76         ;
    77         ; Following block to give an error message to user if there is already an appointment for patient. More verbose than others.
    78         N BSDXERR ; place to store error message
    79         I $D(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0)),$P(^(0),U,2)'["C" DO  QUIT BSDXERR  ; If there's an appt in the "S" node of file 2 and it's not cancelled
    80         . S BSDXERR=1_U_"Patient "_$P(^DPT(BSDR("PAT"),0),U)_" ("_BSDR("PAT")_") "
    81         . S BSDXERR=BSDXERR_"already has appt at "_$$FMTE^XLFDT(BSDR("ADT"))
    82         . N BSDXSCIEN S BSDXSCIEN=$P(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0),U)  ; Clinic IEN in ^SC (0 piece of 0 node of "S" multiple in file 2)
    83         . N BSDXSCNAM S BSDXSCNAM=$P(^SC(BSDXSCIEN,0),U) ; PIMS Name of Clinic
    84         . S BSDXERR=BSDXERR_$C(13,10)_"PIMS clinic: "_BSDXSCNAM ; tell the user of the PIMS clinic
    85         . I $D(^BSDXRES("ALOC",BSDXSCIEN)) DO  ; if the Clinic is linked to a BSDX Resource (we find out using the index ALOC in the BSDX RESOURCE file)
    86         . . N BSDXRESIEN S BSDXRESIEN=$O(^BSDXRES("ALOC",BSDXSCIEN,""))
    87         . . QUIT:'BSDXRESIEN  ; Safeguard if index is corrupt
    88         . . N BSDXRESNAM S BSDXRESNAM=$P(^BSDXRES(BSDXRESIEN,0),U)
    89         . . S BSDXERR=BSDXERR_$C(13,10)_"Scheduling GUI clinic: "_BSDXRESNAM ; tell the user of the BSDX clinic
     70        N BSDXMKCK S BSDXMKCK=$$MAKECK(.BSDR) ; Check if we can make appointment
     71        I BSDXMKCK Q BSDXMKCK ; If we can't, quit with the reason why.
     72    ; Otherwise, we continue
    9073        ;
    9174        NEW DIC,DA,Y,X,DD,DO,DLAYGO
     
    10689        . D FILE^DIE("","BSDXFDA","BSDXMSG")
    10790        . N BSDXTEMP S BSDXTEMP=$G(BSDXMSG)
    108         E  D  I $G(BSDXERR(1)) Q 1_U_"FileMan add to DPT error: Patient="_BSDR("PAT")_" Appt="_BSDR("ADT") 
     91        E  D 
    10992        . N BSDXFDA,BSDXIENS,BSDXMSG
    11093        . S BSDXIENS="?+2,"_BSDR("PAT")_","
     
    11598        . S BSDXFDA(2.98,BSDXIENS,"20")=$$NOW^XLFDT
    11699        . D UPDATE^DIE("","BSDXFDA","BSDXIENS","BSDXERR(1)")
    117         ; add appt to file 44
     100        I $G(BSDXERR(1)) Q 1_U_"FileMan add to DPT error: Patient="_BSDR("PAT")_" Appt="_BSDR("ADT")
     101    ; add appt to file 44
    118102        K DIC,DA,X,Y,DLAYGO,DD,DO
    119103        I '$D(^SC(BSDR("CLN"),"S",0)) S ^SC(BSDR("CLN"),"S",0)="^44.001DA^^"
     
    122106        . S DIC("P")="44.001DA",DIC(0)="L",DLAYGO=44.001
    123107        . S Y=1 I '$D(@(DIC_X_")")) D FILE^DICN
     108   
    124109        ;
    125110        ; Sep 28 2010: Changed old style API to new style API. Keep for reference //smh
     
    150135        Q 0
    151136        ;
     137MAKECK(BSDR) ; $$ - Is it okay to make an appointment? ; PEP
     138        I '$D(^DPT(+$G(BSDR("PAT")),0)) Q 1_U_"Patient not on file: "_$G(BSDR("PAT"))
     139        I '$D(^SC(+$G(BSDR("CLN")),0)) Q 1_U_"Clinic not on file: "_$G(BSDR("CLN"))
     140        I ($G(BSDR("TYP"))<3)!($G(BSDR("TYP"))>4) Q 1_U_"Appt Type error: "_$G(BSDR("TYP"))
     141        I $G(BSDR("ADT")) S BSDR("ADT")=+$E(BSDR("ADT"),1,12)  ;remove seconds
     142        I $G(BSDR("ADT"))'?7N.1".".4N Q 1_U_"Appt Date/Time error: "_$G(BSDR("ADT"))
     143        ;
     144    ; Appt Length check removed in v 1.5
     145    ;
     146        I '$D(^VA(200,+$G(BSDR("USR")),0)) Q 1_U_"User Who Made Appt Error: "_$G(BSDR("USR"))
     147        ; More verbose error message in v1.5
     148        ; Following block to give an error message to user if there is already an appointment for patient. More verbose than others.
     149        N BSDXERR ; place to store error message
     150        I $D(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0)),$P(^(0),U,2)'["C" DO  QUIT BSDXERR  ; If there's an appt in the "S" node of file 2 and it's not cancelled
     151        . S BSDXERR=1_U_"Patient "_$P(^DPT(BSDR("PAT"),0),U)_" ("_BSDR("PAT")_") "
     152        . S BSDXERR=BSDXERR_"already has appt at "_$$FMTE^XLFDT(BSDR("ADT"))
     153        . N BSDXSCIEN S BSDXSCIEN=$P(^DPT(BSDR("PAT"),"S",BSDR("ADT"),0),U)  ; Clinic IEN in ^SC (0 piece of 0 node of "S" multiple in file 2)
     154        . N BSDXSCNAM S BSDXSCNAM=$P(^SC(BSDXSCIEN,0),U) ; PIMS Name of Clinic
     155        . S BSDXERR=BSDXERR_$C(13,10)_"PIMS clinic: "_BSDXSCNAM ; tell the user of the PIMS clinic
     156        . I $D(^BSDXRES("ALOC",BSDXSCIEN)) DO  ; if the Clinic is linked to a BSDX Resource (we find out using the index ALOC in the BSDX RESOURCE file)
     157        . . N BSDXRESIEN S BSDXRESIEN=$O(^BSDXRES("ALOC",BSDXSCIEN,""))
     158        . . QUIT:'BSDXRESIEN  ; Safeguard if index is corrupt
     159        . . N BSDXRESNAM S BSDXRESNAM=$P(^BSDXRES(BSDXRESIEN,0),U)
     160        . . S BSDXERR=BSDXERR_$C(13,10)_"Scheduling GUI clinic: "_BSDXRESNAM ; tell the user of the BSDX clinic
     161        Q 0
     162    ;
     163UNMAKE(BSDR) ; Reverse Make - Private $$
     164    ; Only used in Emergiencies where Fileman data filing fails.
     165    ; If previous data exists, which caused an error, it's destroyed.
     166    N BSDXFDA,BSDXIENS
     167        S BSDXIENS=BSDR("ADT")_","_BSDR("PAT")_","
     168        S BSDXFDA(2.98,BSDXIENS,".01")="@"
     169    ;
     170    I '$D(^SC(BSDR("CLN"),"S",BSDR("ADT"),1)) QUIT 0 ; No stuff in HL file
     171    N X S X=0 F  S X=$O(^SC(BSDR("CLN"),"S",BSDR("ADT"),1,X)) Q:'X  Q:+^(X,0)=BSDR("PAT")
     172        ;
     173    I 'X QUIT 0 ; Patient doesn't have appointment
     174    ;
     175    S BSDXIENS=X_","_BSDR("ADT")_","_BSDR("CLN")_","
     176        S BSDXFDA(44.003,BSDXIENS,.01)="@"
     177    N BSDXMSG
     178    D FILE^DIE("","BSDXFDA","BSDXMSG")
     179    I $D(BSDXMSG) S $EC=",U1," ; If we get an error here, we are REALLY out of control
     180    QUIT 0
    152181CHECKIN1(DFN,CLIN,APDATE)       ; Simplified PEP w/ parameters for $$CHECKIN - Checking in
    153182        ; Call like this for DFN 23435 checking in now at Hospital Location 33
     
    325354        ; remove check-in using filer.
    326355        N BSDXIENS S BSDXIENS=SDDA_","_DATE_","_CLINIC_","
    327         S BSDXFDA(44.003,BSDXIENS,309)="@"      ; CHECKED-IN
    328         S BSDXFDA(44.003,BSDXIENS,302)="@"      ; CHECK IN USER
    329         S BSDXFDA(44.003,BSDXIENS,305)="@"      ; CHECK IN ENTERED
     356        S BSDXFDA(44.003,BSDXIENS,309)="@" ; CHECKED-IN
     357        S BSDXFDA(44.003,BSDXIENS,302)="@" ; CHECK IN USER
     358        S BSDXFDA(44.003,BSDXIENS,305)="@" ; CHECK IN ENTERED
    330359        N BSDXERR
    331360        D FILE^DIE("","BSDXFDA","BSDXERR")
     
    359388        Q $S(X:1,1:0)
    360389        ;
    361 UPDATENOTE(PAT,CLINIC,DATE,NOTE)        ; PEP; Update Note in ^SC for patient's appointment @ DATE
     390UPDATENT(PAT,CLINIC,DATE,NOTE)  ; PEP; Update Note in ^SC for patient's appointment @ DATE
    362391        ; PAT = DFN
    363392        ; CLINIC = SC IEN
Note: See TracChangeset for help on using the changeset viewer.