BGPD24 ; IHS/CMI/LAB - indicator 24 ;
;;7.0;IHS CLINICAL REPORTING;;JAN 24, 2007
;
I24 ;EP ;EP - indicator 24
S (BGPP,BGPP1)=""
;Q:'$D(BGPIND(24))
I BGPAGEB>64 D
.D S(BGPRPT,$S(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),1,1)
.S BGPP=$$PNEU(DFN,BGPEDATE) ;pneumovax anytime in lifetime
.I BGPP]"" D S(BGPRPT,$S(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),2,1)
.;I $D(BGPLIST(24)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",24,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP
.S BGPP1=$$FLU(DFN,BGPEDATE)
.I BGPP1]"" D S(BGPRPT,$S(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),3,1)
.I $D(BGPLIST(24)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",24,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP_" "_BGPP1
I $$DM^BGPD1(DFN,BGPEDATE),BGPAGEB>17 D
.D S(BGPRPT,$S(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),5,1)
.S BGPP=$$PNEU(DFN,BGPEDATE) ;pneumovax anytime in lifetime
.I BGPP]"" D S(BGPRPT,$S(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),6,1)
.;I $D(BGPLIST(24)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",24,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP
.S BGPP1=$$FLU(DFN,BGPEDATE)
.I BGPP1]"" D S(BGPRPT,$S(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),7,1)
.I $D(BGPLIST(24)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",24,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)="DM "_BGPP_" "_BGPP1
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
;
FLU(P,ED) ;
NEW BDATE,EDATE S BDATE=$$FMADD^XLFDT(ED,-365)
NEW BGPG,X,E
S EDATE=$$FMTE^XLFDT(ED),BDATE=$$FMTE^XLFDT(BDATE)
S X=P_"^LAST IMM "_$S($$BI:88,1:12)_";DURING "_BDATE_"-"_EDATE S E=$$START1^APCLDF(X,"BGPG(")
I $D(BGPG(1)) Q " Flu Vaccine"
K BGPG S %=P_"^LAST PROCEDURE 99.52;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BGPG(")
I $D(BGPG(1)) Q " Flu Vaccine"
K BGPG S %=P_"^LAST DX V04.8;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BGPG(")
I $D(BGPG(1)) Q " Flu Vaccine"
K BGPG S %=P_"^LAST DX V06.6;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BGPG(")
I $D(BGPG(1)) Q " Flu Vaccine"
S T=$O(^ATXAX("B","BGP CPT FLU",0))
I T D I X]"" Q " Flu Vaccine"
.S X=$$CPT^BGPDU(P,,ED,T,4)
Q ""
PNEU(P,EDATE) ;
NEW BGPG,X,E
S EDATE=$$FMTE^XLFDT(EDATE)
S X=P_"^LAST IMM "_$S($$BI:33,1:19)_";DURING "_$$FMTE^XLFDT($$DOB^AUPNPAT(P))_"-"_EDATE S E=$$START1^APCLDF(X,"BGPG(")
I $D(BGPG(1)) Q "Pneumovax"
Q ""
BI() ;
Q $S($O(^AUTTIMM(0))>100:1,1:0)
;
BGPD24 ; IHS/CMI/LAB - indicator 24 ;
+1 ;;7.0;IHS CLINICAL REPORTING;;JAN 24, 2007
+2 ;
I24 ;EP ;EP - indicator 24
+1 SET (BGPP,BGPP1)=""
+2 ;Q:'$D(BGPIND(24))
+3 IF BGPAGEB>64
Begin DoDot:1
+4 DO S(BGPRPT,$SELECT(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),1,1)
+5 ;pneumovax anytime in lifetime
SET BGPP=$$PNEU(DFN,BGPEDATE)
+6 IF BGPP]""
DO S(BGPRPT,$SELECT(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),2,1)
+7 ;I $D(BGPLIST(24)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",24,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP
+8 SET BGPP1=$$FLU(DFN,BGPEDATE)
+9 IF BGPP1]""
DO S(BGPRPT,$SELECT(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),3,1)
+10 IF $DATA(BGPLIST(24))
IF BGPTIME=1
SET ^XTMP("BGPD",BGPJ,BGPH,"LIST",24,$SELECT($PIECE($GET(^AUPNPAT(DFN,11)),U,18)]"":$PIECE(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$PIECE(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP_" "_BGPP1
End DoDot:1
+11 IF $$DM^BGPD1(DFN,BGPEDATE)
IF BGPAGEB>17
Begin DoDot:1
+12 DO S(BGPRPT,$SELECT(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),5,1)
+13 ;pneumovax anytime in lifetime
SET BGPP=$$PNEU(DFN,BGPEDATE)
+14 IF BGPP]""
DO S(BGPRPT,$SELECT(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),6,1)
+15 ;I $D(BGPLIST(24)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",24,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP
+16 SET BGPP1=$$FLU(DFN,BGPEDATE)
+17 IF BGPP1]""
DO S(BGPRPT,$SELECT(BGPTIME=1:17,BGPTIME=0:47,BGPTIME=8:87,1:999),7,1)
+18 IF $DATA(BGPLIST(24))
IF BGPTIME=1
SET ^XTMP("BGPD",BGPJ,BGPH,"LIST",24,$SELECT($PIECE($GET(^AUPNPAT(DFN,11)),U,18)]"":$PIECE(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$PIECE(^DPT(DFN,0),U,2),BGPAGEE,DFN)="DM "_BGPP_" "_BGPP1
End DoDot:1
+19 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
+4 ;
FLU(P,ED) ;
+1 NEW BDATE,EDATE
SET BDATE=$$FMADD^XLFDT(ED,-365)
+2 NEW BGPG,X,E
+3 SET EDATE=$$FMTE^XLFDT(ED)
SET BDATE=$$FMTE^XLFDT(BDATE)
+4 SET X=P_"^LAST IMM "_$SELECT($$BI:88,1:12)_";DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(X,"BGPG(")
+5 IF $DATA(BGPG(1))
QUIT " Flu Vaccine"
+6 KILL BGPG
SET %=P_"^LAST PROCEDURE 99.52;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BGPG(")
+7 IF $DATA(BGPG(1))
QUIT " Flu Vaccine"
+8 KILL BGPG
SET %=P_"^LAST DX V04.8;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BGPG(")
+9 IF $DATA(BGPG(1))
QUIT " Flu Vaccine"
+10 KILL BGPG
SET %=P_"^LAST DX V06.6;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BGPG(")
+11 IF $DATA(BGPG(1))
QUIT " Flu Vaccine"
+12 SET T=$ORDER(^ATXAX("B","BGP CPT FLU",0))
+13 IF T
Begin DoDot:1
+14 SET X=$$CPT^BGPDU(P,,ED,T,4)
End DoDot:1
IF X]""
QUIT " Flu Vaccine"
+15 QUIT ""
PNEU(P,EDATE) ;
+1 NEW BGPG,X,E
+2 SET EDATE=$$FMTE^XLFDT(EDATE)
+3 SET X=P_"^LAST IMM "_$SELECT($$BI:33,1:19)_";DURING "_$$FMTE^XLFDT($$DOB^AUPNPAT(P))_"-"_EDATE
SET E=$$START1^APCLDF(X,"BGPG(")
+4 IF $DATA(BGPG(1))
QUIT "Pneumovax"
+5 QUIT ""
BI() ;
+1 QUIT $SELECT($ORDER(^AUTTIMM(0))>100:1,1:0)
+2 ;