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

BGP7D3.m

Go to the documentation of this file.
BGP7D3 ; IHS/CMI/LAB - measure 11 17 Oct 2009 12:40 PM ;
 ;;17.1;IHS CLINICAL REPORTING;;MAY 10, 2017;Build 29
 ;
 ;
I10 ;EP
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7,BGPN8,BGPN9,BGPN10,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9)=0
 S (BGPSEAL,BGPSEALD,BGPSEALR)=""
 K BGPSEALS,BGPSELDS,BGPSEALR
 D SEAL^BGP7D3A(DFN,BGPBDATE,BGPEDATE) ;this is for the number of sealants only
 D SEALR^BGP7D3A(DFN,BGPBDATE,BGPEDATE)
 S BGPN1=$P(BGPSEAL,U)+$P(BGPSEALR,U,1)
 ;BGPN1 is total # of sealants for sealant measure
 I BGPAGEB>1,BGPAGEB<16 S BGPN2=BGPN1
 I BGPAGEB>1,BGPAGEB<20,BGPN1 S BGPN7=1
 I BGPAGEB>15 S BGPN3=BGPN1
 I BGPAGEB>18 S BGPN4=BGPN1
 S BGPD9=0 I BGPAGEB>1,BGPAGEB<16 S X=$$DENTSRV^BGP7D21(DFN,BGPBDATE,BGPEDATE) I X S BGPD9=1  ;V17.1 DEV DENOM
 ;S BGPN1=0 I $P(BGPVALUE,U)=1 S BGPN1=1
I101 ;
 ;get new sealant definition 2015 gpra dev
 S BGPSEALD=""
 I 'BGPN1 S BGPSEALD=$$SEALDEV^BGP7D3A(DFN,BGPBDATE,BGPEDATE)
 I BGPSEALD S BGPN7=1
 I BGPAGEB=2,BGPN7 S BGPN10=1
 I BGPAGEB>2,BGPAGEB<6,BGPN7 S BGPN5=1
 I BGPAGEB>5,BGPAGEB<10,BGPN7 S BGPN6=1
 I BGPAGEB>9,BGPAGEB<13,BGPN7 S BGPN8=1
 I BGPAGEB>12,BGPAGEB<16,BGPN7 S BGPN9=1
 I BGPAGEB>1,BGPAGEB<16 S BGPD7=1
 ;I BGPAGEB>4,BGPAGEB<20 S BGPD8=1
 ;I 'BGPN1,'BGPD7 S BGPSTOP=1 Q
 S BGPVALUE="UP"_$S(BGPD9:",DV",1:"")_"|||"   ;    _+BGPN1_" sealants"
 I 'BGPN1,BGPD7!(BGPD8) S BGPVALUE=BGPVALUE_$P(BGPSEALD,U,2)
 I BGPN1 S BGPVALUE=BGPVALUE_"; "_+BGPN1_" sealants: " D
 .S X=0 F  S X=$O(BGPSEALS(X)) Q:X'=+X  S D=0 F  S D=$O(BGPSEALS(X,D)) Q:D'=+D  S BGPVALUE=BGPVALUE_$S(X=1:"",1:"; ")_$$DATE^BGP7UTL(D)_" "_BGPSEALS(X,D)
 .S X=0 F  S X=$O(BGPSEALR(X)) Q:X'=+X  S D=0 F  S D=$O(BGPSEALR(X,D)) Q:D'=+D  S BGPVALUE=BGPVALUE_$S(X=1:"",1:"; ")_$$DATE^BGP7UTL(D)_" "_BGPSEALR(X,D)
 K BGPSEAL,BGPSEALD,BGPSEALR
 Q
