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

BGP0DPA2.m

Go to the documentation of this file.
BGP0DPA2 ; IHS/CMI/LAB - COMP NATIONAL GPRA FOR PTS W/APPT 09 Jan 2009 3:36 PM 26 Jun 2009 3:40 PM 03 Jun 2010 8:04 AM ; 
 ;;10.0;IHS CLINICAL REPORTING;;JUN 18, 2010
 ;
I017 ;EP - colorectal cancer
 ;
 K BGPFOB,BGPSIG,BGPBE,BGPCOLO,BGPIN,BGPIN1,BGPIN2,BGPIN3
 I BGPAGEB<51 S BGPSKIP=1 Q
 I BGPAGEB>80 S BGPSKIP=1 Q
 I $$CRC^BGP0D61(DFN,BGPEDATE) S BGPSKIP=1 Q
 I 'BGPACTUP S BGPSKIP=1 Q
 S (BGPIN,BGPIN1,BGPIN2,BGPIN3)=""
 S BGPLAST=""
 S BGPFOB=$$FOB^BGP0D61(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)  ;last FOB test
 S D=$P(BGPFOB,U,2)
 I D]"",$$FMDIFF^XLFDT(DT,D)<365 S BGPIN=1
 I D>BGPLAST S BGPLAST=D
 S BGPSIG=$$SIG^BGP0D61(DFN,BGPEDATE,$$DOB^AUPNPAT(DFN))  ;last SIG test
 ;S D=$P(BGPSIG,U,3),BGPNSIG=$S($P(BGPSIG,U,3):$$FMADD^XLFDT(D,(5*365)),1:BGPBDATE) I BGPNSIG'>BGPED S BGPIN1=1
 ;I D>BGPLAST S BGPLAST=D_U_BGPNSIG
 S D=$P(BGPSIG,U,3)
 I D]"",$$FMDIFF^XLFDT(DT,D)<365 S BGPIN1=1
 I D>BGPLAST S BGPLAST=D
 S BGPCOLO=$$COLO^BGP0D61(DFN,BGPEDATE,$$DOB^AUPNPAT(DFN))  ;last COLO test
 ;S D=$P(BGPCOLO,U,3),BGPNCOLO=$S($P(BGPCOLO,U,3):$$FMADD^XLFDT(D,(10*365)),1:BGPBDATE) I BGPNCOLO'>BGPED S BGPIN2=1
 ;I D>BGPLAST S BGPLAST=D_U_BGPNCOLO
 S D=$P(BGPCOLO,U,3)
 I D]"",$$FMDIFF^XLFDT(DT,D)<365 S BGPIN2=1
 I D>BGPLAST S BGPLAST=D
 S BGPBE=$$BE^BGP0D61(DFN,BGPEDATE,$$DOB^AUPNPAT(DFN))  ;last BE test
 ;S D=$P(BGPBE,U,3),BGPNBE=$S($P(BGPBE,U,3):$$FMADD^XLFDT(D,(5*365)),1:DT) I BGPNBE'>BGPED S BGPIN3=1
 ;I D>BGPLAST S BGPLAST=D_U_BGPNBE
 S D=$P(BGPBE,U,3)
 I D]"",$$FMDIFF^XLFDT(DT,D)<365 S BGPIN3=1
 I D>BGPLAST S BGPLAST=D
 I BGPLAST]"",(BGPIN!(BGPIN1)!(BGPIN2)!(BGPIN3)) S BGPSKIP=1 Q  ;met at least one of above
 ;S BGPREF=$$REF^BGP0D61(DFN,BGPBDATE,BGPEDATE) I BGPREF S BGPSKIP=1 Q  ;refusal in past year
 S BGPN1=0
 S BGPISSV=$$TITLE(BGPGPRAI)
 S BGPX=""
 I BGPCOLO]"" S BGPX="Last Colonoscopy: "_$P(BGPCOLO,U,2)
 I BGPSIG]"" S BGPX=BGPX_$S(BGPX]"":"|",1:"") S BGPX=BGPX_"Last Flex Sig: "_$P(BGPSIG,U,2)
 ;
 I BGPFOB]"" S BGPX=BGPX_$S(BGPX]"":"|",1:"") S BGPX=BGPX_"Last FOBT: "_$$DATE^BGP0UTL($P(BGPFOB,U,2))
 I BGPBE]"" S BGPX=BGPX_$S(BGPX]"":"|",1:"")_"Last DCBE: "_$P(BGPBE,U,2)
 I BGPX="" S BGPX="No Colonoscopy, Flex Sig, FOBT or DCBE documented."
 S BGPX=BGPX_"|May be overdue as of: "_$S(BGPLAST]"":$$DATE^BGP0UTL($$FMADD^XLFDT(BGPLAST,365)),1:$$DATE^BGP0UTL(BGPBD))
 S BGPISSV=BGPISSV_U_BGPX
 K BGPREF,BGPOTH,BGPN1,BGPFOB,BGPNFOB,BGPBE,BGPF,BGPBE,BGPNBE,BGPSIG,BGPNSIG,BGPCOLO,BGPNCOLO,BGPIN,BGPIN1,BGPIN2,BGPIN3
 Q
 ;
