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

BGP8D211.m

Go to the documentation of this file.
BGP8D211 ; IHS/CMI/LAB - measure 6 19 Sep 2014 8:12 AM ;
 ;;18.1;IHS CLINICAL REPORTING;;MAY 25, 2018;Build 66
 ;
DENTSRVD(P,BDATE,EDATE) ;EP - V18 GPRA DEV DOCUMENTED DENTAL VISIT
 NEW BGPG,BGPC
 K BGPG
 S BGPC="",%=P_"^LAST ADA 0000;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)) Q 1_U_$P(BGPG(1),U)_"^"_"RPMS DENTAL "_$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)) Q 1_U_$P(BGPG(1),U)_"^"_"RPMS DENTAL "_$P(BGPG(1),U,2)
 K BGPG
 S %=P_"^LAST ADA 0007;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)) Q 1_U_$P(BGPG(1),U)_"^"_"RPMS DENTAL "_$P(BGPG(1),U,2)
 K BGPG
 S BGPG(1)=$$CPT^BGP8DU(P,BDATE,EDATE,$O(^ATXAX("B","BGP DENTAL VISIT CPT CODES",0)),5)
 I BGPG(1)]""  Q 1_U_$P(BGPG(1),U)_"^"_"CDT "_$P(BGPG(1),U,2)
 K BGPG
 S %=P_"^LAST EXAM 30;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)) Q 1_U_$P(BGPG(1),U)_"^"_$P(BGPG(1),U,3)
 S BGPG=$$LASTDX^BGP8UTL1(P,"BGP DENTAL VISIT DXS",BDATE,EDATE)
 I BGPG Q "1^"_$P(BGPG,U,3)_"^"_$P(BGPG,U,2)
 I BGPG,$G(FORECAST),$P(BGPG,U,3)>$P(BGPC,U) S BGPC=$P(BGPG,U,3)_"^POV "_$P(BGPG,U,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]"",'$G(FORECAST) Q G
 .S X=0 F  S X=$O(BGPG(X)) Q:X'=+X  S V=$P(BGPG(X),U,5) D
 ..I $P($G(^AUPNVSIT(V,0)),U,7)="C" Q  ;NO CHART REVIEWS
 ..I $P($G(^AUPNVSIT(V,0)),U,7)="T" Q  ;NO TELEPHONE CALLS
 ..S Y=+$P(BGPG(X),U,4)
 ..Q:'$$DVADA($$VAL^XBDIQ1(9000010.05,Y,.01))
 ..S G=1_U_$P(BGPG(X),U)_"^VISIT RPMS DENTAL "_$P(BGPG(X),U,2) Q
 Q ""
DVADA(A) ;
 ;is this a dental visit ada code?
 I $G(A)="" Q ""
 I +A>109,+A<391 Q 1
 I +A>414,+A<472 Q 1
 I +A>600,+A<604 Q 1
 I +A>998,+A<9975 Q 1
 I +A=9999 Q 1
 Q ""
 ;
