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

BGP2C2X.m

Go to the documentation of this file.
BGP2C2X ; IHS/CMI/LAB - calc CMS measures 26 Sep 2004 11:28 AM ;
 ;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
 ;
HF ;
 ;was there an AMI pov on this visit
 Q:'$$HFDX(BGPVSIT)
 S BGPX=$P(^DPT(DFN,0),U)_U_$$HRN^AUPNPAT(DFN,DUZ(2))_U_$P(^DPT(DFN,0),U,2)_U_$$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))
 S $P(BGPX,U,5)=$$DATE^BGP2UTL($P($P(BGPVSIT0,U),"."))_"-"_$$DATE^BGP2UTL($$DSCH(BGPVINP))
 S $P(BGPX,U,6)=$$PRIMPOV^APCLV(BGPVSIT,"C")_"  "_$$PRIMPOV^APCLV(BGPVSIT,"N")
 S BGPSKIP=0 K BGPZ
 I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 S BGPX="*"_BGPX,BGPSKIP=1,BGPZ(1)="under 18 yrs of age"
 I $$LVADEX(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH(BGPVINP)) S BGPX="*"_BGPX,BGPSKIP=1,BGPZ(1)="LVAD"
 S Z=$$VAL^XBDIQ1(9000010.02,BGPVINP,.06)
 S $P(BGPX,U,7)=Z
 ;I $$TRANS(BGPVINP) S:'BGPSKIP BGPX="*"_BGPX S BGPSKIP=1,BGPZ(2)="transferred out"
 ;I $$DSCH(BGPVINP)=$P($P(BGPVSIT,U),".") S:'BGPSKIP BGPX="*"_BGPX S BGPSKIP=1,BGPZ(3)="discharged on date of arrival"
 ;I $$EXPIRED(BGPVINP) S:'BGPSKIP BGPX="*"_BGPX S BGPSKIP=1,BGPZ(4)="deceased" ;patient expired on any day other than day of arrival
 ;I $$AMA(BGPVINP) S:'BGPSKIP BGPX="*"_BGPX S BGPSKIP=1,BGPZ(5)="left AMA on day other than arrival date"
 S Z=$$VAL^XBDIQ1(9000010.02,BGPVINP,.07)
 S $P(BGPX,U,8)=Z
 Q:$D(^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 1",$P(^DPT(DFN,0),U),DFN,BGPVSIT))
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 1",$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPX  ;a hit on list 1
 K BGPZ1 I $D(BGPZ) S X=0 F  S X=$O(BGPZ(X)) Q:X'=+X  S:$G(BGPZ1)]"" BGPZ1=BGPZ1_", " S BGPZ1=$G(BGPZ1)_BGPZ(X)
 I $D(BGPZ1) S BGPZ1="Exclusions: "_BGPZ1 S $P(^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 1",$P(^DPT(DFN,0),U),DFN,BGPVSIT),U,12)=BGPZ1
 S BGPCOUNT("L1",BGPIND)=$G(BGPCOUNT("L1",BGPIND))+1
 ;set up second list after applying exclusions
 Q:BGPSKIP
 S BGPX=$P(^DPT(DFN,0),U)_U_$$HRN^AUPNPAT(DFN,DUZ(2))_U_$P(^DPT(DFN,0),U,2)_U_$$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))
 S $P(BGPX,U,5)=$$DATE^BGP2UTL($P($P(BGPVSIT0,U),"."))_"-"_$$DATE^BGP2UTL($$DSCH(BGPVINP))
 S $P(BGPX,U,6)=$$PRIMPOV^APCLV(BGPVSIT,"C")_"  "_$$PRIMPOV^APCLV(BGPVSIT,"N")
 S $P(BGPX,U,7)=$$VAL^XBDIQ1(9000010.02,BGPVINP,.06)
 S $P(BGPX,U,8)=$$VAL^XBDIQ1(9000010.02,BGPVINP,.07)
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPX
 S BGPCOUNT("L2",BGPIND)=$G(BGPCOUNT("L2",BGPIND))+1
 ;get other povs
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,1,"Other Discharge POVs:")=""
 S (X,C)=0 F  S X=$O(^AUPNVPOV("AD",BGPVSIT,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVPOV(X,0))
 .Q:$P(^AUPNVPOV(X,0),U,12)="P"
 .S I=$P(^AUPNVPOV(X,0),U),I=$P($$ICDDX^ICDCODE(I),U,2)
 .S N=$$VAL^XBDIQ1(9000010.07,X,.04),N=$$UP^XLFSTR(N)
 .S C=C+1
 .S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,1,"Other Discharge POVs:",C)=I,$E(^(C),9)=N
 .Q
