BGP7NPLD ; IHS/CMI/LAB - IHS gpra print 30 Jun 2010 5:59 PM ;
;;17.1;IHS CLINICAL REPORTING;;MAY 10, 2017;Build 29
;
NPL ;
Q:$G(BGPAREAA)
;S X=" " D S(X,1,1) D S(X,1,1) D S(X,1,1) S X="PATIENT LISTS" D S(X,1,1) S X=" " D S(X,1,1)
S BGPINDG=0 F S BGPINDG=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG)) Q:BGPINDG'=+BGPINDG D NPL1
Q
NPL1 ;EP
Q:$G(BGPAREAA)
S BGPO=0 F S BGPO=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO)) Q:BGPO'=+BGPO D NPL11
Q
NPL11 ;
S BGPL=0 F S BGPL=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL)) Q:BGPL'=+BGPL D
.S BGPCOUNT=0,BGPPCNT=0
.D HEADER
.S BGPCNT=BGPINDL(BGPINDG,BGPL)
.I BGPCNT<11!(BGPLIST'="R") S BGPCNT=1 G GO
.I BGPCNT<100 S BGPCNT=BGPCNT\10 G GO
.S BGPCNT=10
GO .;
.S X=$P(^BGPINDG(BGPINDG,0),U,3) D S(X,1,1)
.;S X=" " D S(X,1,1)
.G NEXT
.S X="Denominator(s):" D S(X,1,1)
.S BGPNODE=$S(BGPRTYPE=1:81,BGPRTYPE=4:61,BGPRTYPE=7:83,BGPRTYPE=9:85,1:61)
.S BGPX=0 F S BGPX=$O(^BGPINDG(BGPINDG,BGPNODE,"B",BGPX)) Q:BGPX'=+BGPX D
..S BGPY=0 F S BGPY=$O(^BGPINDG(BGPINDG,BGPNODE,"B",BGPX,BGPY)) Q:BGPY'=+BGPY D
...;I $P(^BGPINDG(BGPINDG,61,BGPY,0),U,2)'[BGPRTYPE Q ;not a denom def for this report
...;I '$D(^BGPINDG(BGPINDG,61,BGPY,11,"B",BGPRTYPE)) Q ;not this report type
...S BGPZ=0 F S BGPZ=$O(^BGPINDG(BGPINDG,BGPNODE,BGPY,1,BGPZ)) Q:BGPZ'=+BGPZ D
....S Y=^BGPINDG(BGPINDG,BGPNODE,BGPY,1,BGPZ,0) D S(Y,1,1)
....Q
...Q
..Q
.S X=" " D S(X,1,1)
.S X="Numerator(s):" D S(X,1,1)
.S BGPNODE=$S(BGPRTYPE=1:82,BGPRTYPE=4:62,BGPRTYPE=7:84,BGPRTYPE=9:86,1:62)
.S BGPX=0 F S BGPX=$O(^BGPINDG(BGPINDG,BGPNODE,"B",BGPX)) Q:BGPX'=+BGPX D
..S BGPY=0 F S BGPY=$O(^BGPINDG(BGPINDG,BGPNODE,"B",BGPX,BGPY)) Q:BGPY'=+BGPY D
...;I $P(^BGPINDG(BGPINDG,62,BGPY,0),U,2)'[BGPRTYPE Q ;not a denom def for this report
...;I '$D(^BGPINDG(BGPINDG,62,BGPY,11,"B",BGPRTYPE)) Q ;not this report type
...S BGPZ=0 F S BGPZ=$O(^BGPINDG(BGPINDG,BGPNODE,BGPY,1,BGPZ)) Q:BGPZ'=+BGPZ D
....S X=^BGPINDG(BGPINDG,BGPNODE,BGPY,1,BGPZ,0) D S(X,1,1)
....Q
...Q
..Q
.S X=" " D S(X,1,1)
.S BGPNODE=11 I BGPRTYPE=1,$O(^BGPINDG(BGPINDG,54,0)) S BGPNODE=54
.S X="Logic" D S(X,1,1)
.S BGPX=0 F S BGPX=$O(^BGPINDG(BGPINDG,BGPNODE,BGPX)) Q:BGPX'=+BGPX D
..S X=^BGPINDG(BGPINDG,BGPNODE,BGPX,0) D S(X,1,1)
.S X=" " D S(X,1,1) S X="Performance Measure Description" D S(X,1,1) S BGPX=0 F S BGPX=$O(^BGPINDG(BGPINDG,51,BGPX)) Q:BGPX'=+BGPX D
..S X=^BGPINDG(BGPINDG,51,BGPX,0) D S(X,1,1)
.I $O(^BGPINDG(BGPINDG,52,0)) S X=" " D S(X,1,1) S X="Past Performance and/or Target" D S(X,1,1) S BGPX=0 F S BGPX=$O(^BGPINDG(BGPINDG,52,BGPX)) Q:BGPX'=+BGPX D
..S X=^BGPINDG(BGPINDG,52,BGPX,0) D S(X,1,1)
.I $O(^BGPINDG(BGPINDG,55,0)) S X=" " D S(X,1,1) S X="Source" D S(X,1,1) S BGPX=0 F S BGPX=$O(^BGPINDG(BGPINDG,55,BGPX)) Q:BGPX'=+BGPX D
..S X=^BGPINDG(BGPINDG,55,BGPX,0) D S(X,1,1)
.S X=" " D S(X,1,1)
NEXT .;
.S BGPX=0 F S BGPX=$O(^BGPNPLG(BGPL,11,BGPX)) Q:BGPX'=+BGPX D
..S X=^BGPNPLG(BGPL,11,BGPX,0) D S(X,1,1)
.D H1
.S BGPCOM="" F S BGPCOM=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM)) Q:BGPCOM="" D
..S BGPSEX="" F S BGPSEX=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX)) Q:BGPSEX="" D
...S BGPAGE="" F S BGPAGE=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX,BGPAGE)) Q:BGPAGE="" D
....S DFN=0 F S DFN=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX,BGPAGE,DFN)) Q:DFN'=+DFN S BGPCOUNT=BGPCOUNT+1 D PRINTL
....Q
...Q
..Q
.S X=" " D S(X,1,1) S X=" " D S(X,1,1)
.S X=" " D S(X,1,1) S X=" " D S(X,1,1)
.S X="Total # of patients on list: "_+$G(BGPPCNT) D S(X,1,1)
Q
PRINTL ;print one line
Q:(BGPCOUNT#BGPCNT)
S BGPPCNT=BGPPCNT+1
S X=$E($P(^DPT(DFN,0),U),1,22) D S(X,1,1) S X=$$HRN^AUPNPAT(DFN,DUZ(2)) D S(X,,2) S X=$E(BGPCOM,1,14) D S(X,,3) S X=BGPSEX D S(X,,4) S X=BGPAGE D S(X,,5)
S X=$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1) D S(X,,6)
S X=$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2) D S(X,,7)
Q
;
S X="**** CONFIDENTIAL PATIENT INFORMATION, COVERED BY THE PRIVACY ACT *****" D S(X,1,1)
I BGPRTYPE=1 S X="*** IHS 2017 GPRA/GPRAMA Patient List ***" D S(X,1,1)
I BGPRTYPE=7 S X="*** IHS 2017 Other National Measures Patient List ***" D S(X,1,1)
S X=$$RPTVER^BGP7BAN D S(X,1,1)
S X=$P(^DIC(4,DUZ(2),0),U) D S(X,1,1)
S X="Report Period: "_$$FMTE^XLFDT(BGPBD)_" to "_$$FMTE^XLFDT(BGPED) D S(X,1,1)
S X=$S(BGPLIST="A":"All Patients",BGPLIST="R":"Random Patient List",1:"Patient List by Provider: "_BGPLPROV) D S(X,1,1)
S X=$TR($J("",80)," ","-") D S(X,1,1)
Q
H1 ;
S X=" " D S(X,1,1) S X="UP=User Pop; AC=Active Clinical; AD=Active Diabetic;" D S(X,1,1) S X="AAD=Active Adult Diabetic; PREG=Pregnant Female;" D S(X,1,1) D
.S X="IMM=Active IMM Pkg Pt; CHD=Active Coronary Heart Disease;"_$S(BGPRTYPE'=7:" HR=High Risk Patient",1:"") D S(X,1,1)
S X=" " D S(X,1,1)
S X="PATIENT NAME" D S(X,1,1) S X="HRN" D S(X,,2) S X="COMMUNITY" D S(X,,3) S X="SEX" D S(X,,4) S X="AGE" D S(X,,5) S X="DENOMINATOR" D S(X,,6) S X="NUMERATOR" D S(X,,7)
S X=$TR($J("",80)," ","-") D S(X,1,1)
Q
S(Y,F,P) ;EP - 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
CTR(X,Y) ;EP - Center X in a field Y wide.
Q $J("",$S($D(Y):Y,1:IOM)-$L(X)\2)_X
;----------
USR() ;EP - Return name of current user from ^VA(200.
Q $S($G(DUZ):$S($D(^VA(200,DUZ,0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
Q $S($G(DUZ(2)):$S($D(^DIC(4,DUZ(2),0)):$P(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
;----------
BGP7NPLD ; IHS/CMI/LAB - IHS gpra print 30 Jun 2010 5:59 PM ;
+1 ;;17.1;IHS CLINICAL REPORTING;;MAY 10, 2017;Build 29
+2 ;
NPL ;
+1 IF $GET(BGPAREAA)
QUIT
+2 ;S X=" " D S(X,1,1) D S(X,1,1) D S(X,1,1) S X="PATIENT LISTS" D S(X,1,1) S X=" " D S(X,1,1)
+3 SET BGPINDG=0
FOR
SET BGPINDG=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG))
IF BGPINDG'=+BGPINDG
QUIT
DO NPL1
+4 QUIT
NPL1 ;EP
+1 IF $GET(BGPAREAA)
QUIT
+2 SET BGPO=0
FOR
SET BGPO=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO))
IF BGPO'=+BGPO
QUIT
DO NPL11
+3 QUIT
NPL11 ;
+1 SET BGPL=0
FOR
SET BGPL=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL))
IF BGPL'=+BGPL
QUIT
Begin DoDot:1
+2 SET BGPCOUNT=0
SET BGPPCNT=0
+3 DO HEADER
+4 SET BGPCNT=BGPINDL(BGPINDG,BGPL)
+5 IF BGPCNT<11!(BGPLIST'="R")
SET BGPCNT=1
GOTO GO
+6 IF BGPCNT<100
SET BGPCNT=BGPCNT\10
GOTO GO
+7 SET BGPCNT=10
GO ;
+1 SET X=$PIECE(^BGPINDG(BGPINDG,0),U,3)
DO S(X,1,1)
+2 ;S X=" " D S(X,1,1)
+3 GOTO NEXT
+4 SET X="Denominator(s):"
DO S(X,1,1)
+5 SET BGPNODE=$SELECT(BGPRTYPE=1:81,BGPRTYPE=4:61,BGPRTYPE=7:83,BGPRTYPE=9:85,1:61)
+6 SET BGPX=0
FOR
SET BGPX=$ORDER(^BGPINDG(BGPINDG,BGPNODE,"B",BGPX))
IF BGPX'=+BGPX
QUIT
Begin DoDot:2
+7 SET BGPY=0
FOR
SET BGPY=$ORDER(^BGPINDG(BGPINDG,BGPNODE,"B",BGPX,BGPY))
IF BGPY'=+BGPY
QUIT
Begin DoDot:3
+8 ;I $P(^BGPINDG(BGPINDG,61,BGPY,0),U,2)'[BGPRTYPE Q ;not a denom def for this report
+9 ;I '$D(^BGPINDG(BGPINDG,61,BGPY,11,"B",BGPRTYPE)) Q ;not this report type
+10 SET BGPZ=0
FOR
SET BGPZ=$ORDER(^BGPINDG(BGPINDG,BGPNODE,BGPY,1,BGPZ))
IF BGPZ'=+BGPZ
QUIT
Begin DoDot:4
+11 SET Y=^BGPINDG(BGPINDG,BGPNODE,BGPY,1,BGPZ,0)
DO S(Y,1,1)
+12 QUIT
End DoDot:4
+13 QUIT
End DoDot:3
+14 QUIT
End DoDot:2
+15 SET X=" "
DO S(X,1,1)
+16 SET X="Numerator(s):"
DO S(X,1,1)
+17 SET BGPNODE=$SELECT(BGPRTYPE=1:82,BGPRTYPE=4:62,BGPRTYPE=7:84,BGPRTYPE=9:86,1:62)
+18 SET BGPX=0
FOR
SET BGPX=$ORDER(^BGPINDG(BGPINDG,BGPNODE,"B",BGPX))
IF BGPX'=+BGPX
QUIT
Begin DoDot:2
+19 SET BGPY=0
FOR
SET BGPY=$ORDER(^BGPINDG(BGPINDG,BGPNODE,"B",BGPX,BGPY))
IF BGPY'=+BGPY
QUIT
Begin DoDot:3
+20 ;I $P(^BGPINDG(BGPINDG,62,BGPY,0),U,2)'[BGPRTYPE Q ;not a denom def for this report
+21 ;I '$D(^BGPINDG(BGPINDG,62,BGPY,11,"B",BGPRTYPE)) Q ;not this report type
+22 SET BGPZ=0
FOR
SET BGPZ=$ORDER(^BGPINDG(BGPINDG,BGPNODE,BGPY,1,BGPZ))
IF BGPZ'=+BGPZ
QUIT
Begin DoDot:4
+23 SET X=^BGPINDG(BGPINDG,BGPNODE,BGPY,1,BGPZ,0)
DO S(X,1,1)
+24 QUIT
End DoDot:4
+25 QUIT
End DoDot:3
+26 QUIT
End DoDot:2
+27 SET X=" "
DO S(X,1,1)
+28 SET BGPNODE=11
IF BGPRTYPE=1
IF $ORDER(^BGPINDG(BGPINDG,54,0))
SET BGPNODE=54
+29 SET X="Logic"
DO S(X,1,1)
+30 SET BGPX=0
FOR
SET BGPX=$ORDER(^BGPINDG(BGPINDG,BGPNODE,BGPX))
IF BGPX'=+BGPX
QUIT
Begin DoDot:2
+31 SET X=^BGPINDG(BGPINDG,BGPNODE,BGPX,0)
DO S(X,1,1)
End DoDot:2
+32 SET X=" "
DO S(X,1,1)
SET X="Performance Measure Description"
DO S(X,1,1)
SET BGPX=0
FOR
SET BGPX=$ORDER(^BGPINDG(BGPINDG,51,BGPX))
IF BGPX'=+BGPX
QUIT
Begin DoDot:2
+33 SET X=^BGPINDG(BGPINDG,51,BGPX,0)
DO S(X,1,1)
End DoDot:2
+34 IF $ORDER(^BGPINDG(BGPINDG,52,0))
SET X=" "
DO S(X,1,1)
SET X="Past Performance and/or Target"
DO S(X,1,1)
SET BGPX=0
FOR
SET BGPX=$ORDER(^BGPINDG(BGPINDG,52,BGPX))
IF BGPX'=+BGPX
QUIT
Begin DoDot:2
+35 SET X=^BGPINDG(BGPINDG,52,BGPX,0)
DO S(X,1,1)
End DoDot:2
+36 IF $ORDER(^BGPINDG(BGPINDG,55,0))
SET X=" "
DO S(X,1,1)
SET X="Source"
DO S(X,1,1)
SET BGPX=0
FOR
SET BGPX=$ORDER(^BGPINDG(BGPINDG,55,BGPX))
IF BGPX'=+BGPX
QUIT
Begin DoDot:2
+37 SET X=^BGPINDG(BGPINDG,55,BGPX,0)
DO S(X,1,1)
End DoDot:2
+38 SET X=" "
DO S(X,1,1)
NEXT ;
+1 SET BGPX=0
FOR
SET BGPX=$ORDER(^BGPNPLG(BGPL,11,BGPX))
IF BGPX'=+BGPX
QUIT
Begin DoDot:2
+2 SET X=^BGPNPLG(BGPL,11,BGPX,0)
DO S(X,1,1)
End DoDot:2
+3 DO H1
+4 SET BGPCOM=""
FOR
SET BGPCOM=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM))
IF BGPCOM=""
QUIT
Begin DoDot:2
+5 SET BGPSEX=""
FOR
SET BGPSEX=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX))
IF BGPSEX=""
QUIT
Begin DoDot:3
+6 SET BGPAGE=""
FOR
SET BGPAGE=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX,BGPAGE))
IF BGPAGE=""
QUIT
Begin DoDot:4
+7 SET DFN=0
FOR
SET DFN=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX,BGPAGE,DFN))
IF DFN'=+DFN
QUIT
SET BGPCOUNT=BGPCOUNT+1
DO PRINTL
+8 QUIT
End DoDot:4
+9 QUIT
End DoDot:3
+10 QUIT
End DoDot:2
+11 SET X=" "
DO S(X,1,1)
SET X=" "
DO S(X,1,1)
+12 SET X=" "
DO S(X,1,1)
SET X=" "
DO S(X,1,1)
+13 SET X="Total # of patients on list: "_+$GET(BGPPCNT)
DO S(X,1,1)
End DoDot:1
+14 QUIT
PRINTL ;print one line
+1 IF (BGPCOUNT#BGPCNT)
QUIT
+2 SET BGPPCNT=BGPPCNT+1
+3 SET X=$EXTRACT($PIECE(^DPT(DFN,0),U),1,22)
DO S(X,1,1)
SET X=$$HRN^AUPNPAT(DFN,DUZ(2))
DO S(X,,2)
SET X=$EXTRACT(BGPCOM,1,14)
DO S(X,,3)
SET X=BGPSEX
DO S(X,,4)
SET X=BGPAGE
DO S(X,,5)
+4 SET X=$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1)
DO S(X,,6)
+5 SET X=$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,BGPO,BGPL,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2)
DO S(X,,7)
+6 QUIT
+7 ;
+1 SET X="**** CONFIDENTIAL PATIENT INFORMATION, COVERED BY THE PRIVACY ACT *****"
DO S(X,1,1)
+2 IF BGPRTYPE=1
SET X="*** IHS 2017 GPRA/GPRAMA Patient List ***"
DO S(X,1,1)
+3 IF BGPRTYPE=7
SET X="*** IHS 2017 Other National Measures Patient List ***"
DO S(X,1,1)
+4 SET X=$$RPTVER^BGP7BAN
DO S(X,1,1)
+5 SET X=$PIECE(^DIC(4,DUZ(2),0),U)
DO S(X,1,1)
+6 SET X="Report Period: "_$$FMTE^XLFDT(BGPBD)_" to "_$$FMTE^XLFDT(BGPED)
DO S(X,1,1)
+7 SET X=$SELECT(BGPLIST="A":"All Patients",BGPLIST="R":"Random Patient List",1:"Patient List by Provider: "_BGPLPROV)
DO S(X,1,1)
+8 SET X=$TRANSLATE($JUSTIFY("",80)," ","-")
DO S(X,1,1)
+9 QUIT
H1 ;
+1 SET X=" "
DO S(X,1,1)
SET X="UP=User Pop; AC=Active Clinical; AD=Active Diabetic;"
DO S(X,1,1)
SET X="AAD=Active Adult Diabetic; PREG=Pregnant Female;"
DO S(X,1,1)
Begin DoDot:1
+2 SET X="IMM=Active IMM Pkg Pt; CHD=Active Coronary Heart Disease;"_$SELECT(BGPRTYPE'=7:" HR=High Risk Patient",1:"")
DO S(X,1,1)
End DoDot:1
+3 SET X=" "
DO S(X,1,1)
+4 SET X="PATIENT NAME"
DO S(X,1,1)
SET X="HRN"
DO S(X,,2)
SET X="COMMUNITY"
DO S(X,,3)
SET X="SEX"
DO S(X,,4)
SET X="AGE"
DO S(X,,5)
SET X="DENOMINATOR"
DO S(X,,6)
SET X="NUMERATOR"
DO S(X,,7)
+5 SET X=$TRANSLATE($JUSTIFY("",80)," ","-")
DO S(X,1,1)
+6 QUIT
S(Y,F,P) ;EP - 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
CTR(X,Y) ;EP - Center X in a field Y wide.
+1 QUIT $JUSTIFY("",$SELECT($DATA(Y):Y,1:IOM)-$LENGTH(X)\2)_X
+2 ;----------
USR() ;EP - Return name of current user from ^VA(200.
+1 QUIT $SELECT($GET(DUZ):$SELECT($DATA(^VA(200,DUZ,0)):$PIECE(^(0),U),1:"UNKNOWN"),1:"DUZ UNDEFINED OR 0")
+2 ;----------
LOC() ;EP - Return location name from file 4 based on DUZ(2).
+1 QUIT $SELECT($GET(DUZ(2)):$SELECT($DATA(^DIC(4,DUZ(2),0)):$PIECE(^(0),U),1:"UNKNOWN"),1:"DUZ(2) UNDEFINED OR 0")
+2 ;----------