JVN ;EP
 NEW BGPVAL,A,E,%,Y,X,R,D,V
 S BGPVAL=""
 K ^TMP($J,"A")
 S R=$NA(^TMP($J,"A"))
 D ALLV^APCLAPIU(P,BDATE,EDATE,R)
 S X=0,Y=0 F  S X=$O(^TMP($J,"A",X)) Q:X'=+X!(Y)  S R=$$CLINIC^APCLV($P(^TMP($J,"A",X),U,5),"C") I R="A2",'$$DNKA($P(^TMP($J,"A",X),U,5)) S Y=1,D=$P(^TMP($J,"A",X),U)
 I Y S $P(BGPVAL,U,1)="JVN: "_$$DATE^BGP8UTL(D)_" Cl "_R
 ;OPHTHALMOLOGY
 S X=0,Y=0 F  S X=$O(^TMP($J,"A",X)) Q:X'=+X!(Y)  D
 .S V=$P(^TMP($J,"A",X),U,5)
 .Q:$P($G(^AUPNVSIT(V,0)),U,7)="C"
 .Q:$P($G(^AUPNVSIT(V,0)),U,7)="T"
 .S R=$$CLINIC^APCLV($P(^TMP($J,"A",X),U,5),"C")
 .Q:R'=17
 .Q:$$DNKA($P(^TMP($J,"A",X),U,5))
 .S J=$$PRIMPROV^APCLV($P(^TMP($J,"A",X),U,5),"D")
 .Q:J'=79
 .S Y=1,D=$P(^TMP($J,"A",X),U)
 I Y S $P(BGPVAL,U,2)="Ophth: "_$$DATE^BGP8UTL(D)_" Cl/Prv "_R_"/"_J
 ;I 'Y D
 ;.S (X,Y)=0,D="" F  S X=$O(^TMP($J,"A",X)) Q:X'=+X!(Y)  S R=$$PRIMPROV^APCLV($P(^TMP($J,"A",X),U,5),"D") I R=79,'$$DNKA($P(^TMP($J,"A",X),U,5)) S Y=1,D=$P(^TMP($J,"A",X),U)
 ;.I Y S $P(BGPVAL,U,2)="Ophth: "_$$DATE^BGP8UTL(D)_" Prv "_R
 ;S X=0,Y=0 F  S X=$O(^TMP($J,"A",X)) Q:X'=+X!(Y)  S R=$$CLINIC^APCLV($P(^TMP($J,"A",X),U,5),"C") I R=18,'$$DNKA($P(^TMP($J,"A",X),U,5)) S Y=1,D=$P(^TMP($J,"A",X),U)
 ;I Y S $P(BGPVAL,U,3)="Optom: "_$$DATE^BGP8UTL(D)_" Cl "_R
 ;I 'Y D
 ;.S (X,Y)=0,D="" F  S X=$O(^TMP($J,"A",X)) Q:X'=+X!(Y)  S R=$$PRIMPROV^APCLV($P(^TMP($J,"A",X),U,5),"D") I R="08"!(R=24),'$$DNKA($P(^TMP($J,"A",X),U,5)) S Y=1,D=$P(^TMP($J,"A",X),U)
 ;OPTOMETRY
 S X=0,Y=0 F  S X=$O(^TMP($J,"A",X)) Q:X'=+X!(Y)  D
 .S V=$P(^TMP($J,"A",X),U,5)
 .Q:$P($G(^AUPNVSIT(V,0)),U,7)="C"
 .Q:$P($G(^AUPNVSIT(V,0)),U,7)="T"
 .S R=$$CLINIC^APCLV($P(^TMP($J,"A",X),U,5),"C")
 .Q:R'=18
 .Q:$$DNKA($P(^TMP($J,"A",X),U,5))
 .S J=$$PRIMPROV^APCLV($P(^TMP($J,"A",X),U,5),"D")
 .I J'="08",J'=24 Q
 .S Y=1,D=$P(^TMP($J,"A",X),U)
 I Y S $P(BGPVAL,U,3)="Optom: "_$$DATE^BGP8UTL(D)_" Cl/Prv "_R_"/"_J
 Q BGPVAL