I11 ;EP
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9)=0
 NEW BGPFLUOR
 I '$G(BGPACTUP) S BGPSTOP=1 Q
 I BGPACTUP S BGPD1=1
 S BGPFLUOR=$$TF^BGP7D3A(DFN,BGPBDATE,BGPEDATE)
 S BGPN1=$P(BGPFLUOR,U)
 I BGPN1>4 S BGPN1=4
 I BGPAGEB>0,BGPAGEB<16 S BGPD2=1,BGPN3=$S(BGPN1:1,1:0)
 I BGPAGEB>0,BGPAGEB<3 S BGPD3=1
 I BGPAGEB>2,BGPAGEB<6 S BGPD4=1
 I BGPAGEB>0,BGPAGEB<6 S BGPD5=1
 I BGPAGEB>5,BGPAGEB<10 S BGPD6=1
 I BGPAGEB>9,BGPAGEB<13 S BGPD7=1
 I BGPAGEB>12,BGPAGEB<16 S BGPD8=1
 S BGPD9=0 I BGPAGEB>0,BGPAGEB<16 S X=$$DENTSRV^BGP7D21(DFN,BGPBDATE,BGPEDATE) I X S BGPD9=1  ;V17.1 DEV DENOM
I111 ;
 S BGPVALUE="UP|||"_+BGPN1_" topical fluoride"
 I +BGPN1 S BGPVALUE=BGPVALUE_": " F X=2:1:5 I $P(BGPFLUOR,U,X)]"" S BGPVALUE=BGPVALUE_$S(X>2:", ",1:"")_$$DATE^BGP7UTL($P($P(BGPFLUOR,U,X),"|",1))_" "_$P($P(BGPFLUOR,U,X),"|",2)
 ;I BGPN2 S BGPVALUE=BGPVALUE_": "_$$DATE^BGP7UTL($P(BGPFLUOR,U,2))_" "_$P(BGPFLUOR,U,3)
 S BGPVALUD="UP|||"
 I +BGPN1 S BGPVALUD=BGPVALUD_+BGPN1_" topical fluoride" I +BGPN1 S BGPVALUD=BGPVALUD_": " F X=2:1:5 I $P(BGPFLUOR,U,X)]"" S BGPVALUD=BGPVALUD_$S(X>2:", ",1:"")_$$DATE^BGP7UTL($P($P(BGPFLUOR,U,X),"|",1))_" "_$P($P(BGPFLUOR,U,X),"|",2)
 ;I BGPN2 S BGPVALUD=BGPVALUD_": "_$$DATE^BGP7UTL($P(BGPFLUOR,U,2))_" "_$P(BGPFLUOR,U,3)
 K ^TMP($J,"A"),BGPFLUOR
 Q
