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

BGP3D52.m

Go to the documentation of this file.
BGP3D52 ; IHS/CMI/LAB - measure 31 ;
 ;;13.0;IHS CLINICAL REPORTING;**1**;NOV 20, 2012;Build 7
 ;
WASS ;
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5)=0
 NEW BGPBMI,BGPNUTR,BGPPHY
 I 'BGPACTCL S BGPSTOP=1 Q  ;must be active clinical
 I BGPAGEE<3 Q  ;age at end must be 3 or older
 S BGPD1=1
 I BGPAGEE>2,BGPAGEE<12 S BGPD2=1
 I BGPAGEE>11,BGPAGEE<18 S BGPD3=1
 I BGPAGEE>17 S BGPD4=1
 I BGPAGEE>2,BGPAGEE<18 S BGPD5=1
 S BGPBMI=$$BMI^BGP3D6(DFN,BGPEDATE,BGPAGEE)
 I BGPBMI="" S BGPBMI=$$LASTDX^BGP3UTL1(DFN,"BGP BMI DXS",BGPBDATE,BGPEDATE) I BGPBMI S BGPBMI=$P(BGPBMI,U,2)
 S BGPN2=$S(BGPBMI]"":1,1:0)
 S BGPNUTR=$$NUTR(DFN,BGPBDATE,BGPEDATE),BGPN3=$S(BGPNUTR]"":1,1:0)
 S BGPPHY=$$PHY(DFN,BGPBDATE,BGPEDATE),BGPN4=$S(BGPPHY]"":1,1:0)
 I BGPN2,BGPN3,BGPN4 S BGPN1=1
 S BGPVALUE="AC|||"
 S N=""
 I BGPN1 S N="COMP ASSESS"
 I BGPN2 D
 .I N]"" S N=N_"; "
 .S N=N_"BMI: "_$S('$E(BGPBMI):BGPBMI,1:$J(BGPBMI,5,2))
 I BGPN3 D
 .I N]"" S N=N_"; "
 .S N=N_"NUTR: "_$$DATE^BGP3UTL($P(BGPNUTR,U))_" "_$P(BGPNUTR,U,2)
 I BGPN4 D
 .I N]"" S N=N_"; "
 .S N=N_"PHY: "_$$DATE^BGP3UTL($P(BGPPHY,U))_" "_$P(BGPPHY,U,2)
 S BGPVALUE=BGPVALUE_N
 S BGPVALUD=BGPVALUE
 Q
 ;
NUTR(P,BDATE,EDATE) ;EP
 NEW BGPG,X,BGPALLED,Y,E,D,T,%,S
 S X=P_"^LAST DX [BGP DIETARY SURVEILLANCE DXS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,"BGPG(")
 I $D(BGPG(1)) Q $P(BGPG(1),U)_U_"DX "_$P(BGPG(1),U,2)
 S BGPG=$$CPT^BGP3DU(P,BDATE,EDATE,$O(^ATXAX("B","BGP CPT NUTRITION COUNSELING",0)),5)
 I BGPG Q $P(BGPG,U,1)_U_"CPT "_$P(BGPG,U,2)  ;BGPG
 S Y="BGPALLED("
 S X=P_"^ALL EDUC;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 S (X,D)=0,%="",T="" F  S X=$O(BGPALLED(X)) Q:X'=+X!(%]"")  D
 .S T=$P(^AUPNVPED(+$P(BGPALLED(X),U,4),0),U)
 .Q:'T
 .Q:'$D(^AUTTEDT(T,0))
 .S T=$P(^AUTTEDT(T,0),U,2)
 .I $P(T,"-",2)="N"!($P(T,"-",2)="DT")!($P(T,"-",2)="MNT") S %=$P(BGPALLED(X),U)_U_"EDUC: "_T Q
 .S S=$P(T,"-",1)
 .S S=$$ICDDX^ICDCODE(S)
 .I $P(S,U,1)'="-1",$$ICD^ATXCHK($P(S,U,1),$O(^ATXAX("B","BGP DIETARY SURVEILLANCE DXS",0)),9) S %=$P(BGPALLED(X),U)_U_"EDUC: "_T Q
 .S S=$P(T,"-",1),S=$$CPT^ICPTCOD(S)
 .I $P(S,U,1)'="-1",$$ICD^ATXCHK($P(S,U,1),$O(^ATXAX("B","BGP CPT NUTRITION COUNSELING",0)),1) S %=$P(BGPALLED(X),U)_U_"EDUC: "_T Q
 I %]"" Q %
 Q ""
