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

BGP9D3.m

Go to the documentation of this file.
BGP9D3 ; IHS/CMI/LAB - measure 11 17 Oct 2007 12:40 PM ;
 ;;9.0;IHS CLINICAL REPORTING;;JUL 1, 2009
 ;
 ;
I10 ;EP
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6)=0
 S BGPSEAL=$$SEAL(DFN,BGP365,BGPEDATE)
 I $P(BGPSEAL,U,2)]"" S BGPN5=$P(BGPSEAL,U,1),BGPN1=$P(BGPSEAL,U,1) G I101
 S BGPN1=$P(BGPSEAL,U)
 I BGPAGEB<12 S BGPN2=BGPN1
 I BGPAGEB>11,BGPAGEB<19 S BGPN3=BGPN1
 I BGPAGEB>18 S BGPN4=BGPN1
 S BGPN6=BGPN1
I101 ;
 S BGPVALUE="UP|||"_BGPN1_$S($P(BGPSEAL,U,3)]"":" "_$P(BGPSEAL,U,3),1:" sealants ")
 K BGPSEAL
 Q
I11 ;EP
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPD1,BGPD2,BGPD3)=0
 S BGPFLUOR=$$TF(DFN,BGP365,BGPEDATE)
 S BGPN1=$P(BGPFLUOR,U)
 I $P(BGPFLUOR,U,3)]"" S BGPN2=1,BGPD2=1
 I BGPN1>0 S BGPD1=1
 I BGPN1>4 S BGPN1=4
 I BGPD1,'BGPD2 S BGPD3=1
 S BGPVALUE="UP|||"_BGPN1_$S($P(BGPFLUOR,U,3)]"":" "_$P(BGPFLUOR,U,3),1:" topical fluoride ")
 K ^TMP($J,"A"),BGPFLUOR
 Q
I12 ;EP
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN7,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7)=0
 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 '(BGPD1+BGPD2+BGPD3+BGPD4+BGPD5+BGPD6+BGPD7) S BGPSTOP=1 Q
 S BGPVALUE=$$FLU(DFN,,BGPEDATE) ;set to date of flu shot
 I BGPVALUE]"" S BGPN1=1
 I $P(BGPVALUE,U,3)=2 S BGPN2=1
 I $P(BGPVALUE,U,3)=3 S BGPN3=1
 I BGPN1,'BGPN2 S BGPN7=1
 S BGPDV=""
 I BGPRTYPE=4 S BGPDV=$S(BGPD5:"UP",1:"") D
 .I BGPD1 S BGPDV=BGPDV_$S(BGPDV]"":",AC",1:"AC")
 .I BGPD4 S BGPDV=BGPDV_$S(BGPDV]"":",AD",1:"AD")
 I BGPRTYPE=1 S BGPDV=$S(BGPD3!(BGPD2):"AC",1:"") I BGPD4 S BGPDV=BGPDV_$S(BGPDV]"":";AD",1:"AD")
 I BGPRTYPE=3!(BGPRTYPE=8) S BGPDV="AC"
 I BGPRTYPE=7 S BGPDV="AD"
 S BGPVALUE=BGPDV_"|||"_$$DATE^BGP9UTL($P(BGPVALUE,U,1))_" "_$P(BGPVALUE,U,2)
 K BGPLFLU,BGPDV
 Q
I13 ;EP
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7,BGPD1,BGPD2,BGPD3)=0
 I BGPAGEB>64,BGPACTUP S BGPD3=1
 I BGPDMD2 S BGPD2=1
 I BGPAGEB>64,BGPACTCL S BGPD1=1
 I '(BGPD1+BGPD2+BGPD3) S BGPSTOP=1 Q
 I BGPRTYPE=3,'BGPD1 S BGPSTOP=1 Q
