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

BGP0D55.m

Go to the documentation of this file.
BGP0D55 ; IHS/CMI/LAB - measure calc ;
 ;;10.0;IHS CLINICAL REPORTING;**1**;JUN 18, 2010
 ;
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 'BGPACTCL S BGPSTOP=1 Q
 I BGPAGEB<12 S BGPSTOP=1 Q
 I BGPAGEB>75 S BGPSTOP=1 Q
 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>14,BGPAGEB<45 S BGPD8=1
 ;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^BGP0D5(DFN,BGPBDATE,BGPEDATE)
 ;
 S BGPVALUE=$S(BGPD1:"AC",1:"")_$S(BGPD8:";AC PREG",1:"")_"|||"
 I $P(BGPN1,U)=1,BGPN3 S BGPVALUE=BGPVALUE_"Alc scrn: "_$P(C,U,2)_" "_$P(C,U,3)_";"_$P(C,U,6)
 I $P(BGPN1,U)=1,'BGPN3 S BGPVALUE=BGPVALUE_"Alc dx/proc: "_$P(BGPALDX,U,2)_" "_$P(BGPALDX,U,3)
 I $P(BGPN2,U)=1 S BGPVALUE=BGPVALUE_";"_$P(BGPN2,U,2)_" "_$P(BGPN2,U,3)
 ;I $P(BGPN5,U)=1 S BGPVALUE=BGPVALUE_$P(BGPN5,U,2)_" "_$P(BGPN5,U,3)
 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^BGP0UTL($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^ATXCHK(BGPP,BGPT,9) S BGPC=1_U_"BH dx "_$P(^AMHPROB(BGPP,0),U)_U_$$DATE^BGP0UTL((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 dx "_BGPP_U_$$DATE^BGP0UTL((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)'="A"
 .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^ATXCHK(Y,BGPT,9)
 .S D=$P(^AUPNPROB(X,0),U,3)
 .S G=1_U_"PROB LIST "_$P($$ICDDX^ICDCODE(Y),U,2)_U_$$DATE^BGP0UTL((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^ATXCHK(Y,BGPT,9) S G=1_U_"BH PL "_Y_U_$$DATE^BGP0UTL($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^BGP0UTL($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^BGP0UTL1(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^BGP0UTL($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_"^exam 35^"_$$DATE^BGP0UTL(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":"",1:"POSITIVE")
 ..S BGPSC=BGPSC+1,BGPALL(BGPIVD,BGPSC)=1_"^HF: "_I_"^"_$$DATE^BGP0UTL(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 I'="V79.1",I'="V11.3" Q
 ..S BGPSC=BGPSC+1,BGPALL(BGPIVD,BGPSC)=1_U_"DX: "_I_U_$$DATE^BGP0UTL(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^ATXCHK(I,BGPCT,1)
 ..S J=$P(^ICPT(I,0),U,1)
 ..S R=$S($$ICD^ATXCHK(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^BGP0UTL(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^BGP0UTL(BGPVD)_U_BGPVD_U_T_U_"POSITIVE: "_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 exam^"_$$DATE^BGP0UTL(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":"",1:"POSITIVE")
 ..S BGPSC=BGPSC+1,BGPALL(BGPIVD,BGPSC)=1_"^BH HF: "_I_"^"_$$DATE^BGP0UTL(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 I'="V79.1",I'="V11.3",I'="29.1" Q
 ..S BGPSC=BGPSC+1,BGPALL(BGPIVD,BGPSC)=1_U_"BH DX: "_I_U_$$DATE^BGP0UTL(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^BGP0UTL(BGPVD)_U_BGPVD_U_T_U_$S(T=1:"POSITIVE: "_R,1:"NORMAL/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^ATXCHK(I,BGPCT,1)
 ..S J=$P(^ICPT(I,0),U,1)
 ..S R=$S($$ICD^ATXCHK(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^BGP0UTL(BGPVD)_U_BGPVD_U_$S(R="POSITIVE":1,1:0)_U_R
 ..Q
 .Q
 Q