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

BUDHRP6X.m

Go to the documentation of this file.
BUDHRP6X ; IHS/CMI/LAB - measure C ; 13 Jun 2018  4:06 PM
 ;;13.0;IHS/RPMS UNIFORM DATA SYSTEM;;OCT 12, 2018;Build 90
 ;
CNTDTAP ;
 NEW X,Y,C
 S (X,Y)="",C=0 F  S X=$O(BUDDTAP(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDDTAP(X) Q
 .S Y=X
 ;now count
 S BUDDTAP=0,X=0 F  S X=$O(BUDDTAP(X)) Q:X'=+X  S BUDDTAP=BUDDTAP+1
 Q
RESETD ;RESET DUPES
 NEW X,Y,C
 S (X,Y)="",C=0 F  S X=$O(BUDDT(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDDT(X) Q
 .S Y=X
 S (X,Y)="",C=0 F  S X=$O(BUDDIP(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDDIP(X) Q
 .S Y=X
 S (X,Y)="",C=0 F  S X=$O(BUDTET(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDTET(X) Q
 .S Y=X
 S (X,Y)="",C=0 F  S X=$O(BUDTD(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDTD(X) Q
 .S Y=X
 S (X,Y)="",C=0 F  S X=$O(BUDPER(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDPER(X) Q
 .S Y=X
 S BUDDT=0,X=0 F  S X=$O(BUDDT(X)) Q:X'=+X  S BUDDT=BUDDT+1
 S BUDTD=0,X=0 F  S X=$O(BUDTD(X)) Q:X'=+X  S BUDTD=BUDTD+1
 S BUDDIP=0,X=0 F  S X=$O(BUDDIP(X)) Q:X'=+X  S BUDDIP=BUDDIP+1
 S BUDTET=0,X=0 F  S X=$O(BUDTET(X)) Q:X'=+X  S BUDTET=BUDTET+1
 S BUDPER=0,X=0 F  S X=$O(BUDPER(X)) Q:X'=+X  S BUDPER=BUDPER+1
 Q
DTAP(P,BDATE,EDATE) ;EP
 NEW BUDTET,BUDVS,TIEN,TIENDT,TIENTET,TIENDIP,TIENPER,CTR,VIEN,VDATE,X,Y,BUDX,BUDDT,BUDADT,BUDDIP,BUDPER,BUDDTAP,BUDPEREV,BUDHVTD,BUDHVIP,BUDCOTET,BUDCOPER,BUDCODIP,C,BUDG,BUDA,Z,G,A
 ;
DTAPIM ;
 S BUDTET=0
 D ALLV^APCLAPIU(P,BDATE,EDATE,"BUDVS")  ;all visits in 42 days to end
 S TIEN=$O(^BUDHTSSC("B","T6B IMM DTAP CODES",0))
 S TIENDT=$O(^BUDHTSSC("B","T6B IMM DT CODES",0))
 S TIENTET=$O(^BUDHTSSC("B","T6B IMM TETANUS CODES",0))
 S TIENDIP=$O(^BUDHTSSC("B","T6B IMM DIPHTHERIA CODES",0))
 S TIENPER=$O(^BUDHTSSC("B","T6B IMM PERTUSSIS 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 X=0 F  S X=$O(^AUPNVIMM("AD",VIEN,X)) Q:X'=+X  D
 ..Q:'$D(^AUPNVIMM(X,0))
 ..S Y=$$VALI^XBDIQ1(9000010.11,X,.01)
 ..S Y=+$P($G(^AUTTIMM(Y,0)),U,3)
 ..Q:'Y
 ..I $D(^BUDHTSSC(TIEN,15,"B",Y)) S BUDX(VDATE)="CVX "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC(TIENDT,15,"B",Y)) S BUDDT(VDATE)="CVX "_Y_" on "_$$DATE^BUDHUTL1(VDATE),BUDADT(VDATE)="CVX "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC(TIENTET,15,"B",Y)) S BUDTET(VDATE)="CVX "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC(TIENDIP,15,"B",Y)) S BUDDIP(VDATE)="CVX "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC(TIENPER,15,"B",Y)) S BUDPER(VDATE)="CVX "_Y_" on "_$$DATE^BUDHUTL1(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 BUDX(VDATE)="CPT "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AC",Y,TIENDT)) S BUDDT(VDATE)="CPT "_Y_" on "_$$DATE^BUDHUTL1(VDATE),BUDADT(VDATE)="CPT "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AC",Y,TIENTET)) S BUDTET(VDATE)="CPT "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AC",Y,TIENDIP)) S BUDDIP(VDATE)="CPT "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AC",Y,TIENPER)) S BUDPER(VDATE)="CPT "_Y_" on "_$$DATE^BUDHUTL1(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 BUDX(VDATE)="CPT/TRAN "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AC",Y,TIENDT)) S BUDDT(VDATE)="CPT/TRAN "_Y_" on "_$$DATE^BUDHUTL1(VDATE),BUDADT(VDATE)="CPT/TRAN "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AC",Y,TIENTET)) S BUDTET(VDATE)="CPT/TRAN "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AC",Y,TIENDIP)) S BUDDIP(VDATE)="CPT/TRAN "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AC",Y,TIENPER)) S BUDPER(VDATE)="CPT/TRAN "_Y_" on "_$$DATE^BUDHUTL1(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 BUDX(VDATE)="PROC "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AP",Y,TIENDT)) S BUDDT(VDATE)="PROC "_Y_" on "_$$DATE^BUDHUTL1(VDATE),BUDADT(VDATE)="PROC "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AP",Y,TIENTET)) S BUDTET(VDATE)="PROC "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AP",Y,TIENDIP)) S BUDDIP(VDATE)="PROC "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AP",Y,TIENPER)) S BUDPER(VDATE)="PROC "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 .S X=0 F  S X=$O(^AUPNVPOV("AD",VIEN,X)) Q:X'=+X  D
 ..Q:'$D(^AUPNVPOV(X,0))
 ..S Y=$$VAL^XBDIQ1(9000010.07,X,1101)
 ..Q:Y=""
 ..I $D(^BUDHTSSC("AS",Y,TIEN)) S BUDX(VDATE)="SNOMED "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AS",Y,TIENDT)) S BUDDT(VDATE)="SNOMED "_Y_" on "_$$DATE^BUDHUTL1(VDATE),BUDADT(VDATE)="SNOMED "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AS",Y,TIENTET)) S BUDTET(VDATE)="SNOMED "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AS",Y,TIENDIP)) S BUDDIP(VDATE)="SNOMED "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ..I $D(^BUDHTSSC("AS",Y,TIENPER)) S BUDPER(VDATE)="SNOMED "_Y_" on "_$$DATE^BUDHUTL1(VDATE) Q
 ;go through and set into DTAP if 10 days apart
 S X=0 F  S X=$O(BUDX(X)) Q:X'=+X  S BUDDTAP(X)=BUDX(X)
 D CNTDTAP  ;count to see if there are 4
 I BUDDTAP>3 S Y="1^DTap: total #: "_BUDDTAP,X=0 F  S X=$O(BUDDTAP(X)) Q:X'=+X  S Y=Y_"  "_BUDDTAP(X)
 I BUDDTAP>3 Q Y
 S (BUDPEREV,BUDHVTD,BUDHVDIP,BUDCOTET,BUDCOPER,BUDCODIP)=""
 ;now check contra to DTap
 S Y=$$CONTDTAP(P,$$DOB^AUPNPAT(P),EDATE)
 I Y Q Y
