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

BUDHRP6R.m

Go to the documentation of this file.
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 ""