I12 ;EP
 NEW BGPHR,V,BGPAIM
 S BGPAIM=$$AGE^BGP7D36(DFN,2,BGPBDATE)
 ;I BGPAIM<6 S BGPSTOP=1 Q
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN7,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9,BGPD10,BGPD11,BGPD12,BGPD13,BGPD14,BGPD15,BGPD16,BGPD17,BGPHR)=0
 S BGPHR=$$HIGHR^BGP7D3A(DFN,BGPEDATE)
 I BGPAGEB>49,BGPACTUP S BGPD5=1
 I BGPAGEB>49,BGPAGEB<65,BGPACTUP S BGPD6=1
 I BGPAGEB>64,BGPACTUP S BGPD7=1
 I BGPDMD2 S BGPD4=1
 I BGPAGEB>49,BGPACTCL S BGPD1=1
 I BGPAGEB>49,BGPAGEB<65,BGPACTCL S BGPD2=1
 I BGPAGEB>64,BGPACTCL S BGPD3=1
 I BGPACTCL S BGPD8=1
 I BGPAIM>5,BGPAGEB<18,BGPACTCL S BGPD9=1
 I BGPAGEB>17,BGPAGEB<50,BGPACTCL S BGPD10=1
 I BGPAGEB>17,BGPAGEB<50,BGPACTCL,BGPHR S BGPD11=1
 I BGPACTUP S BGPD12=1
 I BGPAIM>5,BGPAGEB<18,BGPACTUP S BGPD13=1
 I BGPAGEB>17,BGPAGEB<50,BGPACTUP S BGPD14=1
 I BGPAGEB>17,BGPAGEB<50,BGPACTUP,BGPHR S BGPD15=1
 I BGPAGEB>17,BGPACTUP S BGPD16=1
 I BGPAGEB>17,BGPACTCL S BGPD17=1
 I '(BGPD1+BGPD2+BGPD3+BGPD4+BGPD5+BGPD6+BGPD7+BGPD8+BGPD9+BGPD10+BGPD11+BGPD12+BGPD13+BGPD14+BGPD15+BGPD16+BGPD17) S BGPSTOP=1 Q
 S BGPVALUE=$$FLU(DFN,,BGPEDATE) ;set to date of flu shot
 I $P(BGPVALUE,U,3)=1 S BGPN1=1
 ;I $P(BGPVALUE,U,3)=2 S BGPN2=1
 I $P(BGPVALUE,U,3)=3 S BGPN3=1,BGPN1=1
 I BGPN1 S BGPN7=1
 S BGPDV=""
 I BGPRTYPE=4 S BGPDV=$S(BGPACTUP:"UP",1:"") D
 .I BGPACTCL S BGPDV=BGPDV_$S(BGPDV]"":",AC",1:"AC")
 .I BGPD4 S BGPDV=BGPDV_$S(BGPDV]"":",AD",1:"AD")
 .I BGPHR S BGPDV=BGPDV_$S(BGPDV]"":",HR",1:"HR")
 I BGPRTYPE=1 D
 .S BGPDV=$S(BGPD3!(BGPD2):"AC",1:"") I BGPD4 S BGPDV=BGPDV_$S(BGPDV]"":",AD",1:"AD")
 .S BGPVALUD=$S(BGPD8:"AC",1:"")
 I BGPRTYPE=3!(BGPRTYPE=8) S BGPDV="AC"
 I BGPRTYPE=7 D
 .I BGPACTCL S BGPDV="AC"
 .I BGPD4 S BGPDV=BGPDV_$S(BGPDV]"":",AD",1:"AD")
 .I BGPHR S BGPDV=BGPDV_$S(BGPDV]"":",HR",1:"HR")
 I BGPRTYPE'=1 S BGPVALUE=BGPDV_"|||"_$$DATE^BGP7UTL($P(BGPVALUE,U,1))_" "_$P(BGPVALUE,U,2)
 I BGPRTYPE=1 D
 .S BGPDV=BGPDV_"|||"
 .S BGPVALUD=BGPVALUD_"|||"
 .I BGPN7 S BGPVALUD=BGPVALUD_$$DATE^BGP7UTL($P(BGPVALUE,U,1))_" "_$P(BGPVALUE,U,2),BGPVALUE=BGPDV_$$DATE^BGP7UTL($P(BGPVALUE,U,1))_" "_$P(BGPVALUE,U,2) Q
 .S BGPVALUE=BGPDV
 K BGPLFLU,BGPDV,BGPHR
 Q
I13 ;EP
 G I13^BGP7D3B
 ;