I019 ;EP - tobacco cessation
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9)=0
 K BGPTOB,BGPSDX,BGP1320,BGPTC,BGPTQ
 S (BGPIN,BGPIN1)=0
 I 'BGPACTUP S BGPSKIP=1  ;must be at least user pop
 S BGPTOBP=$$TOBACCO^BGP0D7(DFN,$$DOB^AUPNPAT(DFN),$$FMADD^XLFDT(BGPBDATE,-1))
 S BGPTOBD=$P(BGPTOBP,U,3)
 S BGPSDX=$$DX^BGP0D7(DFN,$$DOB^AUPNPAT(DFN),$$FMADD^XLFDT(BGPBDATE,-1))
 I BGPTOBD<$P(BGPSDX,U,2) S BGPTOBD=$P(BGPSDX,U,2)
 S BGPSCPT=$$CPTSM^BGP0D7(DFN,$$DOB^AUPNPAT(DFN),$$FMADD^XLFDT(BGPBDATE,-1))
 I BGPTOBD<$P(BGPSCPT,U,2) S BGPTOBD=$P(BGPSDX,U,2)
 S X=0
 I BGPSDX]"",$P(BGPSDX,U,1)="305.13" S X=1
 I BGPSDX]"",$P(BGPSDX,U,1)="V15.82" S X=1
 I $P(BGPTOBP,U,1)["CURRENT"!(BGPSDX]""&('X))!(BGPTOBP["CESSATION")!($P(BGPSCPT,U)="1034F")!($P(BGPSCPT,U)="1035F")!($P(BGPSCPT,U)=99406)!($P(BGPSCPT,U)=99407)!($P(BGPSCPT,U)="G0375")!($P(BGPSCPT,U)="G0376") S BGPD2=1
 I 'BGPD2 S BGPSKIP=1 Q  ;S BGPISSV=$$TITLE(BGPGPRAI)_U_BGPN_U_BGPT D I019X Q  ;not a smoker
 S BGPN="",BGPT=""
 S BGPFOB=$$PED^BGP0D711(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,1)
 I BGPFOB="" S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Intervention: Never|Overdue as of: "_$$DATE^BGP0UTL(BGPBD) D I019X Q
 S D=$P(BGPFOB,U,1),BGPNFOB=$S($P(BGPFOB,U,1):$$FMADD^XLFDT(D,365),1:DT) I BGPNFOB'>BGPED S BGPIN1=1
 I 'BGPIN1 S BGPSKIP=1 Q
 S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Intervention: "_$$DATE^BGP0UTL($P(BGPFOB,U,1))_"|Overdue as of: "_$$DATE^BGP0UTL(BGPNFOB)
I019X ;
 K BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9
 K BGPTOB,BGPSDX,BGP1320,BGPTC,BGPTQ,BPGNTS,BGPN,BGPT,BGPIN1,BGPIN
 Q
I020 ;EP - Alcohol Screening
 I 'BGPACTUP S BGPSKIP=1 Q
 I BGPSEX'="F" S BGPSKIP=1 Q
 I BGPAGEB<15 S BGPSKIP=1 Q
 I BGPAGEB>44 S BGPSKIP=1 Q
 S (BGPD,BGPN,BGPN1,BGPREF,BGPNS,BGPV)=""
 S BGPN1=$$ALHF^BGP0D5(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
 S BGPD=$P(BGPN1,U,4),BGPV=$P(BGPN1,U,2)
 S BGPN1=$$ALDX^BGP0D5A(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
 I BGPD<$P(BGPN1,U,4) S BGPD=$P(BGPN1,U,4),BGPV=$P(BGPN1,U,2)
 S BGPN1=$$ALPED^BGP0D5(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
 I BGPD<$P(BGPN1,U,4) S BGPD=$P(BGPN1,U,4),BGPV=$P(BGPN1,U,2)
 S BGPNS=$S(BGPD:$$FMADD^XLFDT(BGPD,365),1:"")
 I BGPD="" S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Alcohol Screen: Never|Overdue as of: "_$$DATE^BGP0UTL(BGPBD) D I020X Q
 I BGPNS>BGPED S BGPSKIP=1 Q  ;not due
 S BGPISSV=$$TITLE(BGPGPRAI)
 I BGPV]"" S $P(BGPISSV,U,2)="Last Alcohol Screen: "_$$DATE^BGP0UTL(BGPD)
 I BGPV="" S $P(BGPISSV,U,2)="Alcohol Screening not documented",$P(BGPISSV,U,3)="Alcohol Screening Overdue" D I020X Q
 I BGPREF]"" S $P(BGPISSV,U,2)=$P(BGPISSV,U,2)_"|"_$S(BGPREF]"":"Patient Refused Alcohol Screening on "_$P(BGPREF,U,3),1:"")
 S $P(BGPISSV,U,2)=$P(BGPISSV,U,2)_"|"_$S(BGPNS'>BGPED:"Alcohol Screening Overdue as of: ",1:"Alcohol Screening next due: ")_$$DATE^BGP0UTL(BGPNS)
I020X ;
 K BGPD,BGPN,BGPN1,BGPREF,BGPNS
 Q
IAA ;EP
 I 'BGPACTUP S BGPSKIP=1 Q
 I BGPAGEB<18 S BGPSKIP=1 Q
 S (BGPD,BGPN,BGPN1,BGPREF,BGPNS)=""
 S BGPN1=$$DEP^BGP0D25(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
 I BGPN1 NEW X S X=$P(BGPN1,U,4),%DT="" D ^%DT S BGPD=Y,BGPV="2 Mood Disorder DXs "
 S BGPN1=$$DEPSCR^BGP0D25(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
 I BGPN1,BGPD<$P(BGPN1,U,4) S BGPD=$P(BGPN1,U,4),BGPV=$P(BGPN1,U,2)
 S BGPN1=$$DEPEDU^BGP0D25(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
 I BGPN1,BGPD<$P(BGPN1,U,4) S BGPD=$P(BGPN1,U,4),BGPV=$P(BGPN1,U,2)
 I BGPD="" S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Depression Screen: Never|Overdue as of: "_$$DATE^BGP0UTL(BGPBD) D IAAX Q
 S BGPNS=$S(BGPD:$$FMADD^XLFDT(BGPD,365),1:"")
 I BGPNS>BGPED S BGPSKIP=1 D IAAX Q
 S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Depression Screen: "_$$DATE^BGP0UTL(BGPD)_"|Overdue as of: "_$$DATE^BGP0UTL(BGPNS)
 ;
IAAX ;
 K BGPD,BGPN,BGPN1,BGPREF,BGPNS
 Q
I014 ;EP
 I BGPAGEB<5 S BGPSKIP=1 Q
 I BGPAGEB>17 S BGPSKIP=1 Q
 S BGPLDS=$$SEAL(DFN,$$DOB^AUPNPAT(DFN),DT) I 'BGPLDS S BGPSKIP=1 Q  ;never had a sealant
 S D=$P($$DENTSRV(DFN,$$DOB^AUPNPAT(DFN),DT),U,1)
 S BGPS=""
 I D]"",$$FMDIFF^XLFDT(DT,D)<180 S BGPSKIP=1 Q  ;dental exam less than 6 months ago
 I D]"",$$FMDIFF^XLFDT(DT,D)>180 S BGPS="May be overdue:  Patient is overdue for dental|exam and assessment for additional sealants.|Refer to Dental Program."
 I BGPLDS="" S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Dental Sealant: Never" Q
 S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Dental Sealant: "_$$DATE^BGP0UTL(BGPLDS)_"|"_BGPS
 Q
SEAL(P,BDATE,EDATE) ;
 NEW A,%,X,Y,BGPC,BGPG,BGPX,G,T,S,V
 K BGPG,BGPX
 K ^TMP($J,"A")
 S A="^TMP($J,""A"","
 S BGPC=0
 S %=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,A)
 S X=0,Y=0 F  S X=$O(^TMP($J,"A",X)) Q:X'=+X  S V=$P(^TMP($J,"A",X),U,5) D
 .S Y=0,G=0 F  S Y=$O(^AUPNVDEN("AD",V,Y)) Q:Y'=+Y  D
 ..S A=$P($G(^AUPNVDEN(Y,0)),U) I A S A=$P($G(^AUTTADA(A,0)),U) D
 ...Q:A'=1351
 ...S G=1
 ...S T=$P($G(^AUPNVDEN(Y,0)),U,4) S:T=""!(T=0) T=1
 ...S S=$P(^AUPNVDEN(Y,0),U,5)
 ...I S]"" S BGPX(S)=$G(BGPX(S))+T
 ...I S="" S BGPX("NO OS")=$G(BGPX("NO OS"))+T
 ...Q
 .Q:G  ;had ADA codes so skip cpts
 .S Y=0,G=0 F  S Y=$O(^AUPNVCPT("AD",V,Y)) Q:Y'=+Y  D
 ..S A=$P($G(^AUPNVCPT(Y,0)),U)
 ..Q:'A
 ..S A=$P($$CPT^ICPTCOD(A),U,2) I A="D1351" D
 ...S T=$P($G(^AUPNVCPT(Y,0)),U,16) S:T=""!(T=0) T=1
 ...S BGPX("CPT")=$G(BGPX("CPT"))+T
 S X="" F  S X=$O(BGPX(X)) Q:X=""  I X'="CPT" S BGPC=BGPC+$S(BGPX(X)>2:2,1:BGPX(X))
 S BGPC=BGPC+$G(BGPX("CPT"))
 Q BGPC
DENTSRV(P,BDATE,EDATE) ;EP
 K BGPG
 S BGPC="",%=P_"^LAST ADA 0000;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)) S BGPC=$P(BGPG(1),U)_"^"_"ADA "_$P(BGPG(1),U,2)
 K BGPG
 S %=P_"^LAST ADA 0190;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)),$P(BGPG(1),U)>$P(BGPC,U) S BGPC=$P(BGPG(1),U)_"^"_"ADA "_$P(BGPG(1),U,2)
 K BGPG S %=P_"^LAST EXAM DENTAL;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)),$P(BGPG(1),U)>$P(BGPC,U) S BGPC=$P(BGPG(1),U)_"^"_$P(BGPG(1),U,3)
 K BGPG
 S BGPG=$$LASTDXI^BGP0UTL1(P,"V72.2",BDATE,EDATE)
 I BGPG,$P(BGPG,U,3)>$P(BGPC,U,1) S BGPC=$P(BGPG,U,3)_"^V72.2"
 K BGPG S G="" S %=P_"^ALL ADA;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG) D  I G]"" Q G
 .S X=0 F  S X=$O(BGPG(X)) Q:X'=+X!(G]"")  S V=$P(BGPG(X),U,5) D
 ..I $P($G(^AUPNVSIT(V,0)),U,3)="C",$$VD^APCLV(V)>$P(BGPC,U,1) S BGPC=$P(BGPG(X),U)_"^CHS VISIT ADA "_$P(BGPG(X),U,2)
 Q BGPC
 ;
I016 ;EP
 I BGPAGEB<3 S BGPSKIP=1 Q
 I BGPAGEB>18 S BGPSKIP=1 Q
 S BGPLDS=$$TF(DFN,$$DOB^AUPNPAT(DFN),DT) I 'BGPLDS S BGPSKIP=1 Q  ;never had a TF
 S BGPS=""
 I BGPLDS]"",BGPLDS'<BGPBDATE S BGPSKIP=1 Q  ;fluoride during report period
 I BGPLDS]"",BGPLDS<BGPBDATE S BGPS="May be overdue:  Apply topical fluoride or refer|to Dental Program for assessment."
 I BGPLDS="" S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Topical Fluoride: Never" Q
 S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Topical Fluoride: "_$$DATE^BGP0UTL(BGPLDS)_"|"_BGPS
 Q
