BGP9D21A ; IHS/CMI/LAB - measure 6 ;
;;9.0;IHS CLINICAL REPORTING;;JUL 1, 2009
;
POSUR(P,BDATE,EDATE) ;EP
K BGPC,BGPX,BGP1
S BGPC=""
S %="",E=+$$CODEN^ICPTCOD(82043),%=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
I %]"" S BGPX(9999999-$P(%,U,2))="1^MICROALB-CPT^^"_$P(%,U,2)
S %="",E=+$$CODEN^ICPTCOD(82044),%=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
I %]"" S BGPX(9999999-$P(%,U,2))="1^MICROALB-CPT^^"_$P(%,U,2)
S %="",E=+$$CODEN^ICPTCOD(83518),%=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
I %]"" S BGPX(9999999-$P(%,U,2))="1^MICROALB-CPT^^"_$P(%,U,2)
S %="",E=+$$CODEN^ICPTCOD(84166),%=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
I %]"" S BGP1(9999999-$P(%,U,2))="1^MICROALB-CPT^^"_$P(%,U,2)
S %="",E=+$$CODEN^ICPTCOD(81050),%=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
I %]"",$O(BGP1(0)) S BGPX(9999999-$P(%,U,2))="1^MICROALB-CPT^^"_$P(%,U,2)_" and 84166"
S %="",E=+$$CODEN^ICPTCOD(82043),%=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
I %]"" S BGPX(9999999-$P(%,U,2))="1^MICROALB-TRAN^^"_$P(%,U,2)
S %="",E=+$$CODEN^ICPTCOD(82044),%=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
I %]"" S BGPX(9999999-$P(%,U,2))="1^MICROALB-TRAN^^"_$P(%,U,2)
S %="",E=+$$CODEN^ICPTCOD(83518),%=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
I %]"" S BGPX(9999999-$P(%,U,2))="1^MICROALB-TRAN^^"_$P(%,U,2)
S %="",E=+$$CODEN^ICPTCOD(84166),%=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
I %]"" S BGP1(9999999-$P(%,U,2))="1^MICROALB-TRAN^^"_$P(%,U,2)
S %="",E=+$$CODEN^ICPTCOD(81050),%=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
I %]"",$O(BGP1(0)) S BGPX(9999999-$P(%,U,2))="1^MICROALB-TRAN^^"_$P(%,U,2)_" and 84166"
S T=$O(^ATXAX("B","BGP MICROALBUM LOINC CODES",0))
S BGPLT=$O(^ATXLAB("B","DM AUDIT MICROALBUMINURIA 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))
...I BGPLT,$P(^AUPNVLAB(X,0),U),$D(^ATXLAB(BGPLT,21,"B",$P(^AUPNVLAB(X,0),U))) S (BGPC,BGPX(D))="1^MICROALB^^"_(9999999-D) Q
...Q:'T
...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
...Q:'$$LOINC(J,T)
...S (BGPC,BGPX(D))="1^MICROALB^^"_(9999999-D) Q
...Q
I $D(BGPX) S X=$O(BGPX(0)) Q BGPX(X)
S T=$O(^ATXAX("B","DM AUDIT A/C RATIO LOINC",0))
S BGPLT=$O(^ATXLAB("B","DM AUDIT A/C RATIO 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))
...I BGPLT,$P(^AUPNVLAB(X,0),U),$D(^ATXLAB(BGPLT,21,"B",$P(^AUPNVLAB(X,0),U))) S (BGPC,BGPX(D))="1^A/C RATIO^^"_(9999999-D) Q
...Q:'T
...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
...Q:'$$LOINC(J,T)
...S (BGPC,BGPX(D))="1^A/C RATIO^^"_(9999999-D) Q
...Q
I $D(BGPX) S X=$O(BGPX(0)) Q BGPX(X)
K BGPG S %=P_"^LAST LAB [DM AUDIT URINE PROTEIN TAX;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
S (%,R)="" I $D(BGPG(1)) D Q R_"^"_"U"_"^"_%_"^"_$P(BGPG(1),U)
.S %=$P(^AUPNVLAB(+$P(BGPG(1),U,4),0),U,4)
.S R=$S(%="":"",%["+":1,%[">":1,$E(%)="P":1,$E(%)="p":1,$E(%)="L":1,$E(%)="l":1,$E(%)="M":1,$E(%)="m":1,$E(%)="S":1,$E(%)="s":1,$E(%)="c":"",$E(%)="C":"",+%>29:1,1:"")
S T=$O(^ATXAX("B","BGP URINE PROTEIN LOINC CODES",0))
S BGPC="",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 %=$P(^AUPNVLAB(X,0),U,4)
...S R=$S(%="":"",%["+":1,%[">":1,$E(%)="P":1,$E(%)="p":1,$E(%)="L":1,$E(%)="l":1,$E(%)="M":1,$E(%)="m":1,$E(%)="S":1,$E(%)="s":1,$E(%)="c":"",$E(%)="C":"",+%>29:1,1:"")
...S BGPC=R_"^U^"_%_"^"_(9999999-D)
I BGPC]"" Q BGPC
K BGPG S %=P_"^LAST DX 585.6;DURING "_$$FMTE^XLFDT($$DOB^AUPNPAT(P))_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
I $D(BGPG(1)) Q "1^ESRD 585.6^^"_$P(BGPG(1),U)
K BGPG S %=P_"^LAST DX V45.1;DURING "_$$FMTE^XLFDT($$DOB^AUPNPAT(P))_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
I $D(BGPG(1)) Q "1^ESRD V45.1^^"_$P(BGPG(1),U)
S T=$O(^ATXAX("B","BGP ESRD CPTS",0))
I T D I X]"" Q 1_U_"ESRD "_$P(X,U,2)_U_U_$P(X,U,1)
.S X=$$CPT^BGP9DU(P,$$DOB^AUPNPAT(P),EDATE,T,5) Q:X]""
.S X=$$TRAN^BGP9DU(P,$$DOB^AUPNPAT(P),EDATE,T,5)
Q 0
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 ""
BGP9D21A ; IHS/CMI/LAB - measure 6 ;
+1 ;;9.0;IHS CLINICAL REPORTING;;JUL 1, 2009
+2 ;
POSUR(P,BDATE,EDATE) ;EP
+1 KILL BGPC,BGPX,BGP1
+2 SET BGPC=""
+3 SET %=""
SET E=+$$CODEN^ICPTCOD(82043)
SET %=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
+4 IF %]""
SET BGPX(9999999-$PIECE(%,U,2))="1^MICROALB-CPT^^"_$PIECE(%,U,2)
+5 SET %=""
SET E=+$$CODEN^ICPTCOD(82044)
SET %=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
+6 IF %]""
SET BGPX(9999999-$PIECE(%,U,2))="1^MICROALB-CPT^^"_$PIECE(%,U,2)
+7 SET %=""
SET E=+$$CODEN^ICPTCOD(83518)
SET %=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
+8 IF %]""
SET BGPX(9999999-$PIECE(%,U,2))="1^MICROALB-CPT^^"_$PIECE(%,U,2)
+9 SET %=""
SET E=+$$CODEN^ICPTCOD(84166)
SET %=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
+10 IF %]""
SET BGP1(9999999-$PIECE(%,U,2))="1^MICROALB-CPT^^"_$PIECE(%,U,2)
+11 SET %=""
SET E=+$$CODEN^ICPTCOD(81050)
SET %=$$CPTI^BGP9DU(P,BDATE,EDATE,E)
+12 IF %]""
IF $ORDER(BGP1(0))
SET BGPX(9999999-$PIECE(%,U,2))="1^MICROALB-CPT^^"_$PIECE(%,U,2)_" and 84166"
+13 SET %=""
SET E=+$$CODEN^ICPTCOD(82043)
SET %=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
+14 IF %]""
SET BGPX(9999999-$PIECE(%,U,2))="1^MICROALB-TRAN^^"_$PIECE(%,U,2)
+15 SET %=""
SET E=+$$CODEN^ICPTCOD(82044)
SET %=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
+16 IF %]""
SET BGPX(9999999-$PIECE(%,U,2))="1^MICROALB-TRAN^^"_$PIECE(%,U,2)
+17 SET %=""
SET E=+$$CODEN^ICPTCOD(83518)
SET %=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
+18 IF %]""
SET BGPX(9999999-$PIECE(%,U,2))="1^MICROALB-TRAN^^"_$PIECE(%,U,2)
+19 SET %=""
SET E=+$$CODEN^ICPTCOD(84166)
SET %=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
+20 IF %]""
SET BGP1(9999999-$PIECE(%,U,2))="1^MICROALB-TRAN^^"_$PIECE(%,U,2)
+21 SET %=""
SET E=+$$CODEN^ICPTCOD(81050)
SET %=$$TRANI^BGP9DU(P,BDATE,EDATE,E)
+22 IF %]""
IF $ORDER(BGP1(0))
SET BGPX(9999999-$PIECE(%,U,2))="1^MICROALB-TRAN^^"_$PIECE(%,U,2)_" and 84166"
+23 SET T=$ORDER(^ATXAX("B","BGP MICROALBUM LOINC CODES",0))
+24 SET BGPLT=$ORDER(^ATXLAB("B","DM AUDIT MICROALBUMINURIA TAX",0))
+25 SET B=9999999-BDATE
SET E=9999999-EDATE
SET D=E-1
FOR
SET D=$ORDER(^AUPNVLAB("AE",P,D))
IF D'=+D!(D>B)!(BGPC]"")
QUIT
Begin DoDot:1
+26 SET L=0
FOR
SET L=$ORDER(^AUPNVLAB("AE",P,D,L))
IF L'=+L!(BGPC]"")
QUIT
Begin DoDot:2
+27 SET X=0
FOR
SET X=$ORDER(^AUPNVLAB("AE",P,D,L,X))
IF X'=+X!(BGPC]"")
QUIT
Begin DoDot:3
+28 IF '$DATA(^AUPNVLAB(X,0))
QUIT
+29 IF BGPLT
IF $PIECE(^AUPNVLAB(X,0),U)
IF $DATA(^ATXLAB(BGPLT,21,"B",$PIECE(^AUPNVLAB(X,0),U)))
SET (BGPC,BGPX(D))="1^MICROALB^^"_(9999999-D)
QUIT
+30 IF 'T
QUIT
+31 SET J=$PIECE($GET(^AUPNVLAB(X,11)),U,13)
IF J=""
QUIT
+32 IF '$$LOINC(J,T)
QUIT
+33 SET (BGPC,BGPX(D))="1^MICROALB^^"_(9999999-D)
QUIT
+34 QUIT
End DoDot:3
End DoDot:2
End DoDot:1
+35 IF $DATA(BGPX)
SET X=$ORDER(BGPX(0))
QUIT BGPX(X)
+36 SET T=$ORDER(^ATXAX("B","DM AUDIT A/C RATIO LOINC",0))
+37 SET BGPLT=$ORDER(^ATXLAB("B","DM AUDIT A/C RATIO TAX",0))
+38 SET B=9999999-BDATE
SET E=9999999-EDATE
SET D=E-1
FOR
SET D=$ORDER(^AUPNVLAB("AE",P,D))
IF D'=+D!(D>B)!(BGPC]"")
QUIT
Begin DoDot:1
+39 SET L=0
FOR
SET L=$ORDER(^AUPNVLAB("AE",P,D,L))
IF L'=+L!(BGPC]"")
QUIT
Begin DoDot:2
+40 SET X=0
FOR
SET X=$ORDER(^AUPNVLAB("AE",P,D,L,X))
IF X'=+X!(BGPC]"")
QUIT
Begin DoDot:3
+41 IF '$DATA(^AUPNVLAB(X,0))
QUIT
+42 IF BGPLT
IF $PIECE(^AUPNVLAB(X,0),U)
IF $DATA(^ATXLAB(BGPLT,21,"B",$PIECE(^AUPNVLAB(X,0),U)))
SET (BGPC,BGPX(D))="1^A/C RATIO^^"_(9999999-D)
QUIT
+43 IF 'T
QUIT
+44 SET J=$PIECE($GET(^AUPNVLAB(X,11)),U,13)
IF J=""
QUIT
+45 IF '$$LOINC(J,T)
QUIT
+46 SET (BGPC,BGPX(D))="1^A/C RATIO^^"_(9999999-D)
QUIT
+47 QUIT
End DoDot:3
End DoDot:2
End DoDot:1
+48 IF $DATA(BGPX)
SET X=$ORDER(BGPX(0))
QUIT BGPX(X)
+49 KILL BGPG
SET %=P_"^LAST LAB [DM AUDIT URINE PROTEIN TAX;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(%,"BGPG(")
+50 SET (%,R)=""
IF $DATA(BGPG(1))
Begin DoDot:1
+51 SET %=$PIECE(^AUPNVLAB(+$PIECE(BGPG(1),U,4),0),U,4)
+52 SET R=$SELECT(%="":"",%["+":1,%[">":1,$EXTRACT(%)="P":1,$EXTRACT(%)="p":1,$EXTRACT(%)="L":1,$EXTRACT(%)="l":1,$EXTRACT(%)="M":1,$EXTRACT(%)="m":1,$EXTRACT(%)="S":1,$EXTRACT(%)="s":1,$EXTRACT(%)="c":"",$EXTRACT(%)="C":"",+%>29:1,1:"")
End DoDot:1
QUIT R_"^"_"U"_"^"_%_"^"_$PIECE(BGPG(1),U)
+53 SET T=$ORDER(^ATXAX("B","BGP URINE PROTEIN LOINC CODES",0))
+54 SET BGPC=""
SET B=9999999-BDATE
SET E=9999999-EDATE
SET D=E-1
FOR
SET D=$ORDER(^AUPNVLAB("AE",P,D))
IF D'=+D!(D>B)!(BGPC]"")
QUIT
Begin DoDot:1
+55 SET L=0
FOR
SET L=$ORDER(^AUPNVLAB("AE",P,D,L))
IF L'=+L!(BGPC]"")
QUIT
Begin DoDot:2
+56 SET X=0
FOR
SET X=$ORDER(^AUPNVLAB("AE",P,D,L,X))
IF X'=+X!(BGPC]"")
QUIT
Begin DoDot:3
+57 IF 'T
QUIT
+58 SET J=$PIECE($GET(^AUPNVLAB(X,11)),U,13)
IF J=""
QUIT
+59 IF '$$LOINC(J,T)
QUIT
+60 SET %=$PIECE(^AUPNVLAB(X,0),U,4)
+61 SET R=$SELECT(%="":"",%["+":1,%[">":1,$EXTRACT(%)="P":1,$EXTRACT(%)="p":1,$EXTRACT(%)="L":1,$EXTRACT(%)="l":1,$EXTRACT(%)="M":1,$EXTRACT(%)="m":1,$EXTRACT(%)="S":1,$EXTRACT(%)="s":1,$EXTRACT(%)="c":"",$EXTRACT(%)="C":"",
+%>29:1,1:"")
+62 SET BGPC=R_"^U^"_%_"^"_(9999999-D)
End DoDot:3
End DoDot:2
End DoDot:1
+63 IF BGPC]""
QUIT BGPC
+64 KILL BGPG
SET %=P_"^LAST DX 585.6;DURING "_$$FMTE^XLFDT($$DOB^AUPNPAT(P))_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(%,"BGPG(")
+65 IF $DATA(BGPG(1))
QUIT "1^ESRD 585.6^^"_$PIECE(BGPG(1),U)
+66 KILL BGPG
SET %=P_"^LAST DX V45.1;DURING "_$$FMTE^XLFDT($$DOB^AUPNPAT(P))_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(%,"BGPG(")
+67 IF $DATA(BGPG(1))
QUIT "1^ESRD V45.1^^"_$PIECE(BGPG(1),U)
+68 SET T=$ORDER(^ATXAX("B","BGP ESRD CPTS",0))
+69 IF T
Begin DoDot:1
+70 SET X=$$CPT^BGP9DU(P,$$DOB^AUPNPAT(P),EDATE,T,5)
IF X]""
QUIT
+71 SET X=$$TRAN^BGP9DU(P,$$DOB^AUPNPAT(P),EDATE,T,5)
End DoDot:1
IF X]""
QUIT 1_U_"ESRD "_$PIECE(X,U,2)_U_U_$PIECE(X,U,1)
+72 QUIT 0
LOINC(A,B) ;EP
+1 NEW %
+2 SET %=$PIECE($GET(^LAB(95.3,A,9999999)),U,2)
+3 IF %]""
IF $DATA(^ATXAX(B,21,"B",%))
QUIT 1
+4 SET %=$PIECE($GET(^LAB(95.3,A,0)),U)_"-"_$PIECE($GET(^LAB(95.3,A,0)),U,15)
+5 IF $DATA(^ATXAX(B,21,"B",%))
QUIT 1
+6 QUIT ""