BGP2PDL7 ; IHS/CMI/LAB - print ind 1 ;
;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
;
;
I023 ;EP
S BGPORXX=$P(^BGPINDW(BGPIC,12),U,6)
D:'$G(BGPSUMON) H1^BGP2PDL1
I BGPRTYPE=4,BGPINDW="C" D Q
.S BGPDENP=0 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.1E",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.2E",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.3E",0)) D PI1^BGP2PDL1
.S BGPDENP=0 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.1E",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.2E",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.3E",0)) D PI1^BGP2PDL1
.S BGPDENP=0 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.1E",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.2E",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.3E",0)) D PI1^BGP2PDL1
.S BGPDENP=0 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.1F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.2F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.3F",0)) D PI1^BGP2PDL1
.S BGPDENP=0 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.1F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.2F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.3F",0)) D PI1^BGP2PDL1
.S BGPDENP=0 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.1F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.2F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.3F",0)) D PI1^BGP2PDL1
I BGPRTYPE=4,BGPINDW="E" D Q
.S BGPDENP=0 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.1F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.2F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.3F",0)) D PI1^BGP2PDL1
.S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.4F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".8.5F",0)) D PI1^BGP2PDL1
.S BGPDENP=0 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.1F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.2F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.3F",0)) D PI1^BGP2PDL1
.S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.4F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".9.5F",0)) D PI1^BGP2PDL1
.S BGPDENP=0 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.1F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.2F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.3F",0)) D PI1^BGP2PDL1
.S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.4F",0)) D PI1^BGP2PDL1 S BGPPC=$O(^BGPINDWC("OR",BGPORXX_".10.5F",0)) D PI1^BGP2PDL1
F BGPPC1=BGPORXX_".1",BGPORXX_".2",BGPORXX_".3",BGPORXX_".4" D PI^BGP2PDL1
F BGPPC1=BGPORXX_".5",BGPORXX_".6",BGPORXX_".7" D PI^BGP2PDL1
;F BGPPC1=BGPORXX_".4" D PI^BGP2PDL1
D I1AGE
Q
I1AGE ;EP
Q:BGPRTYPE'=4
I BGPINDW="W",BGPRTYPE=4 G FEM
S BGPHD1="TOTAL ACTIVE CLINICAL POPULATION",BGPHD2="Total Active Clinical"
;S X=^BGPINDW(BGPIC,53,1,0) D S(X,2,1) S X=" " D S(X,1,1) D H3 S X=" " D S(X,1,1)
S X=" " D S(X,2,1) D H3 S X=" " D S(X,1,1)
K BGPDAC,BGPDAP,BGPDAB S (C,D)=0 F BGPX="BD","BG","BJ","BM","BP","BS" D I1AGE1,I1AGE2
D I1AGEP
S BGPHD1="MALE ACTIVE CLINICAL POPULATION",BGPHD2="MALE Active Clinical"
;S X=^BGPINDW(BGPIC,53,1,0) D S(X,1,1) D H3
S X=" " D S(X,1,1) D S(" ",1,1) S X=BGPHD1 D S(X,1,1) D H3
K BGPDAC,BGPDAP,BGPDAB S (D,C)=0 F BGPX="BE","BH","BK","BN","BQ","BT" D I1AGE1,I1AGE2
D I1AGEP
FEM ;
S BGPHD1="FEMALE ACTIVE CLINICAL POPULATION",BGPHD2="FEMALE Active Clinical"
;S X=^BGPINDW(BGPIC,53,1,0) D S(X,1,1) D H3
S X=" " D S(X,1,1) D S(" ",1,1) S X=BGPHD1 D S(X,1,1) D H3
K BGPDAC,BGPDAP,BGPDAB S (C,D)=0 F BGPX="BF","BI","BL","BO","BR","BU" D I1AGE1,I1AGE2
D I1AGEP
Q
I1AGE1 ;
S C=C+1
S BGPF="032."_BGPX_".1" S BGPPC=$O(^BGPINDWC("C",BGPF,0))
S BGPDF=$P(^BGPINDWC(BGPPC,0),U,8)
S BGPNP=$P(^DD(90548.03,BGPDF,0),U,4),N=$P(BGPNP,";"),P=$P(BGPNP,";",2)
S $P(BGPDAC(C),U)=$$V^BGP2DP1C(1,BGPRPT,N,P)
S $P(BGPDAP(C),U)=$$V^BGP2DP1C(2,BGPRPT,N,P)
S $P(BGPDAB(C),U)=$$V^BGP2DP1C(3,BGPRPT,N,P)
;set 2nd piece to numerator and 3rd to %
S BGPNF=$P(^BGPINDWC(BGPPC,0),U,9)
S BGPNP=$P(^DD(90548.03,BGPNF,0),U,4),N=$P(BGPNP,";"),P=$P(BGPNP,";",2)
S $P(BGPDAC(C),U,2)=$$V^BGP2DP1C(1,BGPRPT,N,P),$P(BGPDAC(C),U,3)=$S($P(BGPDAC(C),U,1):($P(BGPDAC(C),U,2)/$P(BGPDAC(C),U)*100),1:"")
S $P(BGPDAP(C),U,2)=$$V^BGP2DP1C(2,BGPRPT,N,P),$P(BGPDAP(C),U,3)=$S($P(BGPDAP(C),U,1):($P(BGPDAP(C),U,2)/$P(BGPDAP(C),U)*100),1:"")
S $P(BGPDAB(C),U,2)=$$V^BGP2DP1C(3,BGPRPT,N,P),$P(BGPDAB(C),U,3)=$S($P(BGPDAB(C),U,1):($P(BGPDAB(C),U,2)/$P(BGPDAB(C),U)*100),1:"")
Q
I1AGE2 ;
S D=D+1
S BGPF="032."_BGPX_".2" S BGPPC=$O(^BGPINDWC("C",BGPF,0))
;set 4th piece to numerator and 5th to %
S BGPNF=$P(^BGPINDWC(BGPPC,0),U,9)
S BGPNP=$P(^DD(90548.03,BGPNF,0),U,4),N=$P(BGPNP,";"),P=$P(BGPNP,";",2)
S $P(BGPDAC(D),U,4)=$$V^BGP2DP1C(1,BGPRPT,N,P),$P(BGPDAC(D),U,5)=$S($P(BGPDAC(D),U,2):($P(BGPDAC(D),U,4)/$P(BGPDAC(D),U,2)*100),1:"")
S $P(BGPDAP(D),U,4)=$$V^BGP2DP1C(2,BGPRPT,N,P),$P(BGPDAP(D),U,5)=$S($P(BGPDAP(D),U,2):($P(BGPDAP(D),U,4)/$P(BGPDAP(D),U,2)*100),1:"")
S $P(BGPDAB(D),U,4)=$$V^BGP2DP1C(3,BGPRPT,N,P),$P(BGPDAB(D),U,5)=$S($P(BGPDAB(D),U,2):($P(BGPDAB(D),U,4)/$P(BGPDAB(D),U,2)*100),1:"")
I1AGE3 ;
S BGPF="032."_BGPX_".3" S BGPPC=$O(^BGPINDWC("C",BGPF,0))
;set 6th piece to numerator and 7th to %
S BGPNF=$P(^BGPINDWC(BGPPC,0),U,9)
S BGPNP=$P(^DD(90548.03,BGPNF,0),U,4),N=$P(BGPNP,";"),P=$P(BGPNP,";",2)
S $P(BGPDAC(D),U,6)=$$V^BGP2DP1C(1,BGPRPT,N,P),$P(BGPDAC(D),U,7)=$S($P(BGPDAC(D),U,4):($P(BGPDAC(D),U,6)/$P(BGPDAC(D),U,4)*100),1:"")
S $P(BGPDAP(D),U,6)=$$V^BGP2DP1C(2,BGPRPT,N,P),$P(BGPDAP(D),U,7)=$S($P(BGPDAP(D),U,4):($P(BGPDAP(D),U,6)/$P(BGPDAP(D),U,4)*100),1:"")
S $P(BGPDAB(D),U,6)=$$V^BGP2DP1C(3,BGPRPT,N,P),$P(BGPDAB(D),U,7)=$S($P(BGPDAB(D),U,4):($P(BGPDAB(D),U,6)/$P(BGPDAB(D),U,4)*100),1:"")
I1AGE4 ;
S BGPF="032."_BGPX_".4" S BGPPC=$O(^BGPINDWC("C",BGPF,0))
;set 8th piece to numerator and 9th to %
S BGPNF=$P(^BGPINDWC(BGPPC,0),U,9)
S BGPNP=$P(^DD(90548.03,BGPNF,0),U,4),N=$P(BGPNP,";"),P=$P(BGPNP,";",2)
S $P(BGPDAC(D),U,8)=$$V^BGP2DP1C(1,BGPRPT,N,P),$P(BGPDAC(D),U,9)=$S($P(BGPDAC(D),U,4):($P(BGPDAC(D),U,8)/$P(BGPDAC(D),U,4)*100),1:"")
S $P(BGPDAP(D),U,8)=$$V^BGP2DP1C(2,BGPRPT,N,P),$P(BGPDAP(D),U,9)=$S($P(BGPDAP(D),U,4):($P(BGPDAP(D),U,8)/$P(BGPDAP(D),U,4)*100),1:"")
S $P(BGPDAB(D),U,8)=$$V^BGP2DP1C(3,BGPRPT,N,P),$P(BGPDAB(D),U,9)=$S($P(BGPDAB(D),U,4):($P(BGPDAB(D),U,8)/$P(BGPDAB(D),U,4)*100),1:"")
I1AGE5 ;
G I1AGE6
S BGPF="032."_BGPX_".5" S BGPPC=$O(^BGPINDWC("C",BGPF,0))
;set 10th piece to numerator and 11th to %
S BGPNF=$P(^BGPINDWC(BGPPC,0),U,9)
S BGPNP=$P(^DD(90548.03,BGPNF,0),U,4),N=$P(BGPNP,";"),P=$P(BGPNP,";",2)
S $P(BGPDAC(D),U,10)=$$V^BGP2DP1C(1,BGPRPT,N,P),$P(BGPDAC(D),U,11)=$S($P(BGPDAC(D),U,4):($P(BGPDAC(D),U,10)/$P(BGPDAC(D),U,4)*100),1:"")
S $P(BGPDAP(D),U,10)=$$V^BGP2DP1C(2,BGPRPT,N,P),$P(BGPDAP(D),U,11)=$S($P(BGPDAP(D),U,4):($P(BGPDAP(D),U,10)/$P(BGPDAP(D),U,4)*100),1:"")
S $P(BGPDAB(D),U,10)=$$V^BGP2DP1C(3,BGPRPT,N,P),$P(BGPDAB(D),U,11)=$S($P(BGPDAB(D),U,4):($P(BGPDAB(D),U,10)/$P(BGPDAB(D),U,4)*100),1:"")
I1AGE6 ;
S BGPF="032."_BGPX_".6" S BGPPC=$O(^BGPINDWC("C",BGPF,0))
;set 12th piece to numerator and 13th to %
S BGPNF=$P(^BGPINDWC(BGPPC,0),U,9)
S BGPNP=$P(^DD(90548.03,BGPNF,0),U,4),N=$P(BGPNP,";"),P=$P(BGPNP,";",2)
S $P(BGPDAC(D),U,12)=$$V^BGP2DP1C(1,BGPRPT,N,P),$P(BGPDAC(D),U,13)=$S($P(BGPDAC(D),U,2):($P(BGPDAC(D),U,12)/$P(BGPDAC(D),U,2)*100),1:"")
S $P(BGPDAP(D),U,12)=$$V^BGP2DP1C(2,BGPRPT,N,P),$P(BGPDAP(D),U,13)=$S($P(BGPDAP(D),U,2):($P(BGPDAP(D),U,12)/$P(BGPDAP(D),U,2)*100),1:"")
S $P(BGPDAB(D),U,12)=$$V^BGP2DP1C(3,BGPRPT,N,P),$P(BGPDAB(D),U,13)=$S($P(BGPDAB(D),U,2):($P(BGPDAB(D),U,12)/$P(BGPDAB(D),U,2)*100),1:"")
Q
I1AGEP ;
D I1AGEP^BGP2PDL8
Q
SETN ;set numerator fields
S BGPCYN=$$V^BGP2DP1C(1,BGPRPT,N,P)
S BGPPRN=$$V^BGP2DP1C(2,BGPRPT,N,P)
S BGPBLN=$$V^BGP2DP1C(3,BGPRPT,N,P)
S BGPCYP=$S(BGPCYD:((BGPCYN/BGPCYD)*100),1:"")
S BGPPRP=$S(BGPPRD:((BGPPRN/BGPPRD)*100),1:"")
S BGPBLP=$S(BGPBLD:((BGPBLN/BGPBLD)*100),1:"")
Q
V(T,R,N,P) ;EP
I $G(BGPAREAA) G VA
NEW X
I T=1 S X=$P($G(^BGPGPDCW(R,N)),U,P) Q $S(X]"":X,1:0)
I T=2 S X=$P($G(^BGPGPDPW(R,N)),U,P) Q $S(X]"":X,1:0)
I T=3 S X=$P($G(^BGPGPDBW(R,N)),U,P) Q $S(X]"":X,1:0)
Q ""
VA ;
NEW X,V,C S X=0,C="" F S X=$O(BGPSUL(X)) Q:X'=+X D
.I T=1 S C=C+$P($G(^BGPGPDCW(X,N)),U,P)
.I T=2 S C=C+$P($G(^BGPGPDPW(X,N)),U,P)
.I T=3 S C=C+$P($G(^BGPGPDBW(X,N)),U,P)
.Q
Q $S(C:C,1:0)
C(X,X2,X3) ;
D COMMA^%DTC
Q X
S(Y,F,P) ;set up array
I '$G(F) S F=0
S %=$P(^TMP($J,"BGPDEL",0),U)+F,$P(^TMP($J,"BGPDEL",0),U)=%
I '$D(^TMP($J,"BGPDEL",%)) S ^TMP($J,"BGPDEL",%)=""
S $P(^TMP($J,"BGPDEL",%),U,P)=Y
Q
CALC(N,O) ;
NEW Z
;I O=0!(N=0)!(O="")!(N="") Q "**"
;NEW X,X2,X3
;S X=N,X2=1,X3=0 D COMMA^%DTC S N=X
;S X=O,X2=1,X3=0 D COMMA^%DTC S O=X
;I +O=0 Q "**"
;S Z=(((N-O)/O)*100),Z=$FN(Z,"+,",1)
S Z=N-O,Z=$FN(Z,"+,",1)
Q Z
H3 ;EP
;S X="Age specific Tobacco Use" D S(X,1,1) S Y=" " D S(Y,1,1) S X=BGPHD1 D S(X,1,1) S Y=" " D S(Y,1,1)
S X="Age Distribution" D S(X,3,1) S X=" " D S(X,1,1)
S Y=" 5-13" D S(Y,1,2)
S Y="14-17" D S(Y,,3)
S Y="18-24" D S(Y,,4)
S Y="25-44" D S(Y,,5)
S Y="45-64" D S(Y,,6)
S Y="65 AND OLDER" D S(Y,,7)
Q
SB(X) ;EP - Strip leading and trailing blanks from X.
X ^DD("FUNC",$O(^DD("FUNC","B","STRIPBLANKS",0)),1)
Q X
H2 ;
S BGPX="",BGPX=BGPCYN,$P(BGPX,U,2)=$$SB($J(BGPCYP,5,1)),$P(BGPX,U,3)=BGPPRN,$P(BGPX,U,4)=$$SB($J(BGPPRP,5,1)),$P(BGPX,U,5)=$$SB($J($$CALC(BGPCYP,BGPPRP),6)),$P(BGPX,U,6)=BGPBLN,$P(BGPX,U,7)=$$SB($J(BGPBLP,5,1))
S $P(BGPX,U,8)=$$SB($J($$CALC(BGPCYP,BGPBLP),6))
D S(BGPX,,2)
Q
H1 ;EP
S Y="REPORT" D S(Y,1,2)
S Y="%" D S(Y,,3)
S Y="PREV YR" D S(Y,,4)
S Y="%" D S(Y,,5)
S Y="CHG from" D S(Y,,6)
S Y="BASE" D S(Y,,7)
S Y="%" D S(Y,,8)
S Y="CHG from" D S(Y,,9)
S Y="PERIOD" D S(Y,1,2)
S Y="PERIOD" D S(Y,,4)
S Y="PREV YR %" D S(Y,,6)
S Y="PERIOD" D S(Y,,7)
S Y="BASE %" D S(Y,,9)
Q
BGP2PDL7 ; IHS/CMI/LAB - print ind 1 ;
+1 ;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
+2 ;
+3 ;
I023 ;EP
+1 SET BGPORXX=$PIECE(^BGPINDW(BGPIC,12),U,6)
+2 IF '$GET(BGPSUMON)
DO H1^BGP2PDL1
+3 IF BGPRTYPE=4
IF BGPINDW="C"
Begin DoDot:1
+4 SET BGPDENP=0
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.1E",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.2E",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.3E",0))
DO PI1^BGP2PDL1
+5 SET BGPDENP=0
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.1E",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.2E",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.3E",0))
DO PI1^BGP2PDL1
+6 SET BGPDENP=0
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.1E",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.2E",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.3E",0))
DO PI1^BGP2PDL1
+7 SET BGPDENP=0
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.1F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.2F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.3F",0))
DO PI1^BGP2PDL1
+8 SET BGPDENP=0
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.1F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.2F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.3F",0))
DO PI1^BGP2PDL1
+9 SET BGPDENP=0
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.1F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.2F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.3F",0))
DO PI1^BGP2PDL1
End DoDot:1
QUIT
+10 IF BGPRTYPE=4
IF BGPINDW="E"
Begin DoDot:1
+11 SET BGPDENP=0
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.1F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.2F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.3F",0))
DO PI1^BGP2PDL1
+12 SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.4F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".8.5F",0))
DO PI1^BGP2PDL1
+13 SET BGPDENP=0
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.1F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.2F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.3F",0))
DO PI1^BGP2PDL1
+14 SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.4F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".9.5F",0))
DO PI1^BGP2PDL1
+15 SET BGPDENP=0
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.1F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.2F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.3F",0))
DO PI1^BGP2PDL1
+16 SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.4F",0))
DO PI1^BGP2PDL1
SET BGPPC=$ORDER(^BGPINDWC("OR",BGPORXX_".10.5F",0))
DO PI1^BGP2PDL1
End DoDot:1
QUIT
+17 FOR BGPPC1=BGPORXX_".1",BGPORXX_".2",BGPORXX_".3",BGPORXX_".4"
DO PI^BGP2PDL1
+18 FOR BGPPC1=BGPORXX_".5",BGPORXX_".6",BGPORXX_".7"
DO PI^BGP2PDL1
+19 ;F BGPPC1=BGPORXX_".4" D PI^BGP2PDL1
+20 DO I1AGE
+21 QUIT
I1AGE ;EP
+1 IF BGPRTYPE'=4
QUIT
+2 IF BGPINDW="W"
IF BGPRTYPE=4
GOTO FEM
+3 SET BGPHD1="TOTAL ACTIVE CLINICAL POPULATION"
SET BGPHD2="Total Active Clinical"
+4 ;S X=^BGPINDW(BGPIC,53,1,0) D S(X,2,1) S X=" " D S(X,1,1) D H3 S X=" " D S(X,1,1)
+5 SET X=" "
DO S(X,2,1)
DO H3
SET X=" "
DO S(X,1,1)
+6 KILL BGPDAC,BGPDAP,BGPDAB
SET (C,D)=0
FOR BGPX="BD","BG","BJ","BM","BP","BS"
DO I1AGE1
DO I1AGE2
+7 DO I1AGEP
+8 SET BGPHD1="MALE ACTIVE CLINICAL POPULATION"
SET BGPHD2="MALE Active Clinical"
+9 ;S X=^BGPINDW(BGPIC,53,1,0) D S(X,1,1) D H3
+10 SET X=" "
DO S(X,1,1)
DO S(" ",1,1)
SET X=BGPHD1
DO S(X,1,1)
DO H3
+11 KILL BGPDAC,BGPDAP,BGPDAB
SET (D,C)=0
FOR BGPX="BE","BH","BK","BN","BQ","BT"
DO I1AGE1
DO I1AGE2
+12 DO I1AGEP
FEM ;
+1 SET BGPHD1="FEMALE ACTIVE CLINICAL POPULATION"
SET BGPHD2="FEMALE Active Clinical"
+2 ;S X=^BGPINDW(BGPIC,53,1,0) D S(X,1,1) D H3
+3 SET X=" "
DO S(X,1,1)
DO S(" ",1,1)
SET X=BGPHD1
DO S(X,1,1)
DO H3
+4 KILL BGPDAC,BGPDAP,BGPDAB
SET (C,D)=0
FOR BGPX="BF","BI","BL","BO","BR","BU"
DO I1AGE1
DO I1AGE2
+5 DO I1AGEP
+6 QUIT
I1AGE1 ;
+1 SET C=C+1
+2 SET BGPF="032."_BGPX_".1"
SET BGPPC=$ORDER(^BGPINDWC("C",BGPF,0))
+3 SET BGPDF=$PIECE(^BGPINDWC(BGPPC,0),U,8)
+4 SET BGPNP=$PIECE(^DD(90548.03,BGPDF,0),U,4)
SET N=$PIECE(BGPNP,";")
SET P=$PIECE(BGPNP,";",2)
+5 SET $PIECE(BGPDAC(C),U)=$$V^BGP2DP1C(1,BGPRPT,N,P)
+6 SET $PIECE(BGPDAP(C),U)=$$V^BGP2DP1C(2,BGPRPT,N,P)
+7 SET $PIECE(BGPDAB(C),U)=$$V^BGP2DP1C(3,BGPRPT,N,P)
+8 ;set 2nd piece to numerator and 3rd to %
+9 SET BGPNF=$PIECE(^BGPINDWC(BGPPC,0),U,9)
+10 SET BGPNP=$PIECE(^DD(90548.03,BGPNF,0),U,4)
SET N=$PIECE(BGPNP,";")
SET P=$PIECE(BGPNP,";",2)
+11 SET $PIECE(BGPDAC(C),U,2)=$$V^BGP2DP1C(1,BGPRPT,N,P)
SET $PIECE(BGPDAC(C),U,3)=$SELECT($PIECE(BGPDAC(C),U,1):($PIECE(BGPDAC(C),U,2)/$PIECE(BGPDAC(C),U)*100),1:"")
+12 SET $PIECE(BGPDAP(C),U,2)=$$V^BGP2DP1C(2,BGPRPT,N,P)
SET $PIECE(BGPDAP(C),U,3)=$SELECT($PIECE(BGPDAP(C),U,1):($PIECE(BGPDAP(C),U,2)/$PIECE(BGPDAP(C),U)*100),1:"")
+13 SET $PIECE(BGPDAB(C),U,2)=$$V^BGP2DP1C(3,BGPRPT,N,P)
SET $PIECE(BGPDAB(C),U,3)=$SELECT($PIECE(BGPDAB(C),U,1):($PIECE(BGPDAB(C),U,2)/$PIECE(BGPDAB(C),U)*100),1:"")
+14 QUIT
I1AGE2 ;
+1 SET D=D+1
+2 SET BGPF="032."_BGPX_".2"
SET BGPPC=$ORDER(^BGPINDWC("C",BGPF,0))
+3 ;set 4th piece to numerator and 5th to %
+4 SET BGPNF=$PIECE(^BGPINDWC(BGPPC,0),U,9)
+5 SET BGPNP=$PIECE(^DD(90548.03,BGPNF,0),U,4)
SET N=$PIECE(BGPNP,";")
SET P=$PIECE(BGPNP,";",2)
+6 SET $PIECE(BGPDAC(D),U,4)=$$V^BGP2DP1C(1,BGPRPT,N,P)
SET $PIECE(BGPDAC(D),U,5)=$SELECT($PIECE(BGPDAC(D),U,2):($PIECE(BGPDAC(D),U,4)/$PIECE(BGPDAC(D),U,2)*100),1:"")
+7 SET $PIECE(BGPDAP(D),U,4)=$$V^BGP2DP1C(2,BGPRPT,N,P)
SET $PIECE(BGPDAP(D),U,5)=$SELECT($PIECE(BGPDAP(D),U,2):($PIECE(BGPDAP(D),U,4)/$PIECE(BGPDAP(D),U,2)*100),1:"")
+8 SET $PIECE(BGPDAB(D),U,4)=$$V^BGP2DP1C(3,BGPRPT,N,P)
SET $PIECE(BGPDAB(D),U,5)=$SELECT($PIECE(BGPDAB(D),U,2):($PIECE(BGPDAB(D),U,4)/$PIECE(BGPDAB(D),U,2)*100),1:"")
I1AGE3 ;
+1 SET BGPF="032."_BGPX_".3"
SET BGPPC=$ORDER(^BGPINDWC("C",BGPF,0))
+2 ;set 6th piece to numerator and 7th to %
+3 SET BGPNF=$PIECE(^BGPINDWC(BGPPC,0),U,9)
+4 SET BGPNP=$PIECE(^DD(90548.03,BGPNF,0),U,4)
SET N=$PIECE(BGPNP,";")
SET P=$PIECE(BGPNP,";",2)
+5 SET $PIECE(BGPDAC(D),U,6)=$$V^BGP2DP1C(1,BGPRPT,N,P)
SET $PIECE(BGPDAC(D),U,7)=$SELECT($PIECE(BGPDAC(D),U,4):($PIECE(BGPDAC(D),U,6)/$PIECE(BGPDAC(D),U,4)*100),1:"")
+6 SET $PIECE(BGPDAP(D),U,6)=$$V^BGP2DP1C(2,BGPRPT,N,P)
SET $PIECE(BGPDAP(D),U,7)=$SELECT($PIECE(BGPDAP(D),U,4):($PIECE(BGPDAP(D),U,6)/$PIECE(BGPDAP(D),U,4)*100),1:"")
+7 SET $PIECE(BGPDAB(D),U,6)=$$V^BGP2DP1C(3,BGPRPT,N,P)
SET $PIECE(BGPDAB(D),U,7)=$SELECT($PIECE(BGPDAB(D),U,4):($PIECE(BGPDAB(D),U,6)/$PIECE(BGPDAB(D),U,4)*100),1:"")
I1AGE4 ;
+1 SET BGPF="032."_BGPX_".4"
SET BGPPC=$ORDER(^BGPINDWC("C",BGPF,0))
+2 ;set 8th piece to numerator and 9th to %
+3 SET BGPNF=$PIECE(^BGPINDWC(BGPPC,0),U,9)
+4 SET BGPNP=$PIECE(^DD(90548.03,BGPNF,0),U,4)
SET N=$PIECE(BGPNP,";")
SET P=$PIECE(BGPNP,";",2)
+5 SET $PIECE(BGPDAC(D),U,8)=$$V^BGP2DP1C(1,BGPRPT,N,P)
SET $PIECE(BGPDAC(D),U,9)=$SELECT($PIECE(BGPDAC(D),U,4):($PIECE(BGPDAC(D),U,8)/$PIECE(BGPDAC(D),U,4)*100),1:"")
+6 SET $PIECE(BGPDAP(D),U,8)=$$V^BGP2DP1C(2,BGPRPT,N,P)
SET $PIECE(BGPDAP(D),U,9)=$SELECT($PIECE(BGPDAP(D),U,4):($PIECE(BGPDAP(D),U,8)/$PIECE(BGPDAP(D),U,4)*100),1:"")
+7 SET $PIECE(BGPDAB(D),U,8)=$$V^BGP2DP1C(3,BGPRPT,N,P)
SET $PIECE(BGPDAB(D),U,9)=$SELECT($PIECE(BGPDAB(D),U,4):($PIECE(BGPDAB(D),U,8)/$PIECE(BGPDAB(D),U,4)*100),1:"")
I1AGE5 ;
+1 GOTO I1AGE6
+2 SET BGPF="032."_BGPX_".5"
SET BGPPC=$ORDER(^BGPINDWC("C",BGPF,0))
+3 ;set 10th piece to numerator and 11th to %
+4 SET BGPNF=$PIECE(^BGPINDWC(BGPPC,0),U,9)
+5 SET BGPNP=$PIECE(^DD(90548.03,BGPNF,0),U,4)
SET N=$PIECE(BGPNP,";")
SET P=$PIECE(BGPNP,";",2)
+6 SET $PIECE(BGPDAC(D),U,10)=$$V^BGP2DP1C(1,BGPRPT,N,P)
SET $PIECE(BGPDAC(D),U,11)=$SELECT($PIECE(BGPDAC(D),U,4):($PIECE(BGPDAC(D),U,10)/$PIECE(BGPDAC(D),U,4)*100),1:"")
+7 SET $PIECE(BGPDAP(D),U,10)=$$V^BGP2DP1C(2,BGPRPT,N,P)
SET $PIECE(BGPDAP(D),U,11)=$SELECT($PIECE(BGPDAP(D),U,4):($PIECE(BGPDAP(D),U,10)/$PIECE(BGPDAP(D),U,4)*100),1:"")
+8 SET $PIECE(BGPDAB(D),U,10)=$$V^BGP2DP1C(3,BGPRPT,N,P)
SET $PIECE(BGPDAB(D),U,11)=$SELECT($PIECE(BGPDAB(D),U,4):($PIECE(BGPDAB(D),U,10)/$PIECE(BGPDAB(D),U,4)*100),1:"")
I1AGE6 ;
+1 SET BGPF="032."_BGPX_".6"
SET BGPPC=$ORDER(^BGPINDWC("C",BGPF,0))
+2 ;set 12th piece to numerator and 13th to %
+3 SET BGPNF=$PIECE(^BGPINDWC(BGPPC,0),U,9)
+4 SET BGPNP=$PIECE(^DD(90548.03,BGPNF,0),U,4)
SET N=$PIECE(BGPNP,";")
SET P=$PIECE(BGPNP,";",2)
+5 SET $PIECE(BGPDAC(D),U,12)=$$V^BGP2DP1C(1,BGPRPT,N,P)
SET $PIECE(BGPDAC(D),U,13)=$SELECT($PIECE(BGPDAC(D),U,2):($PIECE(BGPDAC(D),U,12)/$PIECE(BGPDAC(D),U,2)*100),1:"")
+6 SET $PIECE(BGPDAP(D),U,12)=$$V^BGP2DP1C(2,BGPRPT,N,P)
SET $PIECE(BGPDAP(D),U,13)=$SELECT($PIECE(BGPDAP(D),U,2):($PIECE(BGPDAP(D),U,12)/$PIECE(BGPDAP(D),U,2)*100),1:"")
+7 SET $PIECE(BGPDAB(D),U,12)=$$V^BGP2DP1C(3,BGPRPT,N,P)
SET $PIECE(BGPDAB(D),U,13)=$SELECT($PIECE(BGPDAB(D),U,2):($PIECE(BGPDAB(D),U,12)/$PIECE(BGPDAB(D),U,2)*100),1:"")
+8 QUIT
I1AGEP ;
+1 DO I1AGEP^BGP2PDL8
+2 QUIT
SETN ;set numerator fields
+1 SET BGPCYN=$$V^BGP2DP1C(1,BGPRPT,N,P)
+2 SET BGPPRN=$$V^BGP2DP1C(2,BGPRPT,N,P)
+3 SET BGPBLN=$$V^BGP2DP1C(3,BGPRPT,N,P)
+4 SET BGPCYP=$SELECT(BGPCYD:((BGPCYN/BGPCYD)*100),1:"")
+5 SET BGPPRP=$SELECT(BGPPRD:((BGPPRN/BGPPRD)*100),1:"")
+6 SET BGPBLP=$SELECT(BGPBLD:((BGPBLN/BGPBLD)*100),1:"")
+7 QUIT
V(T,R,N,P) ;EP
+1 IF $GET(BGPAREAA)
GOTO VA
+2 NEW X
+3 IF T=1
SET X=$PIECE($GET(^BGPGPDCW(R,N)),U,P)
QUIT $SELECT(X]"":X,1:0)
+4 IF T=2
SET X=$PIECE($GET(^BGPGPDPW(R,N)),U,P)
QUIT $SELECT(X]"":X,1:0)
+5 IF T=3
SET X=$PIECE($GET(^BGPGPDBW(R,N)),U,P)
QUIT $SELECT(X]"":X,1:0)
+6 QUIT ""
VA ;
+1 NEW X,V,C
SET X=0
SET C=""
FOR
SET X=$ORDER(BGPSUL(X))
IF X'=+X
QUIT
Begin DoDot:1
+2 IF T=1
SET C=C+$PIECE($GET(^BGPGPDCW(X,N)),U,P)
+3 IF T=2
SET C=C+$PIECE($GET(^BGPGPDPW(X,N)),U,P)
+4 IF T=3
SET C=C+$PIECE($GET(^BGPGPDBW(X,N)),U,P)
+5 QUIT
End DoDot:1
+6 QUIT $SELECT(C:C,1:0)
C(X,X2,X3) ;
+1 DO COMMA^%DTC
+2 QUIT X
S(Y,F,P) ;set up array
+1 IF '$GET(F)
SET F=0
+2 SET %=$PIECE(^TMP($JOB,"BGPDEL",0),U)+F
SET $PIECE(^TMP($JOB,"BGPDEL",0),U)=%
+3 IF '$DATA(^TMP($JOB,"BGPDEL",%))
SET ^TMP($JOB,"BGPDEL",%)=""
+4 SET $PIECE(^TMP($JOB,"BGPDEL",%),U,P)=Y
+5 QUIT
CALC(N,O) ;
+1 NEW Z
+2 ;I O=0!(N=0)!(O="")!(N="") Q "**"
+3 ;NEW X,X2,X3
+4 ;S X=N,X2=1,X3=0 D COMMA^%DTC S N=X
+5 ;S X=O,X2=1,X3=0 D COMMA^%DTC S O=X
+6 ;I +O=0 Q "**"
+7 ;S Z=(((N-O)/O)*100),Z=$FN(Z,"+,",1)
+8 SET Z=N-O
SET Z=$FNUMBER(Z,"+,",1)
+9 QUIT Z
H3 ;EP
+1 ;S X="Age specific Tobacco Use" D S(X,1,1) S Y=" " D S(Y,1,1) S X=BGPHD1 D S(X,1,1) S Y=" " D S(Y,1,1)
+2 SET X="Age Distribution"
DO S(X,3,1)
SET X=" "
DO S(X,1,1)
+3 SET Y=" 5-13"
DO S(Y,1,2)
+4 SET Y="14-17"
DO S(Y,,3)
+5 SET Y="18-24"
DO S(Y,,4)
+6 SET Y="25-44"
DO S(Y,,5)
+7 SET Y="45-64"
DO S(Y,,6)
+8 SET Y="65 AND OLDER"
DO S(Y,,7)
+9 QUIT
SB(X) ;EP - Strip leading and trailing blanks from X.
+1 XECUTE ^DD("FUNC",$ORDER(^DD("FUNC","B","STRIPBLANKS",0)),1)
+2 QUIT X
H2 ;
+1 SET BGPX=""
SET BGPX=BGPCYN
SET $PIECE(BGPX,U,2)=$$SB($JUSTIFY(BGPCYP,5,1))
SET $PIECE(BGPX,U,3)=BGPPRN
SET $PIECE(BGPX,U,4)=$$SB($JUSTIFY(BGPPRP,5,1))
SET $PIECE(BGPX,U,5)=$$SB($JUSTIFY($$CALC(BGPCYP,BGPPRP),6))
SET $PIECE(BGPX,U,6)=BGPBLN
SET $PIECE(BGPX,U,7)=$$SB($JUSTIFY(BGPBLP,5,1))
+2 SET $PIECE(BGPX,U,8)=$$SB($JUSTIFY($$CALC(BGPCYP,BGPBLP),6))
+3 DO S(BGPX,,2)
+4 QUIT
H1 ;EP
+1 SET Y="REPORT"
DO S(Y,1,2)
+2 SET Y="%"
DO S(Y,,3)
+3 SET Y="PREV YR"
DO S(Y,,4)
+4 SET Y="%"
DO S(Y,,5)
+5 SET Y="CHG from"
DO S(Y,,6)
+6 SET Y="BASE"
DO S(Y,,7)
+7 SET Y="%"
DO S(Y,,8)
+8 SET Y="CHG from"
DO S(Y,,9)
+9 SET Y="PERIOD"
DO S(Y,1,2)
+10 SET Y="PERIOD"
DO S(Y,,4)
+11 SET Y="PREV YR %"
DO S(Y,,6)
+12 SET Y="PERIOD"
DO S(Y,,7)
+13 SET Y="BASE %"
DO S(Y,,9)
+14 QUIT