PN ;EP - called from elder
 S BGPVALUE=$$PNEU^BGP9D31(DFN,$$DOB^AUPNPAT(DFN),BGPEDATE) ;set to date of PNEU shot
 I BGPVALUE]"" S BGPN1=1
 I $P(BGPVALUE,U,3)=2 S BGPN2=1
 I $P(BGPVALUE,U,3)=3 S BGPN3=1
 I BGPN1,'BGPN2 S BGPN7=1
 S BGPVAL=$$PNEU^BGP9D31(DFN,$$FMADD^XLFDT(BGPEDATE,-(5*365)),BGPEDATE)
 I BGPVAL]"" S BGPN4=1
 I $P(BGPVAL,U,3)=2 S BGPN5=1
 I $P(BGPVAL,U,3)=3 S BGPN6=1
 S BGPDV=""
 I BGPRTYPE=4 S BGPDV=$S(BGPD3:"UP",1:"") D
 .I BGPD1 S BGPDV=BGPDV_$S(BGPDV]"":",AC",1:"AC")
 .I BGPD2 S BGPDV=BGPDV_$S(BGPDV]"":",AD",1:"AD")
 I BGPRTYPE=1 S BGPDV=$S(BGPD1:"AC",1:"") I BGPD2 S BGPDV=BGPDV_$S(BGPDV]"":",AD",1:"AD")
 I BGPRTYPE=7 S BGPDV="AD"
 I BGPRTYPE=3!(BGPRTYPE=5) S BGPVALUE="AC"_"|||"_$$DATE^BGP9UTL($P(BGPVALUE,U,1))_" "_$P(BGPVALUE,U,2) I 1
 E  S BGPVALUE=BGPDV_"|||"_$$DATE^BGP9UTL($P(BGPVALUE,U,1))_" "_$P(BGPVALUE,U,2)_$S(BGPVALUE]"":" (ever)",1:"")_" "_$$DATE^BGP9UTL($P(BGPVAL,U,1))_" "_$P(BGPVAL,U,2)_$S(BGPVAL]"":" (past 5 yrs)",1:"")
 K BGPLPNU
 Q
I15 ;EP
 K BGPN1,BGPN2,BGPN3,BGPN4,BGPVALUE,BGPPAP,BGPI7,BGPI7DA,BGPI7DB
 S BGPI7DA=0,BGPI7DB=0,BGPI7DC=0,BGPN1=0,BGPN2=0,BGPN3=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
 I 'BGPI7DA,'BGPI7DB,'BGPI7DC S BGPSTOP=1 Q  ;not in either denom so quit
 S BGPPAP=$$PAP(DFN,BGPEDATE,3)
 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
 I BGPRTYPE'=3 S BGPVALUE=$S(BGPI7DA:"UP",1:"")_$S(BGPI7DB:",AC",1:"")_"|||"_$$DATE^BGP9UTL($P(BGPPAP,U,2))_" "_$P(BGPPAP,U,3)
 I BGPRTYPE=3 S BGPVALUE="AC|||"_$$DATE^BGP9UTL($P(BGPPAP,U,2))_" "_$P(BGPPAP,U,3)
 K BGPLPAP
 Q
 ;
SEAL(P,BDATE,EDATE) ;
 K BGPG,BGPX S BGPC=0
 S %=P_"^ALL ADA 1351;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 S X=0 F  S X=$O(BGPG(X)) Q:X'=+X  D
 .S V=+$P(BGPG(X),U,4)
 .S T=$P($G(^AUPNVDEN(V,0)),U,4)
 .S:T=""!(T=0) T=1
 .S S=$P(^AUPNVDEN(V,0),U,5)
 .I S]"" S BGPX(S)=$G(BGPX(S))+T
 .I S="" S BGPX("NO OS")=$G(BGPX("NO OS"))+T
 .Q
 S X="" F  S X=$O(BGPX(X)) Q:X=""  S BGPC=BGPC+$S(BGPX(X)>2:2,1:BGPX(X))
 I BGPC Q BGPC
 ;now gather up refusals - one per patient
 S G=$$REFUSAL^BGP9UTL1(P,9999999.31,$O(^AUTTADA("B","1351",0)),BDATE,EDATE)
 I $P(G,U)=1 Q "1^"_$P(G,U,2)_"^Refused ADA 1351"
 Q ""
