BMCFLTR ; IHS/PHXAO/TMJ - FILTERING CRITERIA FOR REFERRAL SELECTION ;
;;4.0;REFERRED CARE INFO SYSTEM;**8**;JAN 09, 2006;Build 101
;;4.0;IHS/ITSC/FCJ ADDED REFERRAL TYPE-PRIMARY OR SECONDARY
;BMC*4.0*8;IHS/OIT/FCJ; 8-20-13;ADDED TEST FOR APPROVED (A1) REFERRAL
; This program provides the ability to use different filtering RTYP
; criteria when selecting referrals for close-out or modification
;
; the naked reference is provided by the calling program
;
; Input: RTY [=] 0 if closed referrals are not wanted (C1, C2)
; 1 if only closed referrals are wanted (C1, C2)
; 2 if only active OR approved referrals are wanted (A,A1)
; CFY [=] 1 if only current fiscal year referrals are wanted
; 0 if all fiscal years are eligible
; RTYP [=] 0 Primary Referral
; 1 Secondary Referral
; 2 BOTH
; Returns: 0 if referral does not qualify
; 1 if referral does qualify
;
FILTER(RTY,CFY,RTYP) ; EP - used to select referrals for display on screen
S RTY=$G(RTY),CFY=$G(CFY)
I '$D(^(0)) Q 0 ; no data exists at requested node
I RTY=0,$P(^(0),U,15)["C" Q 0 ; do not want closed referrals
I RTY=1,$P(^(0),U,15)'["C" Q 0 ; want only closed referrals
;I RTY=2,$P(^(0),U,15)'="A" Q 0 ; want only active referrals BMC*4.0*8
I RTY=2,$P(^(0),U,15)'?1"A".E Q 0 ; want only active OR approved referrals ;BMC*4.0*8
I CFY,$E($P(^(0),U,2),7,8)'=BMCFY Q 0 ;not from current fiscal year
I RTYP=0,$P($G(^(1)),U)'="" Q 0 ; NOT PRIMARY REFERRAL.....FCJ
I RTYP=1,$P($G(^(1)),U)="" Q 0 ; NOT A SECONDARY REFERRAL.....FCJ
Q 1 ; valid referral
BMCFLTR ; IHS/PHXAO/TMJ - FILTERING CRITERIA FOR REFERRAL SELECTION ;
+1 ;;4.0;REFERRED CARE INFO SYSTEM;**8**;JAN 09, 2006;Build 101
+2 ;;4.0;IHS/ITSC/FCJ ADDED REFERRAL TYPE-PRIMARY OR SECONDARY
+3 ;BMC*4.0*8;IHS/OIT/FCJ; 8-20-13;ADDED TEST FOR APPROVED (A1) REFERRAL
+4 ; This program provides the ability to use different filtering RTYP
+5 ; criteria when selecting referrals for close-out or modification
+6 ;
+7 ; the naked reference is provided by the calling program
+8 ;
+9 ; Input: RTY [=] 0 if closed referrals are not wanted (C1, C2)
+10 ; 1 if only closed referrals are wanted (C1, C2)
+11 ; 2 if only active OR approved referrals are wanted (A,A1)
+12 ; CFY [=] 1 if only current fiscal year referrals are wanted
+13 ; 0 if all fiscal years are eligible
+14 ; RTYP [=] 0 Primary Referral
+15 ; 1 Secondary Referral
+16 ; 2 BOTH
+17 ; Returns: 0 if referral does not qualify
+18 ; 1 if referral does qualify
+19 ;
FILTER(RTY,CFY,RTYP) ; EP - used to select referrals for display on screen
+1 SET RTY=$GET(RTY)
SET CFY=$GET(CFY)
+2 ; no data exists at requested node
IF '$DATA(^(0))
QUIT 0
+3 ; do not want closed referrals
IF RTY=0
IF $PIECE(^(0),U,15)["C"
QUIT 0
+4 ; want only closed referrals
IF RTY=1
IF $PIECE(^(0),U,15)'["C"
QUIT 0
+5 ;I RTY=2,$P(^(0),U,15)'="A" Q 0 ; want only active referrals BMC*4.0*8
+6 ; want only active OR approved referrals ;BMC*4.0*8
IF RTY=2
IF $PIECE(^(0),U,15)'?1"A".E
QUIT 0
+7 ;not from current fiscal year
IF CFY
IF $EXTRACT($PIECE(^(0),U,2),7,8)'=BMCFY
QUIT 0
+8 ; NOT PRIMARY REFERRAL.....FCJ
IF RTYP=0
IF $PIECE($GET(^(1)),U)'=""
QUIT 0
+9 ; NOT A SECONDARY REFERRAL.....FCJ
IF RTYP=1
IF $PIECE($GET(^(1)),U)=""
QUIT 0
+10 ; valid referral
QUIT 1