BGPD5 ; IHS/CMI/LAB - indicator 5 ;
;;7.0;IHS CLINICAL REPORTING;;JAN 24, 2007
;
I5A ;EP ;EP - indicator 5a
;Q:'$D(BGPIND(12))
Q:'BGPDMPAT ;not in the simple population for denominator
S BGPUP=$$POSUR(DFN,BGPEDATE)
I BGPUP D S(BGPRPT,$S(BGPTIME=1:15,BGPTIME=0:45,BGPTIME=8:85,1:999),1,1)
I $D(BGPLIST(12)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",12,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=$P(BGPUP,U,2)
Q
I5B ;EP
;Q:'$D(BGPIND(13))
Q:'BGPDMPAT ;not in the simple population for denominator
Q:'BGP2BD
I BGPUP D S(BGPRPT,$S(BGPTIME=1:15,BGPTIME=0:45,BGPTIME=8:85,1:999),2,1)
I $D(BGPLIST(13)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",13,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=$P(BGPUP,U,2)
Q
I5C ;EP
;Q:'$D(BGPIND(14))
Q:'BGPDMPAT ;not in the simple population for denominator
Q:'BGP2CD
I BGPUP D S(BGPRPT,$S(BGPTIME=1:15,BGPTIME=0:45,BGPTIME=8:85,1:999),3,1)
I $D(BGPLIST(14)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",14,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=$P(BGPUP,U,2)
Q
S(R,N,P,V) ;
I 'V Q ;no value to add
S $P(^BGPD(R,N),U,P)=$P($G(^BGPD(R,N)),U,P)+V
Q
POSUR(P,EDATE) ;
NEW BGPG,X,%,E,R,V,D
K BGPG
S D=$$FMADD^XLFDT(EDATE,-365)
S %=P_"^LAST LAB [DM AUDIT MICROALBUMINURIA TAX;DURING "_$$FMTE^XLFDT(D)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
I $D(BGPG(1)) Q 1_"^MICROALB"
S %=P_"^LAST LAB [DM AUDIT URINE PROTEIN TAX;DURING "_$$FMTE^XLFDT(D)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
S (%,R)="" I $D(BGPG(1)) D Q R_"^"_%
.S %=$P(^AUPNVLAB(+$P(BGPG(1),U,4),0),U,4)
.S R=$S(%="":"",%["+":1,%[">":1,$E(%)="P":1,$E(%)="p":1,$E(%)="c":"",$E(%)="C":"",+%>29:1,1:"")
.Q
Q ""
BGPD5 ; IHS/CMI/LAB - indicator 5 ;
+1 ;;7.0;IHS CLINICAL REPORTING;;JAN 24, 2007
+2 ;
I5A ;EP ;EP - indicator 5a
+1 ;Q:'$D(BGPIND(12))
+2 ;not in the simple population for denominator
IF 'BGPDMPAT
QUIT
+3 SET BGPUP=$$POSUR(DFN,BGPEDATE)
+4 IF BGPUP
DO S(BGPRPT,$SELECT(BGPTIME=1:15,BGPTIME=0:45,BGPTIME=8:85,1:999),1,1)
+5 IF $DATA(BGPLIST(12))
IF BGPTIME=1
SET ^XTMP("BGPD",BGPJ,BGPH,"LIST",12,$SELECT($PIECE($GET(^AUPNPAT(DFN,11)),U,18)]"":$PIECE(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$PIECE(^DPT(DFN,0),U,2),BGPAGEE,DFN)=$PIECE(BGPUP,U,2)
+6 QUIT
I5B ;EP
+1 ;Q:'$D(BGPIND(13))
+2 ;not in the simple population for denominator
IF 'BGPDMPAT
QUIT
+3 IF 'BGP2BD
QUIT
+4 IF BGPUP
DO S(BGPRPT,$SELECT(BGPTIME=1:15,BGPTIME=0:45,BGPTIME=8:85,1:999),2,1)
+5 IF $DATA(BGPLIST(13))
IF BGPTIME=1
SET ^XTMP("BGPD",BGPJ,BGPH,"LIST",13,$SELECT($PIECE($GET(^AUPNPAT(DFN,11)),U,18)]"":$PIECE(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$PIECE(^DPT(DFN,0),U,2),BGPAGEE,DFN)=$PIECE(BGPUP,U,2)
+6 QUIT
I5C ;EP
+1 ;Q:'$D(BGPIND(14))
+2 ;not in the simple population for denominator
IF 'BGPDMPAT
QUIT
+3 IF 'BGP2CD
QUIT
+4 IF BGPUP
DO S(BGPRPT,$SELECT(BGPTIME=1:15,BGPTIME=0:45,BGPTIME=8:85,1:999),3,1)
+5 IF $DATA(BGPLIST(14))
IF BGPTIME=1
SET ^XTMP("BGPD",BGPJ,BGPH,"LIST",14,$SELECT($PIECE($GET(^AUPNPAT(DFN,11)),U,18)]"":$PIECE(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$PIECE(^DPT(DFN,0),U,2),BGPAGEE,DFN)=$PIECE(BGPUP,U,2)
+6 QUIT
S(R,N,P,V) ;
+1 ;no value to add
IF 'V
QUIT
+2 SET $PIECE(^BGPD(R,N),U,P)=$PIECE($GET(^BGPD(R,N)),U,P)+V
+3 QUIT
POSUR(P,EDATE) ;
+1 NEW BGPG,X,%,E,R,V,D
+2 KILL BGPG
+3 SET D=$$FMADD^XLFDT(EDATE,-365)
+4 SET %=P_"^LAST LAB [DM AUDIT MICROALBUMINURIA TAX;DURING "_$$FMTE^XLFDT(D)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(%,"BGPG(")
+5 IF $DATA(BGPG(1))
QUIT 1_"^MICROALB"
+6 SET %=P_"^LAST LAB [DM AUDIT URINE PROTEIN TAX;DURING "_$$FMTE^XLFDT(D)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(%,"BGPG(")
+7 SET (%,R)=""
IF $DATA(BGPG(1))
Begin DoDot:1
+8 SET %=$PIECE(^AUPNVLAB(+$PIECE(BGPG(1),U,4),0),U,4)
+9 SET R=$SELECT(%="":"",%["+":1,%[">":1,$EXTRACT(%)="P":1,$EXTRACT(%)="p":1,$EXTRACT(%)="c":"",$EXTRACT(%)="C":"",+%>29:1,1:"")
+10 QUIT
End DoDot:1
QUIT R_"^"_%
+11 QUIT ""