DNKA(V) ;EP
 NEW D,N
 S D=$$PRIMPOV^APCLV(V,"C")
 I D=".0860" Q 1
 S N=$$PRIMPOV^APCLV(V,"N")
 I $E(D)="V",N["DNKA" Q 1
 I $E(D)="V",N["DID NOT KEEP APPOINTMENT" Q 1
 I $E(D)="V",N["DID NOT KEEP APPT" Q 1
 Q 0
GFR(P,BDATE,EDATE) ;EP
 S BGPC=""
 S T=$O(^LAB(60,"B","ESTIMATED GFR",0))
 S T1=$O(^ATXLAB("B","BGP GPRA ESTIMATED GFR TAX",0))
 S T2=$O(^ATXAX("B","BGP ESTIMATED GFR LOINC",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))
 ...Q:$P(^AUPNVLAB(X,0),U,4)=""
 ...I T,$P(^AUPNVLAB(X,0),U)=T S BGPC=1_U_(9999999-D) Q
 ...I T1,$D(^ATXLAB(T1,21,"B",$P(^AUPNVLAB(X,0),U))) S BGPC=1_U_(9999999-D) Q
 ...Q:'T2
 ...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
 ...Q:'$$LOINC(J,T2)
 ...S BGPC=1_U_(9999999-D)
 ...Q
 Q BGPC
QUANTUP(P,BDATE,EDATE) ;EP
 K BGPC,BGPX
 S BGPC="",BGPLC=""
 K BGPG S %=P_"^LAST LAB [BGP QUANT UACR TESTS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)) S BGPLC=1_"^"_$P(BGPG(1),U,3)_"^"_$P(BGPG(1),U)
 S T=$O(^ATXAX("B","BGP QUANT UACR LOINC",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:'T
 ...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
 ...Q:'$$LOINC(J,T)
 ...S %=$$VAL^XBDIQ1(9000010.09,X,.01)  ;$P(^AUPNVLAB(X,0),U,4)
 ...I $P(BGPLC,U,3)<(9999999-D) S BGPLC=1_U_%_U_(9999999-D)
 S %="",E=+$$CODEN^ICPTCOD(82043),%=$$CPTI^BGP8DU(P,BDATE,EDATE,E)
 I %]"",$P(BGPLC,U,3)<$P(%,U,2),$$OCPT($P(%,U,3))  S BGPLC="1^CPT 82043/82570^"_$P(%,U,2)
 S %="",E=+$$CODEN^ICPTCOD(82043),%=$$TRANI^BGP8DU(P,BDATE,EDATE,E)
 I %]"",$P(BGPLC,U,3)<$P(%,U,2),$$OCPT($P(%,U,3))  S BGPLC="1^CPT 84023/82570^"_$P(%,U,2)
 Q BGPLC
OCPT(V) ;is there a 82570 on this visit?
 NEW X,Y,D,E,%
 S D=$$VD^APCLV(V)  ;date of visit
 S E=+$$CODEN^ICPTCOD("82570"),%=$$CPTI^BGP8DU(P,D,D,E)
 ;S X=0,Y=0 F  S X=$O(^AUPNVCPT("AD",V,X)) Q:X'=+X  D
 ;.I $$VAL^XBDIQ1(9000010.18,X,.01)=82570 S Y=1 Q
 I % Q 1
 ;check tran codes
 ;S X=0,Y=0 F  S X=$O(^AUPNVTC("AD",V,X)) Q:X'=+X  D
 ;.I $$VAL^XBDIQ1(9000010.33,X,.07)=82570 S Y=1 Q
 S E=+$$CODEN^ICPTCOD("82570"),%=$$TRANI^BGP8DU(P,D,D,E)
 I % Q 1
 Q ""
LOINC(A,B) ;EP 
 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 ""
ESRD(P,BDATE,EDATE) ;EP
 NEW X,T,A,B,C
 S X=$$LASTDX^BGP8UTL1(P,"BGP ESRD PMS DXS",BDATE,EDATE)
 I X Q 1_U_"POV "_$P(X,U,2)_U_$P(X,U,3)
 S T=$O(^ATXAX("B","BGP ESRD CPTS",0))
 I T D  I X]"" Q 1_U_"CPT "_$P(X,U,2)_U_$P(X,U,1)
 .S X=$$CPT^BGP8DU(P,$$DOB^AUPNPAT(P),EDATE,T,5) I X]"" Q
 .S X=$$TRAN^BGP8DU(P,$$DOB^AUPNPAT(P),EDATE,T,5)
 S X=$$LASTPRC^BGP8UTL1(P,"BGP ESRD PROCS",BDATE,EDATE)
 I X Q 1_U_"PRC "_$P(X,U,2)_U_$P(X,U,3)
 ;added non-deleted problem list icd/snomed
 S X=$$PLTAXND^BGP8DU(P,"BGP ESRD PMS DXS",EDATE)
 I X Q X
 S X=$$IPLSNOND^BGP8DU(P,"PXRM END STAGE RENAL DISEASE",EDATE)
 I X Q X
 Q 0
S ;
 S BGPSET($P(^APCDTPGT(X,0),U,1))=0,BGPMET($P(^APCDTPGT(X,0),U,1))=0
 Q
IGOAL ;EP
 NEW BGPSET,BGPMET
 ;
 I 'BGPACTUP S BGPSTOP=1 Q  ;not user pop
 F X=1:1:23 S @("BGPN"_X)=0
 S BGPD1=1  ;USER POP
 S BGPD2=0  ;# goals set
 S BGPD3=0 ;# goals met
 S X=0 F  S X=$O(^APCDTPGT(X)) Q:X'=+X  D
 .S Y=$P(^APCDTPGT(X,0),U,1)
 .I Y="PHYSICAL ACTIVITY" D S
 .I Y="NUTRITION" D S
 .I Y="MEDICATIONS" D S
 .I Y="WELLNESS AND SAFETY" D S
 .I Y="TOBACCO" D S
 .I Y="ALCOHOL OR OTHER DRUGS" D S
 .I Y="STRESS AND COPING" D S
 .I Y="MONITORING" D S
 .I Y="DIABETES CURRICULUM" D S
 .I Y="OTHER" D S
 ;did patient have a goal set with a start date in report period
 D SET
 I BGPD2 S BGPN1=1
 S C=2,X=0
 F  S X=$O(BGPSET(X)) Q:X=""  S C=C+1 S @("BGPN"_C)=@("BGPN"_C)+BGPSET(X)
 D MET
 I BGPD3 S BGPN2=1
 S C=12,X=0
 F  S X=$O(BGPMET(X)) Q:X=""  S C=C+1 S @("BGPN"_C)=@("BGPN"_C)+BGPMET(X)
 S BGPVALUE="UP|||"
 S X="",Y="" F  S X=$O(BGPSET(X)) Q:X=""  I $P(BGPSET(X),U,1) D
 .F J=2:1 S D=$P(BGPSET(X),U,J) Q:D=""  D
 ..I Y]"" S Y=Y_", "
 ..S Y=Y_$$DATE^BGP8UTL(D)_" - "_X
 I Y]"" S Y="GS: "_Y,BGPVALUE=BGPVALUE_Y
 S Y=""
 S X="",Y="" F  S X=$O(BGPMET(X)) Q:X=""  I $P(BGPMET(X),U,1) D
 .F J=2:1 S D=$P(BGPMET(X),U,J) Q:D=""  D
 ..I Y]"" S Y=Y_", "
 ..S Y=Y_$$DATE^BGP8UTL(D)_" - "_X
 I Y]"" S Y="; GM: "_Y,BGPVALUE=BGPVALUE_Y
 K BGPSET,BGPMET
 Q
 ;
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N1)=0
 S BGPVALUE=""
 I 'BGPACTCL S BGPSTOP=1 Q  ;not active clinical
 I BGPAGEB<65 S BGPSTOP=1 Q  ;not over 65
 S BGPD1=1
 I $P(^DPT(DFN,0),U,2)="M" S BGPD2=1
 I $P(^DPT(DFN,0),U,2)="F" S BGPD3=1
 I BGPAGEB>64,BGPAGEB<75 S BGPD4=1
 I BGPAGEB>74,BGPAGEB<85 S BGPD5=1
 I BGPAGEB>84 S BGPD6=1
 S BGPVAL=$$AWV1(DFN,$$FMADD^XLFDT(BGPEDATE,-456),BGPEDATE)
 S BGPN1=$P(BGPVAL,U)
 S BGPVALUE="AC|||" I BGPN1 S BGPVALUE=BGPVALUE_$$DATE^BGP8UTL($P(BGPVAL,U,2))_" CPT "_$P(BGPVAL,U,3)
 K BGPVAL
 Q
 ;
