Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BGP5D55

BGP5D55.m

Go to the documentation of this file.
BGP5D55 ; IHS/CMI/LAB - measure calc ;
 ;;15.1;IHS CLINICAL REPORTING;;MAY 06, 2015;Build 143
 ;
IASCRN ;EP
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9,BGPD10,BGPD11,BGPD12,BGPD13,BGPD14,BGPD15,BGPD16)=0
 I 'BGPACTUP S BGPSTOP=1 Q
 ;I 'BGPACTCB S BGPSTOP=1 Q
 I BGPAGEB<12 S BGPSTOP=1 Q
 I BGPAGEB>75 S BGPSTOP=1 Q
 I BGPACTCB D
 .S BGPD1=1
 .I BGPAGEB>11,BGPAGEB<20 S BGPD2=1
 .I BGPAGEB>19,BGPAGEB<25 S BGPD3=1
 .I BGPAGEB>24,BGPAGEB<35 S BGPD4=1
 .I BGPAGEB>34,BGPAGEB<45 S BGPD5=1
 .I BGPAGEB>44,BGPAGEB<55 S BGPD6=1
 .I BGPAGEB>54,BGPAGEB<76 S BGPD7=1
 I BGPSEX="F",BGPAGEB>13,BGPAGEB<47,BGPACTCL S BGPD8=1
 I '(BGPD1+BGPD2+BGPD3+BGPD4+BGPD5+BGPD6+BGPD7+BGPD8) S BGPSTOP=1 Q
 ;BGPN1 - had screen or dx
 ;BGPN2 - had educ
 ;BGPN3 - had screening
 ;BGPN4 - had positive screen
 ;did they have screening?
 K BGPALL
 D ALSCRN(DFN,BGPBDATE,BGPEDATE,.BGPALL)
 I $D(BGPALL) S BGPN1=1,BGPN3=1
 ;if screened, is any screen positive
 S C=""
 S D=0 F  S D=$O(BGPALL(D)) Q:D'=+D!(C]"")  S Y=0 F  S Y=$O(BGPALL(D,Y)) Q:Y'=+Y!(C]"")  I $P(BGPALL(D,Y),U,5) S C=BGPALL(D,Y)
 I C]"" S BGPN4=1
 ;if no positive then take latest one
 I C="" S D=$O(BGPALL(0)) I D S Y=$O(BGPALL(D,0)) S C=BGPALL(D,Y)
 ;if didn't have screen then check dx/proc
 S BGPALDX="" I 'BGPN1 S BGPALDX=$$ALDX(DFN,BGPBDATE,BGPEDATE)
 I BGPALDX S BGPN1=1  ;BGPALDX
 ;set numerators
 S BGPN2=$$ALPED^BGP5D5(DFN,BGPBDATE,BGPEDATE)
 I BGPN1!(BGPN2) S BGPN5=1 ;HAD EITHER SCREENING OR EDUC G.B.7
 ;
 S BGPVALUE=$S(BGPD8:"AC",1:"")_$S(BGPD8&(BGPD1):",",1:"")_$S(BGPD1:"AC+BH",1:"")_"|||"
 I $P(BGPN1,U)=1,BGPN3 S BGPVALUE=BGPVALUE_"SCREEN: "_$P(C,U,3)_" "_$P(C,U,2)_"-"_$S($P(C,U,6)]"":$P(C,U,6),1:"NO RESULT")
 I BGPN1,'BGPN3 S BGPVALUE=BGPVALUE_"DX/PROC: "_$P(BGPALDX,U,3)_" "_$P(BGPALDX,U,2)
 ;I $P(BGPN1,U)=1,BGPN3!(BGPN5) S BGPVALUE=BGPVALUE_"SCREEN: "_$P(C,U,3)_" "_$P(C,U,2)_"-"_$S($P(C,U,6)]"":$P(C,U,6),1:"NO RESULT")
 ;I $P(BGPN1,U)=1,'BGPN3!(BGPN5) S BGPVALUE=BGPVALUE_"DX/PROC: "_$P(BGPALDX,U,3)_" "_$P(BGPALDX,U,2)
 I $P(BGPN2,U)=1 S BGPVALUE=BGPVALUE_$S(BGPN1:"; ",1:""),BGPVALUE=BGPVALUE_"PT ED: "_$P(BGPN2,U,3)_" "_$P(BGPN2,U,2)
 K X,Y,Z,%,A,B,C,D,E,H,BDATE,EDATE,P,V,S,F,T,BGPALL
 Q
