BGP9D731 ; IHS/CMI/LAB - measure AHR.A ;
;;9.0;IHS CLINICAL REPORTING;;JUL 1, 2009
;
;
IPAMT ;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<35 S BGPSTOP=1 Q
I 'BGPACTCL S BGPSTOP=1 Q ;must be active clinical
S BGPAMI=$$AMI(DFN,$$FMADD^XLFDT(BGPBDATE,-180),$$FMADD^XLFDT(BGPBDATE,180))
I '$P(BGPAMI,U) S BGPSTOP=1 Q ;no ami
S BGPD1=1
I $P(^DPT(DFN,0),U,2)="M" S BGPD2=1
I $P(^DPT(DFN,0),U,2)="F" S BGPD3=1
S BGPADDAT=$S($P(BGPAMI,U,4)]"":$P(BGPAMI,U,4),1:$P(BGPAMI,U,2))
K BGPBETA
S BGPBETA("RX")=$$BETA^BGP9D721(DFN,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180),134)
I BGPBETA("RX") S BGPN2=1 ;pt has 135 days of beta blocker
I 'BGPN2 S BGPBETA("REF")=$$BETAREF^BGP9D721(DFN,$P(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180)) I BGPBETA("REF") S BGPN3=1
I 'BGPN2 S BGPBETA("CONTRA")=$$BETACONT^BGP9D721(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,$P(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180)) I BGPBETA("CONTRA") S BGPN4=1 ;beta contraindication
I 'BGPN2 S BGPBETA("ADR")=$$BETAALG1^BGP9D72(DFN,$$FMADD^XLFDT(BGPADDAT,180)) I BGPBETA("ADR") S BGPN4=1
I (BGPN2+BGPN3+BGPN4) S BGPN1=1
K BGPASA
S BGPASA("RX")=$$ASA^BGP9D721(DFN,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180),134) ;get 1_U_# days
I BGPASA("RX") S BGPN6=1 ;pt has 135 days of beta blocker
I 'BGPN6 S BGPASA("REF")=$$ASAREF^BGP9D721(DFN,$P(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180)) I BGPASA("REF") S BGPN7=1
I 'BGPN6 S BGPASA("CONTRA")=$$ASACONTR(DFN,$P(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180),$$DOB^AUPNPAT(DFN),BGPEDATE) I BGPASA("CONTRA") S BGPN8=1 ;beta contraindication
I 'BGPN6 S BGPASA("ADR")=$$ASAALLEG^BGP9D721(DFN,$$FMADD^XLFDT(BGPADDAT,180)) I BGPASA("ADR") S BGPN8=1
I (BGPN6+BGPN7+BGPN8) S BGPN5=1
K BGPACE
S BGPACE("RX")=$$ACERX^BGP9D722(DFN,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180),134) ;get 1_U_# days
I BGPACE("RX") S BGPN10=1 ;pt has 135 days of ACE
I 'BGPN10 S BGPACE("REF")=$$ACEREF^BGP9D722(DFN,$P(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180)) I BGPACE("REF") S BGPN11=1
I 'BGPN10 S BGPACE("CONTRA")=$$ACECONT^BGP9D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,$P(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180)) I BGPACE("CONTRA") S BGPN12=1 ;beta contraindication
I 'BGPN10 S BGPACE("ADR")=$$ACEALG^BGP9D722(DFN,BGPBDATE,$$FMADD^XLFDT(BGPADDAT,180)) I BGPACE("ADR") S BGPN12=1
I (BGPN10+BGPN11+BGPN12) S BGPN9=1
K BGPSTAT
S BGPSTAT("RX")=$$STATRX^BGP9D722(DFN,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180),134) ;get 1_U_# days
I BGPSTAT("RX") S BGPN14=1 ;pt has 135 days of STAT
I 'BGPN14 S BGPSTAT("REF")=$$STATREF^BGP9D722(DFN,$P(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180)) I BGPSTAT("REF") S BGPN15=1
I 'BGPN14 S BGPSTAT("CONTRA")=$$STATCON^BGP9D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180)) I BGPSTAT("CONTRA") S BGPN16=1 ;beta contraindication
I 'BGPN14 S BGPSTAT("ADR")=$$STATALG^BGP9D722(DFN,$$DOB^AUPNPAT(DFN),$$FMADD^XLFDT(BGPADDAT,180),BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180)) I BGPSTAT("ADR") S BGPN16=1
I (BGPN14+BGPN15+BGPN16) S BGPN13=1
I BGPN1,BGPN5,BGPN9,BGPN13 S BGPN17=1
S BGPVALUE="AC|||"
S BGPVALUE=BGPVALUE_$S(BGPN17:"ALL MEDS; ",1:"")
S BGPVALUE=BGPVALUE_" BETA: " F X="RX","REF","CONTRA","ADR" I $P($G(BGPBETA(X)),U,1),$P($G(BGPBETA(X)),U,2)]"" S BGPVALUE=BGPVALUE_$P(BGPBETA(X),U,2)_" "
S BGPVALUE=BGPVALUE_" ; ASA: " F X="RX","REF","CONTRA","ADR" I $P($G(BGPASA(X)),U,1),$P($G(BGPASA(X)),U,2)]"" S BGPVALUE=BGPVALUE_$P(BGPASA(X),U,2)_" "
S BGPVALUE=BGPVALUE_" ; ACEI/ARB: " F X="RX","REF","CONTRA","ADR" I $P($G(BGPACE(X)),U,1),$P($G(BGPACE(X)),U,2)]"" S BGPVALUE=BGPVALUE_$P(BGPACE(X),U,2)_" "
S BGPVALUE=BGPVALUE_" ; STATIN: " F X="RX","REF","CONTRA","ADR" I $P($G(BGPSTAT(X)),U,1),$P($G(BGPSTAT(X)),U,2)]"" S BGPVALUE=BGPVALUE_$P(BGPSTAT(X),U,2)_" "
K BGPIHD,BGPBETA,BGPMEDS1,BGPASA,BGPACE,BGPSTAT
K ^TMP($J)
Q
AMI(P,BDATE,EDATE) ;
;look for any H with AMI discharge dx
K ^TMP($J,"A"),G
S A="^TMP($J,""A"",",B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(B,A)
I '$D(^TMP($J,"A",1)) Q 0
S T=$O(^ATXAX("B","BGP AMI DXS PAMT",0))
S (BGPX,G,M,D,E)=0 F S BGPX=$O(^TMP($J,"A",BGPX)) Q:BGPX'=+BGPX S V=$P(^TMP($J,"A",BGPX),U,5) D
.Q:'$D(^AUPNVSIT(V,0))
.Q:'$P(^AUPNVSIT(V,0),U,9)
.Q:$P(^AUPNVSIT(V,0),U,11)
.Q:"AOSH"'[$P(^AUPNVSIT(V,0),U,7)
.S H=0
.I $P(^AUPNVSIT(V,0),U,7)="H" S H=$O(^AUPNVINP("AD",V,0)) D Q:'B
..S B=0
..I 'H Q
..Q:$$AMA^BGP9D72(H) ;ama
..Q:$$TRANS^BGP9D72(H) ;transferred
..Q:$$EXPIRED^BGP9D72(H) ;died
..S B=1
.S (D,Y)=0 F S Y=$O(^AUPNVPOV("AD",V,Y)) Q:Y'=+Y!(D) I $D(^AUPNVPOV(Y,0)) D
..S %=$P(^AUPNVPOV(Y,0),U) Q:'$$ICD^ATXCHK(%,T,9)
..I $P(^AUPNVPOV(Y,0),U,6)]"",$P(^AUPNVPOV(Y,0),U,6)'="F" Q ;modifier
..S N=$$VAL^XBDIQ1(9000010.07,Y,.04)
..S N=$$UP^XLFSTR(N)
..I $E(N,1,8)="CONSIDER" Q
..I $E(N,1,8)="DOUBTFUL" Q
..I $E(N,1,5)="MAYBE" Q
..I $E(N,1,8)="POSSIBLE" Q
..I $E(N,1,7)="PERHAPS" Q
..I $E(N,1,8)="RULE OUT" Q
..I $E(N,1,3)="R/O" Q
..I $E(N,1,8)="PROBABLE" Q
..I $E(N,1,8)="RESOLVED" Q
..I $E(N,1,7)="SUSPECT" Q
..I $E(N,1,10)="SUSPICIOUS" Q
..I $E(N,1,11)="STATUS POST" Q
..S D=1
.I D S G=G+1,G($P($P(^AUPNVSIT(V,0),U),"."))=V ;got one visit
I 'G Q G
S D=$O(G(0)),V=G(D),H=$O(^AUPNVINP("AD",V,0))
Q 1_U_$O(G(0))_U_V_U_$S(H:$P($P(^AUPNVINP(H,0),U),"."),1:"")_U_H
ASACONTR(P,BGPADM,BGPDD,BDATE,EDATE) ;does patient have an aspirin allergy
K BGPMEDS1
S K=0,R="",BGPG=""
D GETMEDS^BGP9UTL2(P,$$FMADD^XLFDT(BGPADM,-90),BGPDD,,,,,.BGPMEDS1)
I '$D(BGPMEDS1) Q ""
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))
.S G=0
.S D=$P(^AUPNVMED(Y,0),U)
.I T,$D(^ATXAX(T,21,"B",D)) S G=1 G WAR71
.S N=$P($G(^PSDRUG(D,0)),U,1)
.I N["WARFARIN" S G=1 G WAR71
.Q:'G
WAR71 .;
.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
.I J]"" Q:J<BGPADM ;discontinued before admission
.S E=$P($P(^AUPNVSIT(V,0),U),".")
.I E'<BGPADM,E'>BGPDD S BGPG=1_U_$$DATE^BGP9UTL(E)_U_$P(^PSDRUG(D,0),U)
.S S=$P(^AUPNVMED(Y,0),U,7)
.S Z=$$FMDIFF^XLFDT(BGPADM,$P($P(^AUPNVSIT(V,0),U),"."))
.I S>Z S BGPG=1_U_$$DATE^BGP9UTL($P($P(^AUPNVSIT(V,0),U),"."))_U_$P(^PSDRUG(D,0),U)
.Q
I BGPG Q 1_U_"asa contra warfarin rx "_$P(BGPG,U,2)_" "_$P(BGPG,U,3)
;now check for dx 459
K BGPG S BGPG=$$LASTDXI^BGP9UTL1(P,"459.0",BDATE,EDATE)
I BGPG Q 1_U_"asa contra 459.0 "_$$DATE^BGP9UTL($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 Y>EDATE Q ;documented EDATE OF 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^BGP9UTL($P(^AUPNPREF(N,0),U,3))_" "_$$VAL^XBDIQ1(9000022,X,1101)
..Q
.Q
I BGPG Q BGPG
;now check for CPT code G8008
S X=$$CPTI^BGP9DU(P,BDATE,EDATE,+$$CODEN^ICPTCOD("G8008"))
I X Q 1_U_"asa contra CPT code G8008: "_$$DATE^BGP9UTL($P(X,U,2))
S X=$$TRANI^BGP9DU(P,BDATE,EDATE,+$$CODEN^ICPTCOD("G8008"))
I X Q 1_U_"asa contra Tran Code G8008: "_$$DATE^BGP9UTL($P(X,U,2))
Q ""
BGP9D731 ; IHS/CMI/LAB - measure AHR.A ;
+1 ;;9.0;IHS CLINICAL REPORTING;;JUL 1, 2009
+2 ;
+3 ;
IPAMT ;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<35
SET BGPSTOP=1
QUIT
+4 ;must be active clinical
IF 'BGPACTCL
SET BGPSTOP=1
QUIT
+5 SET BGPAMI=$$AMI(DFN,$$FMADD^XLFDT(BGPBDATE,-180),$$FMADD^XLFDT(BGPBDATE,180))
+6 ;no ami
IF '$PIECE(BGPAMI,U)
SET BGPSTOP=1
QUIT
+7 SET BGPD1=1
+8 IF $PIECE(^DPT(DFN,0),U,2)="M"
SET BGPD2=1
+9 IF $PIECE(^DPT(DFN,0),U,2)="F"
SET BGPD3=1
+10 SET BGPADDAT=$SELECT($PIECE(BGPAMI,U,4)]"":$PIECE(BGPAMI,U,4),1:$PIECE(BGPAMI,U,2))
+11 KILL BGPBETA
+12 SET BGPBETA("RX")=$$BETA^BGP9D721(DFN,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180),134)
+13 ;pt has 135 days of beta blocker
IF BGPBETA("RX")
SET BGPN2=1
+14 IF 'BGPN2
SET BGPBETA("REF")=$$BETAREF^BGP9D721(DFN,$PIECE(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180))
IF BGPBETA("REF")
SET BGPN3=1
+15 ;beta contraindication
IF 'BGPN2
SET BGPBETA("CONTRA")=$$BETACONT^BGP9D721(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,$PIECE(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180))
IF BGPBETA("CONTRA")
SET BGPN4=1
+16 IF 'BGPN2
SET BGPBETA("ADR")=$$BETAALG1^BGP9D72(DFN,$$FMADD^XLFDT(BGPADDAT,180))
IF BGPBETA("ADR")
SET BGPN4=1
+17 IF (BGPN2+BGPN3+BGPN4)
SET BGPN1=1
+18 KILL BGPASA
+19 ;get 1_U_# days
SET BGPASA("RX")=$$ASA^BGP9D721(DFN,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180),134)
+20 ;pt has 135 days of beta blocker
IF BGPASA("RX")
SET BGPN6=1
+21 IF 'BGPN6
SET BGPASA("REF")=$$ASAREF^BGP9D721(DFN,$PIECE(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180))
IF BGPASA("REF")
SET BGPN7=1
+22 ;beta contraindication
IF 'BGPN6
SET BGPASA("CONTRA")=$$ASACONTR(DFN,$PIECE(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180),$$DOB^AUPNPAT(DFN),BGPEDATE)
IF BGPASA("CONTRA")
SET BGPN8=1
+23 IF 'BGPN6
SET BGPASA("ADR")=$$ASAALLEG^BGP9D721(DFN,$$FMADD^XLFDT(BGPADDAT,180))
IF BGPASA("ADR")
SET BGPN8=1
+24 IF (BGPN6+BGPN7+BGPN8)
SET BGPN5=1
+25 KILL BGPACE
+26 ;get 1_U_# days
SET BGPACE("RX")=$$ACERX^BGP9D722(DFN,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180),134)
+27 ;pt has 135 days of ACE
IF BGPACE("RX")
SET BGPN10=1
+28 IF 'BGPN10
SET BGPACE("REF")=$$ACEREF^BGP9D722(DFN,$PIECE(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180))
IF BGPACE("REF")
SET BGPN11=1
+29 ;beta contraindication
IF 'BGPN10
SET BGPACE("CONTRA")=$$ACECONT^BGP9D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,$PIECE(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180))
IF BGPACE("CONTRA")
SET BGPN12=1
+30 IF 'BGPN10
SET BGPACE("ADR")=$$ACEALG^BGP9D722(DFN,BGPBDATE,$$FMADD^XLFDT(BGPADDAT,180))
IF BGPACE("ADR")
SET BGPN12=1
+31 IF (BGPN10+BGPN11+BGPN12)
SET BGPN9=1
+32 KILL BGPSTAT
+33 ;get 1_U_# days
SET BGPSTAT("RX")=$$STATRX^BGP9D722(DFN,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180),134)
+34 ;pt has 135 days of STAT
IF BGPSTAT("RX")
SET BGPN14=1
+35 IF 'BGPN14
SET BGPSTAT("REF")=$$STATREF^BGP9D722(DFN,$PIECE(BGPAMI,U,2),$$FMADD^XLFDT(BGPADDAT,180))
IF BGPSTAT("REF")
SET BGPN15=1
+36 ;beta contraindication
IF 'BGPN14
SET BGPSTAT("CONTRA")=$$STATCON^BGP9D722(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180))
IF BGPSTAT("CONTRA")
SET BGPN16=1
+37 IF 'BGPN14
SET BGPSTAT("ADR")=$$STATALG^BGP9D722(DFN,$$DOB^AUPNPAT(DFN),$$FMADD^XLFDT(BGPADDAT,180),BGPADDAT,$$FMADD^XLFDT(BGPADDAT,180))
IF BGPSTAT("ADR")
SET BGPN16=1
+38 IF (BGPN14+BGPN15+BGPN16)
SET BGPN13=1
+39 IF BGPN1
IF BGPN5
IF BGPN9
IF BGPN13
SET BGPN17=1
+40 SET BGPVALUE="AC|||"
+41 SET BGPVALUE=BGPVALUE_$SELECT(BGPN17:"ALL MEDS; ",1:"")
+42 SET BGPVALUE=BGPVALUE_" BETA: "
FOR X="RX","REF","CONTRA","ADR"
IF $PIECE($GET(BGPBETA(X)),U,1)
IF $PIECE($GET(BGPBETA(X)),U,2)]""
SET BGPVALUE=BGPVALUE_$PIECE(BGPBETA(X),U,2)_" "
+43 SET BGPVALUE=BGPVALUE_" ; ASA: "
FOR X="RX","REF","CONTRA","ADR"
IF $PIECE($GET(BGPASA(X)),U,1)
IF $PIECE($GET(BGPASA(X)),U,2)]""
SET BGPVALUE=BGPVALUE_$PIECE(BGPASA(X),U,2)_" "
+44 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)]""
SET BGPVALUE=BGPVALUE_$PIECE(BGPACE(X),U,2)_" "
+45 SET BGPVALUE=BGPVALUE_" ; STATIN: "
FOR X="RX","REF","CONTRA","ADR"
IF $PIECE($GET(BGPSTAT(X)),U,1)
IF $PIECE($GET(BGPSTAT(X)),U,2)]""
SET BGPVALUE=BGPVALUE_$PIECE(BGPSTAT(X),U,2)_" "
+46 KILL BGPIHD,BGPBETA,BGPMEDS1,BGPASA,BGPACE,BGPSTAT
+47 KILL ^TMP($JOB)
+48 QUIT
AMI(P,BDATE,EDATE) ;
+1 ;look for any H with AMI discharge dx
+2 KILL ^TMP($JOB,"A"),G
+3 SET A="^TMP($J,""A"","
SET B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(B,A)
+4 IF '$DATA(^TMP($JOB,"A",1))
QUIT 0
+5 SET T=$ORDER(^ATXAX("B","BGP AMI DXS PAMT",0))
+6 SET (BGPX,G,M,D,E)=0
FOR
SET BGPX=$ORDER(^TMP($JOB,"A",BGPX))
IF BGPX'=+BGPX
QUIT
SET V=$PIECE(^TMP($JOB,"A",BGPX),U,5)
Begin DoDot:1
+7 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+8 IF '$PIECE(^AUPNVSIT(V,0),U,9)
QUIT
+9 IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+10 IF "AOSH"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+11 SET H=0
+12 IF $PIECE(^AUPNVSIT(V,0),U,7)="H"
SET H=$ORDER(^AUPNVINP("AD",V,0))
Begin DoDot:2
+13 SET B=0
+14 IF 'H
QUIT
+15 ;ama
IF $$AMA^BGP9D72(H)
QUIT
+16 ;transferred
IF $$TRANS^BGP9D72(H)
QUIT
+17 ;died
IF $$EXPIRED^BGP9D72(H)
QUIT
+18 SET B=1
End DoDot:2
IF 'B
QUIT
+19 SET (D,Y)=0
FOR
SET Y=$ORDER(^AUPNVPOV("AD",V,Y))
IF Y'=+Y!(D)
QUIT
IF $DATA(^AUPNVPOV(Y,0))
Begin DoDot:2
+20 SET %=$PIECE(^AUPNVPOV(Y,0),U)
IF '$$ICD^ATXCHK(%,T,9)
QUIT
+21 ;modifier
IF $PIECE(^AUPNVPOV(Y,0),U,6)]""
IF $PIECE(^AUPNVPOV(Y,0),U,6)'="F"
QUIT
+22 SET N=$$VAL^XBDIQ1(9000010.07,Y,.04)
+23 SET N=$$UP^XLFSTR(N)
+24 IF $EXTRACT(N,1,8)="CONSIDER"
QUIT
+25 IF $EXTRACT(N,1,8)="DOUBTFUL"
QUIT
+26 IF $EXTRACT(N,1,5)="MAYBE"
QUIT
+27 IF $EXTRACT(N,1,8)="POSSIBLE"
QUIT
+28 IF $EXTRACT(N,1,7)="PERHAPS"
QUIT
+29 IF $EXTRACT(N,1,8)="RULE OUT"
QUIT
+30 IF $EXTRACT(N,1,3)="R/O"
QUIT
+31 IF $EXTRACT(N,1,8)="PROBABLE"
QUIT
+32 IF $EXTRACT(N,1,8)="RESOLVED"
QUIT
+33 IF $EXTRACT(N,1,7)="SUSPECT"
QUIT
+34 IF $EXTRACT(N,1,10)="SUSPICIOUS"
QUIT
+35 IF $EXTRACT(N,1,11)="STATUS POST"
QUIT
+36 SET D=1
End DoDot:2
+37 ;got one visit
IF D
SET G=G+1
SET G($PIECE($PIECE(^AUPNVSIT(V,0),U),"."))=V
End DoDot:1
+38 IF 'G
QUIT G
+39 SET D=$ORDER(G(0))
SET V=G(D)
SET H=$ORDER(^AUPNVINP("AD",V,0))
+40 QUIT 1_U_$ORDER(G(0))_U_V_U_$SELECT(H:$PIECE($PIECE(^AUPNVINP(H,0),U),"."),1:"")_U_H
ASACONTR(P,BGPADM,BGPDD,BDATE,EDATE) ;does patient have an aspirin allergy
+1 KILL BGPMEDS1
+2 SET K=0
SET R=""
SET BGPG=""
+3 DO GETMEDS^BGP9UTL2(P,$$FMADD^XLFDT(BGPADM,-90),BGPDD,,,,,.BGPMEDS1)
+4 IF '$DATA(BGPMEDS1)
QUIT ""
+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 SET G=0
+9 SET D=$PIECE(^AUPNVMED(Y,0),U)
+10 IF T
IF $DATA(^ATXAX(T,21,"B",D))
SET G=1
GOTO WAR71
+11 SET N=$PIECE($GET(^PSDRUG(D,0)),U,1)
+12 IF N["WARFARIN"
SET G=1
GOTO WAR71
+13 IF 'G
QUIT
WAR71 ;
+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 ;discontinued before admission
IF J]""
IF J<BGPADM
QUIT
+7 SET E=$PIECE($PIECE(^AUPNVSIT(V,0),U),".")
+8 IF E'<BGPADM
IF E'>BGPDD
SET BGPG=1_U_$$DATE^BGP9UTL(E)_U_$PIECE(^PSDRUG(D,0),U)
+9 SET S=$PIECE(^AUPNVMED(Y,0),U,7)
+10 SET Z=$$FMDIFF^XLFDT(BGPADM,$PIECE($PIECE(^AUPNVSIT(V,0),U),"."))
+11 IF S>Z
SET BGPG=1_U_$$DATE^BGP9UTL($PIECE($PIECE(^AUPNVSIT(V,0),U),"."))_U_$PIECE(^PSDRUG(D,0),U)
+12 QUIT
End DoDot:1
+13 IF BGPG
QUIT 1_U_"asa contra warfarin rx "_$PIECE(BGPG,U,2)_" "_$PIECE(BGPG,U,3)
+14 ;now check for dx 459
+15 KILL BGPG
SET BGPG=$$LASTDXI^BGP9UTL1(P,"459.0",BDATE,EDATE)
+16 IF BGPG
QUIT 1_U_"asa contra 459.0 "_$$DATE^BGP9UTL($PIECE(BGPG,U,3))
+17 ;
+18 ;nmi in refusal file for aspirin
+19 SET BGPG=""
+20 SET T=$ORDER(^ATXAX("B","DM AUDIT ASPIRIN DRUGS",0))
+21 SET X=0
FOR
SET X=$ORDER(^AUPNPREF("AA",P,50,X))
IF X'=+X
QUIT
Begin DoDot:1
+22 ;not an aspirin
IF '$DATA(^ATXAX(T,21,"B",X))
QUIT
+23 SET D=0
FOR
SET D=$ORDER(^AUPNPREF("AA",P,50,X,D))
IF D'=+D
QUIT
Begin DoDot:2
+24 ;documented EDATE OF REPORT PERIOD
IF Y>EDATE
QUIT
+25 SET N=0
FOR
SET N=$ORDER(^AUPNPREF("AA",P,50,X,D,N))
IF N'=+N
QUIT
Begin DoDot:3
+26 IF $PIECE($GET(^AUPNPREF(N,0)),U,7)'="N"
QUIT
+27 SET BGPG=1_U_"asa contra NMI Aspirin: "_$$VAL^XBDIQ1(9000022,N,.04)_" "_$$DATE^BGP9UTL($PIECE(^AUPNPREF(N,0),U,3))_" "_$$VAL^XBDIQ1(9000022,X,1101)
End DoDot:3
+28 QUIT
End DoDot:2
+29 QUIT
End DoDot:1
+30 IF BGPG
QUIT BGPG
+31 ;now check for CPT code G8008
+32 SET X=$$CPTI^BGP9DU(P,BDATE,EDATE,+$$CODEN^ICPTCOD("G8008"))
+33 IF X
QUIT 1_U_"asa contra CPT code G8008: "_$$DATE^BGP9UTL($PIECE(X,U,2))
+34 SET X=$$TRANI^BGP9DU(P,BDATE,EDATE,+$$CODEN^ICPTCOD("G8008"))
+35 IF X
QUIT 1_U_"asa contra Tran Code G8008: "_$$DATE^BGP9UTL($PIECE(X,U,2))
+36 QUIT ""