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