ALDX(P,BDATE,EDATE) ;EP
 NEW T,X,BGPC,E,Y,V,D,BGPLAL,BGPP,G,BGPG,BGPJ,BGPT
 S BGPLAL=""
 I $G(P)="" Q ""
 K BGPG
 S Y="BGPG("
 S X=P_"^LAST DX [BGP ALCOHOL DXS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 I $D(BGPG(1)) S BGPLAL=1_U_"DX "_$P(BGPG(1),U,2)_U_$$DATE^BGP5UTL($P(BGPG(1),U))_U_$P(BGPG(1),U)
 S BGPC=""
 ;go through BH record file and find up to 1 visits in date range
 S BGPT=$O(^ATXAX("B","BGP ALCOHOL DXS",0))
 I 'BGPT W !,BGPBOMB
 S BGPJ=$O(^ATXAX("B","BGP BH PC ALCOHOL DXS",0))
 I 'BGPJ W !,BGPBOMB
 S E=9999999-BDATE,D=9999999-EDATE-1_".99" F  S D=$O(^AMHREC("AE",P,D)) Q:D'=+D!($P(D,".")>E)!(BGPC)  S V=0 F  S V=$O(^AMHREC("AE",P,D,V)) Q:V'=+V!(BGPC)  D
 .S X=0 F  S X=$O(^AMHRPRO("AD",V,X)) Q:X'=+X!(BGPC)  S BGPP=$P($G(^AMHRPRO(X,0)),U) D
 ..Q:'BGPP
 ..;S BGPP=$P($G(^AMHPROB(BGPP,0)),U)
 ..I $$ICD^BGP5UTL2(BGPP,BGPT,9) S BGPC=1_U_"BH POV "_$P(^AMHPROB(BGPP,0),U)_U_$$DATE^BGP5UTL((9999999-$P(D,".")))_U_(9999999-$P(D,".")) Q
 ..S BGPP=$P($G(^AMHPROB(BGPP,0)),U)
 ..I $D(^ATXAX(BGPJ,21,"B",BGPP)) S BGPC=1_U_"BH POV "_BGPP_U_$$DATE^BGP5UTL((9999999-$P(D,".")))_U_(9999999-$P(D,".")) Q
 ..Q
 I $P(BGPLAL,U,4)<$P(BGPC,U,4) S BGPLAL=BGPC
 ;now check pcc and bh problem lists
 S (X,G)=0 F  S X=$O(^AUPNPROB("AC",P,X)) Q:X'=+X!(G)  D
 .Q:$P(^AUPNPROB(X,0),U,12)="D"
 .Q:$P(^AUPNPROB(X,0),U,12)="I"
 .Q:$P(^AUPNPROB(X,0),U,3)>EDATE
 .Q:$P(^AUPNPROB(X,0),U,3)<BDATE
 .S Y=$P(^AUPNPROB(X,0),U)
 .Q:'$$ICD^BGP5UTL2(Y,BGPT,9)
 .S D=$P(^AUPNPROB(X,0),U,3)
 .S G=1_U_"PROB LIST "_$P($$ICDDX^BGP5UTL2(Y),U,2)_U_$$DATE^BGP5UTL((D))_U_(D)
 .Q
 I $P(BGPLAL,U,4)<$P(G,U,4) S BGPLAL=G
 S (X,G)=0 F  S X=$O(^AMHPPROB("AC",P,X)) Q:X'=+X!(G)  D
 .Q:$P(^AMHPPROB(X,0),U,12)'="A"
 .Q:$P(^AMHPPROB(X,0),U,3)>EDATE
 .Q:$P(^AMHPPROB(X,0),U,3)<BDATE
 .S Y=$P(^AMHPPROB(X,0),U)
 .I $$ICD^BGP5UTL2(Y,BGPT,9) S G=1_U_"BH PL "_Y_U_$$DATE^BGP5UTL($P(^AMHPPROB(X,0),U,3))_U_$P(^AMHPPROB(X,0),U,3) Q
 .S Y=$P($G(^AMHPROB(Y,0)),U)
 .I $D(^ATXAX(BGPJ,21,"B",Y)) S G=1_U_"BH PL "_Y_U_$$DATE^BGP5UTL($P(^AMHPPROB(X,0),U,3))_U_$P(^AMHPPROB(X,0),U,3) Q
 .Q
 I $P(BGPLAL,U,4)<$P(G,U,4) S BGPLAL=G
 ;
 K BGPG
 S BGPG=$$LASTPRC^BGP5UTL1(P,"BGP ALCOHOL PROCEDURES",BDATE,EDATE)
 I $P(BGPLAL,U,4)<$P(BGPG,U,3) S BGPLAL=1_U_"Proc "_$P(BGPG,U,2)_U_$$DATE^BGP5UTL($P(BGPG,U,3))_U_$P(BGPG,U,3)
 Q BGPLAL