DT1 ;
 ;kill off any that are on the same day as the dtaps
 S (X,Y)="",C=0 F  S X=$O(BUDDT(X)) Q:X'=+X  I $D(BUDDTAP(X)) K BUDDT(X)
 S (X,Y)="",C=0 F  S X=$O(BUDDT(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDDT(X) Q
 .S Y=X
 K BUDALL
 S BUDDT=0,X=0 F  S X=$O(BUDDT(X)) Q:X'=+X  S BUDDT=BUDDT+1,BUDALL(X)=BUDDT(X)
 S BUDDTAP=0,X=0 F  S X=$O(BUDDTAP(X)) Q:X'=+X  S BUDDTAP=BUDDTAP+1,BUDALL(X)=BUDDTAP(X)
 S (X,Y)="",C=0 F  S X=$O(BUDALL(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDALL(X) Q
 .S Y=X
 S BUDALL=0 S X=0 F  S X=$O(BUDALL(X)) Q:X'=+X  S BUDALL=BUDALL+1
 I BUDALL>3 D  Q "1^"_Y
 .S Y=">=1 DTap & DT/TdS",X=0 F  S X=$O(BUDDTAP(X)) Q:X'=+X  S Y=Y_" "_BUDDTAP(X)
 .S X=0 F  S X=$O(BUDDT(X)) Q:X'=+X  S Y=Y_" "_BUDDT(X)
 ;
TETCVX ;
 S BUDTET=0
 ;EVIDENCE?
 S BUDHVTD=""
 K BUDG S %=P_"^LAST DX 037.;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
 I $D(BUDG(1)) S BUDHVTD="1^Tetanus Evidence: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUDHUTL1($P(BUDG(1),U))
 K BUDG S %=P_"^LAST DX A35.;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
 I $D(BUDG(1)) S BUDHVTD="1^Tetanus Evidence: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUDHUTL1($P(BUDG(1),U))
 I $$PLCODE^BUDHDU(P,"037.",EDATE) S BUDHVTD="1^Tetanus Evidence: 037. on Problem List"
 I $$PLCODE^BUDHDU(P,"A35.",EDATE) S BUDHVTD="1^Tetanus Evidence: A35. on Problem List"
 S X=0 F  S X=$O(BUDDT(X)) Q:X'=+X  S BUDTET(X)=BUDDT(X)
 S X=0 F  S X=$O(BUDDTAP(X)) Q:X'=+X  S BUDTET(X)=BUDDTAP(X)
 S (X,Y)="",C=0 F  S X=$O(BUDTET(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDTET(X) Q
 .S Y=X
 S X=0 F  S X=$O(BUDTET(X)) Q:X'=+X  S BUDTET=BUDTET+1
DIP ;
 S BUDHVDIP=""
 ;V10.0 ICD10
 K BUDG S %=P_"^ALL DX;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
 S T=$O(^BUDHTSSC("B","T6B IMM EVIDENCE DIPHTHERIA",0))
 S X=0,BUDHVDIP="" F  S X=$O(BUDG(X)) Q:X'=+X!(BUDHVDIP]"")  D
 .S Y=+$P(BUDG(X),U,4)
 .S Y=$P($G(^AUPNVPOV(Y,0)),U,1)
 .I $D(^BUDHTSSC("AD",Y,T)) S BUDHVDIP="1^Diphtheria Evidence "_$P(BUDG(X),U,2)_" on "_$$DATE^BUDHUTL1($P(BUDG(X),U))
 S X=$$PLCL^BUDHDU(P,"T6B IMM EVIDENCE DIPHTHERIA",EDATE,0) I X S BUDHVDIP="1^Diphtheria Evidence: "_$P(X,U,2)_" on Problem List"
 S X=0 F  S X=$O(BUDDT(X)) Q:X'=+X  S BUDDIP(X)=BUDDT(X)
 S X=0 F  S X=$O(BUDDTAP(X)) Q:X'=+X  S BUDDIP(X)=BUDDTAP(X)
 S (X,Y)="",C=0 F  S X=$O(BUDDIP(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDDIP(X) Q
 .S Y=X
 S X=0,BUDDIP=0 F  S X=$O(BUDDIP(X)) Q:X'=+X  S BUDDIP=BUDDIP+1
 ;
PER ;
 S BUDPEREV=""
 ;V10.0 ICD10
 K BUDG S %=P_"^ALL DX;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
 S T=$O(^BUDHTSSC("B","T6B IMM EVIDENCE PERTUSSIS",0))
 S X=0,BUDPEREV="" F  S X=$O(BUDG(X)) Q:X'=+X!(BUDPEREV]"")  D
 .S Y=+$P(BUDG(X),U,4)
 .S Y=$P($G(^AUPNVPOV(Y,0)),U,1)
 .I $D(^BUDHTSSC("AD",Y,T)) S BUDPEREV="1^Pertussis: Evidence "_$P(BUDG(X),U,2)_" on "_$$DATE^BUDHUTL1($P(BUDG(X),U))
 S X=$$PLCL^BUDHDU(P,"T6B IMM EVIDENCE PERTUSSIS",EDATE,0) I X S BUDPEREV="1^Pertussis: Evidence "_$P(X,U,2)_" on Problem List"
 S X=0 F  S X=$O(BUDDTAP(X)) Q:X'=+X  S BUDPER(X)=BUDDTAP(X)
 S (X,Y)="",C=0 F  S X=$O(BUDPER(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<11 K BUDPER(X) Q
 .S Y=X
 S X=0,BUDPER=0 F  S X=$O(BUDPER(X)) Q:X'=+X  S BUDPER=BUDPER+1
 I BUDPER<4,'BUDPEREV S BUDCOPER=$$CONTRA^BUDHRP6C(P,$$DOB^AUPNPAT(P),EDATE,$O(^BUDHTSSC("B","T6B IMM PERTUSSIS CODES",0)),"PERTUSSIS")
 I BUDDIP<4,'BUDHVDIP S BUDCODEP=$$CONTRA^BUDHRP6C(P,$$DOB^AUPNPAT(P),EDATE,$O(^BUDHTSSC("B","T6B IMM DIPHTHERIA CODES",0)),"DIPHTHERIA")
 I BUDTET<4,'BUDHVTD S BUDCOTET=$$CONTRA^BUDHRP6C(P,$$DOB^AUPNPAT(P),EDATE,$O(^BUDHTSSC("B","T6B IMM TETANUS CODES",0)),"TETANUS")
CHK ;4 of each or evidence
 S BUDA(1)=$P(BUDHVDIP,U)_U_"DIP: Evidence"_U_$P(BUDHVDIP,U,2)
 S X=0,Y="" F  S X=$O(BUDDIP(X)) Q:X'=+X  S Y=Y_" "_BUDDIP(X)
 S BUDA(2)=$S(BUDDIP>3:1,1:0)_U_"DIP: total #: 4"_U_Y
 S BUDA(3)=$P(BUDCODIP,U)_U_"DIP: CONTRA"_U_$P(BUDCODIP,U,2)
 ;
 S BUDA(4)=$P(BUDHVTD,U)_U_"Tetanus: Evidence"_U_$P(BUDHVTD,U,2)
 S X=0,Y="" F  S X=$O(BUDETT(X)) Q:X'=+X  S Y=Y_" "_BUDTET(X)
 S BUDA(5)=$S(BUDTET>3:1,1:0)_U_"Tetanus: total #: 4"_U_Y
 S BUDA(6)=$P(BUDCOTET,U)_U_"Tetanus: CONTRA"_U_$P(BUDCOTET,U,2)
 ;
 S BUDA(7)=$P(BUDPEREV,U)_U_"Perussis: Evidence"_U_$P(BUDPEREV,U,2)
 S X=0,Y="" F  S X=$O(BUDPER(X)) Q:X'=+X  S Y=Y_" "_BUDPER(X)
 S BUDA(8)=$S(BUDPER>3:1,1:0)_U_"Pertussis: total #: 4"_U_Y
 S BUDA(9)=$P(BUDCOPER,U)_U_"Pertussis: CONTRA"_U_$P(BUDCOPER,U,2)
 ;
 S G=""
 F X=1,2,3 D  Q:G]""
 .F Y=4,5,6 D  Q:G]""
 ..F Z=7,8,9 D  Q:G]""
 ...I $P(BUDA(X),U,1),$P(BUDA(Y),U,1),$P(BUDA(Z),U,1) D
 ....S G=1_U_$P(BUDA(X),U,2)_", "_$P(BUDA(Y),U,2)_", "_$P(BUDA(Z),U,2)
 ....S A="",A=$P(BUDA(X),U,3)_", "_$P(BUDA(Y),U,3)_", "_$P(BUDA(Z),U,3)
 ....S G=G_"  "_A
 I G]"" Q G
 S Y="0^"
 I BUDDIP<4,'BUDHVDIP S Y=Y_(4-BUDDIP)_" DIP "
 I BUDTET<4,'BUDHVTD S Y=Y_(4-BUDTET)_" TET "
 I BUDPER<4,'BUDPEREV S Y=Y_(4-BUDPER)_" PER"
 Q Y
CONTDTAP(P,BDATE,EDATE) ;
 NEW BUDG,X,G,Z,E,%,T,S,BUDZ
 ;
 ;CONTRA ALL VACCINES
 S X=$$CONTRA^BUDHRP6C(P,$$DOB^AUPNPAT(P),EDATE,$O(^BUDHTSSC("B","T6B IMM DTAP CODES",0)),"DTAP")
 I X Q X
 ;
 ;CONTRA IMM PKG ANAPHYLACTIC
 ;ANALPHYLAXIS IMM PKG
 S BUDZ=0,X=""
 S T=$O(^BUDHTSSC("B","T6B IMM DTAP CODES",0))
 F  S BUDZ=$O(^BUDHTSSC(T,15,"B",BUDZ)) Q:BUDZ=""!(X]"")  S X=$$ANALCONT^BUDHRP6C(P,BUDZ,EDATE)  ;ANALPHYLAXIS
 I X]"" Q "1^DTAP: CONTRA IMM package: "_$$DATE^BUDHUTL1($P(X,U))_" "_$P(X,U,2)
 ;
 ;SNOMED ANALPHALACTIC V POV OR PROBLEM LIST?
 S T=$O(^BUDHTSSC("B","T6B IMM CONTRA DTAP",0))
 S (X,Y,I)=0
 F  S X=$O(^AUPNPROB("AC",P,X)) Q:X'=+X!(I)  D
 .Q:'$D(^AUPNPROB(X,0))
 .Q:$P(^AUPNPROB(X,0),U,12)="D"
 .I $P(^AUPNPROB(X,0),U,13),$P(^AUPNPROB(X,0),U,13)>EDATE Q  ;if there is a doo and it is after report period skip
 .I $P(^AUPNPROB(X,0),U,13)="",$P(^AUPNPROB(X,0),U,8)>EDATE Q  ;entered after report period, skip
 .S S=$$VAL^XBDIQ1(9000011,X,80001)
 .I S]"",$D(^BUDHTSSC("AS",S,T)) S I="1^DTAP: CONTRA PL "_S Q
 .Q
 I I Q I
 ;NOW V POV SNOMED
 S G="",I=""
 S S="" F  S S=$O(^AUPNVPOV("ASNC",P,S)) Q:S=""!(G)  D
 .S I=0
 .I $D(^BUDHTSSC("AS",S,T)) S I="1^DTAP: CONTRA POV "_S
 .Q:'I
 .S D=0 F  S D=$O(^AUPNVPOV("ASNC",P,S,D)) Q:D=""!(G)  D
 ..S Y=9999999-D
 ..Q:Y>EDATE
 ..S G=I_"^"_$$DATE^BUDHUTL1(Y)
 I G Q G
N1 ;ENCEPHALOPATHY
 ;V POV OR PROBLEM LIST
 NEW X,Y,Z,G,T,S,D,BUDG,BUDZ
 S G=$$PLTAXND^BUDHDU(P,"BGP IPC IZ ENCEPHALOPATHY DXS",EDATE,0) I G Q "1^DTAP: CONTRA DX/SNOMED "_$P(G,U,2)_" on "_$$DATE^BUDHUTL1($P(G,U,3))
 S G=$$IPLSNOND^BUDHDU(P,"T6B IMM CONTRA ENCEPH",EDATE,0) I G Q "1^DTAP: CONTRA DX/SNOMED "_$P(G,U,2)_" on "_$$DATE^BUDHUTL1($P(G,U,3))
 S G=$$LASTDX^BUDHUTL1(P,"BGP IPC IZ ENCEPHALOPATHY DXS",$$DOB^AUPNPAT(P),EDATE) I G Q "1^DTAP: CONTRA DX/SNOMED "_$P(G,U,2)_" on "_$$DATE^BUDHUTL1($P(G,U,3))
 ;NOW V POV SNOMED
 ;NOW SNOMED USING ASNC
 S T=$O(^BUDHTSSC("B","T6B IMM CONTRA ENCEPH",0))
 S G=""
 S S=0 F  S S=$O(^BUDHTSSC(T,13,"B",S)) Q:S=""!(G)  D
 .Q:'$D(^AUPNVPOV("ASNC",P,S))
 .S D=0 F  S D=$O(^AUPNVPOV("ASNC",P,S,D)) Q:D=""!(G)  D
 ..S Y=9999999-D
 ..Q:Y>EDATE
 ..S G="1^DTAP: CONTRA DX/SNOMED "_S_" on "_$$DATE^BUDHUTL1(Y)
 Q G