LVAD ;
 ;S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,2,"LVAD?")=""
 ;K BGPDATA
 ;D LVAD1(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH(BGPVINP),.BGPDATA)
 ;S X=0 F  S X=$O(BGPDATA(X)) Q:X'=+X  D
 ;.S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,2,"LVAD?",X)=BGPDATA(X)
 ;.Q
EF ;
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,3,"LVS Evaluation?")=""
 K BGPDATA
 D LVF(DFN,DT,.BGPDATA)
 S X=0 F  S X=$O(BGPDATA(X)) Q:X'=+X  D
 .S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,3,"LVS Evaluation?",X)=BGPDATA(X)
 .Q
LVSD ;
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,4,"LVSD?")=""
 K BGPDATA
 D LVSD1(DFN,DT,.BGPDATA)
 S X=0 F  S X=$O(BGPDATA(X)) Q:X'=+X  D
 .S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,4,"LVSD?",X)=BGPDATA(X)
 .Q
ACEIALG ;
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,5,"ACEI or ARB Allergy?")=""
 K BGPDATA
 D ACEIALG1^BGP2C11(DFN,$$DSCH(BGPVINP),.BGPDATA) ;return text of ACEI allergy if found
 I $D(BGPDATA) S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,5,"ACEI or ARB Allergy?")=""
 S X=0 F  S X=$O(BGPDATA(X)) Q:X'=+X  D
 .S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,5,"ACEI or ARB Allergy?",X)=BGPDATA(X)
ACEICONT ;
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,6,"Other ACEI or ARB Exclusion?")=""
 K BGPDATA
 D ACEICON1^BGP2C13(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH(BGPVINP),BGPVSIT,.BGPDATA)
 I $D(BGPDATA) S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,6,"Other ACEI or ARB Exclusion?")=""
 S X=0 F  S X=$O(BGPDATA(X)) Q:X'=+X  D
 .S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,6,"Other ACEI or ARB Exclusion?",X)=BGPDATA(X)
ACEIRX ;
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,7,"ACEI or ARB Rx Status?")=""
 K BGPDATA
 D ACEIRX1^BGP2C11(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH(BGPVINP),.BGPDATA)
 S X=0 F  S X=$O(BGPDATA(X)) Q:X'=+X  D
 .S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,7,"ACEI or ARB Rx Status?",X)=BGPDATA(X)
SMOKER ;EP
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,8,"Smoker?")=""
 K BGPASAAL
 D SMOKER1^BGP2C12(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH(BGPVINP),.BGPASAAL)
 S X=0 F  S X=$O(BGPASAAL(X)) Q:X'=+X  D
 .S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,8,"Smoker?",X)=BGPASAAL(X)
CESS ;
 S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,9,"Smoking Cessation Advice/Counseling Status?")=""
 K BGPASAAL
 D CESS1^BGP2C12(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH(BGPVINP),.BGPASAAL)
 S X=0 F  S X=$O(BGPASAAL(X)) Q:X'=+X  D
 .S ^XTMP("BGP2C1",BGPJ,BGPH,BGPORDER,BGPIND,"LIST 2",$P(^DPT(DFN,0),U),DFN,BGPVSIT,9,"Smoking Cessation Advice/Counseling Status?",X)=BGPASAAL(X)
 D EN^BGP2C12
 Q