I15 ;EP
 K BGPN1,BGPN2,BGPN3,BGPN4,BGPVALUE,BGPPAP,BGPI7,BGPI7DA,BGPI7DB,BGPI7DC,BGPI7DD,BGPPAP4,BGPPAP6
 S BGPI7DA=0,BGPI7DB=0,BGPI7DC=0,BGPI7DD=0,BGPN1=0,BGPN2=0,BGPN3=0,BGPPAP4="",BGPN4=0,BGPPAP6="",BGPHPV=""
 S (BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6)=0
 S BGPI7=$$DEN7(DFN,BGPAGEB,BGPAGEE,BGPSEX,BGPEDATE)
 I BGPACTUP,BGPI7 S BGPI7DA=1
 I BGPACTCL,BGPI7 S BGPI7DB=1
 I BGPACTCL,BGPI7,BGPAGEB>23,BGPAGEE<65 S BGPI7DC=1,BGPD4=1  ;2014 GPRA DEV
 I BGPACTUP,BGPI7,BGPAGEB>23,BGPAGEE<65 S BGPI7DD=1
 I BGPACTCL,BGPI7,BGPAGEB>29,BGPAGEE<65 S BGPD1=1
 I BGPACTCL,BGPI7,BGPAGEB>23,BGPAGEB<30 S BGPD2=1
 I BGPACTUP,BGPI7,BGPAGEB>29,BGPAGEE<65 S BGPD7=1
 I BGPACTUP,BGPI7,BGPAGEB>23,BGPAGEB<30 S BGPD8=1
 I 'BGPI7DC,'BGPI7DD S BGPSTOP=1 Q  ;not in either denom so quit
 ;I BGPTIME=1,BGPD4,'(BGPD1+BGPD2) W !,DFN,?10,"BGPD4=",BGPD4,?20,"BGPD2=",BGPD2,?30,"BGPD1=",BGPD1,?40,"AGEB: ",BGPAGEB,?50,"AGEE: ",BGPAGEE
 S BGPPAP=$$PAP(DFN,BGPEDATE,3,1)
 ;S BGPPAP4=$$PAP(DFN,BGPEDATE,4,1)
 S BGPN1=0 I $P(BGPPAP,U)=1 S BGPN1=1
 I $P(BGPPAP,U,3)["Ref" S BGPN2=1
 I BGPN1,'BGPN2 S BGPN3=1
 S BGPN4=0 I $P(BGPPAP,U,1)=1 S BGPN4=1  ;PAP IN 3 YRS, NO REFUSALS
 ;for gpra dev, if they didn't have pap in 4 years check HPV
 I 'BGPN4,(BGPD1!(BGPD7)) D
 .S BGPPAP6=$$PAP(DFN,BGPEDATE,5)
 .S BGPHPV=$$HPV(DFN,BGPEDATE,5)
 .I BGPHPV,BGPPAP6 S BGPN5=1
 I BGPN4!(BGPN5) S BGPN6=1
 ;I BGPTIME=1 W ?40,"BGPN4=",BGPN4,?50,"BGPN5=",?60,"BGPN6=",BGPN6
 S BGPVALUE=$S(BGPI7DD:"UP",1:"")_$S(BGPI7DC:",AC",1:"")_"|||"
 ;I BGPRTYPE=1 S BGPVALUE=$S(BGPI7DA:"UP",1:"")_$S(BGPI7DB:",AC",1:"")_"|||" I BGPN3 S BGPVALUE=BGPVALUE_$$DATE^BGP7UTL($P(BGPPAP,U,2))_" "_$P(BGPPAP,U,3)
 ;I BGPRTYPE=3 S BGPVALUE="AC|||"_$$DATE^BGP7UTL($P(BGPPAP,U,2))_" "_$P(BGPPAP,U,3)
 I BGPN4 S BGPVALUE=BGPVALUE_"PAP 3 YRS: "_$$DATE^BGP7UTL($P(BGPPAP,U,2))_" "_$P(BGPPAP,U,3)
 I BGPN5 S BGPVALUE=BGPVALUE_" PAP&HPV 5 YRS: "_$$DATE^BGP7UTL($P(BGPPAP6,U,2))_" "_$P(BGPPAP6,U,3)_"; HPV: "_$$DATE^BGP7UTL($P(BGPHPV,U,2))_" "_$P(BGPHPV,U,3)
 K BGPLPAP,BGPPAP,BGPHPV,BGPPAP4,BGPPAP6
 Q
 ;
HPV(P,EDATE,YEARS) ;EP
 NEW BGPC,BGPLPAP,T,BGPLT,B,D,E,L,X,J,BGP
 S BGPC=""
 S BGPLPAP=""
 S BDATE=$$FMADD^XLFDT(EDATE,-(365*YEARS))
 S T=$O(^ATXAX("B","BGP HPV LOINC CODES",0))
 S BGPLT=$O(^ATXLAB("B","BGP HPV TESTS TAX",0))
 S B=9999999-BDATE,E=9999999-EDATE S D=E-1 F  S D=$O(^AUPNVLAB("AE",P,D)) Q:D'=+D!(D>B)!(BGPC]"")  D
 .S L=0 F  S L=$O(^AUPNVLAB("AE",P,D,L)) Q:L'=+L!(BGPC]"")  D
 ..S X=0 F  S X=$O(^AUPNVLAB("AE",P,D,L,X)) Q:X'=+X!(BGPC]"")  D
 ...Q:'$D(^AUPNVLAB(X,0))
 ...S Z=$P(^AUPNVLAB(X,0),U),Z=$P($G(^LAB(60,Z,0)),U) I Z="HPV" S BGPC="1^"_(9999999-D)_"^Lab" Q
 ...I BGPLT,$P(^AUPNVLAB(X,0),U),$D(^ATXLAB(BGPLT,21,"B",$P(^AUPNVLAB(X,0),U))) S BGPC="1^"_(9999999-D)_"^Lab" Q
 ...Q:'T
 ...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
 ...Q:'$$LOINC(J,T)
 ...S BGPC="1^"_(9999999-D)_"^Lab-loinc" Q
 ...Q
 S BGPLPAP=BGPC
 K BGP
 S T="BGP HPV DXS"
 S X=$$LASTDX^BGP7UTL1(P,T,BDATE,EDATE) I X,$P(BGPLPAP,U,2)<$P(X,U,3) S BGPLPAP="1^"_$P(X,U,3)_"^POV "_$P(X,U,2)
 S T=$O(^ATXAX("B","BGP HPV CPTS",0))
 I T D  I X]"",$P(BGPLPAP,U,2)<$P(X,U,1) S BGPLPAP="1^"_$P(X,U)_"^CPT "_$P(X,U,2)
 .S X=$$CPT^BGP7DU(P,$$FMADD^XLFDT(EDATE,-(YEARS*365)),EDATE,T,5) I X]"" Q
 .S X=$$TRAN^BGP7DU(P,$$FMADD^XLFDT(EDATE,-(YEARS*365)),EDATE,T,5)
 S T="HPV SCREEN",T=$O(^BWPN("B",T,0))
 I T D  I X]"",$P(BGPLPAP,U,2)<X S BGPLPAP="1^"_X_"^WH"
 .S X=$$WH^BGP7DU(P,$$FMADD^XLFDT(EDATE,-(YEARS*365)),EDATE,T,3)
 S T="PAP SMEAR",T=$O(^BWPN("B",T,0))
 I T D  I X]"",$P(BGPLPAP,U,2)<X S BGPLPAP="1^"_X_"^WH"
 .S X=$$PAPHPVWH(P,$$FMADD^XLFDT(EDATE,-(YEARS*365)),EDATE,T,3)
 Q BGPLPAP
 ;
