BGP7D721 ; IHS/CMI/LAB - measure AHR.A ;
;;17.1;IHS CLINICAL REPORTING;;MAY 10, 2017;Build 29
;
;
IAHRA ;EP
S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7,BGPN8,BGPN9,BGPN10,BGPN11,BGPN12,BGPN13,BGPN14,BGPN15,BGPN16,BGPN17,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9)=0
S BGPVALUE=""
I BGPAGEB<22 S BGPSTOP=1 Q
I 'BGPACTCL S BGPSTOP=1 Q ;must be active clinical
S BGPIHD=$$CHD^BGP7D729(DFN,BGPBDATE,BGPEDATE)
I 'BGPIHD S BGPSTOP=1 Q ;no IHD
S BGPD1=1
I BGPDMD2 S BGPD3=1
I 'BGPDMD2 S BGPD2=1
K BGPBETA
S BGPBETA("RX")=$$BETA(DFN,BGPBDATE,BGPEDATE,179) ;get 1_U_# days
I BGPBETA("RX") S BGPN2=1 ;pt has 180 days of beta blocker
;I 'BGPN2 S BGPBETA("REF")=$$BETAREF(DFN,BGPBDATE,BGPEDATE) I BGPBETA("REF") S BGPN3=1
I 'BGPN2 S BGPBETA("CONTRA")=$$BETACONT(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,BGPBDATE,BGPEDATE) I BGPBETA("CONTRA") S BGPN4=1 ;beta Contraindication
I 'BGPN2 S BGPBETA("ADR")=$$BETAALG1^BGP7D72(DFN,BGPEDATE) I BGPBETA("ADR") S BGPN4=1
I (BGPN2+BGPN4) S BGPN1=1
K BGPASA
S BGPASA("RX")=$$ASA(DFN,BGPBDATE,BGPEDATE,179) ;get 1_U_# days
I BGPASA("RX") S BGPN6=1 ;pt has 180 days of beta blocker
;I 'BGPN6 S BGPASA("REF")=$$ASAREF(DFN,BGPBDATE,BGPEDATE) I BGPASA("REF") S BGPN7=1
I 'BGPN6 S BGPASA("CONTRA")=$$ASACONTR(DFN,BGPBDATE,BGPEDATE,179) I BGPASA("CONTRA") S BGPN8=1 ;beta Contraindication
I 'BGPN6 S BGPASA("ADR")=$$ASAALLEG(DFN,BGPEDATE) I BGPASA("ADR") S BGPN8=1
I (BGPN6+BGPN8) S BGPN5=1
K BGPACE
S BGPACE("RX")=$$ACERX^BGP7D722(DFN,BGPBDATE,BGPEDATE,179) ;get 1_U_# days
I BGPACE("RX") S BGPN10=1 ;pt has 180 days of ACE
;I 'BGPN10 S BGPACE("REF")=$$ACEREF^BGP7D722(DFN,BGPBDATE,BGPEDATE) I BGPACE("REF") S BGPN11=1
I 'BGPN10 S BGPACE("CONTRA")=$$ACECONT^BGP7D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,BGPBDATE,BGPEDATE,BGPBDATE) I BGPACE("CONTRA") S BGPN12=1 ;beta Contraindication
I 'BGPN10 S BGPACE("ADR")=$$ACEALG^BGP7D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE) I BGPACE("ADR") S BGPN12=1
I (BGPN10+BGPN12) S BGPN9=1
K BGPSTAT
S BGPSTAT("RX")=$$STATRX^BGP7D722(DFN,BGPBDATE,BGPEDATE,179) ;get 1_U_# days
I BGPSTAT("RX") S BGPN14=1 ;pt has 180 days of STAT
I 'BGPN14 S BGPSTAT("CONTRA")=$$STATCON^BGP7D722(DFN,BGPBDATE,BGPEDATE,BGPBDATE,BGPEDATE) I BGPSTAT("CONTRA") S BGPN16=1 ;beta Contraindication
I 'BGPN14 S BGPSTAT("ADR")=$$STATALG^BGP7D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,BGPBDATE,BGPEDATE) I BGPSTAT("ADR") S BGPN16=1
I (BGPN14+BGPN16) S BGPN13=1
I BGPN1,BGPN5,BGPN9,BGPN13 S BGPN17=1
S BGPVALUE="CHD"_$S(BGPD3:";AD",1:"")_"|||"
S BGPVALUE=BGPVALUE_$S(BGPN17:"ALL MEDS; ",1:"")
I BGPN2!(BGPN3)!(BGPN4) S BGPVALUE=BGPVALUE_$S($P(BGPVALUE,"|||",2)]"":" ",1:"") S BGPVALUE=BGPVALUE_"BETA: " F X="RX","REF","CONTRA","ADR" I $P($G(BGPBETA(X)),U,1),$P($G(BGPBETA(X)),U,2)]"" D
.S BGPVALUE=BGPVALUE_$P(BGPBETA(X),U,2)_$S($P(BGPBETA(X),U,3)]"":" "_$P(BGPBETA(X),U,3),1:"")
I BGPN6!(BGPN7)!(BGPN8) S BGPVALUE=BGPVALUE_$S($P(BGPVALUE,"|||",2)]"":"; ",1:"") S BGPVALUE=BGPVALUE_"ASA: " F X="RX","REF","CONTRA","ADR" I $P($G(BGPASA(X)),U,1),$P($G(BGPASA(X)),U,2)]"" D
.S BGPVALUE=BGPVALUE_$P(BGPASA(X),U,2)_$S($P(BGPASA(X),U,3)]"":" "_$P(BGPASA(X),U,3),1:"")
I BGPN10!(BGPN11)!(BGPN12) S BGPVALUE=BGPVALUE_$S($P(BGPVALUE,"|||",2)]"":"; ",1:"") S BGPVALUE=BGPVALUE_"ACEI/ARB: " F X="RX","REF","CONTRA","ADR" I $P($G(BGPACE(X)),U,1),$P($G(BGPACE(X)),U,2)]"" D
.S BGPVALUE=BGPVALUE_$P(BGPACE(X),U,2)_$S($P(BGPACE(X),U,3)]"":" "_$P(BGPACE(X),U,3),1:"")
I BGPN14!(BGPN15)!(BGPN16) S BGPVALUE=BGPVALUE_$S($P(BGPVALUE,"|||",2)]"":"; ",1:"") S BGPVALUE=BGPVALUE_"STATIN: " F X="RX","REF","CONTRA","ADR" I $P($G(BGPSTAT(X)),U,1),$P($G(BGPSTAT(X)),U,2)]"" D
.S BGPVALUE=BGPVALUE_$P(BGPSTAT(X),U,2)_$S($P(BGPSTAT(X),U,3)]"":" "_$P(BGPSTAT(X),U,3),1:"")
K ^TMP($J)
Q
BETA(P,BDATE,EDATE,BGPNDAYS) ;EP
NEW BGPMEDS1,K,R,T,T1,X,Y,G,D,N,J,V,S
K BGPMEDS1
S K=0,R=""
D GETMEDS^BGP7UTL2(P,BDATE,EDATE,,,,,.BGPMEDS1)
I '$D(BGPMEDS1) Q ""
S T=$O(^ATXAX("B","BGP HEDIS BETA BLOCKER MEDS",0))
S T1=$O(^ATXAX("B","BGP HEDIS BETA BLOCKER NDC",0))
S X=0 F S X=$O(BGPMEDS1(X)) Q:X'=+X S Y=+$P(BGPMEDS1(X),U,4) D
.Q:'$D(^AUPNVMED(Y,0))
.Q:$$UP^XLFSTR($P($G(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
.S G=0
.S D=$P(^AUPNVMED(Y,0),U)
.I T,$D(^ATXAX(T,21,"B",D)) S G=1 G BETA1
.S N=$P($G(^PSDRUG(D,2)),U,4)
.I N]"",T1,$D(^ATXAX(T1,21,"B",N)) S G=1
.Q:'G
BETA1 .;
.S J=$P(^AUPNVMED(Y,0),U,8)
.S V=$P(^AUPNVMED(Y,0),U,3)
.Q:'V
.Q:'$D(^AUPNVSIT(V,0))
.S S=$$DAYS^BGP7D82(Y,V,EDATE)
.S K=S+K ;TOTAL DAYS SUPPLY
.I R]"" S R=R_";"
.S R=R_$$DATE^BGP7UTL($P($P(^AUPNVSIT(V,0),U),"."))_"("_S_")"
;I K>BGPNDAYS Q 1_U_R_" "_"("_K_" TOTAL DAYS)"
I K>BGPNDAYS Q 1_U_"("_K_" TOTAL DAYS)"
BETAPRIO ;now add in any before BEG DATE
K BGPMEDS1
D GETMEDS^BGP7UTL2(P,$$FMADD^XLFDT(BDATE,-365),BDATE,,,,,.BGPMEDS1)
I '$D(BGPMEDS1) Q ""
S X=0 F S X=$O(BGPMEDS1(X)) Q:X'=+X S Y=+$P(BGPMEDS1(X),U,4) D
.Q:'$D(^AUPNVMED(Y,0))
.Q:$$UP^XLFSTR($P($G(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
.S G=0
.S D=$P(^AUPNVMED(Y,0),U)
.I T,$D(^ATXAX(T,21,"B",D)) S G=1 G BETA2
.S N=$P($G(^PSDRUG(D,2)),U,4)
.I N]"",T1,$D(^ATXAX(T1,21,"B",N)) S G=1
.Q:'G
BETA2 .;
.S J=$P(^AUPNVMED(Y,0),U,8)
.S V=$P(^AUPNVMED(Y,0),U,3)
.Q:'V
.Q:'$D(^AUPNVSIT(V,0))
.Q:J]"" ;don't use if discontinued
.S D=$$FMDIFF^XLFDT(BDATE,$P($P(^AUPNVSIT(V,0),U),"."))
.S S=$P(^AUPNVMED(Y,0),U,7)
.S S=S-D
.S:S<0 S=0
.S K=S+K
.I R]"" S R=R_";"
.S R=R_$$DATE^BGP7UTL($P($P(^AUPNVSIT(V,0),U),"."))_"("_S_")"
I K>BGPNDAYS Q 1_U_R_" "_"("_K_" TOTAL DAYS)"
Q 0_U_"("_K_" TOTAL DAYS)"
;
BETAREF(P,BDATE,EDATE) ;EP
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_$$DATE^BGP7UTL(Y)_U_"Refused "_$P(^PSDRUG(X,0),U,1)
..Q
.Q
Q G
BETACONT(P,BDATE,EDATE,NMIBD,NMIED) ;EP - BETA BLOCKER CONTRAINDICATION
G BETACONT^BGP7D724
ASA(P,BDATE,EDATE,BGPNDAYS) ;EP
K BGPMEDS1
S K=0,R=""
D GETMEDS^BGP7UTL2(P,BDATE,EDATE,,,,,.BGPMEDS1)
I '$D(BGPMEDS1) Q ""
S T=$O(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
S T1=$O(^ATXAX("B","BGP ANTI-PLATELET DRUGS",0))
S T2=$O(^ATXAX("B","BGP CMS ANTI-PLATELET CLASS",0))
S X=0 F S X=$O(BGPMEDS1(X)) Q:X'=+X S Y=+$P(BGPMEDS1(X),U,4) D
.Q:'$D(^AUPNVMED(Y,0))
.Q:$$UP^XLFSTR($P($G(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
.S G=0
.S D=$P(^AUPNVMED(Y,0),U)
.I T,$D(^ATXAX(T,21,"B",D)) S G=1 G ASA1
.S N=$P($G(^PSDRUG(D,2)),U,4)
.I N]"",T1,$D(^ATXAX(T1,21,"B",N)) S G=1 G ASA1
.S C=$P($G(^PSDRUG(D,0)),U,2)
.I C]"",T2,$D(^ATXAX(T2,21,"B",C)) S G=1
.Q:'G
ASA1 .;
.S J=$P(^AUPNVMED(Y,0),U,8)
.S V=$P(^AUPNVMED(Y,0),U,3)
.Q:'V
.Q:'$D(^AUPNVSIT(V,0))
.S S=$$DAYS^BGP7D82(Y,V,EDATE)
.S K=S+K
.I R]"" S R=R_";"
.S R=R_$$DATE^BGP7UTL($P($P(^AUPNVSIT(V,0),U),"."))_"("_S_")"
;I K>BGPNDAYS Q 1_U_R_" "_"("_K_" TOTAL DAYS)"
I K>BGPNDAYS Q 1_U_"("_K_" TOTAL DAYS)"
ASAPRIO ;now add in any before BEG DATE
K BGPMEDS1
D GETMEDS^BGP7UTL2(P,$$FMADD^XLFDT(BDATE,-365),BDATE,,,,,.BGPMEDS1)
I '$D(BGPMEDS1) Q ""
S X=0 F S X=$O(BGPMEDS1(X)) Q:X'=+X S Y=+$P(BGPMEDS1(X),U,4) D
.Q:'$D(^AUPNVMED(Y,0))
.Q:$$UP^XLFSTR($P($G(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
.S G=0
.S D=$P(^AUPNVMED(Y,0),U)
.I T,$D(^ATXAX(T,21,"B",D)) S G=1 G ASA2
.S N=$P($G(^PSDRUG(D,2)),U,4)
.I N]"",T1,$D(^ATXAX(T1,21,"B",N)) S G=1 G ASA2
.S C=$P($G(^PSDRUG(D,0)),U,2)
.I C]"",T2,$D(^ATXAX(T2,21,"B",C)) S G=1
.Q:'G
ASA2 .;
.S J=$P(^AUPNVMED(Y,0),U,8)
.S V=$P(^AUPNVMED(Y,0),U,3)
.Q:'V
.Q:'$D(^AUPNVSIT(V,0))
.Q:J]"" ;don't use if discontinued
.S D=$$FMDIFF^XLFDT(BDATE,$P($P(^AUPNVSIT(V,0),U),"."))
.S S=$P(^AUPNVMED(Y,0),U,7)
.S S=S-D ;subtract the number of days used
.I S<0 S S=0
.S K=S+K ;TOTAL DAYS SUPPLY
.I R]"" S R=R_";"
.S R=R_$$DATE^BGP7UTL($P($P(^AUPNVSIT(V,0),U),"."))_"("_S_")"
I K>BGPNDAYS Q 1_U_R_" "_"("_K_" TOTAL DAYS)"
Q 0_U_"("_K_" TOTAL DAYS)"
;
ASAREF(P,BDATE,EDATE) ;EP
;did patient have a Refusal
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
..I Y>EDATE Q
..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_$$DATE^BGP7UTL(Y)_" Refused "_$P(^PSDRUG(X,0),U,1)
..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
..I Y>EDATE Q
..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_$$DATE^BGP7UTL(Y)_" Refused "_$P(^PSDRUG(X,0),U,1)
..Q
.Q
Q G
ASACONTR(P,BDATE,EDATE,BGPNDAYS) ;does patient have an aspirin allergy
K BGPMEDS1
S K=0,R=""
D GETMEDS^BGP7UTL2(P,BDATE,EDATE,,,,,.BGPMEDS1)
I '$D(BGPMEDS1) G ASAC2
S T=$O(^ATXAX("B","BGP CMS WARFARIN MEDS",0))
S X=0 F S X=$O(BGPMEDS1(X)) Q:X'=+X S Y=+$P(BGPMEDS1(X),U,4) D
.Q:'$D(^AUPNVMED(Y,0))
.Q:$$UP^XLFSTR($P($G(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
.S G=0
.S D=$P(^AUPNVMED(Y,0),U)
.I T,$D(^ATXAX(T,21,"B",D)) S G=1 G WAR1
.S N=$P($G(^PSDRUG(D,0)),U,1)
.I N["WARFARIN" S G=1 G WAR1
.I $$VAPI^BGP7D81(D,$O(^ATXAX("B","BGP CMS WARFARIN VAPI",0))) S G=1 G WAR1
.Q:'G
WAR1 .;
.S J=$P(^AUPNVMED(Y,0),U,8)
.S V=$P(^AUPNVMED(Y,0),U,3)
.Q:'V
.Q:'$D(^AUPNVSIT(V,0))
.S S=$$DAYS^BGP7D82(Y,V,EDATE)
.S K=S+K
.I R]"" S R=R_";"
.S R=R_$$DATE^BGP7UTL($P($P(^AUPNVSIT(V,0),U),"."))_"("_S_")"
I K>BGPNDAYS Q 1_U_" aspirin Contra total days WARFARIN: "_K
WARPRIO ;now add in any before BEG DATE
K BGPMEDS1
D GETMEDS^BGP7UTL2(P,$$FMADD^XLFDT(BDATE,-365),BDATE,,,,,.BGPMEDS1)
I '$D(BGPMEDS1) G ASAC2
S X=0 F S X=$O(BGPMEDS1(X)) Q:X'=+X S Y=+$P(BGPMEDS1(X),U,4) D
.Q:'$D(^AUPNVMED(Y,0))
.Q:$$UP^XLFSTR($P($G(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
.S G=0
.S D=$P(^AUPNVMED(Y,0),U)
.I T,$D(^ATXAX(T,21,"B",D)) S G=1 G WAR2
.S N=$P($G(^PSDRUG(D,0)),U,1)
.I N["WARFARIN" S G=1 G WAR2
.Q:'G
WAR2 .;
.S J=$P(^AUPNVMED(Y,0),U,8)
.S V=$P(^AUPNVMED(Y,0),U,3)
.Q:'V
.Q:'$D(^AUPNVSIT(V,0))
.;S IS DAYS SUPPLY, J IS DATE DISCONTINUED
.Q:J]""
.S D=$$FMDIFF^XLFDT(EDATE,$P($P(^AUPNVSIT(V,0),U),"."))
.S S=$P(^AUPNVMED(Y,0),U,7)
.S S=S-D ;subtract the number of days used
.I S<0 S S=0
.S K=S+K ;TOTAL DAYS SUPPLY
.I R]"" S R=R_";"
.S R=R_$$DATE^BGP7UTL($P($P(^AUPNVSIT(V,0),U),"."))_"("_S_")"
I K>BGPNDAYS Q 1_U_"asp Contra total days WARFARIN: "_K
ASAC2 ;now check for dx 459
K BGPG S BGPG=$$LASTDX^BGP7UTL1(P,"BGP HEMORRHAGE DXS",$$DOB^AUPNPAT(P),EDATE)
I BGPG Q 1_U_"asa Contra "_$P(BGPG,U,2)_" "_$$DATE^BGP7UTL($P(BGPG,U,3))
;
;nmi in Refusal file for aspirin
S BGPG=""
S T=$O(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
S X=0 F S X=$O(^AUPNPREF("AA",P,50,X)) Q:X'=+X D
.Q:'$D(^ATXAX(T,21,"B",X)) ;not an aspirin
.S D=0 F S D=$O(^AUPNPREF("AA",P,50,X,D)) Q:D'=+D D
..I (9999999-D)<BDATE Q ;before report period
..I (9999999-D)>EDATE Q ;documented after report period
..S N=0 F S N=$O(^AUPNPREF("AA",P,50,X,D,N)) Q:N'=+N D
...Q:$P($G(^AUPNPREF(N,0)),U,7)'="N"
...S BGPG=1_U_"asa Contra NMI Aspirin: "_$$VAL^XBDIQ1(9000022,N,.04)_" "_$$DATE^BGP7UTL($P(^AUPNPREF(N,0),U,3))_" "_$$VAL^XBDIQ1(9000022,X,1101)
..Q
.Q
I BGPG Q BGPG
S X=$$CPTI^BGP7DU(P,BDATE,EDATE,+$$CODEN^ICPTCOD("G8008"))
I X Q 1_U_"asa Contra CPT code G8008: "_$$DATE^BGP7UTL($P(X,U,2))
S X=$$TRANI^BGP7DU(P,BDATE,EDATE,+$$CODEN^ICPTCOD("G8008"))
I X Q 1_U_"asa Contra Tran Code G8008: "_$$DATE^BGP7UTL($P(X,U,2))
Q ""
ASAALLEG(P,EDATE) ;EP
K BGPG
S X=$$ASAALLEG^BGP7CU1(P,$$DOB^AUPNPAT(P),EDATE)
I 'X Q 0
S $P(X,U,2)="ADR "_$P(X,U,2)
Q X
BGP7D721 ; IHS/CMI/LAB - measure AHR.A ;
+1 ;;17.1;IHS CLINICAL REPORTING;;MAY 10, 2017;Build 29
+2 ;
+3 ;
IAHRA ;EP
+1 SET (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7,BGPN8,BGPN9,BGPN10,BGPN11,BGPN12,BGPN13,BGPN14,BGPN15,BGPN16,BGPN17,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9)=0
+2 SET BGPVALUE=""
+3 IF BGPAGEB<22
SET BGPSTOP=1
QUIT
+4 ;must be active clinical
IF 'BGPACTCL
SET BGPSTOP=1
QUIT
+5 SET BGPIHD=$$CHD^BGP7D729(DFN,BGPBDATE,BGPEDATE)
+6 ;no IHD
IF 'BGPIHD
SET BGPSTOP=1
QUIT
+7 SET BGPD1=1
+8 IF BGPDMD2
SET BGPD3=1
+9 IF 'BGPDMD2
SET BGPD2=1
+10 KILL BGPBETA
+11 ;get 1_U_# days
SET BGPBETA("RX")=$$BETA(DFN,BGPBDATE,BGPEDATE,179)
+12 ;pt has 180 days of beta blocker
IF BGPBETA("RX")
SET BGPN2=1
+13 ;I 'BGPN2 S BGPBETA("REF")=$$BETAREF(DFN,BGPBDATE,BGPEDATE) I BGPBETA("REF") S BGPN3=1
+14 ;beta Contraindication
IF 'BGPN2
SET BGPBETA("CONTRA")=$$BETACONT(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,BGPBDATE,BGPEDATE)
IF BGPBETA("CONTRA")
SET BGPN4=1
+15 IF 'BGPN2
SET BGPBETA("ADR")=$$BETAALG1^BGP7D72(DFN,BGPEDATE)
IF BGPBETA("ADR")
SET BGPN4=1
+16 IF (BGPN2+BGPN4)
SET BGPN1=1
+17 KILL BGPASA
+18 ;get 1_U_# days
SET BGPASA("RX")=$$ASA(DFN,BGPBDATE,BGPEDATE,179)
+19 ;pt has 180 days of beta blocker
IF BGPASA("RX")
SET BGPN6=1
+20 ;I 'BGPN6 S BGPASA("REF")=$$ASAREF(DFN,BGPBDATE,BGPEDATE) I BGPASA("REF") S BGPN7=1
+21 ;beta Contraindication
IF 'BGPN6
SET BGPASA("CONTRA")=$$ASACONTR(DFN,BGPBDATE,BGPEDATE,179)
IF BGPASA("CONTRA")
SET BGPN8=1
+22 IF 'BGPN6
SET BGPASA("ADR")=$$ASAALLEG(DFN,BGPEDATE)
IF BGPASA("ADR")
SET BGPN8=1
+23 IF (BGPN6+BGPN8)
SET BGPN5=1
+24 KILL BGPACE
+25 ;get 1_U_# days
SET BGPACE("RX")=$$ACERX^BGP7D722(DFN,BGPBDATE,BGPEDATE,179)
+26 ;pt has 180 days of ACE
IF BGPACE("RX")
SET BGPN10=1
+27 ;I 'BGPN10 S BGPACE("REF")=$$ACEREF^BGP7D722(DFN,BGPBDATE,BGPEDATE) I BGPACE("REF") S BGPN11=1
+28 ;beta Contraindication
IF 'BGPN10
SET BGPACE("CONTRA")=$$ACECONT^BGP7D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,BGPBDATE,BGPEDATE,BGPBDATE)
IF BGPACE("CONTRA")
SET BGPN12=1
+29 IF 'BGPN10
SET BGPACE("ADR")=$$ACEALG^BGP7D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
IF BGPACE("ADR")
SET BGPN12=1
+30 IF (BGPN10+BGPN12)
SET BGPN9=1
+31 KILL BGPSTAT
+32 ;get 1_U_# days
SET BGPSTAT("RX")=$$STATRX^BGP7D722(DFN,BGPBDATE,BGPEDATE,179)
+33 ;pt has 180 days of STAT
IF BGPSTAT("RX")
SET BGPN14=1
+34 ;beta Contraindication
IF 'BGPN14
SET BGPSTAT("CONTRA")=$$STATCON^BGP7D722(DFN,BGPBDATE,BGPEDATE,BGPBDATE,BGPEDATE)
IF BGPSTAT("CONTRA")
SET BGPN16=1
+35 IF 'BGPN14
SET BGPSTAT("ADR")=$$STATALG^BGP7D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,BGPBDATE,BGPEDATE)
IF BGPSTAT("ADR")
SET BGPN16=1
+36 IF (BGPN14+BGPN16)
SET BGPN13=1
+37 IF BGPN1
IF BGPN5
IF BGPN9
IF BGPN13
SET BGPN17=1
+38 SET BGPVALUE="CHD"_$SELECT(BGPD3:";AD",1:"")_"|||"
+39 SET BGPVALUE=BGPVALUE_$SELECT(BGPN17:"ALL MEDS; ",1:"")
+40 IF BGPN2!(BGPN3)!(BGPN4)
SET BGPVALUE=BGPVALUE_$SELECT($PIECE(BGPVALUE,"|||",2)]"":" ",1:"")
SET BGPVALUE=BGPVALUE_"BETA: "
FOR X="RX","REF","CONTRA","ADR"
IF $PIECE($GET(BGPBETA(X)),U,1)
IF $PIECE($GET(BGPBETA(X)),U,2)]""
Begin DoDot:1
+41 SET BGPVALUE=BGPVALUE_$PIECE(BGPBETA(X),U,2)_$SELECT($PIECE(BGPBETA(X),U,3)]"":" "_$PIECE(BGPBETA(X),U,3),1:"")
End DoDot:1
+42 IF BGPN6!(BGPN7)!(BGPN8)
SET BGPVALUE=BGPVALUE_$SELECT($PIECE(BGPVALUE,"|||",2)]"":"; ",1:"")
SET BGPVALUE=BGPVALUE_"ASA: "
FOR X="RX","REF","CONTRA","ADR"
IF $PIECE($GET(BGPASA(X)),U,1)
IF $PIECE($GET(BGPASA(X)),U,2)]""
Begin DoDot:1
+43 SET BGPVALUE=BGPVALUE_$PIECE(BGPASA(X),U,2)_$SELECT($PIECE(BGPASA(X),U,3)]"":" "_$PIECE(BGPASA(X),U,3),1:"")
End DoDot:1
+44 IF BGPN10!(BGPN11)!(BGPN12)
SET BGPVALUE=BGPVALUE_$SELECT($PIECE(BGPVALUE,"|||",2)]"":"; ",1:"")
SET BGPVALUE=BGPVALUE_"ACEI/ARB: "
FOR X="RX","REF","CONTRA","ADR"
IF $PIECE($GET(BGPACE(X)),U,1)
IF $PIECE($GET(BGPACE(X)),U,2)]""
Begin DoDot:1
+45 SET BGPVALUE=BGPVALUE_$PIECE(BGPACE(X),U,2)_$SELECT($PIECE(BGPACE(X),U,3)]"":" "_$PIECE(BGPACE(X),U,3),1:"")
End DoDot:1
+46 IF BGPN14!(BGPN15)!(BGPN16)
SET BGPVALUE=BGPVALUE_$SELECT($PIECE(BGPVALUE,"|||",2)]"":"; ",1:"")
SET BGPVALUE=BGPVALUE_"STATIN: "
FOR X="RX","REF","CONTRA","ADR"
IF $PIECE($GET(BGPSTAT(X)),U,1)
IF $PIECE($GET(BGPSTAT(X)),U,2)]""
Begin DoDot:1
+47 SET BGPVALUE=BGPVALUE_$PIECE(BGPSTAT(X),U,2)_$SELECT($PIECE(BGPSTAT(X),U,3)]"":" "_$PIECE(BGPSTAT(X),U,3),1:"")
End DoDot:1
+48 KILL ^TMP($JOB)
+49 QUIT
BETA(P,BDATE,EDATE,BGPNDAYS) ;EP
+1 NEW BGPMEDS1,K,R,T,T1,X,Y,G,D,N,J,V,S
+2 KILL BGPMEDS1
+3 SET K=0
SET R=""
+4 DO GETMEDS^BGP7UTL2(P,BDATE,EDATE,,,,,.BGPMEDS1)
+5 IF '$DATA(BGPMEDS1)
QUIT ""
+6 SET T=$ORDER(^ATXAX("B","BGP HEDIS BETA BLOCKER MEDS",0))
+7 SET T1=$ORDER(^ATXAX("B","BGP HEDIS BETA BLOCKER NDC",0))
+8 SET X=0
FOR
SET X=$ORDER(BGPMEDS1(X))
IF X'=+X
QUIT
SET Y=+$PIECE(BGPMEDS1(X),U,4)
Begin DoDot:1
+9 IF '$DATA(^AUPNVMED(Y,0))
QUIT
+10 IF $$UP^XLFSTR($PIECE($GET(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
QUIT
+11 SET G=0
+12 SET D=$PIECE(^AUPNVMED(Y,0),U)
+13 IF T
IF $DATA(^ATXAX(T,21,"B",D))
SET G=1
GOTO BETA1
+14 SET N=$PIECE($GET(^PSDRUG(D,2)),U,4)
+15 IF N]""
IF T1
IF $DATA(^ATXAX(T1,21,"B",N))
SET G=1
+16 IF 'G
QUIT
BETA1 ;
+1 SET J=$PIECE(^AUPNVMED(Y,0),U,8)
+2 SET V=$PIECE(^AUPNVMED(Y,0),U,3)
+3 IF 'V
QUIT
+4 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+5 SET S=$$DAYS^BGP7D82(Y,V,EDATE)
+6 ;TOTAL DAYS SUPPLY
SET K=S+K
+7 IF R]""
SET R=R_";"
+8 SET R=R_$$DATE^BGP7UTL($PIECE($PIECE(^AUPNVSIT(V,0),U),"."))_"("_S_")"
End DoDot:1
+9 ;I K>BGPNDAYS Q 1_U_R_" "_"("_K_" TOTAL DAYS)"
+10 IF K>BGPNDAYS
QUIT 1_U_"("_K_" TOTAL DAYS)"
BETAPRIO ;now add in any before BEG DATE
+1 KILL BGPMEDS1
+2 DO GETMEDS^BGP7UTL2(P,$$FMADD^XLFDT(BDATE,-365),BDATE,,,,,.BGPMEDS1)
+3 IF '$DATA(BGPMEDS1)
QUIT ""
+4 SET X=0
FOR
SET X=$ORDER(BGPMEDS1(X))
IF X'=+X
QUIT
SET Y=+$PIECE(BGPMEDS1(X),U,4)
Begin DoDot:1
+5 IF '$DATA(^AUPNVMED(Y,0))
QUIT
+6 IF $$UP^XLFSTR($PIECE($GET(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
QUIT
+7 SET G=0
+8 SET D=$PIECE(^AUPNVMED(Y,0),U)
+9 IF T
IF $DATA(^ATXAX(T,21,"B",D))
SET G=1
GOTO BETA2
+10 SET N=$PIECE($GET(^PSDRUG(D,2)),U,4)
+11 IF N]""
IF T1
IF $DATA(^ATXAX(T1,21,"B",N))
SET G=1
+12 IF 'G
QUIT
BETA2 ;
+1 SET J=$PIECE(^AUPNVMED(Y,0),U,8)
+2 SET V=$PIECE(^AUPNVMED(Y,0),U,3)
+3 IF 'V
QUIT
+4 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+5 ;don't use if discontinued
IF J]""
QUIT
+6 SET D=$$FMDIFF^XLFDT(BDATE,$PIECE($PIECE(^AUPNVSIT(V,0),U),"."))
+7 SET S=$PIECE(^AUPNVMED(Y,0),U,7)
+8 SET S=S-D
+9 IF S<0
SET S=0
+10 SET K=S+K
+11 IF R]""
SET R=R_";"
+12 SET R=R_$$DATE^BGP7UTL($PIECE($PIECE(^AUPNVSIT(V,0),U),"."))_"("_S_")"
End DoDot:1
+13 IF K>BGPNDAYS
QUIT 1_U_R_" "_"("_K_" TOTAL DAYS)"
+14 QUIT 0_U_"("_K_" TOTAL DAYS)"
+15 ;
BETAREF(P,BDATE,EDATE) ;EP
+1 NEW T,X,G,D,Y,N
+2 SET T=$ORDER(^ATXAX("B","BGP HEDIS BETA BLOCKER MEDS",0))
+3 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+4 ;not a Beta Blocker
IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+5 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D!(G)
QUIT
Begin DoDot:2
+6 SET Y=9999999-D
IF Y<BDATE
QUIT
+7 ;documented after edate
IF Y>EDATE
QUIT
+8 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N!(G)
QUIT
Begin DoDot:3
+9 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="R"
QUIT
+10 SET G=1_U_$$DATE^BGP7UTL(Y)_U_"Refused "_$PIECE(^PSDRUG(X,0),U,1)
End DoDot:3
+11 QUIT
End DoDot:2
+12 QUIT
End DoDot:1
+13 QUIT G
BETACONT(P,BDATE,EDATE,NMIBD,NMIED) ;EP - BETA BLOCKER CONTRAINDICATION
+1 GOTO BETACONT^BGP7D724
ASA(P,BDATE,EDATE,BGPNDAYS) ;EP
+1 KILL BGPMEDS1
+2 SET K=0
SET R=""
+3 DO GETMEDS^BGP7UTL2(P,BDATE,EDATE,,,,,.BGPMEDS1)
+4 IF '$DATA(BGPMEDS1)
QUIT ""
+5 SET T=$ORDER(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
+6 SET T1=$ORDER(^ATXAX("B","BGP ANTI-PLATELET DRUGS",0))
+7 SET T2=$ORDER(^ATXAX("B","BGP CMS ANTI-PLATELET CLASS",0))
+8 SET X=0
FOR
SET X=$ORDER(BGPMEDS1(X))
IF X'=+X
QUIT
SET Y=+$PIECE(BGPMEDS1(X),U,4)
Begin DoDot:1
+9 IF '$DATA(^AUPNVMED(Y,0))
QUIT
+10 IF $$UP^XLFSTR($PIECE($GET(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
QUIT
+11 SET G=0
+12 SET D=$PIECE(^AUPNVMED(Y,0),U)
+13 IF T
IF $DATA(^ATXAX(T,21,"B",D))
SET G=1
GOTO ASA1
+14 SET N=$PIECE($GET(^PSDRUG(D,2)),U,4)
+15 IF N]""
IF T1
IF $DATA(^ATXAX(T1,21,"B",N))
SET G=1
GOTO ASA1
+16 SET C=$PIECE($GET(^PSDRUG(D,0)),U,2)
+17 IF C]""
IF T2
IF $DATA(^ATXAX(T2,21,"B",C))
SET G=1
+18 IF 'G
QUIT
ASA1 ;
+1 SET J=$PIECE(^AUPNVMED(Y,0),U,8)
+2 SET V=$PIECE(^AUPNVMED(Y,0),U,3)
+3 IF 'V
QUIT
+4 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+5 SET S=$$DAYS^BGP7D82(Y,V,EDATE)
+6 SET K=S+K
+7 IF R]""
SET R=R_";"
+8 SET R=R_$$DATE^BGP7UTL($PIECE($PIECE(^AUPNVSIT(V,0),U),"."))_"("_S_")"
End DoDot:1
+9 ;I K>BGPNDAYS Q 1_U_R_" "_"("_K_" TOTAL DAYS)"
+10 IF K>BGPNDAYS
QUIT 1_U_"("_K_" TOTAL DAYS)"
ASAPRIO ;now add in any before BEG DATE
+1 KILL BGPMEDS1
+2 DO GETMEDS^BGP7UTL2(P,$$FMADD^XLFDT(BDATE,-365),BDATE,,,,,.BGPMEDS1)
+3 IF '$DATA(BGPMEDS1)
QUIT ""
+4 SET X=0
FOR
SET X=$ORDER(BGPMEDS1(X))
IF X'=+X
QUIT
SET Y=+$PIECE(BGPMEDS1(X),U,4)
Begin DoDot:1
+5 IF '$DATA(^AUPNVMED(Y,0))
QUIT
+6 IF $$UP^XLFSTR($PIECE($GET(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
QUIT
+7 SET G=0
+8 SET D=$PIECE(^AUPNVMED(Y,0),U)
+9 IF T
IF $DATA(^ATXAX(T,21,"B",D))
SET G=1
GOTO ASA2
+10 SET N=$PIECE($GET(^PSDRUG(D,2)),U,4)
+11 IF N]""
IF T1
IF $DATA(^ATXAX(T1,21,"B",N))
SET G=1
GOTO ASA2
+12 SET C=$PIECE($GET(^PSDRUG(D,0)),U,2)
+13 IF C]""
IF T2
IF $DATA(^ATXAX(T2,21,"B",C))
SET G=1
+14 IF 'G
QUIT
ASA2 ;
+1 SET J=$PIECE(^AUPNVMED(Y,0),U,8)
+2 SET V=$PIECE(^AUPNVMED(Y,0),U,3)
+3 IF 'V
QUIT
+4 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+5 ;don't use if discontinued
IF J]""
QUIT
+6 SET D=$$FMDIFF^XLFDT(BDATE,$PIECE($PIECE(^AUPNVSIT(V,0),U),"."))
+7 SET S=$PIECE(^AUPNVMED(Y,0),U,7)
+8 ;subtract the number of days used
SET S=S-D
+9 IF S<0
SET S=0
+10 ;TOTAL DAYS SUPPLY
SET K=S+K
+11 IF R]""
SET R=R_";"
+12 SET R=R_$$DATE^BGP7UTL($PIECE($PIECE(^AUPNVSIT(V,0),U),"."))_"("_S_")"
End DoDot:1
+13 IF K>BGPNDAYS
QUIT 1_U_R_" "_"("_K_" TOTAL DAYS)"
+14 QUIT 0_U_"("_K_" TOTAL DAYS)"
+15 ;
ASAREF(P,BDATE,EDATE) ;EP
+1 ;did patient have a Refusal
+2 SET T=$ORDER(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
+3 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+4 IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+5 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D!(G)
QUIT
Begin DoDot:2
+6 SET Y=9999999-D
IF Y<BDATE
QUIT
+7 IF Y>EDATE
QUIT
+8 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N!(G)
QUIT
Begin DoDot:3
+9 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="R"
QUIT
+10 SET G=1_U_$$DATE^BGP7UTL(Y)_" Refused "_$PIECE(^PSDRUG(X,0),U,1)
End DoDot:3
+11 QUIT
End DoDot:2
+12 QUIT
End DoDot:1
+13 IF G
QUIT G
+14 SET T=$ORDER(^ATXAX("B","BGP ANTI-PLATELET DRUGS",0))
+15 SET X=0
SET G=""
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+16 IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+17 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D!(G)
QUIT
Begin DoDot:2
+18 SET Y=9999999-D
IF Y<BDATE
QUIT
+19 IF Y>EDATE
QUIT
+20 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N!(G)
QUIT
Begin DoDot:3
+21 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="R"
QUIT
+22 SET G=1_U_$$DATE^BGP7UTL(Y)_" Refused "_$PIECE(^PSDRUG(X,0),U,1)
End DoDot:3
+23 QUIT
End DoDot:2
+24 QUIT
End DoDot:1
+25 QUIT G
ASACONTR(P,BDATE,EDATE,BGPNDAYS) ;does patient have an aspirin allergy
+1 KILL BGPMEDS1
+2 SET K=0
SET R=""
+3 DO GETMEDS^BGP7UTL2(P,BDATE,EDATE,,,,,.BGPMEDS1)
+4 IF '$DATA(BGPMEDS1)
GOTO ASAC2
+5 SET T=$ORDER(^ATXAX("B","BGP CMS WARFARIN MEDS",0))
+6 SET X=0
FOR
SET X=$ORDER(BGPMEDS1(X))
IF X'=+X
QUIT
SET Y=+$PIECE(BGPMEDS1(X),U,4)
Begin DoDot:1
+7 IF '$DATA(^AUPNVMED(Y,0))
QUIT
+8 IF $$UP^XLFSTR($PIECE($GET(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
QUIT
+9 SET G=0
+10 SET D=$PIECE(^AUPNVMED(Y,0),U)
+11 IF T
IF $DATA(^ATXAX(T,21,"B",D))
SET G=1
GOTO WAR1
+12 SET N=$PIECE($GET(^PSDRUG(D,0)),U,1)
+13 IF N["WARFARIN"
SET G=1
GOTO WAR1
+14 IF $$VAPI^BGP7D81(D,$ORDER(^ATXAX("B","BGP CMS WARFARIN VAPI",0)))
SET G=1
GOTO WAR1
+15 IF 'G
QUIT
WAR1 ;
+1 SET J=$PIECE(^AUPNVMED(Y,0),U,8)
+2 SET V=$PIECE(^AUPNVMED(Y,0),U,3)
+3 IF 'V
QUIT
+4 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+5 SET S=$$DAYS^BGP7D82(Y,V,EDATE)
+6 SET K=S+K
+7 IF R]""
SET R=R_";"
+8 SET R=R_$$DATE^BGP7UTL($PIECE($PIECE(^AUPNVSIT(V,0),U),"."))_"("_S_")"
End DoDot:1
+9 IF K>BGPNDAYS
QUIT 1_U_" aspirin Contra total days WARFARIN: "_K
WARPRIO ;now add in any before BEG DATE
+1 KILL BGPMEDS1
+2 DO GETMEDS^BGP7UTL2(P,$$FMADD^XLFDT(BDATE,-365),BDATE,,,,,.BGPMEDS1)
+3 IF '$DATA(BGPMEDS1)
GOTO ASAC2
+4 SET X=0
FOR
SET X=$ORDER(BGPMEDS1(X))
IF X'=+X
QUIT
SET Y=+$PIECE(BGPMEDS1(X),U,4)
Begin DoDot:1
+5 IF '$DATA(^AUPNVMED(Y,0))
QUIT
+6 IF $$UP^XLFSTR($PIECE($GET(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
QUIT
+7 SET G=0
+8 SET D=$PIECE(^AUPNVMED(Y,0),U)
+9 IF T
IF $DATA(^ATXAX(T,21,"B",D))
SET G=1
GOTO WAR2
+10 SET N=$PIECE($GET(^PSDRUG(D,0)),U,1)
+11 IF N["WARFARIN"
SET G=1
GOTO WAR2
+12 IF 'G
QUIT
WAR2 ;
+1 SET J=$PIECE(^AUPNVMED(Y,0),U,8)
+2 SET V=$PIECE(^AUPNVMED(Y,0),U,3)
+3 IF 'V
QUIT
+4 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+5 ;S IS DAYS SUPPLY, J IS DATE DISCONTINUED
+6 IF J]""
QUIT
+7 SET D=$$FMDIFF^XLFDT(EDATE,$PIECE($PIECE(^AUPNVSIT(V,0),U),"."))
+8 SET S=$PIECE(^AUPNVMED(Y,0),U,7)
+9 ;subtract the number of days used
SET S=S-D
+10 IF S<0
SET S=0
+11 ;TOTAL DAYS SUPPLY
SET K=S+K
+12 IF R]""
SET R=R_";"
+13 SET R=R_$$DATE^BGP7UTL($PIECE($PIECE(^AUPNVSIT(V,0),U),"."))_"("_S_")"
End DoDot:1
+14 IF K>BGPNDAYS
QUIT 1_U_"asp Contra total days WARFARIN: "_K
ASAC2 ;now check for dx 459
+1 KILL BGPG
SET BGPG=$$LASTDX^BGP7UTL1(P,"BGP HEMORRHAGE DXS",$$DOB^AUPNPAT(P),EDATE)
+2 IF BGPG
QUIT 1_U_"asa Contra "_$PIECE(BGPG,U,2)_" "_$$DATE^BGP7UTL($PIECE(BGPG,U,3))
+3 ;
+4 ;nmi in Refusal file for aspirin
+5 SET BGPG=""
+6 SET T=$ORDER(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
+7 SET X=0
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X
QUIT
Begin DoDot:1
+8 ;not an aspirin
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
QUIT
Begin DoDot:2
+10 ;before report period
IF (9999999-D)<BDATE
QUIT
+11 ;documented after report period
IF (9999999-D)>EDATE
QUIT
+12 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N
QUIT
Begin DoDot:3
+13 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="N"
QUIT
+14 SET BGPG=1_U_"asa Contra NMI Aspirin: "_$$VAL^XBDIQ1(9000022,N,.04)_" "_$$DATE^BGP7UTL($PIECE(^AUPNPREF(N,0),U,3))_" "_$$VAL^XBDIQ1(9000022,X,1101)
End DoDot:3
+15 QUIT
End DoDot:2
+16 QUIT
End DoDot:1
+17 IF BGPG
QUIT BGPG
+18 SET X=$$CPTI^BGP7DU(P,BDATE,EDATE,+$$CODEN^ICPTCOD("G8008"))
+19 IF X
QUIT 1_U_"asa Contra CPT code G8008: "_$$DATE^BGP7UTL($PIECE(X,U,2))
+20 SET X=$$TRANI^BGP7DU(P,BDATE,EDATE,+$$CODEN^ICPTCOD("G8008"))
+21 IF X
QUIT 1_U_"asa Contra Tran Code G8008: "_$$DATE^BGP7UTL($PIECE(X,U,2))
+22 QUIT ""
ASAALLEG(P,EDATE) ;EP
+1 KILL BGPG
+2 SET X=$$ASAALLEG^BGP7CU1(P,$$DOB^AUPNPAT(P),EDATE)
+3 IF 'X
QUIT 0
+4 SET $PIECE(X,U,2)="ADR "_$PIECE(X,U,2)
+5 QUIT X