TF(P,BDATE,EDATE) ;
 NEW T,A,%,X,Y,T,Z,G,BGPZ,BGPJ,R
 K BGPG,BGPZ S BGPC=0
 K ^TMP($J,"A")
 S A="^TMP($J,""A"","
 S Z=$O(^ATXAX("B","BGP TOPICAL FLUORIDE ADA CODES",0))
 S %=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,A)
 S X=0,Y=0 F  S X=$O(^TMP($J,"A",X)) Q:X'=+X!(BGPC>3)  S V=$P(^TMP($J,"A",X),U,5) D
 .S Y=0,G=0 F  S Y=$O(^AUPNVDEN("AD",V,Y)) Q:Y'=+Y!(G>0)!(BGPC>3)  D
 ..S A=$P($G(^AUPNVDEN(Y,0)),U) D
 ...I $D(^ATXAX(Z,21,"B",A)) S T=$P($G(^AUPNVDEN(Y,0)),U,4) S:T=""!(T=0) T=1 S BGPC=BGPC+T,G=G+1
 ...Q
 .Q:G
 .S Y=0,G=0 F  S Y=$O(^AUPNVCPT("AD",V,Y)) Q:Y'=+Y!(G)!(BGPC>3)  D
 ..S A=$P($G(^AUPNVCPT(Y,0)),U)
 ..Q:'A
 ..I $$ICD^ATXCHK(A,$O(^ATXAX("B","BGP CPT TOPICAL FLUORIDE",0)),1) S T=$P($G(^AUPNVCPT(Y,0)),U,16) S:T=""!(T=0) T=1 S BGPC=BGPC+T,G=G+1
 .Q:G  ;one per visit
 .S Y=0,G=0 F  S Y=$O(^AUPNVPOV("AD",V,Y)) Q:Y'=+Y!(G)!(BGPC>3)  D
 ..S A=$P($G(^AUPNVPOV(Y,0)),U) I A S A=$P($$ICDDX^ICDCODE(A),U,2) D
 ...I A="V07.31" S BGPC=BGPC+1,G=1
 ...Q
 Q BGPC