FLU(P,BD,ED,FORE) ;EP
 G FLU^BGP7D37
BI() ;
 Q $S($O(^AUTTIMM(0))>100:1,1:0)
DEN7(P,AGEB,AGEE,SEX,EDATE) ;EP
 I SEX'="F" Q 0
 I AGEB<24 Q 0
 I AGEE>64 Q 0
 I $$HYSTER(P,EDATE) Q 0
 Q 1
H1(I) ;
 I $P($G(^ICPT(I,0)),U,1)=90664 Q 1
 I $P($G(^ICPT(I,0)),U,1)=90666 Q 1
 I $P($G(^ICPT(I,0)),U,1)=90667 Q 1
 I $P($G(^ICPT(I,0)),U,1)=90668 Q 1
 Q ""
PAP(P,EDATE,YEARS,REFUSAL) ;EP
 NEW BGPC,BGPLPAP,T,BGPLT,B,D,E,L,X,J,BGP
 S BGPC=""
 S BGPLPAP=""
 S BDATE=$$FMADD^XLFDT(EDATE,-(365*YEARS))
 S T=$O(^ATXAX("B","BGP PAP LOINC CODES",0))
 S BGPLT=$O(^ATXLAB("B","BGP PAP SMEAR TAX",0))
 S B=9999999-BDATE,E=9999999-EDATE S D=E-1 F  S D=$O(^AUPNVLAB("AE",P,D)) Q:D'=+D!(D>B)!(BGPC]"")  D
 .S L=0 F  S L=$O(^AUPNVLAB("AE",P,D,L)) Q:L'=+L!(BGPC]"")  D
 ..S X=0 F  S X=$O(^AUPNVLAB("AE",P,D,L,X)) Q:X'=+X!(BGPC]"")  D
 ...Q:'$D(^AUPNVLAB(X,0))
 ...S Z=$P(^AUPNVLAB(X,0),U),Z=$P($G(^LAB(60,Z,0)),U) I Z="PAP SMEAR" S BGPC="1^"_(9999999-D)_"^Lab" Q
 ...I BGPLT,$P(^AUPNVLAB(X,0),U),$D(^ATXLAB(BGPLT,21,"B",$P(^AUPNVLAB(X,0),U))) S BGPC="1^"_(9999999-D)_"^Lab" Q
 ...Q:'T
 ...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
 ...Q:'$$LOINC(J,T)
 ...S BGPC="1^"_(9999999-D)_"^Lab-loinc" Q
 ...Q
 S BGPLPAP=BGPC
 K BGP
 S T="BGP PAP SMEAR DXS"
 I BGPRTYPE=3 S T="BGP HEDIS PAP SMEAR DXS"
 S X=$$LASTDX^BGP7UTL1(P,T,BDATE,EDATE) I X,$P(BGPLPAP,U,2)<$P(X,U,3) S BGPLPAP="1^"_$P(X,U,3)_"^POV "_$P(X,U,2)
 ;K BGP S BGP(1)=$$LASTPRC^BGP7UTL1(P,"BGP PAP PROCEDURES",BDATE,EDATE)
 ;I $D(BGP(1)),$P(BGPLPAP,U,2)<$P(BGP(1),U,3) S BGPLPAP="1^"_$P(BGP(1),U,3)_"^PROC "_$P(BGP(1),U,2)
 S T=$O(^ATXAX("B","BGP CPT PAP",0))
 I T D  I X]"",$P(BGPLPAP,U,2)<$P(X,U,1) S BGPLPAP="1^"_$P(X,U)_"^CPT "_$P(X,U,2)
 .S X=$$CPT^BGP7DU(P,$$FMADD^XLFDT(EDATE,-(YEARS*365)),EDATE,T,5) I X]"" Q
 .S X=$$TRAN^BGP7DU(P,$$FMADD^XLFDT(EDATE,-(YEARS*365)),EDATE,T,5)
 S T="PAP SMEAR",T=$O(^BWPN("B",T,0))
 I T D  I X]"",$P(BGPLPAP,U,2)<X S BGPLPAP="1^"_X_"^WH"
 .S X=$$WH^BGP7DU(P,$$FMADD^XLFDT(EDATE,-(YEARS*365)),EDATE,T,3)
 I BGPLPAP]"" Q BGPLPAP
 I $G(REFUSAL) Q ""  ;no Refusals counted
 S T=$$REFUSAL^BGP7UTL1(P,60,$O(^LAB(60,"B","PAP SMEAR",0)),$$FMADD^XLFDT(EDATE,-365),EDATE)
 I T Q "1^"_$P(T,U,2)_"^Refused Lab"
 S BGPLT=$O(^ATXLAB("B","BGP PAP SMEAR TAX",0))
 I 'BGPLT Q 0
 S X=0,T="" F  S X=$O(^ATXLAB(BGPLT,21,X)) Q:X'=+X!($P(T,U)=1)  D
 .S T=""
 .S Y=$P(^ATXLAB(BGPLT,21,X,0),U)
 .Q:'Y
 .S T=$$REFUSAL^BGP7UTL1(P,60,Y,$$FMADD^XLFDT(EDATE,-365),EDATE)
 I T Q 1_"^"_$P(T,U,2)_"^Refused Lab "
 ;add cpt Refusals v11.1
 S T=$$CPTREFT^BGP7UTL1(P,$$FMADD^XLFDT(EDATE,-365),EDATE,$O(^ATXAX("B","BGP CPT PAP",0)))
 I T S T="1^"_$P(T,U,2)_"^Refused CPT "_$P(T,U,4) Q T
 Q ""
