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