Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BGP4D39

BGP4D39.m

Go to the documentation of this file.
  1. BGP4D39 ; IHS/CMI/LAB - measure C ;
  1. ;;14.1;IHS CLINICAL REPORTING;;MAY 29, 2014;Build 114
  1. ;
  1. MEDCOV ;EP
  1. S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7,BGPN8,BGPN9,BGPN10,BGPN11,BGPN12,BGPN13,BGPN14,BGPN15,BGPN16,BGPN17,BGPN18,BGPN19,BGPN20,BGPN21,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9,BGPD10,BGPD11)=0
  1. NEW BGPBETA,BGPACEI,BGPCCB,BGPBIG,BGPSULF,BGPTHIA,BGPSTATI,BGPANTI,BGPDPP,BGPDMALL,BDMNWARI
  1. S BGPVALUE=""
  1. I 'BGPACTUP S BGPSTOP=1 Q
  1. I 'BGPACTCL S BGPSTOP=1 Q ;must be active clinical
  1. I BGPAGEB<18 S BGPSTOP=1 Q ;no one under 18
  1. S BGPBETA=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA BETA BLOCKER MEDS","BGP PQA BETA BLOCKER NDC","BB") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPBETA,U,1) D
  1. .S BGPD1=1
  1. .S %=$P(BGPBETA,U,2) I %>79 S BGPN1=1
  1. .S BGPN2=$P(BGPBETA,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPBETA,U,4)
  1. S BGPACEI=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA RASA MEDS","BGP PQA RASA NDC","RASA") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPACEI,U,1) D
  1. .S BGPD2=1
  1. .S %=$P(BGPACEI,U,2) I %>79 S BGPN3=1
  1. .S BGPN4=$P(BGPACEI,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPACEI,U,4)
  1. S BGPCCB=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA CCB MEDS","BGP PQA CCB NDC","CCB") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPCCB,U,1) D
  1. .S BGPD3=1
  1. .S %=$P(BGPCCB,U,2) I %>79 S BGPN5=1
  1. .S BGPN6=$P(BGPCCB,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPCCB,U,4)
  1. S BGPBIG=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA BIGUANIDE MEDS","BGP PQA BIGUANIDE NDC","BIG") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPBIG,U,1) D
  1. .S BGPD4=1
  1. .S %=$P(BGPBIG,U,2) I %>79 S BGPN7=1
  1. .S BGPN8=$P(BGPBIG,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPBIG,U,4)
  1. S BGPSULF=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA SULFONYLUREA MEDS","BGP PQA SULFONYLUREA NDC","SULF") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPSULF,U,1) D
  1. .S BGPD5=1
  1. .S %=$P(BGPSULF,U,2) I %>79 S BGPN9=1
  1. .S BGPN10=$P(BGPSULF,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPSULF,U,4)
  1. S BGPTHIA=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA THIAZOLIDINEDIONE MEDS","BGP PQA THIAZOLIDINEDIONE NDC","THIAZ") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPTHIA,U,1) D
  1. .S BGPD6=1
  1. .S %=$P(BGPTHIA,U,2) I %>79 S BGPN11=1
  1. .S BGPN12=$P(BGPTHIA,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPTHIA,U,4)
  1. S BGPDPP=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA DPP IV MEDS","BGP PQA DPP IV NDC","DPP") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPDPP,U,1) D
  1. .S BGPD9=1
  1. .S %=$P(BGPDPP,U,2) I %>79 S BGPN16=1
  1. .S BGPN17=$P(BGPDPP,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPDPP,U,4)
  1. S BGPDMALL=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA DIABETES ALL CLASS","BGP PQA DIABETES ALL CLASS NDC","DMALL") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPDMALL,U,1) D
  1. .S BGPD10=1
  1. .S %=$P(BGPDMALL,U,2) I %>79 S BGPN18=1
  1. .S BGPN19=$P(BGPDMALL,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPDMALL,U,4)
  1. S BGPSTATI=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA STATIN MEDS","BGP PQA STATIN NDC","STATIN") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPSTATI,U,1) D
  1. .S BGPD7=1
  1. .S %=$P(BGPSTATI,U,2) I %>79 S BGPN13=1
  1. .S BGPN14=$P(BGPSTATI,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPSTATI,U,4)
  1. S BGPNWARI=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA NON-WARF ANTICOAG MEDS","BGP PQA NON-WARF ANTICOAG NDC","ANTICOAG") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPNWARI,U,1) D
  1. .S BGPD11=1
  1. .S %=$P(BGPNWARI,U,2) I %>79 S BGPN20=1
  1. .S BGPN21=$P(BGPNWARI,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPNWARI,U,4)
  1. S BGPANTI=$$COVERAGE(DFN,BGPBDATE,BGPEDATE,"BGP PQA ANTIRETROVIRAL MEDS","BGP PQA ANTIRETROVIRAL NDC","ANTIRET") ; return 1 if meets denominator^%coverage^# gap days^# prescriptions
  1. I $P(BGPANTI,U,1) D
  1. .S BGPD8=1
  1. .S %=$P(BGPANTI,U,2) I %>89 S BGPN15=1
  1. .;S BGPN14=$P(BGPSTATI,U,3)
  1. .S BGPVALUE=BGPVALUE_$S(BGPVALUE]"":"; ",1:"")_$P(BGPANTI,U,4)
  1. S BGPVALUE="AC"_"|||"_BGPVALUE
  1. K A,B,C,D,E,F,G,H,I,J,K,M,N,O,P,Q,R,S,T,V,W,X,Y,Z,BDATE,EDATE,BGPDN,BGPN,BGPG,BGPC,BDMDMALL,BDMSTATI,BDMANTI,BDM
  1. K ^TMP($J,"A"),BGPMEDS1
  1. Q
  1. ;
  1. COVERAGE(P,BDATE,EDATE,MTAX,NTAX,TYPE) ;
  1. K ^TMP($J,"A")
  1. NEW A,B,E,Z,X,D,V,Y,G,M,T,T1,BGPMEDS1,C,BGPISD,BGPMP,DAYS,LEND,SD,DC,N,S,PER,GAP
  1. I TYPE="RASA"!(TYPE="DMALL"),$$ESRD^BGP4D211(DFN,$P(^DPT(DFN,0),U,3),BGPEDATE) Q ""
  1. I TYPE="ANTICOAG" I $$HADWARF(DFN,BDATE,EDATE) Q "" ;HAD WARFARIN IN TIME PERIOD
  1. K BGPMEDS1
  1. D GETMEDS^BGP4UTL2(P,BDATE,EDATE,MTAX,NTAX,,,.BGPMEDS1)
  1. I '$D(BGPMEDS1) Q "" ; no beta blocker meds
  1. S BGPISD=""
  1. S (A,C)=0 F S A=$O(BGPMEDS1(A)) Q:A'=+A D
  1. .S M=$P(BGPMEDS1(A),U,4) ;IEN OF V MED
  1. .Q:'$D(^AUPNVMED(M,0))
  1. .I $$UP^XLFSTR($P($G(^AUPNVMED(M,11)),U))["RETURNED TO STOCK" K BGPMEDS1(A) Q
  1. .I $P(^AUPNVMED(M,0),U,8)=$P(BGPMEDS1(A),U,1) K BGPMEDS1(A) Q ;d/c'ed on same day as visit so no days suppply
  1. .I '$P(^AUPNVMED(M,0),U,7) K BGPMEDS1(A) Q ;no days supply
  1. .I BGPISD="" S BGPISD=$P(BGPMEDS1(A),U,1) ;first date
  1. .S C=C+1
  1. I C<2 Q "" ;does not have 2 scripts
  1. I BGPISD>$$FMADD^XLFDT(EDATE,-90) Q "" ;INDEX START DATE AFTER EDATE-90
  1. I TYPE="ANTICOAG" S G=0 D NONW180 I G Q ""
  1. S BGPMP=$$FMDIFF^XLFDT(EDATE,BGPISD)
  1. ;COVERAGE
  1. S DAYS=0,LEND="",GAP=""
  1. S X=0 F S X=$O(BGPMEDS1(X)) Q:X'=+X D
  1. .S V=$P(BGPMEDS1(X),U,5)
  1. .S SD=$$VD^APCLV(V) ;start date of med
  1. .I LEND="" S LEND=SD
  1. .I LEND,LEND>SD S SD=LEND
  1. .S G=$$FMDIFF^XLFDT(SD,LEND) I G>30,GAP="" S GAP=G
  1. .S M=$P(BGPMEDS1(X),U,4)
  1. .S DC=$P(^AUPNVMED(M,0),U,8) ;date discontinued
  1. .S N=$P(^AUPNVMED(M,0),U,7) ;days supply
  1. .I $$FMADD^XLFDT(SD,N)>EDATE S N=$$FMDIFF^XLFDT(EDATE,SD)
  1. .S S=0 I DC]"",SD]"" S S=$$FMDIFF^XLFDT(DC,SD)
  1. .I S>0,S<N S N=S
  1. .;N IS DAYS SUPPLY
  1. .S LEND=$$FMADD^XLFDT(SD,(N+1)) ;new end date
  1. .S DAYS=DAYS+N
  1. I DAYS<61,TYPE="ANTICOAG" Q ""
  1. I LEND]"" S G=$$FMDIFF^XLFDT(EDATE,LEND) I G>30,GAP="" S GAP=G
  1. S PER=$J(((DAYS/BGPMP)*100),3,0)
  1. S PER=$$STRIP^XLFSTR(PER," ")
  1. S C=1_U_PER_U_$S(GAP:1,1:"")_U_TYPE_": IXRD: "_$$DATE^BGP4UTL(BGPISD)_" ["_BGPMP_"] Days="_DAYS
  1. I TYPE'="ANTIRET" S %=$S(PER>79:">80",1:"<80") S C=C_" "_%
  1. I TYPE="ANTIRET" S %=$S(PER>89:">90",1:"<90") S C=C_" "_%
  1. I TYPE'="ANTIRET" S C=C_$S(GAP:", GAP="_GAP,1:"")
  1. ;CALULATE %COVERAGE AND GAP DAYS
  1. Q C
  1. ;
  1. TEST ;
  1. F Y=44142 S X=$$COVERAGE(Y,3030101,3031231,"BGP PQA BETA BLOCKER MEDS","BGP PQA BETA BLOCKER NDC") I X]"" W !,Y," ",X
  1. Q
  1. HADWARF(P,BDATE,EDATE) ;
  1. NEW BGPMEDS1,C,A,M
  1. K BGPMEDS1
  1. D GETMEDS^BGP4UTL2(P,BDATE,EDATE,"BGP PQA WARFARIN MEDS","BGP PQA WARFARIN NDC",,,.BGPMEDS1)
  1. I '$D(BGPMEDS1) Q "" ; NO MEDS
  1. S (A,C)=0 F S A=$O(BGPMEDS1(A)) Q:A'=+A D
  1. .S M=$P(BGPMEDS1(A),U,4) ;IEN OF V MED
  1. .Q:'$D(^AUPNVMED(M,0))
  1. .I $$UP^XLFSTR($P($G(^AUPNVMED(M,11)),U))["RETURNED TO STOCK" K BGPMEDS1(A) Q
  1. .I $P(^AUPNVMED(M,0),U,8)=$P(BGPMEDS1(A),U,1) K BGPMEDS1(A) Q ;d/c'ed on same day as visit so no days suppply
  1. .I '$P(^AUPNVMED(M,0),U,7) K BGPMEDS1(A) Q ;no days supply
  1. .S C=C+1
  1. .Q
  1. Q C
  1. NONW180 ;
  1. ;is the index start greater that 180 from last fill date? if so set g=1
  1. NEW A,B,C,D
  1. S A=0 F S A=$O(BGPMEDS1(A)) Q:A'=+A S B=A
  1. S D=$P(BGPMEDS1(B),U,1) ;LAST FILL
  1. I $$FMDIFF^XLFDT(D,BGPISD)<180 S G=1
  1. Q