Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: SDAMA301

SDAMA301.m

Go to the documentation of this file.
  1. SDAMA301 ;BPOIFO/ACS-Filter API Main Entry ; 1/3/06 12:45pm
  1. ;;5.3;Scheduling;**301,347,426,508,1015**;13 Aug 1993;Build 21
  1. ;PER VHA DIRECTIVE 2004-038, DO NOT MODIFY THIS ROUTINE
  1. ;
  1. ;** THIS IS A SUPPORTED API: SEE DBIA #4433 **
  1. ;
  1. ;*****************************************************************
  1. ; CHANGE LOG
  1. ;
  1. ; DATE PATCH DESCRIPTION
  1. ;-------- ---------- -----------------------------------------
  1. ;12/04/03 SD*5.3*301 ROUTINE COMPLETED
  1. ;08/06/04 SD*5.3*347 ADDITION OF A NEW FILTER - DATE APPOINTMENT
  1. ; MADE (FIELD #16) AND 2 NEW FIELDS TO RETURN:
  1. ; 1) AUTO-REBOOKED APPT DATE/TIME (FIELD #24)
  1. ; 2) NO-SHOW/CANCEL APPT DATE/TIME (FIELD #25)
  1. ;02/22/07 SD*5.3*508 ADDITION OF A NEW PARAMETER - "PURGED"
  1. ; RETURNS NON-CANCELED VISTA APPTS THAT EXIST
  1. ; ONLY IN SUB-FILE (#2.98). ADDITION OF 8
  1. ; NEW FIELDS TO RETURN:
  1. ; 1) RSA APPT ID (FIELD #26)
  1. ; 2) 2507 REQUEST IEN (FIELD #27)
  1. ; 3) DATA ENTRY CLERK (FIELD #28)
  1. ; 4) NO-SHOW/CANCELED BY (FIELD #29)
  1. ; 5) CHECK-IN USER (FIELD #30)
  1. ; 6) CHECK-OUT USER (FIELD #31)
  1. ; 7) CANCELLATION REASON (FIELD #32)
  1. ; 8) CONSULT IEN (FIELD #33)
  1. ;*****************************************************************
  1. ;
  1. ;*****************************************************************
  1. ;
  1. ; GET APPOINTMENT DATA
  1. ;
  1. ;INPUT
  1. ; SDINPUT Appointment Filters (required)
  1. ;
  1. ;OUTPUT
  1. ; Extrinsic call returns:
  1. ; -1 if error
  1. ; Appointment count if no error
  1. ; If no error, data returned in:
  1. ; ^TMP($J,"SDAMA301",SORT1,SORT2,Appt Date/Time)=DATAn^DATAn^..
  1. ; where SORT1 is first sort (patient or clinic), SORT2 is
  1. ; second sort (patient or clinic), and DATAn
  1. ; is the appointment data requested for Fields 1-27
  1. ; ^TMP($J,"SDAMA301",SORT1,SORT2,Appt Date/Time,0)=DATAn^DATAn^..
  1. ; where DATAn is the appointment data requested for Fields 28-32
  1. ; (Use the MODULO Operator Ie. Field 28#27 = 1, 29#27=2 ...)
  1. ; ^TMP($J,"SDAMA301",SORT1,SORT2,Appt Date/Time,"C")=COMMENTS
  1. ; If RSA appointments are returned then the following global
  1. ; will exist detailing the source of the RSA appointments.
  1. ; ^TMP($J,"SDAMA301","SOURCE")="RSA" - From Remote RSA Database
  1. ; ^TMP($J,"SDAMA301","SOURCE")="VistA Backup" - From Local VistA
  1. ; If errors, error codes and messages returned in:
  1. ; ^TMP($J,"SDAMA301",error_code)=error_message
  1. ;
  1. ;*****************************************************************
  1. SDAPI(SDINPUT) ;main API controller
  1. N SDARRAY,SDFLTR,SDQUIT
  1. S SDQUIT=0
  1. S SDQUIT=$$INIT(.SDINPUT,.SDARRAY,.SDFLTR) ;initialize environment
  1. Q:(SDQUIT) -1 ;input array error
  1. Q $$APPTS(.SDARRAY,.SDFLTR) ;Retrieve VistA and RSA Appointments
  1. ;
  1. ;*****************************************************************
  1. ;INPUT
  1. ; SDINPUT Appointment Filters (Required / By Reference)
  1. ; SDARRAY Array to hold working copy of Appt Filter Array
  1. ; (Required / By Reference)
  1. ; SDFLTR Filter Flag Array (Required / By Reference)
  1. ;
  1. ;OUTPUT
  1. ; Extrinsic call returns:
  1. ; 1 if error occurred initializing environment
  1. ; 0 if no error occurred
  1. ;*****************************************************************
  1. INIT(SDINPUT,SDARRAY,SDFLTR) ;
  1. K ^TMP($J,"SDAMA301")
  1. ;Initialize global variables
  1. N SDI,SDQUIT
  1. S (SDARRAY("CNT"),SDARRAY("RSA"),SDQUIT,SDFLTR)=0
  1. ;Set Field Count and Max Filter variables
  1. S SDARRAY("FC")=33,SDARRAY("MF")=6
  1. ;Copy input array into "working" array
  1. F SDI=1:1:SDARRAY("FC") S SDARRAY(SDI)=$G(SDINPUT(SDI))
  1. S SDARRAY("FLDS")=$G(SDINPUT("FLDS")) ;fields to return to app.
  1. S SDARRAY("MAX")=$G(SDINPUT("MAX")) ;# of records to return (-/+)
  1. S SDARRAY("SORT")=$G(SDINPUT("SORT")) ;removes clinic ien from root
  1. S SDARRAY("VSTAPPTS")=$G(SDINPUT("VSTAPPTS")) ;get only VistA Appts
  1. S SDARRAY("PURGED")=$G(SDINPUT("PURGED")) ;get Purged VistA Appts
  1. ;Initialize Input Array Filters as needed. Quit if error
  1. D INITAE^SDAMA306(.SDARRAY)
  1. Q:SDQUIT 1
  1. ;Validate Input Array Filters. Quit if error
  1. I ($$VALARR^SDAMA300(.SDARRAY,.SDFLTR)=-1) S SDQUIT=1
  1. Q SDQUIT
  1. ;
  1. ;*****************************************************************
  1. ;INPUT
  1. ; SDARRAY Array to hold working copy of Appt Filter Array
  1. ; (Required / By Reference)
  1. ; SDFLTR Filter Flag Array (Required / By Reference)
  1. ;
  1. ;OUTPUT
  1. ; Extrinsic call returns:
  1. ; #<0 if error occurred retrieving appointments
  1. ; 0 if no appointments exist (Based on Filter Criteria)
  1. ; #>0 Number of Appointments returned
  1. ;*****************************************************************
  1. APPTS(SDARRAY,SDFLTR) ;retrieve appointments
  1. ;initialize variables
  1. N SDDV
  1. ;If Patient DFN populated, process by patient
  1. I $G(SDARRAY(4))]"" D
  1. . ;set RSA flag to true if clinic filter not defined
  1. . S:($G(SDARRAY(2))']"") SDARRAY("RSA")=1
  1. . ;get data
  1. . D PAT^SDAMA303(.SDARRAY,.SDDV,.SDFLTR)
  1. . ;if clinic filter defined and RSA flag is false
  1. . ;ensure RSA does not need to be called.
  1. . D:(($G(SDARRAY(2))]"")&(SDARRAY("RSA")=0)) CALLRSA^SDAMA307(.SDARRAY)
  1. ;
  1. ;If Patient DFN is not populated, process by clinic
  1. I $G(SDARRAY(4))']"" D
  1. . D CLIN^SDAMA302(.SDARRAY,.SDDV,.SDFLTR)
  1. ;
  1. ;--Phase II--
  1. ;If RSA flag = "true" and RSA is implemented, and the user has not
  1. ;requested only VistA appointments ("VSTAPPTS"=1), then get data
  1. ;from RSA
  1. D:(('+SDARRAY("VSTAPPTS"))&(SDARRAY("RSA"))&($$IMP^SDAMA307())) DATA^SDAMA307(.SDARRAY)
  1. ;
  1. ;Pass back appointment count
  1. Q SDARRAY("CNT")