PHY(P,BDATE,EDATE) ;EP
 NEW BGPG,X,E,BGPALLED,T,%,D
 S X=P_"^LAST DX [BGP EXERCISE COUNSELING DXS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,"BGPG(")
 I $D(BGPG(1)) Q $P(BGPG(1),U)_U_"DX "_$P(BGPG(1),U,2)
 S BGPG=$$CPT^BGP3DU(P,BDATE,EDATE,$O(^ATXAX("B","BGP CPT PHYSICAL ACTIVITY",0)),5)
 I BGPG Q $P(BGPG,U,1)_U_"CPT "_$P(BGPG,U,2)  ;BGPG
 S Y="BGPALLED("
 S X=P_"^ALL EDUC;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 S (X,D)=0,%="",T="" F  S X=$O(BGPALLED(X)) Q:X'=+X!(%]"")  D
 .S T=$P(^AUPNVPED(+$P(BGPALLED(X),U,4),0),U)
 .Q:'T
 .Q:'$D(^AUTTEDT(T,0))
 .S T=$P(^AUTTEDT(T,0),U,2)
 .I $P(T,"-",2)="EX" S %=$P(BGPALLED(X),U)_U_T Q
 .S S=$P(T,"-",1)
 .S S=$$ICDDX^ICDCODE(S)
 .I $P(S,U,1)'="-1",$$ICD^ATXCHK($P(S,U,1),$O(^ATXAX("B","BGP EXERCISE COUNSELING DXS",0)),9) S %=$P(BGPALLED(X),U)_U_T Q
 .S S=$P(T,"-",1),S=$$CPT^ICPTCOD(S)
 .I $P(S,U,1)'="-1",$$ICD^ATXCHK($P(S,U,1),$O(^ATXAX("B","BGP CPT PHYSICAL ACTIVITY",0)),1) S %=$P(BGPALLED(X),U)_U_"EDUC: "_T Q
 I %]"" Q %
 Q ""
EAPT(P,BDATE,EDATE,BGPDAYS,BGPGAP,BGPDAYS1) ;EP
 ;get all ANTIDEPRESSANTS
 K ^TMP($J,"MEDS")
 K BGPZ,M
 S (G,N,Y,X,T,T1,T2,M,K,S,C,R,A)=""
 S K=0
 S Y="^TMP($J,""MEDS"",",X=P_"^ALL MED;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 S T=$O(^ATXAX("B","BGP HEDIS ANTIDEPRESSANT MEDS",0))
 S T2=$O(^ATXAX("B","BGP HEDIS ANTIDEPRESSANT VA CLASS",0))
 S X=0 F  S X=$O(^TMP($J,"MEDS",X)) Q:X'=+X  S Y=+$P(^TMP($J,"MEDS",X),U,4) D
 .Q:'$D(^AUPNVMED(Y,0))
 .S V=$P(^AUPNVMED(Y,0),U,3)
 .Q:'$D(^AUPNVSIT(V,0))
 .S G=0
 .S D=$P(^AUPNVMED(Y,0),U)
 .I T,$D(^ATXAX(T,21,"B",D)) S G=1 G EAPT1
 .S C=$P($G(^PSDRUG(D,0)),U,2)
 .I C]"",T2,$D(^ATXAX(T2,21,"B",C)) S G=1 G EAPT1
 .Q:'G
EAPT1 .;
 .S J=$P(^AUPNVMED(Y,0),U,8)
 .S S=$$DAYS^BGP3D82(Y,V,EDATE)
 .S K=S+K  ;TOTAL DAYS SUPPLY
 .I R]"" S R=R_";"
 .S R=R_$$DATE^BGP3UTL($P($P(^AUPNVSIT(V,0),U),"."))_"("_S_")"
 .S F=$P($P(^AUPNVSIT(V,0),U),".")
 .S A=$$FMADD^XLFDT(F,$P(^AUPNVMED(Y,0),U,7))
 .I J]"",J<A S A=J
 .S M(F)=A  ;$S(J:J,1:$$FMADD^XLFDT(F,$P(^AUPNVMED(Y,0),U,7)))
 ;I K>83 S BGPREG=1_U_Q 1_U_" total days beta blocker: "_K
GAP ;now FIGURE OUT GAP DAYS
 S G=0  ;gap days
 S B=0 F  S B=$O(M(B)) Q:B'=+B  S E=M(B) D
 .S Y=$O(M(B)) ;NEXT BEGINNING
 .;I Y="" S Y=$$FMADD^XLFDT(BDATE,BGPDAYS1)
 .I Y="" Q
 .I Y>EDATE Q
 .S Z=$$FMDIFF^XLFDT(Y,E)
 .I Z>0 S G=Z+G
 .Q
 I G>BGPGAP!(K<BGPDAYS) Q 0_U_R_U_"DAYS="_K_", GAP="_G
 Q 1_U_R_U_"DAYS="_K_", GAP="_G