SDAMA304 ;BPOIFO/ACS-Filter API Apply Filters ; 6/21/05 1:50pm
;;5.3;Scheduling;**301,347,508**;13 Aug 1993
;PER VHA DIRECTIVE 2004-038, DO NOT MODIFY THIS ROUTINE
;
;*****************************************************************
; 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 SEE SDAMA301 FOR CHANGE LIST
;*****************************************************************
;
;*****************************************************************
;
; APPLY FILTERS (Extrinsic call)
;
;INPUT
; SDFTYPE Filter Type (P-patient or C-clinic)
; SDARRAY Appointment Filter array
; SDFLTR Filter Flags array
; SDDV Appointment Data Values array
;
;OUTPUT
; SDMATCH -1 if no match
; 1 if match
;*****************************************************************
MATCH(SDFTYPE,SDARRAY,SDFLTR,SDDV) ;
N SDMATCH,SDX,SDCLIEN
S SDMATCH=0
;apply patient or clinic filters
I SDFTYPE="P" D PMATCH(.SDARRAY,.SDMATCH)
I SDFTYPE="C" D CMATCH(.SDARRAY,.SDMATCH)
Q SDMATCH
PMATCH(SDARRAY,SDMATCH) ;Apply ^DPT-related filters
S SDMATCH=1
;Clinic
I SDFLTR(2) D
. S SDDV(2)=$P($G(SDARRAY("DPT0")),"^",1)
. I SDDV(2)']"" S SDMATCH=0 Q
. ;apply filter to list or global
. I SDARRAY("CLNGBL")=1 D
.. S SDX=SDARRAY(2),SDCLIEN=SDDV(2)
.. I '$D(@(SDX_"SDCLIEN)")) S SDMATCH=0
. I SDARRAY("CLNGBL")=0 D
.. I ((";"_$G(SDARRAY(2))_";")'[(";"_SDDV(2)_";")) S SDMATCH=0
Q:'SDMATCH
;Appointment Status
I SDFLTR(3) D
. N SDSTAT,SDTEMP
. S SDTEMP=$P($G(SDARRAY("DPT0")),"^",2)
. S SDSTAT=$S($G(SDTEMP)="":"R",SDTEMP="I":"I",SDTEMP="C":"CC",1:"X")
. I SDSTAT="X" S SDSTAT=$S(SDTEMP="CA":"CCR",SDTEMP="PC":"CP",1:"X")
. I SDSTAT="X" S SDSTAT=$S(SDTEMP="PCA":"CPR",SDTEMP="N":"NS",1:"X")
. I SDSTAT="X" S SDSTAT=$S(SDTEMP="NA":"NSR",SDTEMP="NT":"NT",1:"X")
. S SDDV(3)=SDSTAT
. I ((";"_$G(SDARRAY(3))_";")'[(";"_SDDV(3)_";")) S SDMATCH=0
Q:'SDMATCH
;Encounter Exists (DEPRECATED 11/10/06 JFW)
;I SDFLTR(12) D
;.;get appointment encounter information
;.S SDDV(12)=$P($G(SDARRAY("DPT0")),"^",20)
;.;compare encounter information to filter value
;.; Y AND NULL match or N and NOT NULL match
;.I (((SDARRAY("ENCTR")["Y")&(SDDV(12)']""))!((SDARRAY("ENCTR")["N")&(SDDV(12)]""))) D
;..S SDMATCH=0
;Date Appointment Made
I SDFLTR(16) D
.;get date appointment made from specific appt
.S SDDV(16)=$P($G(SDARRAY("DPT0")),"^",19)
.;compare date with range of dates specified
.I $S(+SDDV(16)=SDARRAY("DAMFR"):0,+SDDV(16)=SDARRAY("DAMTO"):0,1:1) D
..I ((+SDDV(16)'>SDARRAY("DAMFR"))!(+SDDV(16)'<SDARRAY("DAMTO"))) D
...S SDMATCH=0
Q
;
CMATCH(SDARRAY,SDMATCH) ;Apply ^SC-related filters
N SDAMCLIN,SDSTOP
S SDMATCH=1
;Primary Stop Code
I SDFLTR(13) D
. S SDAMCLIN=+$G(SDARRAY("DPT0"))
. I $G(SDAMCLIN)="" S SDMATCH=0 Q
. S SDSTOP=$P($G(^SC(SDAMCLIN,0)),"^",7)
. I $G(SDSTOP)="" S SDMATCH=0 Q
. S SDDV(13)=$P($G(^DIC(40.7,SDSTOP,0)),"^",2)
. I $G(SDDV(13))="" S SDMATCH=0 Q
. I ((";"_$G(SDARRAY(13))_";")'[(";"_SDDV(13)_";")) S SDMATCH=0
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDAMA304 3558 printed Dec 13, 2024@02:47:19 Page 2
SDAMA304 ;BPOIFO/ACS-Filter API Apply Filters ; 6/21/05 1:50pm
+1 ;;5.3;Scheduling;**301,347,508**;13 Aug 1993
+2 ;PER VHA DIRECTIVE 2004-038, DO NOT MODIFY THIS ROUTINE
+3 ;
+4 ;*****************************************************************
+5 ; CHANGE LOG
+6 ;
+7 ; DATE PATCH DESCRIPTION
+8 ;-------- ---------- -----------------------------------------
+9 ;12/04/03 SD*5.3*301 ROUTINE COMPLETED
+10 ;08/06/04 SD*5.3*347 ADDITION OF A NEW FILTER - DATE APPOINTMENT
+11 ; MADE (FIELD #16) AND 2 NEW FIELDS TO RETURN:
+12 ; 1) AUTO-REBOOKED APPT DATE/TIME (FIELD #24)
+13 ; 2) NO-SHOW/CANCEL APPT DATE/TIME (FIELD #25)
+14 ;02/22/07 SD*5.3*508 SEE SDAMA301 FOR CHANGE LIST
+15 ;*****************************************************************
+16 ;
+17 ;*****************************************************************
+18 ;
+19 ; APPLY FILTERS (Extrinsic call)
+20 ;
+21 ;INPUT
+22 ; SDFTYPE Filter Type (P-patient or C-clinic)
+23 ; SDARRAY Appointment Filter array
+24 ; SDFLTR Filter Flags array
+25 ; SDDV Appointment Data Values array
+26 ;
+27 ;OUTPUT
+28 ; SDMATCH -1 if no match
+29 ; 1 if match
+30 ;*****************************************************************
MATCH(SDFTYPE,SDARRAY,SDFLTR,SDDV) ;
+1 NEW SDMATCH,SDX,SDCLIEN
+2 SET SDMATCH=0
+3 ;apply patient or clinic filters
+4 IF SDFTYPE="P"
DO PMATCH(.SDARRAY,.SDMATCH)
+5 IF SDFTYPE="C"
DO CMATCH(.SDARRAY,.SDMATCH)
+6 QUIT SDMATCH
PMATCH(SDARRAY,SDMATCH) ;Apply ^DPT-related filters
+1 SET SDMATCH=1
+2 ;Clinic
+3 IF SDFLTR(2)
Begin DoDot:1
+4 SET SDDV(2)=$PIECE($GET(SDARRAY("DPT0")),"^",1)
+5 IF SDDV(2)']""
SET SDMATCH=0
QUIT
+6 ;apply filter to list or global
+7 IF SDARRAY("CLNGBL")=1
Begin DoDot:2
+8 SET SDX=SDARRAY(2)
SET SDCLIEN=SDDV(2)
+9 IF '$DATA(@(SDX_"SDCLIEN)"))
SET SDMATCH=0
End DoDot:2
+10 IF SDARRAY("CLNGBL")=0
Begin DoDot:2
+11 IF ((";"_$GET(SDARRAY(2))_";")'[(";"_SDDV(2)_";"))
SET SDMATCH=0
End DoDot:2
End DoDot:1
+12 if 'SDMATCH
QUIT
+13 ;Appointment Status
+14 IF SDFLTR(3)
Begin DoDot:1
+15 NEW SDSTAT,SDTEMP
+16 SET SDTEMP=$PIECE($GET(SDARRAY("DPT0")),"^",2)
+17 SET SDSTAT=$SELECT($GET(SDTEMP)="":"R",SDTEMP="I":"I",SDTEMP="C":"CC",1:"X")
+18 IF SDSTAT="X"
SET SDSTAT=$SELECT(SDTEMP="CA":"CCR",SDTEMP="PC":"CP",1:"X")
+19 IF SDSTAT="X"
SET SDSTAT=$SELECT(SDTEMP="PCA":"CPR",SDTEMP="N":"NS",1:"X")
+20 IF SDSTAT="X"
SET SDSTAT=$SELECT(SDTEMP="NA":"NSR",SDTEMP="NT":"NT",1:"X")
+21 SET SDDV(3)=SDSTAT
+22 IF ((";"_$GET(SDARRAY(3))_";")'[(";"_SDDV(3)_";"))
SET SDMATCH=0
End DoDot:1
+23 if 'SDMATCH
QUIT
+24 ;Encounter Exists (DEPRECATED 11/10/06 JFW)
+25 ;I SDFLTR(12) D
+26 ;.;get appointment encounter information
+27 ;.S SDDV(12)=$P($G(SDARRAY("DPT0")),"^",20)
+28 ;.;compare encounter information to filter value
+29 ;.; Y AND NULL match or N and NOT NULL match
+30 ;.I (((SDARRAY("ENCTR")["Y")&(SDDV(12)']""))!((SDARRAY("ENCTR")["N")&(SDDV(12)]""))) D
+31 ;..S SDMATCH=0
+32 ;Date Appointment Made
+33 IF SDFLTR(16)
Begin DoDot:1
+34 ;get date appointment made from specific appt
+35 SET SDDV(16)=$PIECE($GET(SDARRAY("DPT0")),"^",19)
+36 ;compare date with range of dates specified
+37 IF $SELECT(+SDDV(16)=SDARRAY("DAMFR"):0,+SDDV(16)=SDARRAY("DAMTO"):0,1:1)
Begin DoDot:2
+38 IF ((+SDDV(16)'>SDARRAY("DAMFR"))!(+SDDV(16)'<SDARRAY("DAMTO")))
Begin DoDot:3
+39 SET SDMATCH=0
End DoDot:3
End DoDot:2
End DoDot:1
+40 QUIT
+41 ;
CMATCH(SDARRAY,SDMATCH) ;Apply ^SC-related filters
+1 NEW SDAMCLIN,SDSTOP
+2 SET SDMATCH=1
+3 ;Primary Stop Code
+4 IF SDFLTR(13)
Begin DoDot:1
+5 SET SDAMCLIN=+$GET(SDARRAY("DPT0"))
+6 IF $GET(SDAMCLIN)=""
SET SDMATCH=0
QUIT
+7 SET SDSTOP=$PIECE($GET(^SC(SDAMCLIN,0)),"^",7)
+8 IF $GET(SDSTOP)=""
SET SDMATCH=0
QUIT
+9 SET SDDV(13)=$PIECE($GET(^DIC(40.7,SDSTOP,0)),"^",2)
+10 IF $GET(SDDV(13))=""
SET SDMATCH=0
QUIT
+11 IF ((";"_$GET(SDARRAY(13))_";")'[(";"_SDDV(13)_";"))
SET SDMATCH=0
End DoDot:1
+12 QUIT