TF(P,BDATE,EDATE) ;
 K BGPG S BGPC=0
 K ^TMP($J,"A")
 S A="^TMP($J,""A"","
 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) I A S A=$P($G(^AUTTADA(A,0)),U) D
 ...I A=1201!(A=1203)!(A=1204)!(A=1205)!(A=1206) 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(^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
 I BGPC Q BGPC
 ;one refusal per patient
 S G=$$REFUSAL^BGP9UTL1(P,9999999.31,$O(^AUTTADA("B","1201",0)),BDATE,EDATE)
 I $P(G,U)=1 Q "1^"_$P(G,U,2)_"^Refused ADA 1201"
 S G=$$REFUSAL^BGP9UTL1(P,9999999.31,$O(^AUTTADA("B","1203",0)),BDATE,EDATE)
 I $P(G,U)=1 Q "1^"_$P(G,U,2)_"^Refused ADA 1203"
 S G=$$REFUSAL^BGP9UTL1(P,9999999.31,$O(^AUTTADA("B","1204",0)),BDATE,EDATE)
 I $P(G,U)=1 Q "1^"_$P(G,U,2)_"^Refused ADA 1204"
 S G=$$REFUSAL^BGP9UTL1(P,9999999.31,$O(^AUTTADA("B","1205",0)),BDATE,EDATE)
 I $P(G,U)=1 Q "1^"_$P(G,U,2)_"^Refused ADA 1205"
 S G=$$REFUSAL^BGP9UTL1(P,9999999.31,$O(^AUTTADA("B","1206",0)),BDATE,EDATE)
 I $P(G,U)=1 Q "1^"_$P(G,U,2)_"^Refused ADA 1206"
 Q ""
FLU(P,BD,ED) ;EP
 K BGPG
 S BGPLFLU=""
 I $G(BD)="" S BD=$$FMADD^XLFDT(ED,-365)
 S EDATE=$$FMTE^XLFDT(ED),BDATE=$$FMTE^XLFDT(BD)
 S X=P_"^LAST IMM 88;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BGPG(")
 I $D(BGPG(1)) S BGPLFLU=$P(BGPG(1),U)_U_"Imm 88"
 S X=P_"^LAST IMM 111;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BGPG(")
 I $D(BGPG(1)),$P(BGPLFLU,U)<$P(BGPG(1),U) S BGPLFLU=$P(BGPG(1),U)_U_"Imm 111"
 S X=P_"^LAST IMM 15;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BGPG(")
 I $D(BGPG(1)),$P(BGPLFLU,U)<$P(BGPG(1),U) S BGPLFLU=$P(BGPG(1),U)_U_"Imm 15"
 S X=P_"^LAST IMM 16;DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BGPG(")
 I $D(BGPG(1)),$P(BGPLFLU,U)<$P(BGPG(1),U) S BGPLFLU=$P(BGPG(1),U)_U_"Imm 16"
 S BGPG=$$LASTPRCI^BGP9UTL1(P,"99.52",BDATE,EDATE)
 I $P(BGPG,U,1)=1,$P(BGPLFLU,U)<$P(BGPG,U,3) S BGPLFLU=$P(BGPG,U,3)_U_"99.52"
 K BGPG S %=P_"^LAST DX V04.8;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)),$P(BGPLFLU,U)<$P(BGPG(1),U,1) S BGPLFLU=$P(BGPG(1),U,1)_U_"V04.8"
 K BGPG S %=P_"^LAST DX V04.81;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)),$P(BGPLFLU,U)<$P(BGPG(1),U,1) S BGPLFLU=$P(BGPG(1),U,1)_U_"V04.81"
 K BGPG S %=P_"^LAST DX V06.6;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)),$P(BGPLFLU,U)<$P(BGPG(1),U,1) S BGPLFLU=$P(BGPG(1),U,1)_U_"V06.6"
 S T=$O(^ATXAX("B","BGP CPT FLU",0))
 I T D  I X]"" I $P(BGPLFLU,U)<X S BGPLFLU=$P(X,U)_U_"CPT "_$P(X,U,2)
 .S X=$$CPT^BGP9DU(P,,ED,T,5) I X]"" Q
 .S X=$$TRAN^BGP9DU(P,,ED,T,5)
 I BGPLFLU]"" Q BGPLFLU_U_1
 ;contraindication new in 8.0
 F BGPZ=15,16,88,111 S X=$$FLCONT(P,BGPZ,$$DOB^AUPNPAT(P),ED) Q:X]""
 I X]"" Q X_U_3
 ;NMI refusal
 S G=$$NMIREF^BGP9UTL1(P,9999999.14,$O(^AUTTIMM("C",88,0)),$$DOB^AUPNPAT(P),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"NMI Refusal"_U_3
 S G=$$NMIREF^BGP9UTL1(P,9999999.14,$O(^AUTTIMM("C",111,0)),$$DOB^AUPNPAT(P),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"NMI Refusal"_U_3
 S G=$$NMIREF^BGP9UTL1(P,9999999.14,$O(^AUTTIMM("C",15,0)),$$DOB^AUPNPAT(P),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"NMI Refusal"_U_3
 S G=$$NMIREF^BGP9UTL1(P,9999999.14,$O(^AUTTIMM("C",16,0)),$$DOB^AUPNPAT(P),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"NMI Refusal"_U_3
 ;refusal
 S G=$$REFUSAL^BGP9UTL1(P,9999999.14,$O(^AUTTIMM("C",88,0)),$$FMADD^XLFDT(ED,-365),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"Refused"_U_2
 S G=$$REFUSAL^BGP9UTL1(P,9999999.14,$O(^AUTTIMM("C",111,0)),$$FMADD^XLFDT(ED,-365),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"Refused"_U_2
 S G=$$REFUSAL^BGP9UTL1(P,9999999.14,$O(^AUTTIMM("C",15,0)),$$FMADD^XLFDT(ED,-365),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"Refused"_U_2
 S G=$$REFUSAL^BGP9UTL1(P,9999999.14,$O(^AUTTIMM("C",16,0)),$$FMADD^XLFDT(ED,-365),ED)
 I $P(G,U)=1 Q $P(G,U,2)_U_"Refused"_U_2
 S (X,G)=0,Y=$O(^AUTTIMM("C",88,0)) F  S X=$O(^BIPC("AC",P,Y,X)) Q:X'=+X!(G)  D
 .S R=$P(^BIPC(X,0),U,3)
 .Q:R=""
 .Q:'$D(^BICONT(R,0))
 .Q:$P(^BICONT(R,0),U,1)'["Refusal"
 .S D=$P(^BIPC(X,0),U,4)
 .Q:D=""
 .Q:$P(^BIPC(X,0),U,4)<BD
 .Q:$P(^BIPC(X,0),U,4)>ED
 .S G=1
 I G Q $P(G,U,2)_U_"Refused Imm pkg"_U_2
 S (X,G)=0,Y=$O(^AUTTIMM("C",111,0)) I Y F  S X=$O(^BIPC("AC",P,Y,X)) Q:X'=+X!(G)  D
 .S R=$P(^BIPC(X,0),U,3)
 .Q:R=""
 .Q:'$D(^BICONT(R,0))
 .Q:$P(^BICONT(R,0),U,1)'["Refusal"
 .S D=$P(^BIPC(X,0),U,4)
 .Q:D=""
 .Q:$P(^BIPC(X,0),U,4)<BD
 .Q:$P(^BIPC(X,0),U,4)>ED
 .S G=1
 I G Q $P(G,U,2)_U_"Refused Imm pkg"_U_2
 S (X,G)=0,Y=$O(^AUTTIMM("C",15,0)) I Y F  S X=$O(^BIPC("AC",P,Y,X)) Q:X'=+X!(G)  D
 .S R=$P(^BIPC(X,0),U,3)
 .Q:R=""
 .Q:'$D(^BICONT(R,0))
 .Q:$P(^BICONT(R,0),U,1)'["Refusal"
 .S D=$P(^BIPC(X,0),U,4)
 .Q:D=""
 .Q:$P(^BIPC(X,0),U,4)<BD
 .Q:$P(^BIPC(X,0),U,4)>ED
 .S G=1
 I G Q $P(G,U,2)_U_"Refused Imm pkg"_U_2
 S (X,G)=0,Y=$O(^AUTTIMM("C",16,0)) I Y F  S X=$O(^BIPC("AC",P,Y,X)) Q:X'=+X!(G)  D
 .S R=$P(^BIPC(X,0),U,3)
 .Q:R=""
 .Q:'$D(^BICONT(R,0))
 .Q:$P(^BICONT(R,0),U,1)'["Refusal"
 .S D=$P(^BIPC(X,0),U,4)
 .Q:D=""
 .Q:$P(^BIPC(X,0),U,4)<BD
 .Q:$P(^BIPC(X,0),U,4)>ED
 .S G=1
 I G Q $P(G,U,2)_U_"Refused Imm pkg"_U_2
 Q ""
FLCONT(P,C,BD,ED) ;EP
 NEW X,G,Y,R,D
 S X=0,G="",Y=$O(^AUTTIMM("C",C,0)) I Y F  S X=$O(^BIPC("AC",P,Y,X)) Q:X'=+X!(G)  D
 .S R=$P(^BIPC(X,0),U,3)
 .Q:R=""
 .Q:'$D(^BICONT(R,0))
 .S D=$P(^BIPC(X,0),U,4)
 .Q:D=""
 .Q:$P(^BIPC(X,0),U,4)<BD
 .Q:$P(^BIPC(X,0),U,4)>ED
 .I $P(^BICONT(R,0),U,1)="Egg Allergy" S G=D_U_"Contraindication: Egg Allergy"
 .I $P(^BICONT(R,0),U,1)="Anaphylaxis" S G=D_U_"Contraindication: Anaphylaxis"
 Q G
BI() ;
 Q $S($O(^AUTTIMM(0))>100:1,1:0)
DEN7(P,AGEB,AGEE,SEX,EDATE) ;EP
 I SEX'="F" Q 0
 I AGEB<21 Q 0
 I AGEE>64 Q 0
 I $$HYSTER(P,EDATE) Q 0
 Q 1
PAP(P,EDATE,YEARS) ;EP
 K BGPC
 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^BGP9UTL1(P,T,BDATE,EDATE) I X,$P(BGPLPAP,U,2)<$P(X,U,3) S BGPLPAP="1^"_$P(X,U,3)_"^"_$P(X,U,2)
 K BGP S %=P_"^LAST PROCEDURE 91.46;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGP(")
 I $D(BGP(1)),$P(BGPLPAP,U,2)<$P(BGP(1),U,1) S BGPLPAP="1^"_$P(BGP(1),U)_"^91.46"
 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)_"^"_$P(X,U,2)
 .S X=$$CPT^BGP9DU(P,$$FMADD^XLFDT(EDATE,-(YEARS*365)),EDATE,T,5) I X]"" Q
 .S X=$$TRAN^BGP9DU(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^BGP9DU(P,$$FMADD^XLFDT(EDATE,-(YEARS*365)),EDATE,T,3)
 I BGPLPAP]"" Q BGPLPAP
 S T=$$REFUSAL^BGP9UTL1(P,60,$O(^LAB(60,"B","PAP SMEAR",0)),$$FMADD^XLFDT(EDATE,-365),EDATE)
 I T Q "1^"_$P(T,U,2)_"^ref"
 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^BGP9UTL1(P,60,Y,$$FMADD^XLFDT(EDATE,-365),EDATE)
 I T Q 1_"^"_$P(T,U,2)_"^ref"
 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 ""
 S X=$$LASTPRC^BGP9UTL1(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^BGP9DU(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^BGP9DU(P,$P(^DPT(P,0),U,3),EDATE,T,3) I X]"" Q
 .S X=$$TRAN^BGP9DU(P,$P(^DPT(P,0),U,3),EDATE,T,3)
 S X=$$LASTDXI^BGP9UTL1(P,618.5,$$DOB^AUPNPAT(P),EDATE,1)
 I X Q 1
 Q ""