BUDHRP6R ; IHS/CMI/LAB - UDS REPORT PROCESSOR ;
;;13.0;IHS/RPMS UNIFORM DATA SYSTEM;;OCT 12, 2018;Build 90
;
G ;EP
NEW BUDGOT,BUDX18RB,BUDX18TH,X,BUDTOBS,BUDTOBD,BUDTOBDD,BUDB24M
S BUDGOT=""
S BUDDOB=$P(^DPT(DFN,0),U,3)
S BUDX18RB=($E(BUDBD,1,3)-19)_"1231"
Q:BUDDOB>BUDX18RB
S BUDX18TH=$E(BUDDOB,1,3)+18_$E(BUDDOB,4,7)
I '$$VBBD^BUDHRP6V(DFN,BUDX18TH,BUDED) Q ; seen after 18th birthday
I BUDMEDV>1 G N ;AT LEAST 2 MED VISITS OR 1 PREVENTATIVE
S X=$$PREVV^BUDHRP6U(DFN,BUDBD,BUDED)
Q:X<1
S B=$E(BUDED,1,3)-1_$E(BUDBD,4,7)
S B=$$FMADD^XLFDT(B,-29)
Q:$$NOSCREEN(DFN,B,BUDED)
S B=$E(BUDED,1,3)-1_$E(BUDBD,4,7)
S B=$$FMADD^XLFDT(B,-29)
Q:$$OTHER(DFN,B,BUDED)
N ;
S (BUDTOBS,BUDCESS,BUDUSER)=""
S BUDTOBDD=$E(BUDBD,1,3)-1_$E(BUDBD,4,7)
S BUDB24M=$$VD^APCLV(BUDLASTV),BUDB24M=$E(BUDB24M,1,3)-2_$E(BUDB24M,4,7)
S BUDB24M=$$FMADD^XLFDT(BUDB24M,-29)
S BUDUSER=$$TOBUSER(DFN,BUDB24M,BUDED)
I BUDUSER]"" S BUDTOBS=BUDUSER G C
S BUDTOBS=$$TOBSCRN(DFN,BUDB24M,BUDED) ;SCREENED IN 24 MONTHS PRIOR TO OR ON LAST VISIT
C S BUDCESS=""
I BUDTOBS]"",BUDUSER="" S BUDGOT=1
I BUDTOBS]"",BUDUSER]"" S BUDCESS=$$TOBCESS(DFN,BUDB24M,BUDED) I BUDCESS]"" S BUDGOT=1
I BUDGOT S BUDSECG1("ABM")=$G(BUDSECG1("ABM"))+1
S1 ;put the rest in demoninator
S BUDSECG1("PTS")=$G(BUDSECG1("PTS"))+1 D
.I $G(BUDTUA2L) D
..I 'BUDGOT S ^XTMP("BUDHRP6B",BUDJ,BUDH,"TUA2",BUDAGE,$P(^DPT(DFN,0),U),BUDCCOM,DFN)=BUDTOBS_"|"_$S(BUDUSER]"":$P(BUDUSER,U,1)_" "_$$DATE^BUDHUTL1($P(BUDUSER,U,3))_"|"_$P(BUDCESS,U,1)_" "_$$DATE^BUDHUTL1($P(BUDCESS,U,3)),1:"")
.I $G(BUDTUA1L) D
..I BUDGOT S ^XTMP("BUDHRP6B",BUDJ,BUDH,"TUA1",BUDAGE,$P(^DPT(DFN,0),U),BUDCCOM,DFN)=BUDTOBS_"|"_$S(BUDUSER]"":$P(BUDUSER,U,1)_" "_$$DATE^BUDHUTL1($P(BUDUSER,U,3))_"|"_$P(BUDCESS,U,1)_" "_$$DATE^BUDHUTL1($P(BUDCESS,U,3)),1:"")
Q
;
TOBCESS(P,BDATE,EDATE,PDATE) ;EP
;TOBACCO SCREENING IN DATE RANGE?
NEW BUDVS,TIEN,CTR,VIEN,VDATE,X,Y,Z,BUDTOB,TIEN1
D ALLV^APCLAPIU(P,BDATE,EDATE,"BUDVS")
S TIEN=$O(^BUDHTSSC("B","T6B TOBACCO CESSATION CODES",0))
S TIEN1=$O(^BUDHTSSC("B","T6B TOBACCO USER CODES",0))
S CTR=0 F S CTR=$O(BUDVS(CTR)) Q:CTR'=+CTR D
.S VIEN=$P(BUDVS(CTR),U,5)
.S VDATE=$P(BUDVS(CTR),U,1)
.S C=$$CLINIC^APCLV(VIEN) I C=94 S BUDTOB(9999999-VDATE)="Cl 94"_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
.;CPT
.S X=0 F S X=$O(^AUPNVCPT("AD",VIEN,X)) Q:X'=+X D
..Q:'$D(^AUPNVCPT(X,0))
..S Y=$$VAL^XBDIQ1(9000010.18,X,.01)
..Q:Y=""
..I $D(^BUDHTSSC("AC",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
.;V TRANS
.S X=0 F S X=$O(^AUPNVTC("AD",VIEN,X)) Q:X'=+X D
..Q:'$D(^AUPNVTC(X,0))
..S Y=$$VAL^XBDIQ1(9000010.33,X,.07)
..Q:Y=""
..I $D(^BUDHTSSC("AC",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
.;V PROC
.S X=0 F S X=$O(^AUPNVPRC("AD",VIEN,X)) Q:X'=+X D
..Q:'$D(^AUPNVPRC(X,0))
..S Y=$$VALI^XBDIQ1(9000010.08,X,.01)
..I $D(^BUDHTSSC("AP",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
.;POV/SNOMED
.S X=0 F S X=$O(^AUPNVPOV("AD",VIEN,X)) Q:X'=+X D
..Q:'$D(^AUPNVPOV(X,0))
..S Y=$$VALI^XBDIQ1(9000010.07,X,.01) I $D(^BUDHTSSC("AD",Y,TIEN)) S BUDTOB(9999999-VDATE)=$$VAL^XBDIQ1(9000010.07,X,.01)_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
..S Y=$$VAL^XBDIQ1(9000010.07,X,1101)
..Q:Y=""
..I $D(^BUDHTSSC("AS",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
.;V REFERRAL .01
.S X=0 F S X=$O(^AUPNVREF("AD",VIEN,X)) Q:X'=+X D
..Q:'$D(^AUPNVREF(X,0))
..S Y=$$VALI^XBDIQ1(9000010.59,X,.01) I Y]"",$D(^BUDHTSSC("AS",Y,TIEN)) S BUDTOB(9999999-VDATE)=$$VAL^XBDIQ1(9000010.59,X,.01)_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
.;PATIENT ED
.S X=0 F S X=$O(^AUPNVPED("AD",VIEN,X)) Q:X'=+X D
..Q:'$D(^AUPNVPED(X,0))
..S T=$$VALI^XBDIQ1(9000010.16,X,.01)
..Q:'T
..Q:'$D(^AUTTEDT(T,0))
..S T=$P(^AUTTEDT(T,0),U,2)
..I $P(T,"-")="TO" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
..I $P(T,"-",2)="TO" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
..I $P(T,"-",2)="SHS" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
..I $P(T,"-")="99406" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
..I $P(T,"-")="99407" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
..I $P(T,"-")="4000F" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
..I $P(T,"-")="4001F" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
..S S=$P(T,"-") I S]"",$D(^BUDHTSSC("AS",S,TIEN1)) S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
..S S=$P(T,"-") I S]"",$D(^BUDHTSSC("AS",S,TIEN)) S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE Q
I $O(BUDTOB(0)) S X=$O(BUDTOB(0)),X=BUDTOB(X) Q X
S Y=$$PLCL^BUDHDU(P,"T6B TOBACCO CESSATION CODES",EDATE,0,BDATE)
I Y Q "PL SCREEN "_$P(Y,U,2)_U_$$DATE^BUDHUTL1($P(Y,U,3))_U_$P(Y,U,3)
NEW BUDMEDS1,T1,M,E,G,Z,N,C,BUDLPED
S BUDLPED=""
D GETMEDS^BUDHUTL2(P,BDATE,EDATE,,,,,.BUDMEDS1)
;I '$D(BUDMEDS1) G PEDREF
S T=$O(^ATXAX("B","BGP CMS SMOKING CESSATION MEDS",0))
S T1=$O(^ATXAX("B","BGP CMS SMOKING CESSATION NDC",0))
S (X,G,M,E)=0,D="" F S X=$O(BUDMEDS1(X)) Q:X'=+X S V=$P(BUDMEDS1(X),U,5),Y=+$P(BUDMEDS1(X),U,4) D
.Q:'$D(^AUPNVSIT(V,0))
.Q:$$UP^XLFSTR($P($G(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
.S Z=$P($G(^AUPNVMED(Y,0)),U) ;get drug ien
.Q:'Z
.S N=$P($G(^PSDRUG(Z,0)),U)
.I $D(^ATXAX(T,21,"B",Z)) I $P(BUDLPED,U)<$P($P(^AUPNVSIT(V,0),U),".") S BUDLPED=$P($P(^AUPNVSIT(V,0),U),".")_U_"CESSATION MED - "_N Q
.I $D(^ATXAX(T,21,"B",Z))!(N["NICOTINE PATCH")!(N["NICOTINE POLACRILEX")!(N["NICOTINE INHALER")!(N["NICOTINE NASAL SPRAY") D
..I $P(BUDLPED,U)<$P($P(^AUPNVSIT(V,0),U),".") S BUDLPED=$P($P(^AUPNVSIT(V,0),U),".")_U_"CESSATION MED - "_N
.S C=$P($G(^PSDRUG(Z,2)),U,4)
.I C]"",$D(^ATXAX(T1,21,"B",C)) I $P(BUDLPED,U)<$P($P(^AUPNVSIT(V,0),U),".") S BUDLPED=$P($P(^AUPNVSIT(V,0),U),".")_U_"CESSATION MED - "_N
I BUDLPED]"" Q $P(BUDLPED,U,2)_U_$$DATE^BUDHUTL1($P(BUDLPED,U,1))_U_$P(BUDLPED,U,1) ;BUDLPED
S BUDLPED=$$PRES^BUDHRP6W(P,T,BDATE,EDATE,T1)
I BUDLPED]"" Q BUDLPED
Q ""
NDC(A,B) ;
;a is drug ien
;b is taxonomy ien
NEW BUDNDC
S BUDNDC=$P($G(^PSDRUG(A,2)),U,4)
I BUDNDC]"",B,$D(^ATXAX(B,21,"B",BUDNDC)) Q 1
Q 0
TOBUSER(P,BDATE,EDATE) ;
NEW BUDVS,TIEN,CTR,VIEN,VDATE,X,Y,Z,BUDTOB,V
D ALLV^APCLAPIU(P,BDATE,EDATE,"BUDVS")
S TIEN=$O(^BUDHTSSC("B","T6B TOBACCO USER CODES",0))
S CTR=0 F S CTR=$O(BUDVS(CTR)) Q:CTR'=+CTR D
.S VIEN=$P(BUDVS(CTR),U,5)
.S VDATE=$P(BUDVS(CTR),U,1)
.S V=""
.S X=0 F S X=$O(^AUPNVHF("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVHF(X,0))
..S Y=$$VAL^XBDIQ1(9000010.23,X,.01)
..I $D(^BUDHTSSC(TIEN,18,"B",Y)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
.;CPT
.S X=0 F S X=$O(^AUPNVCPT("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVCPT(X,0))
..S Y=$$VAL^XBDIQ1(9000010.18,X,.01)
..Q:Y=""
..I $D(^BUDHTSSC("AC",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
.;V TRANS
.S X=0 F S X=$O(^AUPNVTC("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVTC(X,0))
..S Y=$$VAL^XBDIQ1(9000010.33,X,.07)
..Q:Y=""
..I $D(^BUDHTSSC("AC",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
.;V PROC
.S X=0 F S X=$O(^AUPNVPRC("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVPRC(X,0))
..S Y=$$VALI^XBDIQ1(9000010.08,X,.01)
..I $D(^BUDHTSSC("AP",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
.;POV/SNOMED
.S X=0 F S X=$O(^AUPNVPOV("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVPOV(X,0))
..S Y=$$VALI^XBDIQ1(9000010.07,X,.01) I $D(^BUDHTSSC("AD",Y,TIEN)) S BUDTOB(9999999-VDATE)=$$VAL^XBDIQ1(9000010.07,X,.01)_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..S Y=$$VAL^XBDIQ1(9000010.07,X,1101)
..Q:Y=""
..I $D(^BUDHTSSC("AS",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
I $O(BUDTOB(0)) S X=$O(BUDTOB(0)),X=BUDTOB(X) Q X
S Y=$$PLCL^BUDHDU(P,"T6B TOBACCO USER CODES",EDATE,0,BDATE)
I Y Q "PL USER "_$P(Y,U,2)_U_$$DATE^BUDHUTL1($P(Y,U,3))_U_$P(Y,U,3)
Q ""
TOBSCRN(P,BDATE,EDATE) ;
;TOBACCO SCREENING IN DATE RANGE?
NEW BUDVS,TIEN,CTR,VIEN,VDATE,X,Y,Z,BUDTOB,V
D ALLV^APCLAPIU(P,BDATE,EDATE,"BUDVS")
S TIEN=$O(^BUDHTSSC("B","T6B TOBACCO SCREEN CODES",0))
S CTR=0 F S CTR=$O(BUDVS(CTR)) Q:CTR'=+CTR D
.S V=""
.S VIEN=$P(BUDVS(CTR),U,5)
.S VDATE=$P(BUDVS(CTR),U,1)
.S X=0 F S X=$O(^AUPNVHF("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVHF(X,0))
..S Y=$$VAL^XBDIQ1(9000010.23,X,.01)
..I $D(^BUDHTSSC(TIEN,18,"B",Y)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
.;CPT
.S X=0 F S X=$O(^AUPNVCPT("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVCPT(X,0))
..S Y=$$VAL^XBDIQ1(9000010.18,X,.01)
..Q:Y=""
..I $D(^BUDHTSSC("AC",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
.;V TRANS
.S X=0 F S X=$O(^AUPNVTC("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVTC(X,0))
..S Y=$$VAL^XBDIQ1(9000010.33,X,.07)
..Q:Y=""
..I $D(^BUDHTSSC("AC",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
.;V PROC
.S X=0 F S X=$O(^AUPNVPRC("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVPRC(X,0))
..S Y=$$VALI^XBDIQ1(9000010.08,X,.01)
..I $D(^BUDHTSSC("AP",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
.;POV/SNOMED
.S X=0 F S X=$O(^AUPNVPOV("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVPOV(X,0))
..S Y=$$VALI^XBDIQ1(9000010.07,X,.01) I $D(^BUDHTSSC("AD",Y,TIEN)) S V=1,BUDTOB(9999999-VDATE)=$$VAL^XBDIQ1(9000010.07,X,.01)_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..S Y=$$VAL^XBDIQ1(9000010.07,X,1101)
..Q:Y=""
..I $D(^BUDHTSSC("AS",Y,TIEN)) S BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
.;PATIENT ED
.S X=0 F S X=$O(^AUPNVPED("AD",VIEN,X)) Q:X'=+X!(V) D
..Q:'$D(^AUPNVPED(X,0))
..S T=$$VALI^XBDIQ1(9000010.16,X,.01)
..Q:'T
..Q:'$D(^AUTTEDT(T,0))
..S T=$P(^AUTTEDT(T,0),U,2)
..I $P(T,"-")="TO" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..I $P(T,"-",2)="TO" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..I $P(T,"-",2)="SHS" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..I $P(T,"-")="1034F" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..I $P(T,"-")="1035F" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..I $P(T,"-")="1036F" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..I $P(T,"-")="1000F" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..I $E($P(T,"-"),1,3)="F17" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..I $E($P(T,"-"),1,6)="O99.33" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..I $P(T,"-")="Z72.0" S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
..S S=$P(T,"-") I S]"",$D(^BUDHTSSC("AS",S,TIEN)) S BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE,V=1 Q
I $O(BUDTOB(0)) S X=$O(BUDTOB(0)),X=BUDTOB(X) Q X
S Y=$$PLCL^BUDHDU(P,"T6B TOBACCO SCREEN CODES",EDATE,0,BDATE)
I Y Q "PL SCREEN "_$P(Y,U,2)_U_$$DATE^BUDHUTL1($P(Y,U,3))_U_$P(Y,U,3)
Q ""
S(V) ;
S BUDDECNT=BUDDECNT+1
S ^TMP($J,"BUDDEL",BUDDECNT)=$G(V)
Q
;------
NOSCREEN(P,BDATE,EDATE) ;
NEW D,BUDG,E,%
S %=P_"^ALL DX;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
NEW X,Y,G,T,V,Z,A
S T=$O(^BUDHTSSC("B","T6B TOBACCO NO SCREEN",0))
S G=""
S X=0 F S X=$O(BUDG(X)) Q:X'=+X!(G) D
.S Y=+$P(BUDG(X),U,4)
.S Z=$P($G(^AUPNVPOV(Y,0)),U,1)
.I $D(^BUDHTSSC("AD",Z,T)) S G=1 Q
.S Y=$$VAL^XBDIQ1(9000010.07,Y,1101)
.Q:Y=""
.I $D(^BUDHTSSC("AS",Y,T)) S G=1
I G Q G
S X=$$PLCL^BUDHDU(P,"T6B TOBACCO NO SCREEN",EDATE,0,BDATE) I X Q 1 ;"PROBLEM SNOMED "_$P(X,U,2)
Q ""
OTHER(P,BDATE,EDATE) ;
NEW D,BUDG,E,%
S %=P_"^ALL DX;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
NEW X,Y,G,T,V,Z,A
S T=$O(^BUDHTSSC("B","T6B TOBACCO OTHER MEDICAL",0))
S G=""
S X=0 F S X=$O(BUDG(X)) Q:X'=+X!(G) D
.S Y=+$P(BUDG(X),U,4)
.S Z=$P($G(^AUPNVPOV(Y,0)),U,1)
.I $D(^BUDHTSSC("AD",Z,T)) S G=1 Q
.S Y=$$VAL^XBDIQ1(9000010.07,Y,1101)
.Q:Y=""
.I $D(^BUDHTSSC("AS",Y,T)) S G=1
I G Q G
S X=$$PLCL^BUDHDU(P,"T6B TOBACCO OTHER MEDICAL",EDATE,0,BDATE) I X Q 1 ;"PROBLEM SNOMED "_$P(X,U,2)
Q ""
BUDHRP6R ; IHS/CMI/LAB - UDS REPORT PROCESSOR ;
+1 ;;13.0;IHS/RPMS UNIFORM DATA SYSTEM;;OCT 12, 2018;Build 90
+2 ;
G ;EP
+1 NEW BUDGOT,BUDX18RB,BUDX18TH,X,BUDTOBS,BUDTOBD,BUDTOBDD,BUDB24M
+2 SET BUDGOT=""
+3 SET BUDDOB=$PIECE(^DPT(DFN,0),U,3)
+4 SET BUDX18RB=($EXTRACT(BUDBD,1,3)-19)_"1231"
+5 IF BUDDOB>BUDX18RB
QUIT
+6 SET BUDX18TH=$EXTRACT(BUDDOB,1,3)+18_$EXTRACT(BUDDOB,4,7)
+7 ; seen after 18th birthday
IF '$$VBBD^BUDHRP6V(DFN,BUDX18TH,BUDED)
QUIT
+8 ;AT LEAST 2 MED VISITS OR 1 PREVENTATIVE
IF BUDMEDV>1
GOTO N
+9 SET X=$$PREVV^BUDHRP6U(DFN,BUDBD,BUDED)
+10 IF X<1
QUIT
+11 SET B=$EXTRACT(BUDED,1,3)-1_$EXTRACT(BUDBD,4,7)
+12 SET B=$$FMADD^XLFDT(B,-29)
+13 IF $$NOSCREEN(DFN,B,BUDED)
QUIT
+14 SET B=$EXTRACT(BUDED,1,3)-1_$EXTRACT(BUDBD,4,7)
+15 SET B=$$FMADD^XLFDT(B,-29)
+16 IF $$OTHER(DFN,B,BUDED)
QUIT
N ;
+1 SET (BUDTOBS,BUDCESS,BUDUSER)=""
+2 SET BUDTOBDD=$EXTRACT(BUDBD,1,3)-1_$EXTRACT(BUDBD,4,7)
+3 SET BUDB24M=$$VD^APCLV(BUDLASTV)
SET BUDB24M=$EXTRACT(BUDB24M,1,3)-2_$EXTRACT(BUDB24M,4,7)
+4 SET BUDB24M=$$FMADD^XLFDT(BUDB24M,-29)
+5 SET BUDUSER=$$TOBUSER(DFN,BUDB24M,BUDED)
+6 IF BUDUSER]""
SET BUDTOBS=BUDUSER
GOTO C
+7 ;SCREENED IN 24 MONTHS PRIOR TO OR ON LAST VISIT
SET BUDTOBS=$$TOBSCRN(DFN,BUDB24M,BUDED)
C SET BUDCESS=""
+1 IF BUDTOBS]""
IF BUDUSER=""
SET BUDGOT=1
+2 IF BUDTOBS]""
IF BUDUSER]""
SET BUDCESS=$$TOBCESS(DFN,BUDB24M,BUDED)
IF BUDCESS]""
SET BUDGOT=1
+3 IF BUDGOT
SET BUDSECG1("ABM")=$GET(BUDSECG1("ABM"))+1
S1 ;put the rest in demoninator
+1 SET BUDSECG1("PTS")=$GET(BUDSECG1("PTS"))+1
Begin DoDot:1
+2 IF $GET(BUDTUA2L)
Begin DoDot:2
+3 IF 'BUDGOT
SET ^XTMP("BUDHRP6B",BUDJ,BUDH,"TUA2",BUDAGE,$PIECE(^DPT(DFN,0),U),BUDCCOM,DFN)=BUDTOBS_"|"_$SELECT(BUDUSER]"":$PIECE(BUDUSER,U,1)_" "_$$DATE^BUDHUTL1($PIECE(BUDUSER,U,3))_"|"_$PIECE(BUDCESS,U,1)_" "_$$DATE^BUDHUTL1($PIECE(BUDCE
SS,U,3)),1:"")
End DoDot:2
+4 IF $GET(BUDTUA1L)
Begin DoDot:2
+5 IF BUDGOT
SET ^XTMP("BUDHRP6B",BUDJ,BUDH,"TUA1",BUDAGE,$PIECE(^DPT(DFN,0),U),BUDCCOM,DFN)=BUDTOBS_"|"_$SELECT(BUDUSER]"":$PIECE(BUDUSER,U,1)_" "_$$DATE^BUDHUTL1($PIECE(BUDUSER,U,3))_"|"_$PIECE(BUDCESS,U,1)_" "_$$DATE^BUDHUTL1($PIECE(BUDCE
SS,U,3)),1:"")
End DoDot:2
End DoDot:1
+6 QUIT
+7 ;
TOBCESS(P,BDATE,EDATE,PDATE) ;EP
+1 ;TOBACCO SCREENING IN DATE RANGE?
+2 NEW BUDVS,TIEN,CTR,VIEN,VDATE,X,Y,Z,BUDTOB,TIEN1
+3 DO ALLV^APCLAPIU(P,BDATE,EDATE,"BUDVS")
+4 SET TIEN=$ORDER(^BUDHTSSC("B","T6B TOBACCO CESSATION CODES",0))
+5 SET TIEN1=$ORDER(^BUDHTSSC("B","T6B TOBACCO USER CODES",0))
+6 SET CTR=0
FOR
SET CTR=$ORDER(BUDVS(CTR))
IF CTR'=+CTR
QUIT
Begin DoDot:1
+7 SET VIEN=$PIECE(BUDVS(CTR),U,5)
+8 SET VDATE=$PIECE(BUDVS(CTR),U,1)
+9 SET C=$$CLINIC^APCLV(VIEN)
IF C=94
SET BUDTOB(9999999-VDATE)="Cl 94"_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+10 ;CPT
+11 SET X=0
FOR
SET X=$ORDER(^AUPNVCPT("AD",VIEN,X))
IF X'=+X
QUIT
Begin DoDot:2
+12 IF '$DATA(^AUPNVCPT(X,0))
QUIT
+13 SET Y=$$VAL^XBDIQ1(9000010.18,X,.01)
+14 IF Y=""
QUIT
+15 IF $DATA(^BUDHTSSC("AC",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
End DoDot:2
+16 ;V TRANS
+17 SET X=0
FOR
SET X=$ORDER(^AUPNVTC("AD",VIEN,X))
IF X'=+X
QUIT
Begin DoDot:2
+18 IF '$DATA(^AUPNVTC(X,0))
QUIT
+19 SET Y=$$VAL^XBDIQ1(9000010.33,X,.07)
+20 IF Y=""
QUIT
+21 IF $DATA(^BUDHTSSC("AC",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
End DoDot:2
+22 ;V PROC
+23 SET X=0
FOR
SET X=$ORDER(^AUPNVPRC("AD",VIEN,X))
IF X'=+X
QUIT
Begin DoDot:2
+24 IF '$DATA(^AUPNVPRC(X,0))
QUIT
+25 SET Y=$$VALI^XBDIQ1(9000010.08,X,.01)
+26 IF $DATA(^BUDHTSSC("AP",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
End DoDot:2
+27 ;POV/SNOMED
+28 SET X=0
FOR
SET X=$ORDER(^AUPNVPOV("AD",VIEN,X))
IF X'=+X
QUIT
Begin DoDot:2
+29 IF '$DATA(^AUPNVPOV(X,0))
QUIT
+30 SET Y=$$VALI^XBDIQ1(9000010.07,X,.01)
IF $DATA(^BUDHTSSC("AD",Y,TIEN))
SET BUDTOB(9999999-VDATE)=$$VAL^XBDIQ1(9000010.07,X,.01)_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+31 SET Y=$$VAL^XBDIQ1(9000010.07,X,1101)
+32 IF Y=""
QUIT
+33 IF $DATA(^BUDHTSSC("AS",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
End DoDot:2
+34 ;V REFERRAL .01
+35 SET X=0
FOR
SET X=$ORDER(^AUPNVREF("AD",VIEN,X))
IF X'=+X
QUIT
Begin DoDot:2
+36 IF '$DATA(^AUPNVREF(X,0))
QUIT
+37 SET Y=$$VALI^XBDIQ1(9000010.59,X,.01)
IF Y]""
IF $DATA(^BUDHTSSC("AS",Y,TIEN))
SET BUDTOB(9999999-VDATE)=$$VAL^XBDIQ1(9000010.59,X,.01)_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
End DoDot:2
+38 ;PATIENT ED
+39 SET X=0
FOR
SET X=$ORDER(^AUPNVPED("AD",VIEN,X))
IF X'=+X
QUIT
Begin DoDot:2
+40 IF '$DATA(^AUPNVPED(X,0))
QUIT
+41 SET T=$$VALI^XBDIQ1(9000010.16,X,.01)
+42 IF 'T
QUIT
+43 IF '$DATA(^AUTTEDT(T,0))
QUIT
+44 SET T=$PIECE(^AUTTEDT(T,0),U,2)
+45 IF $PIECE(T,"-")="TO"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+46 IF $PIECE(T,"-",2)="TO"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+47 IF $PIECE(T,"-",2)="SHS"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+48 IF $PIECE(T,"-")="99406"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+49 IF $PIECE(T,"-")="99407"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+50 IF $PIECE(T,"-")="4000F"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+51 IF $PIECE(T,"-")="4001F"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+52 SET S=$PIECE(T,"-")
IF S]""
IF $DATA(^BUDHTSSC("AS",S,TIEN1))
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
+53 SET S=$PIECE(T,"-")
IF S]""
IF $DATA(^BUDHTSSC("AS",S,TIEN))
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
QUIT
End DoDot:2
End DoDot:1
+54 IF $ORDER(BUDTOB(0))
SET X=$ORDER(BUDTOB(0))
SET X=BUDTOB(X)
QUIT X
+55 SET Y=$$PLCL^BUDHDU(P,"T6B TOBACCO CESSATION CODES",EDATE,0,BDATE)
+56 IF Y
QUIT "PL SCREEN "_$PIECE(Y,U,2)_U_$$DATE^BUDHUTL1($PIECE(Y,U,3))_U_$PIECE(Y,U,3)
+57 NEW BUDMEDS1,T1,M,E,G,Z,N,C,BUDLPED
+58 SET BUDLPED=""
+59 DO GETMEDS^BUDHUTL2(P,BDATE,EDATE,,,,,.BUDMEDS1)
+60 ;I '$D(BUDMEDS1) G PEDREF
+61 SET T=$ORDER(^ATXAX("B","BGP CMS SMOKING CESSATION MEDS",0))
+62 SET T1=$ORDER(^ATXAX("B","BGP CMS SMOKING CESSATION NDC",0))
+63 SET (X,G,M,E)=0
SET D=""
FOR
SET X=$ORDER(BUDMEDS1(X))
IF X'=+X
QUIT
SET V=$PIECE(BUDMEDS1(X),U,5)
SET Y=+$PIECE(BUDMEDS1(X),U,4)
Begin DoDot:1
+64 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+65 IF $$UP^XLFSTR($PIECE($GET(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
QUIT
+66 ;get drug ien
SET Z=$PIECE($GET(^AUPNVMED(Y,0)),U)
+67 IF 'Z
QUIT
+68 SET N=$PIECE($GET(^PSDRUG(Z,0)),U)
+69 IF $DATA(^ATXAX(T,21,"B",Z))
IF $PIECE(BUDLPED,U)<$PIECE($PIECE(^AUPNVSIT(V,0),U),".")
SET BUDLPED=$PIECE($PIECE(^AUPNVSIT(V,0),U),".")_U_"CESSATION MED - "_N
QUIT
+70 IF $DATA(^ATXAX(T,21,"B",Z))!(N["NICOTINE PATCH")!(N["NICOTINE POLACRILEX")!(N["NICOTINE INHALER")!(N["NICOTINE NASAL SPRAY")
Begin DoDot:2
+71 IF $PIECE(BUDLPED,U)<$PIECE($PIECE(^AUPNVSIT(V,0),U),".")
SET BUDLPED=$PIECE($PIECE(^AUPNVSIT(V,0),U),".")_U_"CESSATION MED - "_N
End DoDot:2
+72 SET C=$PIECE($GET(^PSDRUG(Z,2)),U,4)
+73 IF C]""
IF $DATA(^ATXAX(T1,21,"B",C))
IF $PIECE(BUDLPED,U)<$PIECE($PIECE(^AUPNVSIT(V,0),U),".")
SET BUDLPED=$PIECE($PIECE(^AUPNVSIT(V,0),U),".")_U_"CESSATION MED - "_N
End DoDot:1
+74 ;BUDLPED
IF BUDLPED]""
QUIT $PIECE(BUDLPED,U,2)_U_$$DATE^BUDHUTL1($PIECE(BUDLPED,U,1))_U_$PIECE(BUDLPED,U,1)
+75 SET BUDLPED=$$PRES^BUDHRP6W(P,T,BDATE,EDATE,T1)
+76 IF BUDLPED]""
QUIT BUDLPED
+77 QUIT ""
NDC(A,B) ;
+1 ;a is drug ien
+2 ;b is taxonomy ien
+3 NEW BUDNDC
+4 SET BUDNDC=$PIECE($GET(^PSDRUG(A,2)),U,4)
+5 IF BUDNDC]""
IF B
IF $DATA(^ATXAX(B,21,"B",BUDNDC))
QUIT 1
+6 QUIT 0
TOBUSER(P,BDATE,EDATE) ;
+1 NEW BUDVS,TIEN,CTR,VIEN,VDATE,X,Y,Z,BUDTOB,V
+2 DO ALLV^APCLAPIU(P,BDATE,EDATE,"BUDVS")
+3 SET TIEN=$ORDER(^BUDHTSSC("B","T6B TOBACCO USER CODES",0))
+4 SET CTR=0
FOR
SET CTR=$ORDER(BUDVS(CTR))
IF CTR'=+CTR
QUIT
Begin DoDot:1
+5 SET VIEN=$PIECE(BUDVS(CTR),U,5)
+6 SET VDATE=$PIECE(BUDVS(CTR),U,1)
+7 SET V=""
+8 SET X=0
FOR
SET X=$ORDER(^AUPNVHF("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+9 IF '$DATA(^AUPNVHF(X,0))
QUIT
+10 SET Y=$$VAL^XBDIQ1(9000010.23,X,.01)
+11 IF $DATA(^BUDHTSSC(TIEN,18,"B",Y))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
+12 ;CPT
+13 SET X=0
FOR
SET X=$ORDER(^AUPNVCPT("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+14 IF '$DATA(^AUPNVCPT(X,0))
QUIT
+15 SET Y=$$VAL^XBDIQ1(9000010.18,X,.01)
+16 IF Y=""
QUIT
+17 IF $DATA(^BUDHTSSC("AC",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
+18 ;V TRANS
+19 SET X=0
FOR
SET X=$ORDER(^AUPNVTC("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+20 IF '$DATA(^AUPNVTC(X,0))
QUIT
+21 SET Y=$$VAL^XBDIQ1(9000010.33,X,.07)
+22 IF Y=""
QUIT
+23 IF $DATA(^BUDHTSSC("AC",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
+24 ;V PROC
+25 SET X=0
FOR
SET X=$ORDER(^AUPNVPRC("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+26 IF '$DATA(^AUPNVPRC(X,0))
QUIT
+27 SET Y=$$VALI^XBDIQ1(9000010.08,X,.01)
+28 IF $DATA(^BUDHTSSC("AP",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
+29 ;POV/SNOMED
+30 SET X=0
FOR
SET X=$ORDER(^AUPNVPOV("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+31 IF '$DATA(^AUPNVPOV(X,0))
QUIT
+32 SET Y=$$VALI^XBDIQ1(9000010.07,X,.01)
IF $DATA(^BUDHTSSC("AD",Y,TIEN))
SET BUDTOB(9999999-VDATE)=$$VAL^XBDIQ1(9000010.07,X,.01)_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+33 SET Y=$$VAL^XBDIQ1(9000010.07,X,1101)
+34 IF Y=""
QUIT
+35 IF $DATA(^BUDHTSSC("AS",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
End DoDot:1
+36 IF $ORDER(BUDTOB(0))
SET X=$ORDER(BUDTOB(0))
SET X=BUDTOB(X)
QUIT X
+37 SET Y=$$PLCL^BUDHDU(P,"T6B TOBACCO USER CODES",EDATE,0,BDATE)
+38 IF Y
QUIT "PL USER "_$PIECE(Y,U,2)_U_$$DATE^BUDHUTL1($PIECE(Y,U,3))_U_$PIECE(Y,U,3)
+39 QUIT ""
TOBSCRN(P,BDATE,EDATE) ;
+1 ;TOBACCO SCREENING IN DATE RANGE?
+2 NEW BUDVS,TIEN,CTR,VIEN,VDATE,X,Y,Z,BUDTOB,V
+3 DO ALLV^APCLAPIU(P,BDATE,EDATE,"BUDVS")
+4 SET TIEN=$ORDER(^BUDHTSSC("B","T6B TOBACCO SCREEN CODES",0))
+5 SET CTR=0
FOR
SET CTR=$ORDER(BUDVS(CTR))
IF CTR'=+CTR
QUIT
Begin DoDot:1
+6 SET V=""
+7 SET VIEN=$PIECE(BUDVS(CTR),U,5)
+8 SET VDATE=$PIECE(BUDVS(CTR),U,1)
+9 SET X=0
FOR
SET X=$ORDER(^AUPNVHF("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+10 IF '$DATA(^AUPNVHF(X,0))
QUIT
+11 SET Y=$$VAL^XBDIQ1(9000010.23,X,.01)
+12 IF $DATA(^BUDHTSSC(TIEN,18,"B",Y))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
+13 ;CPT
+14 SET X=0
FOR
SET X=$ORDER(^AUPNVCPT("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+15 IF '$DATA(^AUPNVCPT(X,0))
QUIT
+16 SET Y=$$VAL^XBDIQ1(9000010.18,X,.01)
+17 IF Y=""
QUIT
+18 IF $DATA(^BUDHTSSC("AC",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
+19 ;V TRANS
+20 SET X=0
FOR
SET X=$ORDER(^AUPNVTC("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+21 IF '$DATA(^AUPNVTC(X,0))
QUIT
+22 SET Y=$$VAL^XBDIQ1(9000010.33,X,.07)
+23 IF Y=""
QUIT
+24 IF $DATA(^BUDHTSSC("AC",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
+25 ;V PROC
+26 SET X=0
FOR
SET X=$ORDER(^AUPNVPRC("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+27 IF '$DATA(^AUPNVPRC(X,0))
QUIT
+28 SET Y=$$VALI^XBDIQ1(9000010.08,X,.01)
+29 IF $DATA(^BUDHTSSC("AP",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
+30 ;POV/SNOMED
+31 SET X=0
FOR
SET X=$ORDER(^AUPNVPOV("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+32 IF '$DATA(^AUPNVPOV(X,0))
QUIT
+33 SET Y=$$VALI^XBDIQ1(9000010.07,X,.01)
IF $DATA(^BUDHTSSC("AD",Y,TIEN))
SET V=1
SET BUDTOB(9999999-VDATE)=$$VAL^XBDIQ1(9000010.07,X,.01)_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+34 SET Y=$$VAL^XBDIQ1(9000010.07,X,1101)
+35 IF Y=""
QUIT
+36 IF $DATA(^BUDHTSSC("AS",Y,TIEN))
SET BUDTOB(9999999-VDATE)=Y_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
+37 ;PATIENT ED
+38 SET X=0
FOR
SET X=$ORDER(^AUPNVPED("AD",VIEN,X))
IF X'=+X!(V)
QUIT
Begin DoDot:2
+39 IF '$DATA(^AUPNVPED(X,0))
QUIT
+40 SET T=$$VALI^XBDIQ1(9000010.16,X,.01)
+41 IF 'T
QUIT
+42 IF '$DATA(^AUTTEDT(T,0))
QUIT
+43 SET T=$PIECE(^AUTTEDT(T,0),U,2)
+44 IF $PIECE(T,"-")="TO"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+45 IF $PIECE(T,"-",2)="TO"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+46 IF $PIECE(T,"-",2)="SHS"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+47 IF $PIECE(T,"-")="1034F"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+48 IF $PIECE(T,"-")="1035F"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+49 IF $PIECE(T,"-")="1036F"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+50 IF $PIECE(T,"-")="1000F"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+51 IF $EXTRACT($PIECE(T,"-"),1,3)="F17"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+52 IF $EXTRACT($PIECE(T,"-"),1,6)="O99.33"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+53 IF $PIECE(T,"-")="Z72.0"
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
+54 SET S=$PIECE(T,"-")
IF S]""
IF $DATA(^BUDHTSSC("AS",S,TIEN))
SET BUDTOB(9999999-VDATE)=T_U_$$DATE^BUDHUTL1(VDATE)_U_VDATE
SET V=1
QUIT
End DoDot:2
End DoDot:1
+55 IF $ORDER(BUDTOB(0))
SET X=$ORDER(BUDTOB(0))
SET X=BUDTOB(X)
QUIT X
+56 SET Y=$$PLCL^BUDHDU(P,"T6B TOBACCO SCREEN CODES",EDATE,0,BDATE)
+57 IF Y
QUIT "PL SCREEN "_$PIECE(Y,U,2)_U_$$DATE^BUDHUTL1($PIECE(Y,U,3))_U_$PIECE(Y,U,3)
+58 QUIT ""
S(V) ;
+1 SET BUDDECNT=BUDDECNT+1
+2 SET ^TMP($JOB,"BUDDEL",BUDDECNT)=$GET(V)
+3 QUIT
+4 ;------
NOSCREEN(P,BDATE,EDATE) ;
+1 NEW D,BUDG,E,%
+2 SET %=P_"^ALL DX;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+3 NEW X,Y,G,T,V,Z,A
+4 SET T=$ORDER(^BUDHTSSC("B","T6B TOBACCO NO SCREEN",0))
+5 SET G=""
+6 SET X=0
FOR
SET X=$ORDER(BUDG(X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+7 SET Y=+$PIECE(BUDG(X),U,4)
+8 SET Z=$PIECE($GET(^AUPNVPOV(Y,0)),U,1)
+9 IF $DATA(^BUDHTSSC("AD",Z,T))
SET G=1
QUIT
+10 SET Y=$$VAL^XBDIQ1(9000010.07,Y,1101)
+11 IF Y=""
QUIT
+12 IF $DATA(^BUDHTSSC("AS",Y,T))
SET G=1
End DoDot:1
+13 IF G
QUIT G
+14 ;"PROBLEM SNOMED "_$P(X,U,2)
SET X=$$PLCL^BUDHDU(P,"T6B TOBACCO NO SCREEN",EDATE,0,BDATE)
IF X
QUIT 1
+15 QUIT ""
OTHER(P,BDATE,EDATE) ;
+1 NEW D,BUDG,E,%
+2 SET %=P_"^ALL DX;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+3 NEW X,Y,G,T,V,Z,A
+4 SET T=$ORDER(^BUDHTSSC("B","T6B TOBACCO OTHER MEDICAL",0))
+5 SET G=""
+6 SET X=0
FOR
SET X=$ORDER(BUDG(X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+7 SET Y=+$PIECE(BUDG(X),U,4)
+8 SET Z=$PIECE($GET(^AUPNVPOV(Y,0)),U,1)
+9 IF $DATA(^BUDHTSSC("AD",Z,T))
SET G=1
QUIT
+10 SET Y=$$VAL^XBDIQ1(9000010.07,Y,1101)
+11 IF Y=""
QUIT
+12 IF $DATA(^BUDHTSSC("AS",Y,T))
SET G=1
End DoDot:1
+13 IF G
QUIT G
+14 ;"PROBLEM SNOMED "_$P(X,U,2)
SET X=$$PLCL^BUDHDU(P,"T6B TOBACCO OTHER MEDICAL",EDATE,0,BDATE)
IF X
QUIT 1
+15 QUIT ""