Changeset 1034


Ignore:
Timestamp:
Dec 6, 2010, 1:53:27 AM (14 years ago)
Author:
Sam Habiel
Message:

Refactoring of BSDX26; BSDXAPI has new ep to update note in file 44

Location:
Scheduling/trunk/m
Files:
2 edited

Legend:

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

    r968 r1034  
    1 BSDX26  ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ;
    2         ;;1.41;BSDX;;Sep 29, 2010
    3         ;
    4         ;
    5 EDITAPTD(BSDXY,BSDXAPTID,BSDXNOTE)      ;EP
    6         ;Entry point for debugging
    7         ;
    8         ;D DEBUG^%Serenji("EDITAPT^BSDX26(.BSDXY,BSDXAPTID,BSDXNOTE)")
    9         Q
    10         ;
    11 EDITAPT(BSDXY,BSDXAPTID,BSDXNOTE)       ;EP Edit appointment (only note text can be edited)
    12         ;
    13         N BSDXNOD,BSDXPATID,BSDXSTART,DIK,DA,BSDXID,BSDXI,BSDXZ,BSDXIENS
    14         ;
    15         D ^XBKVAR
    16         S X="ETRAP^BSDX26",@^%ZOSF("TRAP")
    17         S BSDXI=0
    18         K ^BSDXTMP($J)
    19         S BSDXY="^BSDXTMP("_$J_")"
    20         S ^BSDXTMP($J,BSDXI)="T00020ERRORID"_$C(30)
    21         S BSDXI=BSDXI+1
    22         TSTART
    23         I '+BSDXAPTID D ERR(BSDXI,"BSDX26: Invalid Appointment ID") Q
    24         I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(BSDXI,"BSDX26: Invalid Appointment ID") Q
    25         ;Add WP field
    26         ;I BSDXNOTE]"" S BSDXNOTE(.5)=BSDXNOTE,BSDXNOTE=""
    27         S BSDXNOTE(.5)=BSDXNOTE,BSDXNOTE=""
    28         I $D(BSDXNOTE(0)) S BSDXNOTE(.5)=BSDXNOTE(0) K BSDXNOTE(0)
    29         I $D(BSDXNOTE(.5)) D
    30         . D WP^DIE(9002018.4,BSDXAPTID_",",1,"","BSDXNOTE","BSDXMSG")
    31         ;
    32         ;Return Recordset
    33         TCOMMIT
    34         S BSDXI=BSDXI+1
    35         S ^BSDXTMP($J,BSDXI)="-1"_$C(30)
    36         S BSDXI=BSDXI+1
    37         S ^BSDXTMP($J,BSDXI)=$C(31)
    38         Q
    39         ;
    40         ;
    41 ERR(BSDXI,BSDXERR)      ;Error processing
    42         S BSDXI=BSDXI+1
    43         TROLLBACK
    44         S ^BSDXTMP($J,BSDXI)=BSDXERR_$C(30)
    45         S BSDXI=BSDXI+1
    46         S ^BSDXTMP($J,BSDXI)=$C(31)
    47         Q
    48         ;
    49 ETRAP   ;EP Error trap entry
    50         TROLLBACK
    51         D ^%ZTER
    52         I '$D(BSDXI) N BSDXI S BSDXI=999999
    53         S BSDXI=BSDXI+1
    54         D ERR(BSDXI,"BSDX26 Error: "_$G(%ZTERROR))
    55         Q
     1BSDX26  ; IHS/OIT/HMW - WINDOWS SCHEDULING RPCS ; 11/18/10 5:36pm
     2    ;;1.42;BSDX;;Sep 29, 2010
     3    ; Change History:
     4    ; 3101023 - UJO/SMH - Addition of restartable transaction; relocation of tx.
     5    ; --> Thanks to Zach Gonzalez and Rick Marshall
     6    ; 3101205 - UJO/SMH - Extensive refactoring.
     7    ;
     8    ; Error Reference:
     9    ; -1: Appt ID is not a number
     10    ; -2: Appt IEN is not in ^BSDXAPPT
     11    ; -3: FM Failure to file WP field in ^BSDXAPPT
     12    ;
     13EDITAPTD(BSDXY,BSDXAPTID,BSDXNOTE)  ;EP
     14    ;Entry point for debugging
     15    ;
     16    D DEBUG^%Serenji("EDITAPT^BSDX26(.BSDXY,BSDXAPTID,BSDXNOTE)")
     17    Q
     18UT ; Unit Tests
     19    ; Test 1: Make sure this damn thing works
     20    N ZZZ
     21    N %H S %H=$H
     22    N NOTE S NOTE="New Note "_%H
     23    D EDITAPT(.ZZZ,188,NOTE)
     24    I ^BSDXAPPT(188,1,1,0)'=NOTE W "ERROR",! B
     25    ; Test 2: Test Errors -1 and -2
     26    N ZZZ
     27    N NOTE S NOTE="Nothing important"
     28    D EDITAPT(.ZZZ,"BLAHBLAH",NOTE)
     29    I +^BSDXTMP($J,1)'=-1 W "ERROR IN -1",! B
     30    D EDITAPT(.ZZZ,298734322,NOTE)
     31    I +^BSDXTMP($J,1)'=-2 W "ERROR IN -2",! B
     32    ; Test 4: M Error
     33    N bsdxdie S bsdxdie=1
     34    D EDITAPT(.ZZZ,188,NOTE)
     35    I +^BSDXTMP($J,1)'=-100 W "ERROR IN -100",! B
     36    ; Test 5: Trestart
     37    N bsdxrestart S bsdxrestart=1
     38    N %H S %H=$H
     39    N NOTE S NOTE="New Note "_%H
     40    D EDITAPT(.ZZZ,188,NOTE)
     41    I ^BSDXAPPT(188,1,1,0)'=NOTE W "ERROR in TRESTART",! B
     42    ; Test for Hosp Location Update
     43    N DATE S DATE=$$NOW^XLFDT()
     44    D APPADD^BSDX07(.ZZZ,DATE,DATE+.001,3,"Dr Office",30,"Old Note",1)
     45    N APPID S APPID=+$P(^BSDXTMP($J,1),U)
     46    D EDITAPT(.ZZZ,APTID,"New Note")
     47    I ^BSDXAPPT(APTID,1,1,0)'="New Note" W "Error in HL Section",! B
     48    I $P(^SC(2,"S",DATE,1,1,0),U,4)'="New Note" W "Error in HL Section",! B
     49    QUIT
     50    ;
     51EDITAPT(BSDXY,BSDXAPTID,BSDXNOTE)   ;EP Edit appointment (only note text can be edited)
     52    ; Called by RPC: BSDX EDIT APPOINTMENT
     53    ;
     54    ; Edits Appointment Text in BSDX APPOINTMENT file & Hosp Location (44) file
     55    ;
     56    ; Parameters:
     57    ; - BSDXY: Global Return (RPC must be set to Global Array)
     58    ; - BSDXAPTID: Appointment IEN in BSDX APPOINTMENT
     59    ; - BSDXNOTE: New note
     60    ;
     61    ; Return:
     62    ; ADO.net Recordset having 1 field: ERRORID
     63    ; If Okay: -1; otherwise, positive integer with message
     64    ;
     65    ; Return Array; set Return and clear array
     66    S BSDXY=$NA(^BSDXTMP($J))
     67    K ^BSDXTMP($J)
     68    ; ET
     69    N $ET S $ET="G ETRAP^BSDX26"
     70    ; Set up basic DUZ variables
     71    D ^XBKVAR
     72    ; Counter
     73    N BSDXI S BSDXI=0
     74    ; Header Node
     75    S ^BSDXTMP($J,BSDXI)="T00020ERRORID"_$C(30)
     76    ; Restartable txn for GT.M. Restored vars are Params + BSDXI.
     77    TSTART (BSDXY,BSDXAPTID,BSDXNOTE,BSDXI):T="BSDX EDIT APPOINTMENT^BSDX26"
     78    ;
     79    ;;;test for error inside transaction. See if %ZTER works
     80    I $G(bsdxdie) S X=1/0
     81    ;;;test
     82    ;;;test for TRESTART
     83    I $G(bsdxrestart) K bsdxrestart TRESTART
     84    ;;;test
     85    ;
     86    ; Validate Appointment ID
     87    I '+BSDXAPTID D ERR(BSDXI,"-1~BSDX26: Invalid Appointment ID") QUIT
     88    I '$D(^BSDXAPPT(BSDXAPTID,0)) D ERR(BSDXI,"-2~BSDX26: Invalid Appointment ID") QUIT
     89    ; Put the WP in decendant fields from the root to file as a WP field
     90    S BSDXNOTE(.5)=BSDXNOTE,BSDXNOTE=""
     91    I $D(BSDXNOTE(0)) S BSDXNOTE(.5)=BSDXNOTE(0) K BSDXNOTE(0)
     92    N BSDXMSG ; Message in case of error in filing.
     93    I $D(BSDXNOTE(.5)) D
     94    . D WP^DIE(9002018.4,BSDXAPTID_",",1,"","BSDXNOTE","BSDXMSG")
     95    I $D(BSDXMSG) D ERR(BSDXI,"-3~BSDX26: Fileman failure to file data into 9002018.4") QUIT
     96    ;
     97    ; Now file in file 44:
     98    N PTIEN S PTIEN=$$GET1^DIQ(9002018.4,BSDXAPTID,".05","I") ; Patient IEN
     99    N HLIEN S HLIEN=$$GET1^DIQ(9002018.4,BSDXAPTID,".07:.04","I") ; HL Location IEN pointed to by Resource ID
     100    N DATE S DATE=+^BSDXAPPT(BSDXAPTID,0) ; Date of APPT
     101    N BSDXRES S BSDXRES=0 ; Result
     102    ; Update Note only if we have a linked hospital location.
     103    I HLIEN S BSDXRES=$$UPDATENOTE^BSDXAPI(PTIEN,HLIEN,DATE,BSDXNOTE(.5))
     104    ; If we get an error (denoted by -1 in BSDXRES), return error to client
     105    I BSDXRES<0 D ERR(BSDXI,"-4~BSDX26: BSDXAPI reports an error: "_BSDXRES) QUIT
     106    ;Return Recordset
     107    TCOMMIT
     108    S BSDXI=BSDXI+1
     109    S ^BSDXTMP($J,BSDXI)="-1"_$C(30)
     110    S BSDXI=BSDXI+1
     111    S ^BSDXTMP($J,BSDXI)=$C(31)
     112    QUIT
     113    ;
     114ERR(BSDXI,BSDXERR)  ;Error processing
     115    S BSDXI=BSDXI+1
     116    S BSDXERR=$TR(BSDXERR,"^","~")
     117    I $TL>0 TROLLBACK
     118    S ^BSDXTMP($J,BSDXI)=BSDXERR_$C(30)
     119    S BSDXI=BSDXI+1
     120    S ^BSDXTMP($J,BSDXI)=$C(31)
     121    QUIT
     122    ;
     123ETRAP   ;EP Error trap entry
     124    N $ET S $ET="D ^%ZTER HALT" ; Emergency Error Trap
     125    I $TL>0 TROLLBACK
     126    D ^%ZTER
     127    S $EC=""
     128    I '$D(BSDXI) N BSDXI S BSDXI=0
     129    D ERR(BSDXI,"-100~BSDX26 Error: "_$G(%ZTERZE))
     130    Q
  • Scheduling/trunk/m/BSDXAPI.m

    r1006 r1034  
    1 BSDXAPI ; IHS/ANMC/LJF - SCHEDULING APIs ; 11/2/10 4:36pm
     1BSDXAPI ; IHS/ANMC/LJF - SCHEDULING APIs ; 11/18/10 5:34pm
    22        ;;1.42;BSDX;;Sep 29, 2010;Build 7
    33        ;Orignal routine is BSDAPI by IHS/LJF, HMW, and MAW
     
    99    ; 2010-11-12:
    1010    ; - Changed ="C" to ["C" in SCIEN. Cancelled appointments can be "PC" as well.
     11    ; 2010-12-5
     12    ; Added an entry point to update the patient note in file 44.
    1113        ;
    1214MAKE1(DFN,CLIN,TYP,DATE,LEN,INFO)       ; Simplified PEP w/ parameters for $$MAKE - making appointment
     
    276278        Q $S(X:1,1:0)
    277279        ;
     280UPDATENOTE(PAT,CLINIC,DATE,NOTE) ; PEP; Update Note in ^SC for patient's appointment @ DATE
     281    ; PAT = DFN
     282    ; CLINIC = SC IEN
     283    ; DATE = FM Date/Time of Appointment
     284    ;
     285    ; Returns:
     286    ; 0 if okay
     287    ; -1 if failure
     288    N SCIEN S SCIEN=$$SCIEN(PAT,CLINIC,DATE) ; ien of appt in ^SC
     289    I SCIEN<1 QUIT "-1~No Appt can be found in file 44 for Patient "_PAT_" on "_DATE_" in clinic "_CLINIC
     290    N BSDXIENS S BSDXIENS=SCIEN_","_DATE_","_CLINIC_","
     291    S BSDXFDA(44.003,BSDXIENS,3)=$E(NOTE,1,150)
     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    QUIT 0
Note: See TracChangeset for help on using the changeset viewer.