ALSCRN(P,BDATE,EDATE,BGPALL) ;EP - alcohol hf or screening pov
 NEW BGPG,%,E,BGPSC,V,BGPC,T,F,D,R,BGPCT,BGPX,BGPV,BGPVD,BGPIVD
 K BGPALL
 S BGPSC=0
PCC ;check PCC first
 S BGPCT=$O(^ATXAX("B","BGP ALCOHOL SCREENING CPTS",0))
 K BGPG
 D ALLV^APCLAPIU(P,BDATE,EDATE,"BGPG")
 S BGPX=0 F  S BGPX=$O(BGPG(BGPX)) Q:BGPX'=+BGPX  S BGPV=$P(BGPG(BGPX),U,5) D
 .S BGPVD=$$VD^APCLV(BGPV)
 .S BGPIVD=9999999-BGPVD
PCCEX .;
 .S E=0 F  S E=$O(^AUPNVXAM("AD",BGPV,E)) Q:E'=+E  D
 ..S I=$P($G(^AUPNVXAM(E,0)),U,1)
 ..Q:'I
 ..Q:$P($G(^AUTTEXAM(I,0)),U,2)'=35
 ..S BGPSC=BGPSC+1
 ..S R=$$VAL^XBDIQ1(9000010.13,E,.04)
 ..S BGPALL(BGPIVD,BGPSC)=1_"^Ex 35^"_$$DATE^BGP5UTL(BGPVD)_U_BGPVD_U_$S(R="POSITIVE":1,1:0)_U_R