I021 ;EP
 I 'BGPACTUP S BGPSKIP=1 Q
 I BGPSEX'="F" S BGPSKIP=1 Q
 I BGPAGEB<15 S BGPSKIP=1 Q
 I BGPAGEB>40 S BGPSKIP=1 Q
 S (BGPD,BGPN,BGPN1,BGPREF,BGPNS,BGPVA)=""
 S BGPN1=$$DVEX^BGP0D5(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
 S BGPD=$P(BGPN1,U,2),BGPVA=$P(BGPN1,U,3)
 S BGPN1=$$DVDX^BGP0D5(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
 I BGPD<$P(BGPN1,U,2) S BGPD=$P(BGPN1,U,2),BGPVA=$P(BGPN1,U,3)
 S BGPN1=$$DVPED^BGP0D5(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE)
 I BGPD<$P(BGPN1,U,2) S BGPD=$P(BGPN1,U,2),BGPVA=$P(BGPN1,U,3)
 S BGPNS=$S(BGPD:$$FMADD^XLFDT(BGPD,365),1:"")
 I BGPNS="" S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last DV Screen: Never|Overdue as of: "_$$DATE^BGP0UTL(BGPBD) D I021X Q
 I BGPNS>BGPED S BGPSKIP=1 D I021X Q
 S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last DV Screen: "_$$DATE^BGP0UTL(BGPD)_"|Overdue as of: "_$$DATE^BGP0UTL(BGPNS)
I021X ;
 K BGPD,BGPN,BGPN1,BGPREF,BGPNS
 Q
IE2 ;EP
 K BGPSTOP
 S BGPISSO=1
 D IE2^BGP0D8
 I $D(BGPSTOP) S BGPSKIP=1 Q
 S BGPISSV=""
 I BGPN4 S BGPSKIP=1 Q
 I 'BGPD1 S BGPSKIP=1 Q  ;only ac pregnant
 S BGPISSV=BGPISSV_$$TITLE(BGPGPRAI)
 I 'BGPN4 S $P(BGPISSV,U,2)="Overdue as of: "_$$DATE^BGP0UTL(BGPBD)
 K BGPHIV,BGPN1,X,Y,Z,%,A,B,C,D,E,H,BDATE,EDATE,P,V,S,F,T,BGPEDUC,BGPHIV
 K BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9
 Q
I0302A ;EP
 K BGPSTOP
 I BGPAGEB<22 S BGPSKIP=1 Q
 K ^TMP($J)
 I '$$FIRSTIHD^BGP0D721(DFN,BGPEDATE) S BGPSKIP=1 Q  ;first dx not prior to report period
 I '$$V2IHD^BGP0D721(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE) S BGPSKIP=1 Q  ;at least 2 IHD dxs ever
 D I0302ASC^BGP0D41
 S BGPISSV=""
 I BGPN9 S BGPSKIP=1 D I0302AX Q  ;met measure 
 S BGPISSV=BGPISSV_$$TITLE(BGPGPRAI)
 S X="",BGPVAL="",BGPVAL2=""
 I BGPN8 S BGPN4=0
BP ;
 I 'BGPN1 S BGPVAL=BGPVAL_"2 BPs"
LDL ;
 I 'BGPN2 S BGPVAL=BGPVAL_$S(BGPVAL]"":", ",1:"")_"LDL"
TOB ;
 I 'BGPN3 S BGPVAL=BGPVAL_$S(BGPVAL]"":", ",1:"")_"Tobacco Screen"
BMI ;
 I 'BGPN4 S BGPVAL2=BGPVAL2_$S(BGPVAL2]"":", ",1:"")_"BMI"
LIFE ;
 I 'BGPN5 S BGPVAL2=BGPVAL2_$S(BGPVAL2]"":", ",1:"")_"Lifestyle Counseling"
 S BGPISSV=BGPISSV_U_"Sreenings Overdue: "_BGPVAL_"|"_BGPVAL2
I0302AX ;EP
 K BGPBP,BGPLDL,BGPTOB,BGPBMI,BGPLIFE,BGPDEP,X,Y,Z,%,A,B,C,D,E,H,BDATE,EDATE,P,V,S,F,T,BGPEDUC,BGPHIV
 K BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9
 Q
I031A ;EP
 S BGPSKIP=""
 K BGPSTOP
 I BGPAGEB<2 S BGPSKIP=1 Q
 I BGPAGEB>5 S BGPSKIP=1 Q
 I BGPAGEE>5 S BGPSKIP=1 Q
 ;I 'BGPACTCL S BGPSKIP=1 Q
 S BGPD1=1,BGPN1=0,BGPN2=0,BGPIN1=0
 S BGPBMI=$$BMIOR^BGP0D6(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE,BGPAGEE)
 I $P(BGPBMI,U)="" S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last BMI: Never|Overdue as of: "_$$DATE^BGP0UTL(BGPBD) D I031AX Q
 I $$FMADD^XLFDT($P(BGPBMI,U,2),365)<BGPED S BGPIN1=1
 S BGPOW=$$OW^BGP0D6(DFN,$P(BGPBMI,U),$$AGE^AUPNPAT(DFN,$P(BGPBMI,U,2))) I BGPOW S BGPN1=1
 S BGPOB=$$OB^BGP0D6(DFN,$P(BGPBMI,U),$$AGE^AUPNPAT(DFN,$P(BGPBMI,U,2))) I BGPOB S BGPN2=1
 S A=$$AGE^AUPNPAT(DFN,$P(BGPBMI,U,2))
 I 'BGPIN1,'BGPOB S BGPSKIP=1 D I031AX Q
 S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last BMI: "_$P(BGPBMI,U)_":"_$$DATE^BGP0UTL($P(BGPBMI,U,2))_" Age at BMI: "_A_$S(BGPOW:" At Risk 85-94%",BGPOB:" OW 95%",1:"")
 I BGPIN1 S BGPISSV=BGPISSV_"|Overdue as of: "_$$DATE^BGP0UTL($$FMADD^XLFDT($P(BGPBMI,U,2),365))
I031AX ; 
 K BGPBMIH,BGPBMI,BGPOW,BGPOB,BGPD1
 Q
TITLE(I) ;
 Q $P($G(^BGPINDTC(I,12)),U,9)
BFR ;EP
 S BGPSKIP=""
 K BGPSTOP,BGPBFR
 S BGPADAY=$$FMDIFF^XLFDT(DT,$P(^DPT(DFN,0),U,3))  ;LORI CHANGE AFTER TESTING TO DT
 I BGPADAY<45 S BGPSKIP=1 Q
 I BGPADAY>394 S BGPSKIP=1 Q
 D GETIFC(DFN,BGPBDATE,BGPEDATE,.BGPBFR)
 I '$D(BGPBFR) S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Infant Feeding Choice Screening: Never" D BFRX Q   ;|Overdue as of: "_$$DATE^BGP0UTL(DT) D BFRX Q
 ;GET LASTEST (highest days old)
 S X=0,Y="" F  S X=$O(BGPBFR(X)) Q:X'=+X  S Y=X
 S BGPISSV=$$TITLE(BGPGPRAI)_U_"Last Infant Feeding Choice Screening: "_$$DATE^BGP0UTL($P(BGPBFR(Y),U,2))  ;_"|Overdue as of: "_$$DATE^BGP0UTL(DT)
 ;
BFRX ;
 K BGPADAY,BGPBFR
 Q
GETIFC(P,BDATE,EDATE,BGPRET) ;EP
 K BGPRET,BGPG,C,X
 S X=0 F  S X=$O(^AUPNVIF("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVIF(X))
 .S V=$P(^AUPNVIF(X,0),U,3),C=$P(^AUPNVIF(X,0),U,1)
 .Q:V=""
 .Q:'$D(^AUPNVSIT(V,0))
 .S V=$P($P(^AUPNVSIT(V,0),U),".")
 .S BGPRET($$FMDIFF^XLFDT(V,$P(^DPT(P,0),U,3)))=C_U_V
 .Q
 Q