PAPHPVWH(P,BDATE,EDATE,T,F) ;EP
 I '$G(P) Q ""
 I '$G(T) Q ""
 I '$G(F) S F=1
 I $G(EDATE)="" Q ""
 I $G(BDATE)="" S BDATE=$$FMADD^XLFDT(EDATE,-365)
 ;go through procedures in a date range for this patient, check proc type
 NEW D,X,Y,G,V,O
 S (G,V)=0,I="" F  S V=$O(^BWPCD("C",P,V)) Q:V=""  D
 .Q:'$D(^BWPCD(V,0))
 .I $P(^BWPCD(V,0),U,4)'=T Q
 .Q:$$UP^XLFSTR($$VAL^XBDIQ1(9002086.1,V,.05))="ERROR/DISREGARD"
 .S D=$P(^BWPCD(V,0),U,12)
 .Q:D<BDATE
 .Q:D>EDATE
 .;DOES HPV SAY YES?
 .I '$P(^BWPCD(V,0),U,8) Q  ;has to have HPV yes
 .S I=$O(G(0)) I I>D Q
 .S G=V,G(D)=""
 .Q
 I 'G Q ""
 I F=1 Q $S(G:1,1:"")
 I F=2 Q G
 I F=3 S D=$P(^BWPCD(G,0),U,12) Q D
 I F=4 S D=$P(^BWPCD(G,0),U,12) Q $$FMTE^XLFDT(D)
 Q ""
