BGP7NPLP ; IHS/CMI/LAB - IHS gpra print 30 Jun 2010 5:58 PM ;
;;17.1;IHS CLINICAL REPORTING;;MAY 10, 2017;Build 29
;
NPL ;
Q:$G(BGPAREAA)
S BGPQUIT="",BGPGPG=0
S BGPINDG=0,BGPCOUNT=0
S BGPINDG=0 F S BGPINDG=$O(BGPINDL(BGPINDG)) Q:BGPINDG'=+BGPINDG D
.S BGPORD=$P($G(^BGPINDG(BGPINDG,12)),U,6)
.S BGPLIEN=0 F S BGPLIEN=$O(BGPINDG(BGPINDG,BGPLIEN)) Q:BGPLIEN'=+BGPLIEN D
..S BGPLORD=$S(BGPRTYPE=1:$P(^BGPNPLG(BGPLIEN,0),U,5),1:$P(^BGPNPLG(BGPLIEN,0),U,6))
..S BGPINDG("AOI",BGPORD,BGPINDG,BGPLORD,BGPLIEN)=""
S BGPORD=0 F S BGPORD=$O(BGPINDL("AOI",BGPORD)) Q:BGPORD=""!(BGPQUIT) D
.S BGPINDG=$O(BGPINDL("AOI",BGPORD,0))
.S BGPLORD=0 F S BGPLORD=$O(BGPINDL("AOI",BGPORD,BGPINDG,BGPLORD)) Q:BGPLORD=""!(BGPQUIT) D
..S BGPLIEN=$O(BGPINDL("AOI",BGPORD,BGPINDG,BGPLORD,0))
..;I '$$ANYPATS(BGPINDG,BGPINDII) D HEADER W !!,"No Patients to Report.",! Q
..D NPL11 ;F S BGPINDG=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG)) Q:BGPINDG'=+BGPINDG!(BGPQUIT) D NPL1
Q
ANYPATS(I,L) ;
NEW O,G
S G=""
S O=0 F S O=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,O)) Q:O'=+O D
.I $D(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,O,BGPL)) S G=1
.Q
Q
NPL1 ;EP
Q:$G(BGPAREAA)
S BGPCR=$S(BGPRTYPE=7:"AON",1:"AN")
S BGPORD=$P(^BGPINDG(BGPINDG,12),U,6)
S BGPLORD=0 F S BGPLORD=$O(^BGPNPLG(BGPCR,BGPINDG,BGPLORD)) Q:BGPLORD'=+BGPLORD D
.S BGPLIEN=$O(^BGPNPLG(BGPCR,BGPINDG,BGPLORD,0)) Q:'BGPLIEN
.I BGPRTYPE=1!(BGPRTYPE=9) Q:BGPRTYPE'=$P(^BGPNPLG(BGPLIEN,0),U,7)
.Q:'$D(BGPINDL(BGPINDG,BGPLIEN))
.I '$D(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN)) D Q
..D HEADER
..S X=0 F S X=$O(^BGPNPLG(BGPLIEN,11,X)) Q:X'=+X D W^BGP7DP(^BGPNPLG(BGPLIEN,11,X,0),0,1,BGPPTYPE)
..D H1
..D W^BGP7DP(" ",0,0,BGPRTYPE)
..D W^BGP7DP("Total # of patients on list: 0",0,0,BGPPTYPE)
..I BGPPTYPE="D" D W^BGP7DP(" ",0,2,BGPPTYPE)
.D NPL11
Q
NPL11 ;
D ;S BGPLIEN=0 F S BGPLIEN=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN)) Q:BGPLIEN'=+BGPLIEN!(BGPQUIT) D
.I BGPRTYPE=1!(BGPRTYPE=9) Q:BGPRTYPE'=$P(^BGPNPLG(BGPLIEN,0),U,7)
.;I BGPRTYPE="" S BGPRTYPE=1
.S BGPCOUNT=0,BGPPCNT=0
.D HEADER Q:BGPQUIT
.;I BGPPTYPE="D" D W^BGP7DP("",0,3,BGPPTYPE)
.S BGPCNT=BGPINDL(BGPINDG,BGPLIEN)
.I BGPCNT<11!(BGPLIST'="R") S BGPCNT=1 G GO
.I BGPCNT<100 S BGPCNT=BGPCNT\10 G GO
.S BGPCNT=10
GO .;
.D WTITLE^BGP7DP(BGPINDG) ;W !,$P(^BGPINDG(BGPINDG,0),U,3)
NEXT .;
.S BGPX=0 F S BGPX=$O(^BGPNPLG(BGPLIEN,11,BGPX)) Q:BGPX'=+BGPX D
..I BGPPTYPE="P",$Y>(BGPIOSL-3) D HEADER Q:BGPQUIT
..D W^BGP7DP(^BGPNPLG(BGPLIEN,11,BGPX,0),0,1,BGPPTYPE)
.D H1
.;I '$D(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN)) W !!,"No patients to report.",! Q
.S BGPCOM="" F S BGPCOM=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM)) Q:BGPCOM=""!(BGPQUIT) D
..S BGPSEX="" F S BGPSEX=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX)) Q:BGPSEX=""!(BGPQUIT) D
...S BGPAGE="" F S BGPAGE=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE)) Q:BGPAGE=""!(BGPQUIT) D
....S DFN=0 F S DFN=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN)) Q:DFN'=+DFN!(BGPQUIT) S BGPCOUNT=BGPCOUNT+1 D PRINTL
...Q
..Q
.Q
I BGPPTYPE="P",$Y>(BGPIOSL-3) D HEADER Q:BGPQUIT
D W^BGP7DP("Total # of patients on list: ",+$G(BGPPCNT),0,2,BGPPTYPE)
D W^BGP7DP("",0,2,BGPPTYPE)
Q
;
PRINTL ;print one line
Q:(BGPCOUNT#BGPCNT)
I BGPPTYPE="P",$Y>(BGPIOSL-3) D HEADER Q:BGPQUIT D
.S X=0 F S X=$O(^BGPNPLG(BGPLIEN,11,X)) Q:X'=+X W !,^BGPNPLG(BGPLIEN,11,X,0)
.D H1
Q:BGPQUIT
S BGPPCNT=BGPPCNT+1
I BGPPTYPE="P" W !,$E($P(^DPT(DFN,0),U),1,22),?24,$$HRN^AUPNPAT(DFN,DUZ(2)),?31,$E(BGPCOM,1,12),?45,BGPSEX,?49,BGPAGE,?53,$$DATE^BGP7UTL($$DOB^AUPNPAT(DFN)) D
.S L=$$LASTV(DFN,BGPED)
.I BGPRTYPE=1!(BGPRTYPE=9) D I 1
..W ?62,$P(L,U),?72,$P(L,U,2)
..W !,$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1),?30,$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2)
.E D
..W ?53,$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1),?65,$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2)
I BGPPTYPE="D" D
.S X=$E($P(^DPT(DFN,0),U),1,22)_U_$$HRN^AUPNPAT(DFN,DUZ(2))_U_$E(BGPCOM,1,14)_U_BGPSEX_U_BGPAGE_U_$$EDT^BGP7UTL($$DOB^AUPNPAT(DFN))
.S L=$$LASTV(DFN,BGPED)
.I BGPRTYPE=1!(BGPRTYPE=9) D I 1
..S $P(X,U,7)=$P(L,U)
..S $P(X,U,8)=$P(L,U,2)
..S Y=$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1) S $P(X,U,9)=Y
..S Y=$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2) S $P(X,U,10)=Y
.E D
..S Y=$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1) S $P(X,U,7)=Y
..S Y=$P(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2) S $P(X,U,8)=Y
PRINTL1 .D W^BGP7DP(X,0,1,BGPPTYPE)
K ^TMP($J,"A")
Q
;
I BGPPTYPE="D" D HEADERD Q
G:'BGPGPG HEADER1
K DIR I $E(IOST)="C",IO=IO(0),'$D(ZTQUEUED) W ! S DIR(0)="EO" D ^DIR K DIR I Y=0!(Y="^")!($D(DTOUT)) S BGPQUIT=1 Q
W:$D(IOF) @IOF S BGPGPG=BGPGPG+1
I $G(BGPGUI) W "ZZZZZZZ",! ;maw
W !,"***** CONFIDENTIAL PATIENT INFORMATION, COVERED BY THE PRIVACY ACT *****"
W !?3,$P(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",BGPGPG,!
I BGPRTYPE=1 W !,$$CTR("*** IHS 2017 GPRA/GPRAMA Patient List ***",80),!
I BGPRTYPE=9 W !,$$CTR("*** IHS 2017 GPRA Developmental Measures Patient List ***",80),!
I BGPRTYPE=7 W !,$$CTR("*** IHS 2017 Other National Measures Patient List ***",80),!
W $$CTR($$RPTVER^BGP7BAN,80),!
W $$CTR($P(^DIC(4,DUZ(2),0),U),80),!
S X="Report Period: "_$$FMTE^XLFDT(BGPBD)_" to "_$$FMTE^XLFDT(BGPED) W $$CTR(X,80),!
W $$CTR($S(BGPLIST="A":"All Patients",BGPLIST="R":"Random Patient List",1:"Patient List by Provider: "_BGPLPROV),80),!
W !,$TR($J("",80)," ","-")
Q
H1 ;
;I BGPRTYPE'=1,BGPRTYPE'=9 D H1O Q
D W^BGP7DP("UP=User Pop; AC=Active Clinical; AD=Active Diabetic; AAD=Active Adult Diabetic",0,2,BGPPTYPE)
D W^BGP7DP("PREG=Pregnant Female; IMM=Active IMM Pkg Pt; CHD=Active Coronary Heart Disease",0,1,BGPPTYPE)
D W^BGP7DP("HR-High Risk Patient",0,1,BGPPTYPE)
D W^BGP7DP("PATIENT NAME",0,1,BGPPTYPE,1)
D W^BGP7DP("HRN",0,0,BGPPTYPE,2,24) ;,?24,"HRN",
D W^BGP7DP("COMMUNITY",0,0,BGPPTYPE,3,31) ;?31,"COMMUNITY",
D W^BGP7DP("SEX",0,0,BGPPTYPE,4,45) ;?45,"SEX",
D W^BGP7DP("AGE",0,0,BGPPTYPE,5,49) ;?49,"AGE",
D W^BGP7DP("DOB",0,0,BGPPTYPE,6,53)
I BGPPTYPE="D" D W^BGP7DP("LAST MEDICAL VISIT",0,0,BGPPTYPE,7,62)
I BGPPTYPE="P" D W^BGP7DP("LAST MEDI-",0,0,BGPPTYPE,7,62)
I BGPPTYPE="D" D W^BGP7DP("LAST VISIT",0,0,BGPPTYPE,8,74)
I BGPPTYPE="P" D W^BGP4DP("LAST ",0,0,BGPPTYPE,8,74)
D W^BGP7DP("DENOMINATOR",0,$S(BGPPTYPE="P":1,1:0),BGPPTYPE,9,1) ;?53,"DENOMINATOR",
D W^BGP7DP("NUMERATOR",0,0,BGPPTYPE,10,30) ;?65,"NUMERATOR"
I BGPPTYPE="P" D W^BGP7DP("CAL VISIT",0,0,BGPPTYPE,7,62)
I BGPPTYPE="P" D W^BGP4DP("VISIT",0,0,BGPPTYPE,8,74)
D W^BGP7DP($TR($J("",80)," ","-"),0,1,BGPPTYPE)
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")
;----------
S X="**** CONFIDENTIAL PATIENT INFORMATION, COVERED BY THE PRIVACY ACT *****" D W^BGP7DP(X,0,2,BGPPTYPE)
I BGPRTYPE=1 S X="*** IHS 2017 GPRA/GPRAMA Patient List ***" D W^BGP7DP(X,0,1,BGPPTYPE)
I BGPRTYPE=9 S X="*** IHS 2017 GPRA Developmental Measures Patient List ***" D W^BGP7DP(X,0,1,BGPPTYPE)
I BGPRTYPE=7 S X="*** IHS 2017 Other National Measures Patient List ***" D W^BGP7DP(X,0,1,BGPPTYPE)
S X=$$RPTVER^BGP7BAN D W^BGP7DP(X,0,1,BGPPTYPE)
S X=$P(^DIC(4,DUZ(2),0),U) D W^BGP7DP(X,0,1,BGPPTYPE)
S X="Report Period: "_$$FMTE^XLFDT(BGPBD)_" to "_$$FMTE^XLFDT(BGPED) D W^BGP7DP(X,0,1,BGPPTYPE)
S X=$S(BGPLIST="A":"All Patients",BGPLIST="R":"Random Patient List",1:"Patient List by Provider: "_BGPLPROV) D W^BGP7DP(X,0,1,BGPPTYPE)
S X=$TR($J("",80)," ","-") D W^BGP7DP(X,0,1,BGPPTYPE)
Q
LASTV(P,EDATE) ;
;return last medical visit date^last visit date in mm/dd/yy format
K ^TMP($J,"A")
NEW LCC,LV,A,B,E,X
S LCC="",LV=""
S A="^TMP($J,""A"",",B=P_"^ALL VISITS;DURING "_$$FMADD^XLFDT(EDATE,-(4*365))_"-"_EDATE,E=$$START1^APCLDF(B,A)
I '$D(^TMP($J,"A",1)) Q ""
;reorder in reverse order
S (X,G,F,S)=0 F S X=$O(^TMP($J,"A",X)) Q:X'=+X S V=$P(^TMP($J,"A",X),U,5) D
.Q:'$D(^AUPNVSIT(V,0))
.Q:'$P(^AUPNVSIT(V,0),U,9)
.Q:$P(^AUPNVSIT(V,0),U,11)
.Q:'$D(^AUPNVPRV("AD",V))
.Q:"SAHOR"'[$P(^AUPNVSIT(V,0),U,7)
.Q:"V"[$P(^AUPNVSIT(V,0),U,3)
.Q:$P(^AUPNVSIT(V,0),U,6)=""
.S D=$$VD^APCLV(V)
.S B=$$CLINIC^APCLV(V,"C")
.I B,$D(^BGPCTRL($O(^BGPCTRL("B",2017,0)),11,"B",B)) S LCC(9999999-D)=V
.I B,$D(^BGPCTRL($O(^BGPCTRL("B",2017,0)),12,"B",B)) S LCC(9999999-D)=V
.S LV(9999999-D)=V
.Q
S LV=$O(LV(0))
S LCC=$O(LCC(0))
I LV S LV=$$DATE^BGP7UTL((9999999-LV))
I LCC S LCC=$$DATE^BGP7UTL((9999999-LCC))
Q LCC_U_LV
BGP7NPLP ; IHS/CMI/LAB - IHS gpra print 30 Jun 2010 5:58 PM ;
+1 ;;17.1;IHS CLINICAL REPORTING;;MAY 10, 2017;Build 29
+2 ;
NPL ;
+1 IF $GET(BGPAREAA)
QUIT
+2 SET BGPQUIT=""
SET BGPGPG=0
+3 SET BGPINDG=0
SET BGPCOUNT=0
+4 SET BGPINDG=0
FOR
SET BGPINDG=$ORDER(BGPINDL(BGPINDG))
IF BGPINDG'=+BGPINDG
QUIT
Begin DoDot:1
+5 SET BGPORD=$PIECE($GET(^BGPINDG(BGPINDG,12)),U,6)
+6 SET BGPLIEN=0
FOR
SET BGPLIEN=$ORDER(BGPINDG(BGPINDG,BGPLIEN))
IF BGPLIEN'=+BGPLIEN
QUIT
Begin DoDot:2
+7 SET BGPLORD=$SELECT(BGPRTYPE=1:$PIECE(^BGPNPLG(BGPLIEN,0),U,5),1:$PIECE(^BGPNPLG(BGPLIEN,0),U,6))
+8 SET BGPINDG("AOI",BGPORD,BGPINDG,BGPLORD,BGPLIEN)=""
End DoDot:2
End DoDot:1
+9 SET BGPORD=0
FOR
SET BGPORD=$ORDER(BGPINDL("AOI",BGPORD))
IF BGPORD=""!(BGPQUIT)
QUIT
Begin DoDot:1
+10 SET BGPINDG=$ORDER(BGPINDL("AOI",BGPORD,0))
+11 SET BGPLORD=0
FOR
SET BGPLORD=$ORDER(BGPINDL("AOI",BGPORD,BGPINDG,BGPLORD))
IF BGPLORD=""!(BGPQUIT)
QUIT
Begin DoDot:2
+12 SET BGPLIEN=$ORDER(BGPINDL("AOI",BGPORD,BGPINDG,BGPLORD,0))
+13 ;I '$$ANYPATS(BGPINDG,BGPINDII) D HEADER W !!,"No Patients to Report.",! Q
+14 ;F S BGPINDG=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG)) Q:BGPINDG'=+BGPINDG!(BGPQUIT) D NPL1
DO NPL11
End DoDot:2
End DoDot:1
+15 QUIT
ANYPATS(I,L) ;
+1 NEW O,G
+2 SET G=""
+3 SET O=0
FOR
SET O=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,O))
IF O'=+O
QUIT
Begin DoDot:1
+4 IF $DATA(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPINDG,O,BGPL))
SET G=1
+5 QUIT
End DoDot:1
+6 QUIT
NPL1 ;EP
+1 IF $GET(BGPAREAA)
QUIT
+2 SET BGPCR=$SELECT(BGPRTYPE=7:"AON",1:"AN")
+3 SET BGPORD=$PIECE(^BGPINDG(BGPINDG,12),U,6)
+4 SET BGPLORD=0
FOR
SET BGPLORD=$ORDER(^BGPNPLG(BGPCR,BGPINDG,BGPLORD))
IF BGPLORD'=+BGPLORD
QUIT
Begin DoDot:1
+5 SET BGPLIEN=$ORDER(^BGPNPLG(BGPCR,BGPINDG,BGPLORD,0))
IF 'BGPLIEN
QUIT
+6 IF BGPRTYPE=1!(BGPRTYPE=9)
IF BGPRTYPE'=$PIECE(^BGPNPLG(BGPLIEN,0),U,7)
QUIT
+7 IF '$DATA(BGPINDL(BGPINDG,BGPLIEN))
QUIT
+8 IF '$DATA(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN))
Begin DoDot:2
+9 DO HEADER
+10 SET X=0
FOR
SET X=$ORDER(^BGPNPLG(BGPLIEN,11,X))
IF X'=+X
QUIT
DO W^BGP7DP(^BGPNPLG(BGPLIEN,11,X,0),0,1,BGPPTYPE)
+11 DO H1
+12 DO W^BGP7DP(" ",0,0,BGPRTYPE)
+13 DO W^BGP7DP("Total # of patients on list: 0",0,0,BGPPTYPE)
+14 IF BGPPTYPE="D"
DO W^BGP7DP(" ",0,2,BGPPTYPE)
End DoDot:2
QUIT
+15 DO NPL11
End DoDot:1
+16 QUIT
NPL11 ;
+1 ;S BGPLIEN=0 F S BGPLIEN=$O(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN)) Q:BGPLIEN'=+BGPLIEN!(BGPQUIT) D
Begin DoDot:1
+2 IF BGPRTYPE=1!(BGPRTYPE=9)
IF BGPRTYPE'=$PIECE(^BGPNPLG(BGPLIEN,0),U,7)
QUIT
+3 ;I BGPRTYPE="" S BGPRTYPE=1
+4 SET BGPCOUNT=0
SET BGPPCNT=0
+5 DO HEADER
IF BGPQUIT
QUIT
+6 ;I BGPPTYPE="D" D W^BGP7DP("",0,3,BGPPTYPE)
+7 SET BGPCNT=BGPINDL(BGPINDG,BGPLIEN)
+8 IF BGPCNT<11!(BGPLIST'="R")
SET BGPCNT=1
GOTO GO
+9 IF BGPCNT<100
SET BGPCNT=BGPCNT\10
GOTO GO
+10 SET BGPCNT=10
GO ;
+1 ;W !,$P(^BGPINDG(BGPINDG,0),U,3)
DO WTITLE^BGP7DP(BGPINDG)
NEXT ;
+1 SET BGPX=0
FOR
SET BGPX=$ORDER(^BGPNPLG(BGPLIEN,11,BGPX))
IF BGPX'=+BGPX
QUIT
Begin DoDot:2
+2 IF BGPPTYPE="P"
IF $Y>(BGPIOSL-3)
DO HEADER
IF BGPQUIT
QUIT
+3 DO W^BGP7DP(^BGPNPLG(BGPLIEN,11,BGPX,0),0,1,BGPPTYPE)
End DoDot:2
+4 DO H1
+5 ;I '$D(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN)) W !!,"No patients to report.",! Q
+6 SET BGPCOM=""
FOR
SET BGPCOM=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM))
IF BGPCOM=""!(BGPQUIT)
QUIT
Begin DoDot:2
+7 SET BGPSEX=""
FOR
SET BGPSEX=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX))
IF BGPSEX=""!(BGPQUIT)
QUIT
Begin DoDot:3
+8 SET BGPAGE=""
FOR
SET BGPAGE=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE))
IF BGPAGE=""!(BGPQUIT)
QUIT
Begin DoDot:4
+9 SET DFN=0
FOR
SET DFN=$ORDER(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN))
IF DFN'=+DFN!(BGPQUIT)
QUIT
SET BGPCOUNT=BGPCOUNT+1
DO PRINTL
End DoDot:4
+10 QUIT
End DoDot:3
+11 QUIT
End DoDot:2
+12 QUIT
End DoDot:1
+13 IF BGPPTYPE="P"
IF $Y>(BGPIOSL-3)
DO HEADER
IF BGPQUIT
QUIT
+14 DO W^BGP7DP("Total # of patients on list: ",+$GET(BGPPCNT),0,2,BGPPTYPE)
+15 DO W^BGP7DP("",0,2,BGPPTYPE)
+16 QUIT
+17 ;
PRINTL ;print one line
+1 IF (BGPCOUNT#BGPCNT)
QUIT
+2 IF BGPPTYPE="P"
IF $Y>(BGPIOSL-3)
DO HEADER
IF BGPQUIT
QUIT
Begin DoDot:1
+3 SET X=0
FOR
SET X=$ORDER(^BGPNPLG(BGPLIEN,11,X))
IF X'=+X
QUIT
WRITE !,^BGPNPLG(BGPLIEN,11,X,0)
+4 DO H1
End DoDot:1
+5 IF BGPQUIT
QUIT
+6 SET BGPPCNT=BGPPCNT+1
+7 IF BGPPTYPE="P"
WRITE !,$EXTRACT($PIECE(^DPT(DFN,0),U),1,22),?24,$$HRN^AUPNPAT(DFN,DUZ(2)),?31,$EXTRACT(BGPCOM,1,12),?45,BGPSEX,?49,BGPAGE,?53,$$DATE^BGP7UTL($$DOB^AUPNPAT(DFN))
Begin DoDot:1
+8 SET L=$$LASTV(DFN,BGPED)
+9 IF BGPRTYPE=1!(BGPRTYPE=9)
Begin DoDot:2
+10 WRITE ?62,$PIECE(L,U),?72,$PIECE(L,U,2)
+11 WRITE !,$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1),?30,$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2)
End DoDot:2
IF 1
+12 IF '$TEST
Begin DoDot:2
+13 WRITE ?53,$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1),?65,$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2)
End DoDot:2
End DoDot:1
+14 IF BGPPTYPE="D"
Begin DoDot:1
+15 SET X=$EXTRACT($PIECE(^DPT(DFN,0),U),1,22)_U_$$HRN^AUPNPAT(DFN,DUZ(2))_U_$EXTRACT(BGPCOM,1,14)_U_BGPSEX_U_BGPAGE_U_$$EDT^BGP7UTL($$DOB^AUPNPAT(DFN))
+16 SET L=$$LASTV(DFN,BGPED)
+17 IF BGPRTYPE=1!(BGPRTYPE=9)
Begin DoDot:2
+18 SET $PIECE(X,U,7)=$PIECE(L,U)
+19 SET $PIECE(X,U,8)=$PIECE(L,U,2)
+20 SET Y=$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1)
SET $PIECE(X,U,9)=Y
+21 SET Y=$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2)
SET $PIECE(X,U,10)=Y
End DoDot:2
IF 1
+22 IF '$TEST
Begin DoDot:2
+23 SET Y=$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",1)
SET $PIECE(X,U,7)=Y
+24 SET Y=$PIECE(^XTMP("BGP7DNP",BGPJ,BGPH,"LIST",BGPORD,BGPINDG,BGPLORD,BGPLIEN,BGPCOM,BGPSEX,BGPAGE,DFN),"|||",2)
SET $PIECE(X,U,8)=Y
End DoDot:2
PRINTL1 DO W^BGP7DP(X,0,1,BGPPTYPE)
End DoDot:1
+1 KILL ^TMP($JOB,"A")
+2 QUIT
+3 ;
+1 IF BGPPTYPE="D"
DO HEADERD
QUIT
+2 IF 'BGPGPG
GOTO HEADER1
+3 KILL DIR
IF $EXTRACT(IOST)="C"
IF IO=IO(0)
IF '$DATA(ZTQUEUED)
WRITE !
SET DIR(0)="EO"
DO ^DIR
KILL DIR
IF Y=0!(Y="^")!($DATA(DTOUT))
SET BGPQUIT=1
QUIT
+1 IF $DATA(IOF)
WRITE @IOF
SET BGPGPG=BGPGPG+1
+2 ;maw
IF $GET(BGPGUI)
WRITE "ZZZZZZZ",!
+3 WRITE !,"***** CONFIDENTIAL PATIENT INFORMATION, COVERED BY THE PRIVACY ACT *****"
+4 WRITE !?3,$PIECE(^VA(200,DUZ,0),U,2),?35,$$FMTE^XLFDT(DT),?70,"Page ",BGPGPG,!
+5 IF BGPRTYPE=1
WRITE !,$$CTR("*** IHS 2017 GPRA/GPRAMA Patient List ***",80),!
+6 IF BGPRTYPE=9
WRITE !,$$CTR("*** IHS 2017 GPRA Developmental Measures Patient List ***",80),!
+7 IF BGPRTYPE=7
WRITE !,$$CTR("*** IHS 2017 Other National Measures Patient List ***",80),!
+8 WRITE $$CTR($$RPTVER^BGP7BAN,80),!
+9 WRITE $$CTR($PIECE(^DIC(4,DUZ(2),0),U),80),!
+10 SET X="Report Period: "_$$FMTE^XLFDT(BGPBD)_" to "_$$FMTE^XLFDT(BGPED)
WRITE $$CTR(X,80),!
+11 WRITE $$CTR($SELECT(BGPLIST="A":"All Patients",BGPLIST="R":"Random Patient List",1:"Patient List by Provider: "_BGPLPROV),80),!
+12 WRITE !,$TRANSLATE($JUSTIFY("",80)," ","-")
+13 QUIT
H1 ;
+1 ;I BGPRTYPE'=1,BGPRTYPE'=9 D H1O Q
+2 DO W^BGP7DP("UP=User Pop; AC=Active Clinical; AD=Active Diabetic; AAD=Active Adult Diabetic",0,2,BGPPTYPE)
+3 DO W^BGP7DP("PREG=Pregnant Female; IMM=Active IMM Pkg Pt; CHD=Active Coronary Heart Disease",0,1,BGPPTYPE)
+4 DO W^BGP7DP("HR-High Risk Patient",0,1,BGPPTYPE)
+5 DO W^BGP7DP("PATIENT NAME",0,1,BGPPTYPE,1)
+6 ;,?24,"HRN",
DO W^BGP7DP("HRN",0,0,BGPPTYPE,2,24)
+7 ;?31,"COMMUNITY",
DO W^BGP7DP("COMMUNITY",0,0,BGPPTYPE,3,31)
+8 ;?45,"SEX",
DO W^BGP7DP("SEX",0,0,BGPPTYPE,4,45)
+9 ;?49,"AGE",
DO W^BGP7DP("AGE",0,0,BGPPTYPE,5,49)
+10 DO W^BGP7DP("DOB",0,0,BGPPTYPE,6,53)
+11 IF BGPPTYPE="D"
DO W^BGP7DP("LAST MEDICAL VISIT",0,0,BGPPTYPE,7,62)
+12 IF BGPPTYPE="P"
DO W^BGP7DP("LAST MEDI-",0,0,BGPPTYPE,7,62)
+13 IF BGPPTYPE="D"
DO W^BGP7DP("LAST VISIT",0,0,BGPPTYPE,8,74)
+14 IF BGPPTYPE="P"
DO W^BGP4DP("LAST ",0,0,BGPPTYPE,8,74)
+15 ;?53,"DENOMINATOR",
DO W^BGP7DP("DENOMINATOR",0,$SELECT(BGPPTYPE="P":1,1:0),BGPPTYPE,9,1)
+16 ;?65,"NUMERATOR"
DO W^BGP7DP("NUMERATOR",0,0,BGPPTYPE,10,30)
+17 IF BGPPTYPE="P"
DO W^BGP7DP("CAL VISIT",0,0,BGPPTYPE,7,62)
+18 IF BGPPTYPE="P"
DO W^BGP4DP("VISIT",0,0,BGPPTYPE,8,74)
+19 DO W^BGP7DP($TRANSLATE($JUSTIFY("",80)," ","-"),0,1,BGPPTYPE)
+20 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 ;----------
+1 SET X="**** CONFIDENTIAL PATIENT INFORMATION, COVERED BY THE PRIVACY ACT *****"
DO W^BGP7DP(X,0,2,BGPPTYPE)
+2 IF BGPRTYPE=1
SET X="*** IHS 2017 GPRA/GPRAMA Patient List ***"
DO W^BGP7DP(X,0,1,BGPPTYPE)
+3 IF BGPRTYPE=9
SET X="*** IHS 2017 GPRA Developmental Measures Patient List ***"
DO W^BGP7DP(X,0,1,BGPPTYPE)
+4 IF BGPRTYPE=7
SET X="*** IHS 2017 Other National Measures Patient List ***"
DO W^BGP7DP(X,0,1,BGPPTYPE)
+5 SET X=$$RPTVER^BGP7BAN
DO W^BGP7DP(X,0,1,BGPPTYPE)
+6 SET X=$PIECE(^DIC(4,DUZ(2),0),U)
DO W^BGP7DP(X,0,1,BGPPTYPE)
+7 SET X="Report Period: "_$$FMTE^XLFDT(BGPBD)_" to "_$$FMTE^XLFDT(BGPED)
DO W^BGP7DP(X,0,1,BGPPTYPE)
+8 SET X=$SELECT(BGPLIST="A":"All Patients",BGPLIST="R":"Random Patient List",1:"Patient List by Provider: "_BGPLPROV)
DO W^BGP7DP(X,0,1,BGPPTYPE)
+9 SET X=$TRANSLATE($JUSTIFY("",80)," ","-")
DO W^BGP7DP(X,0,1,BGPPTYPE)
+10 QUIT
LASTV(P,EDATE) ;
+1 ;return last medical visit date^last visit date in mm/dd/yy format
+2 KILL ^TMP($JOB,"A")
+3 NEW LCC,LV,A,B,E,X
+4 SET LCC=""
SET LV=""
+5 SET A="^TMP($J,""A"","
SET B=P_"^ALL VISITS;DURING "_$$FMADD^XLFDT(EDATE,-(4*365))_"-"_EDATE
SET E=$$START1^APCLDF(B,A)
+6 IF '$DATA(^TMP($JOB,"A",1))
QUIT ""
+7 ;reorder in reverse order
+8 SET (X,G,F,S)=0
FOR
SET X=$ORDER(^TMP($JOB,"A",X))
IF X'=+X
QUIT
SET V=$PIECE(^TMP($JOB,"A",X),U,5)
Begin DoDot:1
+9 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+10 IF '$PIECE(^AUPNVSIT(V,0),U,9)
QUIT
+11 IF $PIECE(^AUPNVSIT(V,0),U,11)
QUIT
+12 IF '$DATA(^AUPNVPRV("AD",V))
QUIT
+13 IF "SAHOR"'[$PIECE(^AUPNVSIT(V,0),U,7)
QUIT
+14 IF "V"[$PIECE(^AUPNVSIT(V,0),U,3)
QUIT
+15 IF $PIECE(^AUPNVSIT(V,0),U,6)=""
QUIT
+16 SET D=$$VD^APCLV(V)
+17 SET B=$$CLINIC^APCLV(V,"C")
+18 IF B
IF $DATA(^BGPCTRL($ORDER(^BGPCTRL("B",2017,0)),11,"B",B))
SET LCC(9999999-D)=V
+19 IF B
IF $DATA(^BGPCTRL($ORDER(^BGPCTRL("B",2017,0)),12,"B",B))
SET LCC(9999999-D)=V
+20 SET LV(9999999-D)=V
+21 QUIT
End DoDot:1
+22 SET LV=$ORDER(LV(0))
+23 SET LCC=$ORDER(LCC(0))
+24 IF LV
SET LV=$$DATE^BGP7UTL((9999999-LV))
+25 IF LCC
SET LCC=$$DATE^BGP7UTL((9999999-LCC))
+26 QUIT LCC_U_LV