LVF(P,BGPD,BGPY) ;does patient have LVSD
 NEW ED,BD,BGPG,BGPC,X,Y,Z,N,I,T
 ;BGPD is discharge date
 S BGPC=0 K BGPY
CEFMEAS ;now get all measurements CEF
 K BGPG S Y="BGPG(",X=P_"^ALL MEAS CEF;DURING "_$$FMTE^XLFDT($$DOB^AUPNPAT(DFN))_"-"_$$FMTE^XLFDT(BGPD) S E=$$START1^APCLDF(X,Y)
 S X=0 F  S X=$O(BGPG(X)) Q:X'=+X  S Y=+$P(BGPG(X),U,4) D
 .Q:$P($G(^AUPNVMSR(Y,2)),U,1)
 .S N=$P(^AUPNVMSR(Y,0),U,4)
 .S BGPC=BGPC+1,BGPY(BGPC)="MEASUREMENT CEF:  "_$$DATE^BGP2UTL($P(BGPG(X),U))_"  value: "_N
 .Q
CEFPROC ;now see if any procedures
 S X=0 F  S X=$O(^AUPNVPRC("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVPRC(X,0))
 .S I=$P($G(^AUPNVPRC(X,0)),U) Q:'I
 .S Y=$P($$ICDOP^ICDCODE(I),U,2)
 .S T="",T=$O(^ATXAX("B","BGP CMS EJECTION FRACTION PROC",0))
 .I $$ICD^ATXCHK(I,T,0) D
 ..S V=$P(^AUPNVPRC(X,0),U,3)
 ..S V=$P($P($G(^AUPNVSIT(V,0)),U),".")
 ..;I V>BGPD Q  ;after discharge
 ..S BGPC=BGPC+1,BGPY(BGPC)="CEF PROCEDURE:  "_$$DATE^BGP2UTL(V)_"  ["_Y_"]  "_$$VAL^XBDIQ1(9000010.08,X,.04)
CEFCPT ;now get all cpts
 S X=0 F  S X=$O(^AUPNVCPT("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVCPT(X,0))
 .S I=$P($G(^AUPNVCPT(X,0)),U) Q:'I
 .S Y=$P($$CPT^ICPTCOD(I),U,2)
 .S T="",T=$O(^ATXAX("B","BGP CMS EJECTION FRACTION CPTS",0))
 .I $$ICD^ATXCHK(I,T,1) D
 ..S V=$P(^AUPNVCPT(X,0),U,3)
 ..S V=$P($P($G(^AUPNVSIT(V,0)),U),".")
 ..;I V>BGPD Q  ;after discharge
 ..S BGPC=BGPC+1,BGPY(BGPC)="CEF CPT:  "_$$DATE^BGP2UTL(V)_"  ["_Y_"]  "_$P($$CPT^ICPTCOD(I),U,3)
 S X=0 F  S X=$O(^AUPNVTC("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVTC(X,0))
 .S I=$P($G(^AUPNVTC(X,0)),U,7) Q:'I
 .S Y=$P($$CPT^ICPTCOD(I),U,2)
 .Q:Y=""
 .S T="",T=$O(^ATXAX("B","BGP CMS EJECTION FRACTION CPTS",0))
 .I $$ICD^ATXCHK(I,T,1) D
 ..S V=$P(^AUPNVTC(X,0),U,3)
 ..S V=$P($P($G(^AUPNVSIT(V,0)),U),".")
 ..;I V>BGPD Q  ;after discharge
 ..S BGPC=BGPC+1,BGPY(BGPC)="CEF TRAN CODE CPT:  "_$$DATE^BGP2UTL(V)_"  ["_Y_"]  "_$P($$CPT^ICPTCOD(I),U,3)
 ;now check rcis referrals
 S X=0 F  S X=$O(^BMCREF("D",P,X)) Q:X'=+X  D
 .S I=$P($G(^BMCREF(X,0)),U,12)
 .Q:I=""
 .Q:'$D(^BMCTDXC(I))
 .Q:$P(^BMCTDXC(I,0),U)'="CARDIOVASCULAR DISORDERS"
 .S C=$P($G(^BMCREF(X,0)),U,13)
 .Q:C=""
 .Q:'$D(^BMCTSVC(C))
 .S V=$P(^BMCTSVC(C,0),U)
 .Q:'$$CPTC(V)
 .S BGPC=BGPC+1,BGPY(BGPC)="RCIS REFERRAL:  "_$$DATE^BGP2UTL($P(^BMCREF(X,0),U))_"  ICD CAT: "_$P(^BMCTDXC(I,0),U)_"  CPT CAT: "_V
 Q
CPTC(Z) ;
 I Z="EVALUATION AND/OR MANAGEMENT" Q 1
 I Z="NONSURGICAL PROCEDURES" Q 1
 I Z="DIAGNOSTIC IMAGING" Q 1
 Q 0
LVSD1(P,BGPD,BGPY) ;
 NEW X,Y,I,T,V,BGPC
 S BGPC=0
 S X=0 F  S X=$O(^AUPNVPOV("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVPOV(X,0))
 .S I=$P($G(^AUPNVPOV(X,0)),U) Q:'I
 .S Y=$P($$ICDDX^ICDCODE(I),U,2)
 .S T=$O(^ATXAX("B","BGP CMS LVSD DXS",0))
 .Q:'$$ICD^ATXCHK(I,T,9)
 .S V=$P(^AUPNVPOV(X,0),U,3)
 .S V=$P($P($G(^AUPNVSIT(V,0)),U),".")
 .I V>BGPD Q  ;after discharge
 .S BGPC=BGPC+1,BGPY(BGPC)="POV:  "_$$DATE^BGP2UTL(V)_"  ["_Y_"]  "_$$VAL^XBDIQ1(9000010.07,X,.04)
 .Q
 ;now get all measurements CEF
 K BGPG S Y="BGPG(",X=P_"^ALL MEAS CEF;DURING "_$$FMTE^XLFDT($$DOB^AUPNPAT(DFN))_"-"_$$FMTE^XLFDT(BGPD) S E=$$START1^APCLDF(X,Y)
 S X=0 F  S X=$O(BGPG(X)) Q:X'=+X  S Y=+$P(BGPG(X),U,4) D
 .Q:$P($G(^AUPNVMSR(Y,2)),U,1)
 .S N=$P(^AUPNVMSR(Y,0),U,4)
 .Q:N>39
 .S BGPC=BGPC+1,BGPY(BGPC)="MEASUREMENT CEF:  "_$$DATE^BGP2UTL($P(BGPG(X),U))_"  value: "_N
 .Q
 ;now see if any procedures
 S X=0 F  S X=$O(^AUPNVPRC("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVPRC(X,0))
 .S I=$P($G(^AUPNVPRC(X,0)),U) Q:'I
 .S Y=$P($$ICDOP^ICDCODE(I),U,2)
 .S T="",T=$O(^ATXAX("B","BGP CMS EJECTION FRACTION PROC",0))
 .I $$ICD^ATXCHK(I,T,0) D
 ..S V=$P(^AUPNVPRC(X,0),U,3)
 ..S V=$P($P($G(^AUPNVSIT(V,0)),U),".")
 ..;I V>BGPD Q  ;after discharge
 ..S BGPC=BGPC+1,BGPY(BGPC)="CEF PROCEDURE:  "_$$DATE^BGP2UTL(V)_"  ["_Y_"]  "_$$VAL^XBDIQ1(9000010.08,X,.04)
 ;now get all cpts
 S X=0 F  S X=$O(^AUPNVCPT("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVCPT(X,0))
 .S I=$P($G(^AUPNVPRC(X,0)),U) Q:'I
 .S Y=$P($$CPT^ICPTCOD(I),U,2)
 .S T="",T=$O(^ATXAX("B","BGP CMS EJECTION FRACTION CPTS",0))
 .I $$ICD^ATXCHK(I,T,1) D
 ..S V=$P(^AUPNVCPT(X,0),U,3)
 ..S V=$P($P($G(^AUPNVSIT(V,0)),U),".")
 ..;I V>BGPD Q  ;after discharge
 ..S BGPC=BGPC+1,BGPY(BGPC)="CEF CPT:  "_$$DATE^BGP2UTL(V)_"  ["_Y_"]  "_$P($$CPT^ICPTCOD(I),U,3)
 Q
AMA(H) ;
 S X=$P(^AUPNVINP(H,0),U,6)
 I X="" Q 0
 S X=$P($G(^DG(405.1,X,"IHS")),U,1)
 I X=3 Q 1
 Q 0
HFDX(V) ;
 S C=$$PRIMPOV^APCLV(V,"I")
 I C="" Q 0 ;no primary dx
 S T=$O(^ATXAX("B","BGP CMS HEART FAILURE DXS",0))
 I 'T Q
 Q $$ICD^ATXCHK(C,T,9)
EXPIRED(H) ;
 S X=$P(^AUPNVINP(H,0),U,6)
 I X="" Q 0
 S X=$P($G(^DG(405.1,X,"IHS")),U,1)
 I X=4!(X=5)!(X=6)!(X=7) Q 1
 Q 0
DSCH(H) ;
 Q $P($P(^AUPNVINP(H,0),U),".")
TRANSIN(H) ;
 S X=$P(^AUPNVINP(H,0),U,7)
 I X="" Q 0
 S X=$P($G(^DG(405.1,X,"IHS")),U,1)
 I X=2!(X=3) Q 1
 Q 0
TRANS(H) ;
 S X=$P(^AUPNVINP(H,0),U,6)
 I X="" Q 0
 S X=$P($G(^DG(405.1,X,"IHS")),U,1)
 I X=2 Q 1
 Q 0
LVADEX(P,BD,ED) ;
 S X=$$LASTPRC^BGP2UTL1(P,"BGP LVAD/HEART TRANSPLANT PROC",BD,ED)
 Q +X
 ;
LVAD1(P,BD,ED,BGPY) ;
 S X=0 F  S X=$O(^AUPNVPRC("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVPRC(X,0))
 .S I=$P($G(^AUPNVPRC(X,0)),U) Q:'I
 .S Y=$P($$ICDOP^ICDCODE(I),U,2)
 .S T="",T=$O(^ATXAX("B","BGP LVAD/HEART TRANSPLANT PROC",0))
 .I $$ICD^ATXCHK(I,T,0) D
 ..S V=$P(^AUPNVPRC(X,0),U,3)
 ..S V=$P($P($G(^AUPNVSIT(V,0)),U),".")
 ..I V>ED Q  ;after discharge
 ..I V<BD Q  ;before admission
 ..S BGPC=BGPC+1,BGPY(BGPC)=$$DATE^BGP2UTL(V)_"  ["_Y_"]  "_$$VAL^XBDIQ1(9000010.08,X,.04)
 ..Q
 .Q
 Q
SMOKER1(P,BGPA,BGPD,BGPY) ;
 K BGPY S BGPC=0
 NEW BGPTOB,BGPDX,BGPDENT
 S BGPTOB=$$TOBACCO^BGP2D7(P,$$FMADD^XLFDT(BGPA,-365),BGPA)
 I BGPTOB["CURRENT SMOKER" S BGPC=BGPC+1,BGPY(BGPC)="Yes, Health Factor: "_$P(BGPTOB,U)_" on "_$P(BGPTOB,U,2)
 S BGPDX=$$DX^BGP2D7(P,$$FMADD^XLFDT(BGPA,-365),BGPA)
 I BGPDX]"",'$$ICD^ATXCHK($P(BGPDX,U,3),$O(^ATXAX("B","BGP TOBACCO PAST USE DXS",0)),9) S BGPC=BGPC+1,BGPY(BGPC)="Yes, Diagnosis: "_$P(BGPDX,U)_" on "_$$DATE^BGP2UTL($P(BGPDX,U,2))
 S BGPDENT=$$DENT^BGP2D7(P,$$FMADD^XLFDT(BGPA,-365),BGPA)
 I BGPDENT]"" S BGPC=BGPC+1,BGPY(BGPC)="Yes, "_$P(BGPDENT,U)_" on "_$$DATE^BGP2UTL($P(BGPDENT,U,2))
 Q
CESS1(P,BDATE,EDATE,BGPY) ;
 K BGPY S BGPC=0
 S Y="BGPALLED("
 S X=P_"^ALL EDUC;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 I $D(BGPALLED(1)) S %="" D
 .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,"-")="TO" S BGPC=BGPC+1,BGPY(BGPC)=$$DATE^BGP2UTL($P(BGPALLED(X),U))_" Topic: "_T Q
 ..I $P(T,"-",2)="TO" S BGPC=BGPC+1,BGPY(BGPC)=$$DATE^BGP2UTL($P(BGPALLED(X),U))_" Topic: "_T Q
 ..I $P(T,"-",2)="SHS" S BGPC=BGPC+1,BGPY(BGPC)=$$DATE^BGP2UTL($P(BGPALLED(X),U))_" Topic: "_T Q
 K ^TMP($J,"A")
 S A="^TMP($J,""A"",",B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(B,A)
 I '$D(^TMP($J,"A",1)) Q ""
 S X=0,G="" F  S X=$O(^TMP($J,"A",X)) Q:X'=+X  S V=$P(^TMP($J,"A",X),U,5) D
 .Q:'$D(^AUPNVSIT(V,0))
 .Q:'$P(^AUPNVSIT(V,0),U,9)
 .Q:$P(^AUPNVSIT(V,0),U,11)
 .S B=$$CLINIC^APCLV(V,"C")
 .I B=94 S BGPC=BGPC+1,BGPY(BGPC)=$$DATE^BGP2UTL($P($P(^AUPNVSIT(V,0),U),"."))_" Clinic 94 visit" Q
 .S Z=0 F  S Z=$O(^AUPNVDEN("AD",V,Z)) Q:Z'=+Z  S B=$P($G(^AUPNVDEN(Z,0)),U) I B S B=$P($G(^AUTTADA(B,0)),U) I B=1320 S BGPC=BGPC+1,BGPY(BGPC)=$$DATE^BGP2UTL($P($P(^AUPNVSIT(V,0),U),"."))_" ADA 1320"
 .Q
 I $D(BGPY) Q
 ;now check all refusals of these education topics
 S G="",X=0 F  S X=$O(^AUPNPREF("AA",P,9999999.09,X)) Q:X=""  D
 .S D=0 F  S D=$O(^AUPNPREF("AA",P,9999999.09,X,D)) Q:D=""!(G]"")  D
 ..S I=0 F  S I=$O(^AUPNPREF("AA",P,9999999.09,X,D,I)) Q:I'=+I!(G]"")  D
 ...S Z=$P($G(^AUPNPREF(I,0)),U,3)
 ...Q:Z=""
 ...I Z<BDATE Q
 ...I Z>EDATE Q
 ...S Y=$P($G(^AUTTEDT(X,0)),U,2)
 ...I $P(Y,"-")="TO"!($P(Y,"-",2)="TO")!($P(Y,"-",2)="SHS") S BGPC=BGPC+1,BGPY(BGPC)=$$DATE^BGP2UTL(Z)_" Refusal of Topic: "_Y
 Q