LOINC(A,B) ;
 NEW %
 S %=$P($G(^LAB(95.3,A,9999999)),U,2)
 I %]"",$D(^ATXAX(B,21,"B",%)) Q 1
 S %=$P($G(^LAB(95.3,A,0)),U)_"-"_$P($G(^LAB(95.3,A,0)),U,15)
 I $D(^ATXAX(B,21,"B",%)) Q 1
 Q ""
HYSTER(P,EDATE) ;EP 
 I '$G(P) Q ""
 NEW X,T
 S X=$$LASTPRC^BGP7UTL1(P,"BGP HYSTERECTOMY PROCEDURES",$$DOB^AUPNPAT(P),EDATE)
 I X Q 1
 S T="HYSTERECTOMY",T=$O(^BWPN("B",T,0))
 I T D  I X]"" Q 1
 .S X=$$WH^BGP7DU(P,$$DOB^AUPNPAT(P),EDATE,T,2)
 S T=$O(^ATXAX("B","BGP HYSTERECTOMY CPTS",0))
 I T D  I X]"" Q 1
 .S X=$$CPT^BGP7DU(P,$P(^DPT(P,0),U,3),EDATE,T,3) I X]"" Q
 .S X=$$TRAN^BGP7DU(P,$P(^DPT(P,0),U,3),EDATE,T,3)
 S X=$$LASTDX^BGP7UTL1(P,"BGP HYSTERECTOMY DXS",$$DOB^AUPNPAT(P),EDATE)
 I X Q 1
 ;S X=$$PLTAX^BGP7DU(P,"BGP HYSTERECTOMY DXS")
 ;I X Q 1
 S X=$$PLTAXND^BGP7DU(P,"BGP HYSTERECTOMY DXS",EDATE)
 I X Q 1
 S X=$$IPLSNOND^BGP7DU(P,"PXRM BGP HYSTERECTOMY DX",EDATE)
 I X Q 1
 Q ""