BGP2REF1 ; IHS/CMI/LAB - measure AHR.A ;
;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
;
;
BETA ;EP
I $G(P)="" Q ""
I $G(EDATE)="" S EDATE=DT
I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,-365)
NEW T,X,G,D,Y,N
S T=$O(^ATXAX("B","BGP HEDIS BETA BLOCKER MEDS",0))
S X=0,G="" F S X=$O(^AUPNPREF("AA",P,50,X)) Q:X'=+X!(G) D
.Q:'$D(^ATXAX(T,21,"B",X)) ;not a Beta Blocker
.S D=0 F S D=$O(^AUPNPREF("AA",P,50,X,D)) Q:D'=+D!(G) D
..S Y=9999999-D I Y<BDATE Q
..I Y>EDATE Q ;documented after edate
..S N=0 F S N=$O(^AUPNPREF("AA",P,50,X,D,N)) Q:N'=+N!(G) D
...Q:$P($G(^AUPNPREF(N,0)),U,7)'="R"
...S G=1_U_"Beta Blocker Refusal "_$$DATE^BGP2UTL(Y)
..Q
.Q
Q G
;
ASA ;EP
;did patient have a refusal in time period?
I $G(P)="" Q ""
I $G(EDATE)="" S EDATE=DT
I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,-365)
NEW T,G,X,D,Y,N
S T=$O(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
S X=0,G="" F S X=$O(^AUPNPREF("AA",P,50,X)) Q:X'=+X!(G) D
.Q:'$D(^ATXAX(T,21,"B",X))
.S D=0 F S D=$O(^AUPNPREF("AA",P,50,X,D)) Q:D'=+D!(G) D
..S Y=9999999-D I Y<BDATE Q ;documented more than 1 year before edate
..I Y>EDATE Q ;documented after end date
..S N=0 F S N=$O(^AUPNPREF("AA",P,50,X,D,N)) Q:N'=+N!(G) D
...Q:$P($G(^AUPNPREF(N,0)),U,7)'="R"
...S G=1_U_"Aspirin Refusal "_$$DATE^BGP2UTL(Y)
..Q
.Q
I G Q G
S T=$O(^ATXAX("B","BGP ANTI-PLATELET DRUGS",0))
S X=0,G="" F S X=$O(^AUPNPREF("AA",P,50,X)) Q:X'=+X!(G) D
.Q:'$D(^ATXAX(T,21,"B",X))
.S D=0 F S D=$O(^AUPNPREF("AA",P,50,X,D)) Q:D'=+D!(G) D
..S Y=9999999-D I Y<BDATE Q ;documented more than 1 year before edate
..I Y>EDATE Q ;documented after end date
..S N=0 F S N=$O(^AUPNPREF("AA",P,50,X,D,N)) Q:N'=+N!(G) D
...Q:$P($G(^AUPNPREF(N,0)),U,7)'="R"
...S G=1_U_"Anti-Platelet Refusal "_$$DATE^BGP2UTL(Y)
..Q
.Q
Q G
ACEI ;EP
;did patient have a refusal in time period?
I $G(P)="" Q ""
I $G(EDATE)="" S EDATE=DT
I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,-365)
NEW T,G,X,D,Y,N
S T=$O(^ATXAX("B","BGP HEDIS ACEI MEDS",0))
S X=0,G="" F S X=$O(^AUPNPREF("AA",P,50,X)) Q:X'=+X!(G) D
.Q:'$D(^ATXAX(T,21,"B",X))
.S D=0 F S D=$O(^AUPNPREF("AA",P,50,X,D)) Q:D'=+D!(G) D
..S Y=9999999-D I Y<BDATE Q ;documented more than 1 year before edate
..I Y>EDATE Q ;documented after end date
..S N=0 F S N=$O(^AUPNPREF("AA",P,50,X,D,N)) Q:N'=+N!(G) D
...Q:$P($G(^AUPNPREF(N,0)),U,7)'="R"
...S G=1_U_"ACEI Refusal "_$$DATE^BGP2UTL(Y)
..Q
.Q
Q G
;
ARB ;EP
;did patient have a refusal in time period?
I $G(P)="" Q ""
I $G(EDATE)="" S EDATE=DT
I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,-365)
NEW T,G,X,D,Y,N
S T=$O(^ATXAX("B","BGP HEDIS ARB MEDS",0))
S X=0,G="" F S X=$O(^AUPNPREF("AA",P,50,X)) Q:X'=+X!(G) D
.Q:'$D(^ATXAX(T,21,"B",X))
.S D=0 F S D=$O(^AUPNPREF("AA",P,50,X,D)) Q:D'=+D!(G) D
..S Y=9999999-D I Y<BDATE Q ;documented more than 1 year before edate
..I Y>EDATE Q ;documented after end date
..S N=0 F S N=$O(^AUPNPREF("AA",P,50,X,D,N)) Q:N'=+N!(G) D
...;Q:$P($G(^AUPNPREF(N,0)),U,7)'="N"
...S G=1_U_"ARB Refusal "_$$DATE^BGP2UTL(Y)
..Q
.Q
Q G
;
STATIN ;EP
;did patient have a refusal in time period?
I $G(P)="" Q ""
I $G(EDATE)="" S EDATE=DT
I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,-365)
NEW T,G,X,D,Y,N
S T=$O(^ATXAX("B","BGP HEDIS STATIN MEDS",0))
S X=0,G="" F S X=$O(^AUPNPREF("AA",P,50,X)) Q:X'=+X!(G) D
.Q:'$D(^ATXAX(T,21,"B",X))
.S D=0 F S D=$O(^AUPNPREF("AA",P,50,X,D)) Q:D'=+D!(G) D
..S Y=9999999-D I Y<BDATE Q ;documented more than 1 year before edate
..I Y>EDATE Q ;documented after end date
..S N=0 F S N=$O(^AUPNPREF("AA",P,50,X,D,N)) Q:N'=+N!(G) D
...Q:$P($G(^AUPNPREF(N,0)),U,7)'="R"
...S G=1_U_"Statin Refusal "_$$DATE^BGP2UTL(Y)
..Q
.Q
Q G
BGP2REF1 ; IHS/CMI/LAB - measure AHR.A ;
+1 ;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
+2 ;
+3 ;
BETA ;EP
+1 IF $GET(P)=""
QUIT ""
+2 IF $GET(EDATE)=""
SET EDATE=DT
+3 IF $GET(BDATE)=""
SET BDATE=$$FMADD^XLFDT(EDATE,-365)
+4 NEW T,X,G,D,Y,N
+5 SET T=$ORDER(^ATXAX("B","BGP HEDIS BETA BLOCKER MEDS",0))
+6 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+7 ;not a Beta Blocker
IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+8 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D!(G)
QUIT
Begin DoDot:2
+9 SET Y=9999999-D
IF Y<BDATE
QUIT
+10 ;documented after edate
IF Y>EDATE
QUIT
+11 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N!(G)
QUIT
Begin DoDot:3
+12 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="R"
QUIT
+13 SET G=1_U_"Beta Blocker Refusal "_$$DATE^BGP2UTL(Y)
End DoDot:3
+14 QUIT
End DoDot:2
+15 QUIT
End DoDot:1
+16 QUIT G
+17 ;
ASA ;EP
+1 ;did patient have a refusal in time period?
+2 IF $GET(P)=""
QUIT ""
+3 IF $GET(EDATE)=""
SET EDATE=DT
+4 IF $GET(BDATE)=""
SET BDATE=$$FMADD^XLFDT(EDATE,-365)
+5 NEW T,G,X,D,Y,N
+6 SET T=$ORDER(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
+7 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+8 IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+9 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D!(G)
QUIT
Begin DoDot:2
+10 ;documented more than 1 year before edate
SET Y=9999999-D
IF Y<BDATE
QUIT
+11 ;documented after end date
IF Y>EDATE
QUIT
+12 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N!(G)
QUIT
Begin DoDot:3
+13 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="R"
QUIT
+14 SET G=1_U_"Aspirin Refusal "_$$DATE^BGP2UTL(Y)
End DoDot:3
+15 QUIT
End DoDot:2
+16 QUIT
End DoDot:1
+17 IF G
QUIT G
+18 SET T=$ORDER(^ATXAX("B","BGP ANTI-PLATELET DRUGS",0))
+19 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+20 IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+21 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D!(G)
QUIT
Begin DoDot:2
+22 ;documented more than 1 year before edate
SET Y=9999999-D
IF Y<BDATE
QUIT
+23 ;documented after end date
IF Y>EDATE
QUIT
+24 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N!(G)
QUIT
Begin DoDot:3
+25 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="R"
QUIT
+26 SET G=1_U_"Anti-Platelet Refusal "_$$DATE^BGP2UTL(Y)
End DoDot:3
+27 QUIT
End DoDot:2
+28 QUIT
End DoDot:1
+29 QUIT G
ACEI ;EP
+1 ;did patient have a refusal in time period?
+2 IF $GET(P)=""
QUIT ""
+3 IF $GET(EDATE)=""
SET EDATE=DT
+4 IF $GET(BDATE)=""
SET BDATE=$$FMADD^XLFDT(EDATE,-365)
+5 NEW T,G,X,D,Y,N
+6 SET T=$ORDER(^ATXAX("B","BGP HEDIS ACEI MEDS",0))
+7 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+8 IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+9 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D!(G)
QUIT
Begin DoDot:2
+10 ;documented more than 1 year before edate
SET Y=9999999-D
IF Y<BDATE
QUIT
+11 ;documented after end date
IF Y>EDATE
QUIT
+12 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N!(G)
QUIT
Begin DoDot:3
+13 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="R"
QUIT
+14 SET G=1_U_"ACEI Refusal "_$$DATE^BGP2UTL(Y)
End DoDot:3
+15 QUIT
End DoDot:2
+16 QUIT
End DoDot:1
+17 QUIT G
+18 ;
ARB ;EP
+1 ;did patient have a refusal in time period?
+2 IF $GET(P)=""
QUIT ""
+3 IF $GET(EDATE)=""
SET EDATE=DT
+4 IF $GET(BDATE)=""
SET BDATE=$$FMADD^XLFDT(EDATE,-365)
+5 NEW T,G,X,D,Y,N
+6 SET T=$ORDER(^ATXAX("B","BGP HEDIS ARB MEDS",0))
+7 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+8 IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+9 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D!(G)
QUIT
Begin DoDot:2
+10 ;documented more than 1 year before edate
SET Y=9999999-D
IF Y<BDATE
QUIT
+11 ;documented after end date
IF Y>EDATE
QUIT
+12 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N!(G)
QUIT
Begin DoDot:3
+13 ;Q:$P($G(^AUPNPREF(N,0)),U,7)'="N"
+14 SET G=1_U_"ARB Refusal "_$$DATE^BGP2UTL(Y)
End DoDot:3
+15 QUIT
End DoDot:2
+16 QUIT
End DoDot:1
+17 QUIT G
+18 ;
STATIN ;EP
+1 ;did patient have a refusal in time period?
+2 IF $GET(P)=""
QUIT ""
+3 IF $GET(EDATE)=""
SET EDATE=DT
+4 IF $GET(BDATE)=""
SET BDATE=$$FMADD^XLFDT(EDATE,-365)
+5 NEW T,G,X,D,Y,N
+6 SET T=$ORDER(^ATXAX("B","BGP HEDIS STATIN MEDS",0))
+7 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+8 IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+9 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D!(G)
QUIT
Begin DoDot:2
+10 ;documented more than 1 year before edate
SET Y=9999999-D
IF Y<BDATE
QUIT
+11 ;documented after end date
IF Y>EDATE
QUIT
+12 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N!(G)
QUIT
Begin DoDot:3
+13 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="R"
QUIT
+14 SET G=1_U_"Statin Refusal "_$$DATE^BGP2UTL(Y)
End DoDot:3
+15 QUIT
End DoDot:2
+16 QUIT
End DoDot:1
+17 QUIT G