AWV1(P,BDATE,EDATE) ;EP
 NEW T,X
 S T=$O(^ATXAX("B","BGP ANNUAL WELLNESS CPTS",0))
 I 'T Q ""
 S X=$$CPT^BGP8DU(P,BDATE,EDATE,T,6)
 I 'X S X=$$TRAN^BGP8DU(P,BDATE,EDATE,T,6)
 Q X
DMPVPL(P,BDATE,EDATE) ;EP - DM ON PL OR 2 DM VISITS EVER
 I '$G(P) Q ""
 I $$PLTAXND^BGP8DU(P,"SURVEILLANCE DIABETES",EDATE) Q 1
 I $$IPLSNOND^BGP8DU(P,"PXRM DIABETES",EDATE) Q 1
 I $$V2DM^BGP8D1(P,BDATE,EDATE) Q 1
 Q ""
DMFB(P,EDATE) ;EP - DM V POV BEFORE TIME PERIOD OR PL BEFORE TIME PERIOD
 I '$G(P) Q ""
 I $$PLTAXND^BGP8DU(P,"SURVEILLANCE DIABETES",EDATE) Q 1
 I $$IPLSNOND^BGP8DU(P,"PXRM DIABETES",EDATE) Q 1
 NEW X,BGPG,E,Y
 K BGPG
 S Y="BGPG("
 S X=P_"^FIRST DX [SURVEILLANCE DIABETES" S E=$$START1^APCLDF(X,Y)
 I '$D(BGPG(1)) Q ""
 I $P(BGPG(1),U,1)'>EDATE Q 1
 Q ""