PCCHF .;
 .S E=0 F  S E=$O(^AUPNVHF("AD",BGPV,E)) Q:E'=+E  D
 ..S I=$P($G(^AUPNVHF(E,0)),U,1)
 ..S I=$P($G(^AUTTHF(I,0)),U,1)
 ..I I'="CAGE 0/4",I'="CAGE 1/4",I'="CAGE 2/4",I'="CAGE 3/4",I'="CAGE 4/4" Q  ;cage only
 ..S R=$S(I["0":"NEGATIVE",1:"POSITIVE")
 ..S BGPSC=BGPSC+1,BGPALL(BGPIVD,BGPSC)=1_"^HF "_I_"^"_$$DATE^BGP5UTL(BGPVD)_U_BGPVD_U_$S(R="POSITIVE":1,1:0)_U_R
PCCDX .;
 .S E=0 F  S E=$O(^AUPNVPOV("AD",BGPV,E)) Q:E'=+E  D
 ..S I=$$VAL^XBDIQ1(9000010.07,E,.01)
 ..I '$$ICD^BGP5UTL2($$VALI^XBDIQ1(9000010.07,E,.01),$O(^ATXAX("B","BGP ALCOHOL SCREEN DXS",0)),9) Q
 ..S BGPSC=BGPSC+1,BGPALL(BGPIVD,BGPSC)=1_U_"POV "_I_U_$$DATE^BGP5UTL(BGPVD)_U_BGPVD
PCCCPT .;
 .S E=0 F  S E=$O(^AUPNVCPT("AD",BGPV,E)) Q:E'=+E  D
 ..S I=$P($G(^AUPNVCPT(E,0)),U,1)
 ..Q:'I
 ..Q:'$$ICD^BGP5UTL2(I,BGPCT,1)
 ..S J=$P(^ICPT(I,0),U,1)
 ..S R=$S($$ICD^BGP5UTL2(I,$O(^ATXAX("B","BGP ALCOHOL POSITIVE SCRN CPTS",0)),1):"POSITIVE",1:"")
 ..S BGPSC=BGPSC+1
 ..S BGPALL(BGPIVD,BGPSC)=1_"^CPT "_J_"^"_$$DATE^BGP5UTL(BGPVD)_U_BGPVD_U_$S(R="POSITIVE":1,1:0)_U_R
PCCMEAS .;now add in v measurements
 .S E=0 F  S E=$O(^AUPNVCPT("AD",BGPV,E)) Q:E'=+E  D
 ..S I=$$VAL^XBDIQ1(9000010.01,E,.01)
 ..I I'="AUDT",I'="AUDC",I'="CRFT" Q
 ..S BGPSC=BGPSC+1
 ..S R=$$VAL^XBDIQ1(9000010.01,E,.04)
 ..S T=""
 ..I I="AUDT",R>7 S T=1
 ..I I="AUDC",$P(^DPT(P,0),U,2)="M",R>3 S T=1
 ..I I="AUDC",$P(^DPT(P,0),U,2)="F",R>2 S T=1
 ..I I="CRFT",R>1,R<7 S T=1
 ..S BGPALL(BGPVD,BGPSC)=1_"^Meas "_I_"^"_$$DATE^BGP5UTL(BGPVD)_U_BGPVD_U_T_U_$S(T:"POSITIVE: "_R,1:"NEGATIVE: "_R)
BH ;CHECK BH VISITS
 S BGPC="",T="",F=""
 S E=9999999-BDATE,D=9999999-EDATE-1_".99"
 F  S D=$O(^AMHREC("AE",P,D)) Q:D'=+D!($P(D,".")>E)  S V=0 F  S V=$O(^AMHREC("AE",P,D,V)) Q:V'=+V  D
BHEX .;
 .S BGPVD=9999999-$P(D,"."),BGPIVD=$P(D,".")
 .S X=$P($G(^AMHREC(V,14)),U,3)
 .I X="P"!(X="N") D
 ..S R=$S(X="P":"POSITIVE",1:"NEGATIVE")
 ..S BGPSC=BGPSC+1
 ..S BGPALL(BGPIVD,BGPSC)=1_"^BH Ex^"_$$DATE^BGP5UTL(BGPVD)_U_BGPVD_U_$S(R="POSITIVE":1,1:0)_U_R
BHHF .;
 .S X=0 F  S X=$O(^AMHRHF("AD",V,X)) Q:X'=+X  D
 ..S I=$P($G(^AMHRHF(X,0)),U,1)
 ..Q:'I
 ..S I=$P($G(^AUTTHF(I,0)),U,1)
 ..I I'="CAGE 0/4",I'="CAGE 1/4",I'="CAGE 2/4",I'="CAGE 3/4",I'="CAGE 4/4" Q  ;cage only
 ..S R=$S(I["0":"NEGATIVE",1:"POSITIVE")
 ..S BGPSC=BGPSC+1,BGPALL(BGPIVD,BGPSC)=1_"^BH HF "_I_"^"_$$DATE^BGP5UTL(BGPVD)_U_BGPVD_U_$S(R="POSITIVE":1,1:0)_U_R
 ..Q
BHDX .;
 .S X=0 F  S X=$O(^AMHRPRO("AD",V,X)) Q:X'=+X  D
 ..S I=$$VAL^XBDIQ1(9002011.01,X,.01)
 ..I '$$ICD^BGP5UTL2($$VALI^XBDIQ1(9002011.01,X,.01),$O(^ATXAX("B","BGP ALCOHOL SCREEN DXS",0)),9),I'="29.1" Q
 ..S BGPSC=BGPSC+1,BGPALL(BGPIVD,BGPSC)=1_U_"BH POV "_I_U_$$DATE^BGP5UTL(BGPVD)_U_BGPVD
 ..Q
BHMEAS .;
 .S X=0 F  S X=$O(^AMHRMSR("AD",V,X)) Q:X'=+X  D
 ..S I=$$VAL^XBDIQ1(9002011.12,X,.01)
 ..I I'="AUDT",I'="AUDC",I'="CRFT" Q
 ..S BGPSC=BGPSC+1
 ..S R=$$VAL^XBDIQ1(9002011.12,X,.04)
 ..S T=""
 ..I I="AUDT",R>7 S T=1
 ..I I="AUDC",$P(^DPT(P,0),U,2)="M",R>3 S T=1
 ..I I="AUDC",$P(^DPT(P,0),U,2)="F",R>2 S T=1
 ..I I="CRFT",R>1,R<7 S T=1
 ..S BGPALL(BGPIVD,BGPSC)=1_"^BH Meas "_I_"^"_$$DATE^BGP5UTL(BGPVD)_U_BGPVD_U_T_U_$S(T=1:"POSITIVE: "_R,1:"NEGATIVE")
BHCPT .;now add in CPT codes
 .S X=0 F  S X=$O(^AMHRPROC("AD",V,X)) Q:X'=+X  D
 ..S I=$P($G(^AUPNVCPT(X,0)),U,1)
 ..Q:'I
 ..Q:'$$ICD^BGP5UTL2(I,BGPCT,1)
 ..S J=$P(^ICPT(I,0),U,1)
 ..S R=$S($$ICD^BGP5UTL2(I,$O(^ATXAX("B","BGP ALCOHOL POSITIVE SCRN CPTS",0)),1):"POSITIVE",1:"")
 ..S BGPSC=BGPSC+1
 ..S BGPALL(BGPIVD,BGPSC)=1_"^BH CPT "_J_"^"_$$DATE^BGP5UTL(BGPVD)_U_BGPVD_U_$S(R="POSITIVE":1,1:0)_U_R
 ..Q
 .Q
 Q