| 1 | SDAMA301 ;BPOIFO/ACS-Filter API Main Entry ; 1/3/06 12:45pm
 | 
|---|
| 2 |  ;;5.3;Scheduling;**301,347,426,508**;13 Aug 1993
 | 
|---|
| 3 |  ;PER VHA DIRECTIVE 2004-038, DO NOT MODIFY THIS ROUTINE
 | 
|---|
| 4 |  ;
 | 
|---|
| 5 |  ;**   THIS IS A SUPPORTED API: SEE DBIA #4433                   **
 | 
|---|
| 6 |  ;
 | 
|---|
| 7 |  ;*****************************************************************
 | 
|---|
| 8 |  ;              CHANGE LOG
 | 
|---|
| 9 |  ;
 | 
|---|
| 10 |  ;  DATE      PATCH       DESCRIPTION
 | 
|---|
| 11 |  ;--------  ----------    -----------------------------------------
 | 
|---|
| 12 |  ;12/04/03  SD*5.3*301    ROUTINE COMPLETED
 | 
|---|
| 13 |  ;08/06/04  SD*5.3*347    ADDITION OF A NEW FILTER - DATE APPOINTMENT
 | 
|---|
| 14 |  ;                        MADE (FIELD #16) AND 2 NEW FIELDS TO RETURN:
 | 
|---|
| 15 |  ;                        1) AUTO-REBOOKED APPT DATE/TIME (FIELD #24)
 | 
|---|
| 16 |  ;                        2) NO-SHOW/CANCEL APPT DATE/TIME (FIELD #25)
 | 
|---|
| 17 |  ;02/22/07  SD*5.3*508    ADDITION OF A NEW PARAMETER - "PURGED"
 | 
|---|
| 18 |  ;                        RETURNS NON-CANCELED VISTA APPTS THAT EXIST
 | 
|---|
| 19 |  ;                        ONLY IN SUB-FILE (#2.98).  ADDITION OF 8
 | 
|---|
| 20 |  ;                        NEW FIELDS TO RETURN:
 | 
|---|
| 21 |  ;                        1) RSA APPT ID (FIELD #26)
 | 
|---|
| 22 |  ;                        2) 2507 REQUEST IEN (FIELD #27)
 | 
|---|
| 23 |  ;                        3) DATA ENTRY CLERK (FIELD #28)
 | 
|---|
| 24 |  ;                        4) NO-SHOW/CANCELED BY (FIELD #29)
 | 
|---|
| 25 |  ;                        5) CHECK-IN USER (FIELD #30)
 | 
|---|
| 26 |  ;                        6) CHECK-OUT USER (FIELD #31)
 | 
|---|
| 27 |  ;                        7) CANCELLATION REASON (FIELD #32)
 | 
|---|
| 28 |  ;                        8) CONSULT IEN (FIELD #33)
 | 
|---|
| 29 |  ;*****************************************************************
 | 
|---|
| 30 |  ;
 | 
|---|
| 31 |  ;*****************************************************************
 | 
|---|
| 32 |  ;
 | 
|---|
| 33 |  ;               GET APPOINTMENT DATA
 | 
|---|
| 34 |  ;
 | 
|---|
| 35 |  ;INPUT
 | 
|---|
| 36 |  ;  SDINPUT   Appointment Filters (required)
 | 
|---|
| 37 |  ;  
 | 
|---|
| 38 |  ;OUTPUT
 | 
|---|
| 39 |  ;  Extrinsic call returns: 
 | 
|---|
| 40 |  ;    -1 if error
 | 
|---|
| 41 |  ;    Appointment count if no error
 | 
|---|
| 42 |  ;  If no error, data returned in:
 | 
|---|
| 43 |  ;    ^TMP($J,"SDAMA301",SORT1,SORT2,Appt Date/Time)=DATAn^DATAn^..
 | 
|---|
| 44 |  ;    where SORT1 is first sort (patient or clinic), SORT2 is
 | 
|---|
| 45 |  ;    second sort (patient or clinic), and DATAn
 | 
|---|
| 46 |  ;    is the appointment data requested for Fields 1-27
 | 
|---|
| 47 |  ;    ^TMP($J,"SDAMA301",SORT1,SORT2,Appt Date/Time,0)=DATAn^DATAn^..
 | 
|---|
| 48 |  ;    where DATAn is the appointment data requested for Fields 28-32
 | 
|---|
| 49 |  ;    (Use the MODULO Operator Ie. Field 28#27 = 1, 29#27=2 ...)
 | 
|---|
| 50 |  ;    ^TMP($J,"SDAMA301",SORT1,SORT2,Appt Date/Time,"C")=COMMENTS
 | 
|---|
| 51 |  ;  If RSA appointments are returned then the following global
 | 
|---|
| 52 |  ;    will exist detailing the source of the RSA appointments.
 | 
|---|
| 53 |  ;    ^TMP($J,"SDAMA301","SOURCE")="RSA" - From Remote RSA Database
 | 
|---|
| 54 |  ;    ^TMP($J,"SDAMA301","SOURCE")="VistA Backup" - From Local VistA
 | 
|---|
| 55 |  ;  If errors, error codes and messages returned in:
 | 
|---|
| 56 |  ;    ^TMP($J,"SDAMA301",error_code)=error_message
 | 
|---|
| 57 |  ;  
 | 
|---|
| 58 |  ;*****************************************************************
 | 
|---|
| 59 | SDAPI(SDINPUT) ;main API controller
 | 
|---|
| 60 |  N SDARRAY,SDFLTR,SDQUIT
 | 
|---|
| 61 |  S SDQUIT=0
 | 
|---|
| 62 |  S SDQUIT=$$INIT(.SDINPUT,.SDARRAY,.SDFLTR)  ;initialize environment
 | 
|---|
| 63 |  Q:(SDQUIT) -1  ;input array error
 | 
|---|
| 64 |  Q $$APPTS(.SDARRAY,.SDFLTR)  ;Retrieve VistA and RSA Appointments
 | 
|---|
| 65 |  ;
 | 
|---|
| 66 |  ;*****************************************************************
 | 
|---|
| 67 |  ;INPUT
 | 
|---|
| 68 |  ;  SDINPUT   Appointment Filters (Required / By Reference)
 | 
|---|
| 69 |  ;  SDARRAY   Array to hold working copy of Appt Filter Array
 | 
|---|
| 70 |  ;            (Required / By Reference)
 | 
|---|
| 71 |  ;  SDFLTR    Filter Flag Array (Required / By Reference)
 | 
|---|
| 72 |  ;  
 | 
|---|
| 73 |  ;OUTPUT
 | 
|---|
| 74 |  ;    Extrinsic call returns: 
 | 
|---|
| 75 |  ;      1 if error occurred initializing environment
 | 
|---|
| 76 |  ;      0 if no error occurred  
 | 
|---|
| 77 |  ;*****************************************************************
 | 
|---|
| 78 | INIT(SDINPUT,SDARRAY,SDFLTR) ;
 | 
|---|
| 79 |  K ^TMP($J,"SDAMA301")
 | 
|---|
| 80 |  ;Initialize global variables
 | 
|---|
| 81 |  N SDI,SDQUIT
 | 
|---|
| 82 |  S (SDARRAY("CNT"),SDARRAY("RSA"),SDQUIT,SDFLTR)=0
 | 
|---|
| 83 |  ;Set Field Count and Max Filter variables
 | 
|---|
| 84 |  S SDARRAY("FC")=33,SDARRAY("MF")=6
 | 
|---|
| 85 |  ;Copy input array into "working" array
 | 
|---|
| 86 |  F SDI=1:1:SDARRAY("FC") S SDARRAY(SDI)=$G(SDINPUT(SDI))
 | 
|---|
| 87 |  S SDARRAY("FLDS")=$G(SDINPUT("FLDS"))  ;fields to return to app.
 | 
|---|
| 88 |  S SDARRAY("MAX")=$G(SDINPUT("MAX"))  ;# of records to return (-/+)
 | 
|---|
| 89 |  S SDARRAY("SORT")=$G(SDINPUT("SORT"))  ;removes clinic ien from root
 | 
|---|
| 90 |  S SDARRAY("VSTAPPTS")=$G(SDINPUT("VSTAPPTS"))  ;get only VistA Appts
 | 
|---|
| 91 |  S SDARRAY("PURGED")=$G(SDINPUT("PURGED"))  ;get Purged VistA Appts
 | 
|---|
| 92 |  ;Initialize Input Array Filters as needed. Quit if error
 | 
|---|
| 93 |  D INITAE^SDAMA306(.SDARRAY)
 | 
|---|
| 94 |  Q:SDQUIT 1
 | 
|---|
| 95 |  ;Validate Input Array Filters.  Quit if error
 | 
|---|
| 96 |  I ($$VALARR^SDAMA300(.SDARRAY,.SDFLTR)=-1) S SDQUIT=1
 | 
|---|
| 97 |  Q SDQUIT
 | 
|---|
| 98 |  ;
 | 
|---|
| 99 |  ;*****************************************************************
 | 
|---|
| 100 |  ;INPUT
 | 
|---|
| 101 |  ;  SDARRAY   Array to hold working copy of Appt Filter Array
 | 
|---|
| 102 |  ;            (Required / By Reference)
 | 
|---|
| 103 |  ;  SDFLTR    Filter Flag Array (Required / By Reference)
 | 
|---|
| 104 |  ;  
 | 
|---|
| 105 |  ;OUTPUT
 | 
|---|
| 106 |  ;    Extrinsic call returns: 
 | 
|---|
| 107 |  ;      #<0 if error occurred retrieving appointments
 | 
|---|
| 108 |  ;      0 if no appointments exist (Based on Filter Criteria)
 | 
|---|
| 109 |  ;      #>0 Number of Appointments returned 
 | 
|---|
| 110 |  ;*****************************************************************
 | 
|---|
| 111 | APPTS(SDARRAY,SDFLTR) ;retrieve appointments
 | 
|---|
| 112 |  ;initialize variables
 | 
|---|
| 113 |  N SDDV
 | 
|---|
| 114 |  ;If Patient DFN populated, process by patient
 | 
|---|
| 115 |  I $G(SDARRAY(4))]"" D
 | 
|---|
| 116 |  . ;set RSA flag to true if clinic filter not defined
 | 
|---|
| 117 |  . S:($G(SDARRAY(2))']"") SDARRAY("RSA")=1
 | 
|---|
| 118 |  . ;get data
 | 
|---|
| 119 |  . D PAT^SDAMA303(.SDARRAY,.SDDV,.SDFLTR)
 | 
|---|
| 120 |  . ;if clinic filter defined and RSA flag is false
 | 
|---|
| 121 |  . ;ensure RSA does not need to be called.
 | 
|---|
| 122 |  . D:(($G(SDARRAY(2))]"")&(SDARRAY("RSA")=0)) CALLRSA^SDAMA307(.SDARRAY)
 | 
|---|
| 123 |  ;
 | 
|---|
| 124 |  ;If Patient DFN is not populated, process by clinic
 | 
|---|
| 125 |  I $G(SDARRAY(4))']"" D
 | 
|---|
| 126 |  . D CLIN^SDAMA302(.SDARRAY,.SDDV,.SDFLTR)
 | 
|---|
| 127 |  ;
 | 
|---|
| 128 |  ;--Phase II--
 | 
|---|
| 129 |  ;If RSA flag = "true" and RSA is implemented, and the user has not
 | 
|---|
| 130 |  ;requested only VistA appointments ("VSTAPPTS"=1), then get data 
 | 
|---|
| 131 |  ;from RSA
 | 
|---|
| 132 |  D:(('+SDARRAY("VSTAPPTS"))&(SDARRAY("RSA"))&($$IMP^SDAMA307())) DATA^SDAMA307(.SDARRAY)
 | 
|---|
| 133 |  ;
 | 
|---|
| 134 |  ;Pass back appointment count
 | 
|---|
| 135 |  Q SDARRAY("CNT")
 | 
|---|