BUD1RP6C ; IHS/CMI/LAB - UDS REPORT PROCESSOR 01 Dec 2011 3:10 PM 30 Dec 2011 7:19 PM ;
;;10.0;IHS/RPMS UNIFORM DATA SYSTEM;;FEB 04, 2016;Build 50
;
;
GETIMMS(P,BDATE,EDATE,C,BUDX) ;EP
K BUDX
NEW X,Y,I,Z,V
S X=0 F S X=$O(^AUPNVIMM("AC",P,X)) Q:X'=+X D
.Q:'$D(^AUPNVIMM(X,0)) ;happens
.S Y=$P(^AUPNVIMM(X,0),U)
.Q:'Y ;happens too
.S I=$P($G(^AUTTIMM(Y,0)),U,3) ;get HL7/CVX code
.F Z=1:1:$L(C,U) I I=$P(C,U,Z) S V=$P(^AUPNVIMM(X,0),U,3) I V S D=$P($P($G(^AUPNVSIT(V,0)),U),".") I D]"",D'>EDATE,D'<BDATE S BUDX(D)="CVX: "_I_" on "_$$DATE^BUD1UTL1(D)
.Q
Q
;
IMM ;EP - IMM
;must have DOB between in the year - 2
S BUD2YRB=($E(BUDBD,1,3)-2)_"0101"
S BUD2YRE=($E(BUDED,1,3)-2)_"1231"
S BUDDOB=$P(^DPT(DFN,0),U,3)
Q:BUDDOB<BUD2YRB
Q:BUDDOB>BUD2YRE
S BUD2ND=$E(BUDDOB,1,3)+2_$E(BUDDOB,4,7)
S BUD1ST=$E(BUDDOB,1,3)+1_$E(BUDDOB,4,7)
;
Q:BUDMEDV<1 ;didn't have at least 1 medical visit
S BUDVBBD=$$VBBD^BUD1RP6D(DFN,BUDDOB,$$FMADD^XLFDT(BUD2ND,-1)) I 'BUDVBBD Q ;no visit before 2nd bd
S BUDSECTC("PTS")=$G(BUDSECTC("PTS"))+1
S BUD42D=$$FMADD^XLFDT(BUDDOB,42)
S BUD180D=$$FMADD^XLFDT(BUDDOB,180)
S (BUDNDTP,BUDNIPV,BUDNMMR,BUDNHEP,BUDNHIB,BUDNVAR,BUDNPNEU)=""
;see if ever had a 999.4 before 2nd birthday
S BUDCTA=""
S X=$$CONTRA(DFN,BUDDOB,BUD2ND)
I X S BUDCTA=X
I BUDCTA D Q
.S BUDSECTC("IMM")=$G(BUDSECTC("IMM"))+1 D Q
..I $G(BUDIMM1L) D
...S ^XTMP("BUD1RP6B",BUDJ,BUDH,"IMM1",$P(^DPT(DFN,0),U),BUDCOM,DFN)="CONTRA ALL: 999.4 on "_$$FMTE^XLFDT(X)_"|||"_BUDVBBD_U_BUDMEDVI
..Q
S BUDNDTP=$$DTAP^BUD1RP6X(DFN,BUD42D,BUD2ND)
S BUDNIPV=$$IPV(DFN,BUD42D,BUD2ND)
S BUDNMMR=$$MMR(DFN,BUDDOB,BUD2ND)
S BUDNHEP=$$HEP^BUD1RP6Y(DFN,BUDDOB,BUD2ND)
S BUDNHIB=$$HIB^BUD1RP6Y(DFN,BUD42D,BUD2ND)
S BUDNVAR=$$VAR^BUD1RP6Y(DFN,BUD1ST,BUD2ND)
S BUDNPNEU=$$PNEU^BUD1RP6Y(DFN,BUDDOB,BUD2ND)
S BUDNHEPA=$$HEPA^BUD1RP6Y(DFN,BUDDOB,BUD2ND)
S BUDNROTA=$$ROTA^BUD1RP6W(DFN,BUD42D,BUD2ND)
S BUDNFLU=$$FLU^BUD1RP6Y(DFN,BUD180D,BUD2ND)
I $P(BUDNDTP,U,1)=1,$P(BUDNIPV,U,1)=1,$P(BUDNMMR,U,1)=1,$P(BUDNHEP,U,1)=1,$P(BUDNHIB,U,1)=1,$P(BUDNVAR,U,1)=1,$P(BUDNPNEU,U,1)=1,$P(BUDNHEPA,U,1)=1,$P(BUDNROTA,U,1)=1,$P(BUDNFLU,U,1)=1 S BUDSECTC("IMM")=$G(BUDSECTC("IMM"))+1 D Q
.I $G(BUDIMM1L) D
..S X=$P(BUDNDTP,U,2)_U_$P(BUDNIPV,U,2)_U_$P(BUDNMMR,U,2)_U_$P(BUDNHEP,U,2)_U_$P(BUDNHIB,U,2)_U_$P(BUDNVAR,U,2)_U_$P(BUDNPNEU,U,2)_U_$P(BUDNHEPA,U,2)_U_$P(BUDNROTA,U,2)_U_$P(BUDNFLU,U,2)_"|||"_BUDVBBD_U_BUDMEDVI
..S ^XTMP("BUD1RP6B",BUDJ,BUDH,"IMM1",$P(^DPT(DFN,0),U),BUDCOM,DFN)=X
..Q
I $G(BUDIMM2L) D
.S V=$S($P(BUDNDTP,U,1)=1:"",1:$P(BUDNDTP,U,2))_$S($P(BUDNIPV,U,1)=1:"",1:";"_$P(BUDNIPV,U,2))_$S($P(BUDNMMR,U,1)=1:"",1:";"_$P(BUDNMMR,U,2))_$S($P(BUDNHEP,U,1)=1:"",1:";"_$P(BUDNHEP,U,2))
.S V=V_$S($P(BUDNHIB,U,1)=1:"",1:";"_$P(BUDNHIB,U,2))_$S($P(BUDNVAR,U,1)=1:"",1:";VARI")_$S($P(BUDNPNEU,U,1)=1:"",1:";"_$P(BUDNPNEU,U,2))_$S($P(BUDNHEPA,U,1)=1:"",1:";"_$P(BUDNHEPA,U,2))_$S($P(BUDNROTA,U,1)=1:"",1:";"_$P(BUDNROTA,U,2))
.S V=V_$S($P(BUDNFLU,U,1)=1:"",1:";"_$P(BUDNFLU,U,2))
.S ^XTMP("BUD1RP6B",BUDJ,BUDH,"IMM2",$P(^DPT(DFN,0),U),BUDCOM,DFN)=V
Q
;
CONTRA(P,BD,ED) ;EP
NEW D,BUDG,E,%
K BUDG S %=P_"^LAST DX 999.4;DURING "_BD_"-"_ED,E=$$START1^APCLDF(%,"BUDG(")
Q $P($G(BUDG(1)),U)
ANAREACT(I) ;EP
NEW X,Y,R
S X=0,Y=0 F S X=$O(^GMR(120.8,I,10,X)) Q:X'=+X D
.S R=$P($G(^GMR(120.8,I,10,X,0)),U)
.Q:R=""
.S R=$P($G(^GMRD(120.83,R,0)),U)
.I R'="ANAPHYLAXIS" Q
.S Y=1
.Q
Q Y
;
ANCONT(P,C,ED) ;EP - ANALPHYLAXIS CONTRA
NEW X
S X=0,G="",Y=$O(^AUTTIMM("C",C,0)) I Y F S X=$O(^BIPC("AC",P,Y,X)) Q:X'=+X!(G) D
.S R=$P(^BIPC(X,0),U,3)
.Q:R=""
.Q:'$D(^BICONT(R,0))
.S D=$P(^BIPC(X,0),U,4)
.Q:D=""
.;Q:$P(^BIPC(X,0),U,4)<BD
.;Q:$P(^BIPC(X,0),U,4)>ED
.I $P(^BICONT(R,0),U,1)="Anaphylaxis" S G=D_U_"Anaphylaxis"
Q G
;
EGGCONT(P,C,ED) ;EP - EGG CONTRA
NEW X
S X=0,G="",Y=$O(^AUTTIMM("C",C,0)) I Y F S X=$O(^BIPC("AC",P,Y,X)) Q:X'=+X!(G) D
.S R=$P(^BIPC(X,0),U,3)
.Q:R=""
.Q:'$D(^BICONT(R,0))
.S D=$P(^BIPC(X,0),U,4)
.Q:D=""
.;Q:$P(^BIPC(X,0),U,4)<BD
.;Q:$P(^BIPC(X,0),U,4)>ED
.I $P(^BICONT(R,0),U,1)="Egg Allergy" S G=D_U_"Egg Allergy"
Q G
ANNECONT(P,C,ED) ;EP - ANALPHYLAXIS/NEOMYCIN CONTRA
NEW X
S X=0,G="",Y=$O(^AUTTIMM("C",C,0)) I Y F S X=$O(^BIPC("AC",P,Y,X)) Q:X'=+X!(G) D
.S R=$P(^BIPC(X,0),U,3)
.Q:R=""
.Q:'$D(^BICONT(R,0))
.S D=$P(^BIPC(X,0),U,4)
.Q:D=""
.;Q:$P(^BIPC(X,0),U,4)<BD
.;Q:$P(^BIPC(X,0),U,4)>ED
.I $P(^BICONT(R,0),U,1)="Anaphylaxis" S G=D_U_"Anaphylaxis"
.I $P(^BICONT(R,0),U,1)="Neomycin Allergy" S G=D_U_"Neomycin Allergy"
Q G
;
MMRCONT(P,C,ED) ;EP - ANALPHYLAXIS/NEOMYCIN/IMMUNE CONTRA
NEW X
S X=0,G="",Y=$O(^AUTTIMM("C",C,0)) I Y F S X=$O(^BIPC("AC",P,Y,X)) Q:X'=+X!(G) D
.S R=$P(^BIPC(X,0),U,3)
.Q:R=""
.Q:'$D(^BICONT(R,0))
.S D=$P(^BIPC(X,0),U,4)
.Q:D=""
.;Q:$P(^BIPC(X,0),U,4)<BD
.;Q:$P(^BIPC(X,0),U,4)>ED
.I $P(^BICONT(R,0),U,1)="Anaphylaxis" S G=D_U_"Anaphylaxis"
.I $P(^BICONT(R,0),U,1)="Neomycin Allergy" S G=D_U_"Neomycin Allergy"
.I $P(^BICONT(R,0),U,1)="Immune Deficiency" S G=D_U_"Immune Deficiency"
.I $P(^BICONT(R,0),U,1)["Immune Deficient" S G=D_U_"Immune Deficient"
.I $P(^BICONT(R,0),U,1)="Immune" S G=D_U_"Immune"
Q G
;
IPV(P,BDATE,EDATE) ;EP
;check for a contraindication from DOB to 2nd birthday
NEW X,G,N,BUDG,BUDX,BUDC,BUDOPV,BUDAPOV,C,BD,ED,V,Y,E
IPVCONT ;check allergy tracking
S G=""
S X=0 F S X=$O(^GMR(120.8,"B",P,X)) Q:X'=+X!(G) D
.;Q:$P($P($G(^GMR(120.8,X,0)),U,4),".")>EDATE ;entered after 2ND birthday
.S N=$P($G(^GMR(120.8,X,0)),U,2),N=$$UP^XLFSTR(N)
.I N["STREPTOMYCIN"!(N["POLYMYXIN B")!(N["NEOMYCIN") S G="1^IPV Contraindiction: "_$$DATE^BUD1UTL1($P($P($G(^GMR(120.8,X,0)),U,4),"."))_" Allergy Tracking: "_N
.Q:'$$ANAREACT(X) ;quit if anaphylactic is not a reaction/sign/symptom
I G]"" Q G
;now check immunization package
F BUDZ=10,89,110,120,130,132 S X=$$ANNECONT(P,BUDZ,EDATE) Q:X]""
I X]"" Q "1^IPV Contraindication IM package: "_$$DATE^BUD1UTL1($P(X,U))_" "_$P(X,U,2)
;now check for evidence of disease
IPVEVID ;
K BUDG S %=P_"^LAST DX [BUD IPV EVID DISEASE;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
I $D(BUDG(1)) Q "1^IPV Evidence: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U))
;S X=$$PLTAX^BUD1DU(P,"BUD IPV EVID DISEASE") I X Q "IPV Evidence: Problem List "_$P(X,U,2)
;now get imms and see if there are 3
K BUDC,BUDG,BUDX
K BUDOPV,BUDAPOV
IPVIMM ;get all immunizations
S C="10^89^110^120^130^132"
K BUDX D GETIMMS(P,BDATE,EDATE,C,.BUDX)
;now get cpt codes
S X=0 F S X=$O(BUDX(X)) Q:X'=+X S BUDOPV(X)=BUDX(X),BUDAPOV(X)=BUDX(X)
;now get cpts
S ED=9999999-EDATE,BD=9999999-BDATE,G=0
F S ED=$O(^AUPNVSIT("AA",P,ED)) Q:ED=""!($P(ED,".")>BD) D
.S V=0 F S V=$O(^AUPNVSIT("AA",P,ED,V)) Q:V'=+V D
..Q:'$D(^AUPNVSIT(V,0))
..S X=0 F S X=$O(^AUPNVCPT("AD",V,X)) Q:X'=+X D
...S Y=$P(^AUPNVCPT(X,0),U),Y=$P($$CPT^ICPTCOD(Y),U,2) D
....I Y=90698!(Y=90713)!(Y=90723) S BUDOPV(9999999-$P(ED,"."))="CPT: "_Y_" on "_$$DATE^BUD1UTL1((9999999-$P(ED,"."))),BUDAPOV(9999999-$P(ED,"."))="CPT: "_Y_" on "_$$DATE^BUD1UTL1((9999999-$P(ED,".")))
..S X=0 F S X=$O(^AUPNVTC("AD",V,X)) Q:X'=+X D
...S Y=$P(^AUPNVTC(X,0),U,7) Q:'Y S Y=$P($$CPT^ICPTCOD(Y),U,2) D
....I Y=90698!(Y=90713)!(Y=90723) S BUDOPV(9999999-$P(ED,"."))="CPT: "_Y_" on "_$$DATE^BUD1UTL1((9999999-$P(ED,"."))),BUDAPOV(9999999-$P(ED,"."))="CPT: "_Y_" on "_$$DATE^BUD1UTL1((9999999-$P(ED,".")))
;now check to see if they are all spaced 10 days apart, if not, kill off the odd ones
S (X,Y)="",C=0 F S X=$O(BUDOPV(X)) Q:X'=+X S C=C+1 D
.I C=1 S Y=X Q
.I $$FMDIFF^XLFDT(X,Y)<11 K BUDOPV(X) Q
.S Y=X
;now count them and see if there are 4 of them
S BUDOPV=0,X=0 F S X=$O(BUDOPV(X)) Q:X'=+X S BUDOPV=BUDOPV+1
I BUDOPV>2 S Y="1^IPV: total #: "_BUDOPV,X="" F S X=$O(BUDOPV(X)) Q:X'=+X S Y=Y_" "_BUDOPV(X)
I BUDOPV>2 Q Y
;now get povs
K BUDOPV M BUDOPV=BUDAPOV
I $D(BUDG(1)) S X=0 F S X=$O(BUDG(X)) Q:X'=+X S BUDOPV($P(BUDG(X),U))="POV: "_$P(BUDG(X),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1)),BUDAOPV($P(BUDG(X),U))="POV: "_$P(BUDG(X),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
K BUDG S %=P_"^ALL PROCEDURE 99.41;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
I $D(BUDG(1)) S X=0 F S X=$O(BUDG(X)) Q:X'=+X S BUDOPV($P(BUDG(X),U))="Procedure: "_$P(BUDG(X),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1)),BUDAPOV($P(BUDG(X),U))="Procedure: "_$P(BUDG(X),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
;now check to see if they are all spaced 10 days apart, if not, kill off the odd ones
S (X,Y)="",C=0 F S X=$O(BUDOPV(X)) Q:X'=+X S C=C+1 D
.I C=1 S Y=X Q
.I $$FMDIFF^XLFDT(X,Y)<11 K BUDOPV(X) Q
.S Y=X
;now count them and see if there are 4 of them
S BUDOPV=0,X=0 F S X=$O(BUDOPV(X)) Q:X'=+X S BUDOPV=BUDOPV+1
I BUDOPV>2 S Y="1^IPV: total #: "_BUDOPV,X="" F S X=$O(BUDOPV(X)) Q:X'=+X S Y=Y_" "_BUDOPV(X)
I BUDOPV>2 Q Y
Q "0^"_(3-BUDOPV)_" IPV"
;
MMR(P,BDATE,EDATE) ;EP
;first check for contraindications
;dx first
MMRC ;
NEW BUDG,%,X,BUDZ,BUDC,BUDX,G,N
K BUDG S %=P_"^LAST DX [BUD MMR CONTRAINDICATIONS;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
I $D(BUDG(1)) Q "1^MMR CONTRA DX: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U))
S X=$$PLTAX^BUD1DU(P,"BUD MMR CONTRAINDICATIONS") I X Q "1^MMR CONTRA DX: "_$P(X,U,2)_" on Problem List"
S G=""
S X=0 F S X=$O(^GMR(120.8,"B",P,X)) Q:X'=+X!(G) D
.;Q:$P($P($G(^GMR(120.8,X,0)),U,4),".")>EDATE ;entered after 2ND birthday
.S N=$P($G(^GMR(120.8,X,0)),U,2),N=$$UP^XLFSTR(N)
.Q:'$$ANAREACT(X) ;quit if anaphylactic is not a reaction/sign/symptom
.I N["NEOMYCIN" S G="1^MMR Contraindiction: "_$$DATE^BUD1UTL1($P($P($G(^GMR(120.8,X,0)),U,4),"."))_" Allergy Tracking: "_N
I G]"" Q G
F BUDZ=3,94,5,7,6 S X=$$MMRCONT(P,BUDZ,EDATE) Q:X]""
I X]"" Q "1^MMR Contraindication: "_$P(X,U,2)_" on "_$$DATE^BUD1UTL1($P(X,U,1))_" Immunization Package"
MMREVID ;
;any evidence of MMR?
K BUDG S %=P_"^LAST DX [BGP MEASLES EVIDENCE;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
I $D(BUDG(1)) Q "1^MMR Evidence: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U))
;S BUDMEAS=1,BUDVALUE=BUDVALUE_" MEASLES EVIDENCE DX: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
;
S X=$$PLTAX^BUD1DU(P,"BGP MEASLES EVIDENCE")
I X Q "1^MMR Evidence: "_$P(X,U,2)_" on "_$$DATE^BUD1UTL1($P(X,U,1))_" problem list" ;S BUDMEAS=1,BUDVALUE=BUDVALUE_" MEASLES EVIDENCE PROB LIST: "_$P(X,U,2)
;no codes for MMR, only individual
MMRI ;
K BUDC,BUDG,BUDX
K ^TMP($J,"CPT")
S (BUDMMR,BUDMUMPS,BUDRUB,BUDMEAS)="" ;set to null for all
;first gather up all cpt codes that relate in any way to MMR and store in ^TMP
S ED=9999999-EDATE,BD=9999999-BDATE,G=0
F S ED=$O(^AUPNVSIT("AA",P,ED)) Q:ED=""!($P(ED,".")>BD) D
.S V=0 F S V=$O(^AUPNVSIT("AA",P,ED,V)) Q:V'=+V D
..Q:'$D(^AUPNVSIT(V,0))
..Q:'$D(^AUPNVCPT("AD",V))
..S X=0 F S X=$O(^AUPNVCPT("AD",V,X)) Q:X'=+X D
...S Y=$P(^AUPNVCPT(X,0),U),Y=$P($$CPT^ICPTCOD(Y),U,2) I Y=+Y,$T(@Y)]"" S ^TMP($J,"CPT",9999999-$P(ED,"."),Y)=""
;get all immunizations
S C="3^94"
K BUDX D GETIMMS(P,BDATE,EDATE,C,.BUDX) ;before 2nd birthday
I $D(BUDX) S D=$O(BUDX(0)) Q "1^MMR "_BUDX(D) ;HAD 1 MMR
S D=0 F S D=$O(^TMP($J,"CPT",D)) Q:D'=+D S Y="" F S Y=$O(^TMP($J,"CPT",D,Y)) Q:Y="" D
.I Y=90707!(Y=90710)!(Y=90708) S BUDMMR="CPT: "_Y_" on "_$$DATE^BUD1UTL1(D)
I BUDMMR]"" Q "1^MMR "_BUDMMR
;
K BUDG S %=P_"^ALL PROCEDURE 99.45;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
I $D(BUDG(1)) Q "1^MMR PROCEDURE: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U))
;now check individuals
MR ;see if one M/R, Mumps or R/M
S BUDVALUE=""
ME S C=5
K BUDX D GETIMMS(P,BDATE,EDATE,C,.BUDX)
I $D(BUDX) S BUDMEAS=1 S D=$O(BUDX(0)) S BUDVALUE=BUDVALUE_" MEASLES "_BUDX(D)
S D=0 F S D=$O(^TMP($J,"CPT",D)) Q:D'=+D S Y="" F S Y=$O(^TMP($J,"CPT",D,Y)) Q:Y="" D
.I Y=90705!(Y=90708) S BUDMEAS=1,BUDVALUE=BUDVALUE_" MEASLES CPT "_Y_" on "_$$DATE^BUD1UTL1(D)
K BUDG S %=P_"^ALL PROCEDURE 99.45;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
I $D(BUDG(1)) S BUDMEAS=1,BUDVALUE=BUDVALUE_" MEASLES PROCEDURE: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
I BUDMEAS="" K BUDG S %=P_"^LAST DX [BGP MEASLES EVIDENCE;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(") I $D(BUDG(1)) S BUDMEAS=1,BUDVALUE=BUDVALUE_" MEASLES EVIDENCE DX: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
I BUDMEAS="" S X=$$PLTAX^BUD1DU(P,"BGP MEASLES EVIDENCE") I X S BUDMEAS=1,BUDVALUE=BUDVALUE_" MEASLES EVIDENCE PROB LIST: "_$P(X,U,2)
I BUDMEAS,BUDMUMPS,BUDRUB Q "1^"_BUDVALUE
MU S C=7
D GETIMMS(P,BDATE,EDATE,C,.BUDX)
I $D(BUDX) S BUDMUMPS=1 S D=$O(BUDX(0)) S BUDVALUE=BUDVALUE_" MUMPS "_BUDX(D)
S D=0 F S D=$O(^TMP($J,"CPT",D)) Q:D'=+D S Y="" F S Y=$O(^TMP($J,"CPT",D,Y)) Q:Y="" D
.I Y=90704!(Y=90710) S BUDMUMPS=1,BUDVALUE=BUDVALUE_" MUMPS CPT "_Y_" on "_$$DATE^BUD1UTL1(D)
K BUDG S %=P_"^ALL PROCEDURE 99.46;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
I $D(BUDG(1)) S BUDMUMPS=1,BUDVALUE=BUDVALUE_" MUMPS PROCEDURE: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
I BUDMUMPS="" K BUDG S %=P_"^LAST DX [BGP MUMPS EVIDENCE;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(") I $D(BUDG(1)) S BUDMUMPS=1,BUDVALUE=BUDVALUE_" MUMPS EVIDENCE DX: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
I BUDMUMPS="" S X=$$PLTAX^BUD1DU(P,"BGP MUMPS EVIDENCE") I X S BUDMUMPS=1,BUDVALUE=BUDVALUE_" MUMPS EVIDENCE PROB LIST: "_$P(X,U,2)
I BUDMEAS,BUDMUMPS,BUDRUB Q "1^"_BUDVALUE
RUB S C=6
D GETIMMS(P,BDATE,EDATE,C,.BUDX)
I $D(BUDX) S BUDRUB=1,D=$O(BUDX(0)) S BUDVALUE=BUDVALUE_" RUBELLA "_BUDX(D)
S D=0 F S D=$O(^TMP($J,"CPT",D)) Q:D'=+D S Y="" F S Y=$O(^TMP($J,"CPT",D,Y)) Q:Y="" D
.I Y=90706!(Y=90707)!(Y=90708)!(Y=90710) S BUDRUB=1,BUDVALUE=BUDVALUE_" RUBELLA CPT "_Y_" on "_$$DATE^BUD1UTL1(D)
K BUDG S %=P_"^ALL PROCEDURE 99.47;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(")
I $D(BUDG(1)) S BUDRUB=1,BUDVALUE=BUDVALUE_" RUBELLA PROCEDURE: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
I BUDRUB="" K BUDG S %=P_"^LAST DX [BGP RUBELLA EVIDENCE;DURING "_BDATE_"-"_EDATE,E=$$START1^APCLDF(%,"BUDG(") I $D(BUDG(1)) S BUDRUB=1,BUDVALUE=BUDVALUE_" RUBELLA EVIDENCE DX: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
I BUDRUB="" S X=$$PLTAX^BUD1DU(P,"BGP RUBELLA EVIDENCE") I X S BUDRUB=1,BUDVALUE=BUDVALUE_" RUBELLA EVIDENCE PROB LIST: "_$P(X,U,2)
I BUDMEAS,BUDMUMPS,BUDRUB Q "1^"_BUDVALUE
I 'BUDMEAS,'BUDMUMPS,'BUDRUB Q "0^1 MEASLES MUMPS RUBBELLA"
Q "0^"_$S('BUDMEAS:" 1 MEASLES",1:"")_$S('BUDMUMPS:" 1 MUMPS",1:"")_$S('BUDRUB:" 1 RUBELLA",1:"")
;
90707 ;;
90710 ;;
90708 ;;
90705 ;;
90704 ;;
90706 ;;
BUD1RP6C ; IHS/CMI/LAB - UDS REPORT PROCESSOR 01 Dec 2011 3:10 PM 30 Dec 2011 7:19 PM ;
+1 ;;10.0;IHS/RPMS UNIFORM DATA SYSTEM;;FEB 04, 2016;Build 50
+2 ;
+3 ;
GETIMMS(P,BDATE,EDATE,C,BUDX) ;EP
+1 KILL BUDX
+2 NEW X,Y,I,Z,V
+3 SET X=0
FOR
SET X=$ORDER(^AUPNVIMM("AC",P,X))
IF X'=+X
QUIT
Begin DoDot:1
+4 ;happens
IF '$DATA(^AUPNVIMM(X,0))
QUIT
+5 SET Y=$PIECE(^AUPNVIMM(X,0),U)
+6 ;happens too
IF 'Y
QUIT
+7 ;get HL7/CVX code
SET I=$PIECE($GET(^AUTTIMM(Y,0)),U,3)
+8 FOR Z=1:1:$LENGTH(C,U)
IF I=$PIECE(C,U,Z)
SET V=$PIECE(^AUPNVIMM(X,0),U,3)
IF V
SET D=$PIECE($PIECE($GET(^AUPNVSIT(V,0)),U),".")
IF D]""
IF D'>EDATE
IF D'<BDATE
SET BUDX(D)="CVX: "_I_" on "_$$DATE^BUD1UTL1(D)
+9 QUIT
End DoDot:1
+10 QUIT
+11 ;
IMM ;EP - IMM
+1 ;must have DOB between in the year - 2
+2 SET BUD2YRB=($EXTRACT(BUDBD,1,3)-2)_"0101"
+3 SET BUD2YRE=($EXTRACT(BUDED,1,3)-2)_"1231"
+4 SET BUDDOB=$PIECE(^DPT(DFN,0),U,3)
+5 IF BUDDOB<BUD2YRB
QUIT
+6 IF BUDDOB>BUD2YRE
QUIT
+7 SET BUD2ND=$EXTRACT(BUDDOB,1,3)+2_$EXTRACT(BUDDOB,4,7)
+8 SET BUD1ST=$EXTRACT(BUDDOB,1,3)+1_$EXTRACT(BUDDOB,4,7)
+9 ;
+10 ;didn't have at least 1 medical visit
IF BUDMEDV<1
QUIT
+11 ;no visit before 2nd bd
SET BUDVBBD=$$VBBD^BUD1RP6D(DFN,BUDDOB,$$FMADD^XLFDT(BUD2ND,-1))
IF 'BUDVBBD
QUIT
+12 SET BUDSECTC("PTS")=$GET(BUDSECTC("PTS"))+1
+13 SET BUD42D=$$FMADD^XLFDT(BUDDOB,42)
+14 SET BUD180D=$$FMADD^XLFDT(BUDDOB,180)
+15 SET (BUDNDTP,BUDNIPV,BUDNMMR,BUDNHEP,BUDNHIB,BUDNVAR,BUDNPNEU)=""
+16 ;see if ever had a 999.4 before 2nd birthday
+17 SET BUDCTA=""
+18 SET X=$$CONTRA(DFN,BUDDOB,BUD2ND)
+19 IF X
SET BUDCTA=X
+20 IF BUDCTA
Begin DoDot:1
+21 SET BUDSECTC("IMM")=$GET(BUDSECTC("IMM"))+1
Begin DoDot:2
+22 IF $GET(BUDIMM1L)
Begin DoDot:3
+23 SET ^XTMP("BUD1RP6B",BUDJ,BUDH,"IMM1",$PIECE(^DPT(DFN,0),U),BUDCOM,DFN)="CONTRA ALL: 999.4 on "_$$FMTE^XLFDT(X)_"|||"_BUDVBBD_U_BUDMEDVI
End DoDot:3
+24 QUIT
End DoDot:2
QUIT
End DoDot:1
QUIT
+25 SET BUDNDTP=$$DTAP^BUD1RP6X(DFN,BUD42D,BUD2ND)
+26 SET BUDNIPV=$$IPV(DFN,BUD42D,BUD2ND)
+27 SET BUDNMMR=$$MMR(DFN,BUDDOB,BUD2ND)
+28 SET BUDNHEP=$$HEP^BUD1RP6Y(DFN,BUDDOB,BUD2ND)
+29 SET BUDNHIB=$$HIB^BUD1RP6Y(DFN,BUD42D,BUD2ND)
+30 SET BUDNVAR=$$VAR^BUD1RP6Y(DFN,BUD1ST,BUD2ND)
+31 SET BUDNPNEU=$$PNEU^BUD1RP6Y(DFN,BUDDOB,BUD2ND)
+32 SET BUDNHEPA=$$HEPA^BUD1RP6Y(DFN,BUDDOB,BUD2ND)
+33 SET BUDNROTA=$$ROTA^BUD1RP6W(DFN,BUD42D,BUD2ND)
+34 SET BUDNFLU=$$FLU^BUD1RP6Y(DFN,BUD180D,BUD2ND)
+35 IF $PIECE(BUDNDTP,U,1)=1
IF $PIECE(BUDNIPV,U,1)=1
IF $PIECE(BUDNMMR,U,1)=1
IF $PIECE(BUDNHEP,U,1)=1
IF $PIECE(BUDNHIB,U,1)=1
IF $PIECE(BUDNVAR,U,1)=1
IF $PIECE(BUDNPNEU,U,1)=1
IF $PIECE(BUDNHEPA,U,1)=1
IF $PIECE(BUDNROTA,U,1)=1
IF $PIECE(BUDNFLU,U,1)=1
SET BUDSECTC("IMM")=$GET(BUDSECTC("IMM"))+1
Begin DoDot:1
+36 IF $GET(BUDIMM1L)
Begin DoDot:2
+37 SET X=$PIECE(BUDNDTP,U,2)_U_$PIECE(BUDNIPV,U,2)_U_$PIECE(BUDNMMR,U,2)_U_$PIECE(BUDNHEP,U,2)_U_$PIECE(BUDNHIB,U,2)_U_$PIECE(BUDNVAR,U,2)_U_$PIECE(BUDNPNEU,U,2)_U_$PIECE(BUDNHEPA,U,2)_U_$PIECE(B
UDNROTA,U,2)_U_$PIECE(BUDNFLU,U,2)_"|||"_BUDVBBD_U_BUDMEDVI
+38 SET ^XTMP("BUD1RP6B",BUDJ,BUDH,"IMM1",$PIECE(^DPT(DFN,0),U),BUDCOM,DFN)=X
+39 QUIT
End DoDot:2
End DoDot:1
QUIT
+40 IF $GET(BUDIMM2L)
Begin DoDot:1
+41 SET V=$SELECT($PIECE(BUDNDTP,U,1)=1:"",1:$PIECE(BUDNDTP,U,2))_$SELECT($PIECE(BUDNIPV,U,1)=1:"",1:";"_$PIECE(BUDNIPV,U,2))_$SELECT($PIECE(BUDNMMR,U,1)=1:"",1:";"_$PIECE(BUDNMMR,U,2))_$SELECT($PIECE(BUDNHEP,U,1)=1:"",1:";"_$PIECE(BUDNHEP,
U,2))
+42 SET V=V_$SELECT($PIECE(BUDNHIB,U,1)=1:"",1:";"_$PIECE(BUDNHIB,U,2))_$SELECT(...
... $PIECE(BUDNVAR,U,1)=1:"",1:";VARI")_$SELECT($PIECE(BUDNPNEU,U,1)=1:"",1:";"_$PIECE(BUDNPNEU,U,2))_$SELECT($PIECE(BUDNHEPA,U,1)=1:"",1:";"_$PIECE(BUDNHEPA,U,2))_$SELECT($PIECE(BUDNROTA,U,1)=1:"",1:";"_$PIECE(BUDNROTA,U,2))
+43 SET V=V_$SELECT($PIECE(BUDNFLU,U,1)=1:"",1:";"_$PIECE(BUDNFLU,U,2))
+44 SET ^XTMP("BUD1RP6B",BUDJ,BUDH,"IMM2",$PIECE(^DPT(DFN,0),U),BUDCOM,DFN)=V
End DoDot:1
+45 QUIT
+46 ;
CONTRA(P,BD,ED) ;EP
+1 NEW D,BUDG,E,%
+2 KILL BUDG
SET %=P_"^LAST DX 999.4;DURING "_BD_"-"_ED
SET E=$$START1^APCLDF(%,"BUDG(")
+3 QUIT $PIECE($GET(BUDG(1)),U)
ANAREACT(I) ;EP
+1 NEW X,Y,R
+2 SET X=0
SET Y=0
FOR
SET X=$ORDER(^GMR(120.8,I,10,X))
IF X'=+X
QUIT
Begin DoDot:1
+3 SET R=$PIECE($GET(^GMR(120.8,I,10,X,0)),U)
+4 IF R=""
QUIT
+5 SET R=$PIECE($GET(^GMRD(120.83,R,0)),U)
+6 IF R'="ANAPHYLAXIS"
QUIT
+7 SET Y=1
+8 QUIT
End DoDot:1
+9 QUIT Y
+10 ;
ANCONT(P,C,ED) ;EP - ANALPHYLAXIS CONTRA
+1 NEW X
+2 SET X=0
SET G=""
SET Y=$ORDER(^AUTTIMM("C",C,0))
IF Y
FOR
SET X=$ORDER(^BIPC("AC",P,Y,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+3 SET R=$PIECE(^BIPC(X,0),U,3)
+4 IF R=""
QUIT
+5 IF '$DATA(^BICONT(R,0))
QUIT
+6 SET D=$PIECE(^BIPC(X,0),U,4)
+7 IF D=""
QUIT
+8 ;Q:$P(^BIPC(X,0),U,4)<BD
+9 ;Q:$P(^BIPC(X,0),U,4)>ED
+10 IF $PIECE(^BICONT(R,0),U,1)="Anaphylaxis"
SET G=D_U_"Anaphylaxis"
End DoDot:1
+11 QUIT G
+12 ;
EGGCONT(P,C,ED) ;EP - EGG CONTRA
+1 NEW X
+2 SET X=0
SET G=""
SET Y=$ORDER(^AUTTIMM("C",C,0))
IF Y
FOR
SET X=$ORDER(^BIPC("AC",P,Y,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+3 SET R=$PIECE(^BIPC(X,0),U,3)
+4 IF R=""
QUIT
+5 IF '$DATA(^BICONT(R,0))
QUIT
+6 SET D=$PIECE(^BIPC(X,0),U,4)
+7 IF D=""
QUIT
+8 ;Q:$P(^BIPC(X,0),U,4)<BD
+9 ;Q:$P(^BIPC(X,0),U,4)>ED
+10 IF $PIECE(^BICONT(R,0),U,1)="Egg Allergy"
SET G=D_U_"Egg Allergy"
End DoDot:1
+11 QUIT G
ANNECONT(P,C,ED) ;EP - ANALPHYLAXIS/NEOMYCIN CONTRA
+1 NEW X
+2 SET X=0
SET G=""
SET Y=$ORDER(^AUTTIMM("C",C,0))
IF Y
FOR
SET X=$ORDER(^BIPC("AC",P,Y,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+3 SET R=$PIECE(^BIPC(X,0),U,3)
+4 IF R=""
QUIT
+5 IF '$DATA(^BICONT(R,0))
QUIT
+6 SET D=$PIECE(^BIPC(X,0),U,4)
+7 IF D=""
QUIT
+8 ;Q:$P(^BIPC(X,0),U,4)<BD
+9 ;Q:$P(^BIPC(X,0),U,4)>ED
+10 IF $PIECE(^BICONT(R,0),U,1)="Anaphylaxis"
SET G=D_U_"Anaphylaxis"
+11 IF $PIECE(^BICONT(R,0),U,1)="Neomycin Allergy"
SET G=D_U_"Neomycin Allergy"
End DoDot:1
+12 QUIT G
+13 ;
MMRCONT(P,C,ED) ;EP - ANALPHYLAXIS/NEOMYCIN/IMMUNE CONTRA
+1 NEW X
+2 SET X=0
SET G=""
SET Y=$ORDER(^AUTTIMM("C",C,0))
IF Y
FOR
SET X=$ORDER(^BIPC("AC",P,Y,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+3 SET R=$PIECE(^BIPC(X,0),U,3)
+4 IF R=""
QUIT
+5 IF '$DATA(^BICONT(R,0))
QUIT
+6 SET D=$PIECE(^BIPC(X,0),U,4)
+7 IF D=""
QUIT
+8 ;Q:$P(^BIPC(X,0),U,4)<BD
+9 ;Q:$P(^BIPC(X,0),U,4)>ED
+10 IF $PIECE(^BICONT(R,0),U,1)="Anaphylaxis"
SET G=D_U_"Anaphylaxis"
+11 IF $PIECE(^BICONT(R,0),U,1)="Neomycin Allergy"
SET G=D_U_"Neomycin Allergy"
+12 IF $PIECE(^BICONT(R,0),U,1)="Immune Deficiency"
SET G=D_U_"Immune Deficiency"
+13 IF $PIECE(^BICONT(R,0),U,1)["Immune Deficient"
SET G=D_U_"Immune Deficient"
+14 IF $PIECE(^BICONT(R,0),U,1)="Immune"
SET G=D_U_"Immune"
End DoDot:1
+15 QUIT G
+16 ;
IPV(P,BDATE,EDATE) ;EP
+1 ;check for a contraindication from DOB to 2nd birthday
+2 NEW X,G,N,BUDG,BUDX,BUDC,BUDOPV,BUDAPOV,C,BD,ED,V,Y,E
IPVCONT ;check allergy tracking
+1 SET G=""
+2 SET X=0
FOR
SET X=$ORDER(^GMR(120.8,"B",P,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+3 ;Q:$P($P($G(^GMR(120.8,X,0)),U,4),".")>EDATE ;entered after 2ND birthday
+4 SET N=$PIECE($GET(^GMR(120.8,X,0)),U,2)
SET N=$$UP^XLFSTR(N)
+5 IF N["STREPTOMYCIN"!(N["POLYMYXIN B")!(N["NEOMYCIN")
SET G="1^IPV Contraindiction: "_$$DATE^BUD1UTL1($PIECE($PIECE($GET(^GMR(120.8,X,0)),U,4),"."))_" Allergy Tracking: "_N
+6 ;quit if anaphylactic is not a reaction/sign/symptom
IF '$$ANAREACT(X)
QUIT
End DoDot:1
+7 IF G]""
QUIT G
+8 ;now check immunization package
+9 FOR BUDZ=10,89,110,120,130,132
SET X=$$ANNECONT(P,BUDZ,EDATE)
IF X]""
QUIT
+10 IF X]""
QUIT "1^IPV Contraindication IM package: "_$$DATE^BUD1UTL1($PIECE(X,U))_" "_$PIECE(X,U,2)
+11 ;now check for evidence of disease
IPVEVID ;
+1 KILL BUDG
SET %=P_"^LAST DX [BUD IPV EVID DISEASE;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+2 IF $DATA(BUDG(1))
QUIT "1^IPV Evidence: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U))
+3 ;S X=$$PLTAX^BUD1DU(P,"BUD IPV EVID DISEASE") I X Q "IPV Evidence: Problem List "_$P(X,U,2)
+4 ;now get imms and see if there are 3
+5 KILL BUDC,BUDG,BUDX
+6 KILL BUDOPV,BUDAPOV
IPVIMM ;get all immunizations
+1 SET C="10^89^110^120^130^132"
+2 KILL BUDX
DO GETIMMS(P,BDATE,EDATE,C,.BUDX)
+3 ;now get cpt codes
+4 SET X=0
FOR
SET X=$ORDER(BUDX(X))
IF X'=+X
QUIT
SET BUDOPV(X)=BUDX(X)
SET BUDAPOV(X)=BUDX(X)
+5 ;now get cpts
+6 SET ED=9999999-EDATE
SET BD=9999999-BDATE
SET G=0
+7 FOR
SET ED=$ORDER(^AUPNVSIT("AA",P,ED))
IF ED=""!($PIECE(ED,".")>BD)
QUIT
Begin DoDot:1
+8 SET V=0
FOR
SET V=$ORDER(^AUPNVSIT("AA",P,ED,V))
IF V'=+V
QUIT
Begin DoDot:2
+9 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+10 SET X=0
FOR
SET X=$ORDER(^AUPNVCPT("AD",V,X))
IF X'=+X
QUIT
Begin DoDot:3
+11 SET Y=$PIECE(^AUPNVCPT(X,0),U)
SET Y=$PIECE($$CPT^ICPTCOD(Y),U,2)
Begin DoDot:4
+12 IF Y=90698!(Y=90713)!(Y=90723)
SET BUDOPV(9999999-$PIECE(ED,"."))="CPT: "_Y_" on "_$$DATE^BUD1UTL1((9999999-$PIECE(ED,".")))
SET BUDAPOV(9999999-$PIECE(ED,"."))="CPT: "_Y_" on "_$$DATE^BUD1UTL1((9999999-$PIECE(ED,".")))
End DoDot:4
End DoDot:3
+13 SET X=0
FOR
SET X=$ORDER(^AUPNVTC("AD",V,X))
IF X'=+X
QUIT
Begin DoDot:3
+14 SET Y=$PIECE(^AUPNVTC(X,0),U,7)
IF 'Y
QUIT
SET Y=$PIECE($$CPT^ICPTCOD(Y),U,2)
Begin DoDot:4
+15 IF Y=90698!(Y=90713)!(Y=90723)
SET BUDOPV(9999999-$PIECE(ED,"."))="CPT: "_Y_" on "_$$DATE^BUD1UTL1((9999999-$PIECE(ED,".")))
SET BUDAPOV(9999999-$PIECE(ED,"."))="CPT: "_Y_" on "_$$DATE^BUD1UTL1((9999999-$PIECE(ED,".")))
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+16 ;now check to see if they are all spaced 10 days apart, if not, kill off the odd ones
+17 SET (X,Y)=""
SET C=0
FOR
SET X=$ORDER(BUDOPV(X))
IF X'=+X
QUIT
SET C=C+1
Begin DoDot:1
+18 IF C=1
SET Y=X
QUIT
+19 IF $$FMDIFF^XLFDT(X,Y)<11
KILL BUDOPV(X)
QUIT
+20 SET Y=X
End DoDot:1
+21 ;now count them and see if there are 4 of them
+22 SET BUDOPV=0
SET X=0
FOR
SET X=$ORDER(BUDOPV(X))
IF X'=+X
QUIT
SET BUDOPV=BUDOPV+1
+23 IF BUDOPV>2
SET Y="1^IPV: total #: "_BUDOPV
SET X=""
FOR
SET X=$ORDER(BUDOPV(X))
IF X'=+X
QUIT
SET Y=Y_" "_BUDOPV(X)
+24 IF BUDOPV>2
QUIT Y
+25 ;now get povs
+26 KILL BUDOPV
MERGE BUDOPV=BUDAPOV
+27 IF $DATA(BUDG(1))
SET X=0
FOR
SET X=$ORDER(BUDG(X))
IF X'=+X
QUIT
SET BUDOPV($PIECE(BUDG(X),U))="POV: "_$PIECE(BUDG(X),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
SET BUDAOPV($PIECE(BUDG(X),U))="POV: "_$PIECE(BUDG(X),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
+28 KILL BUDG
SET %=P_"^ALL PROCEDURE 99.41;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+29 IF $DATA(BUDG(1))
SET X=0
FOR
SET X=$ORDER(BUDG(X))
IF X'=+X
QUIT
SET BUDOPV($PIECE(BUDG(X),U))="Procedure: "_$PIECE(BUDG(X),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
SET BUDAPOV($PIECE(BUDG(X),U))="Procedure: "_$PIECE(BUDG(X),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
+30 ;now check to see if they are all spaced 10 days apart, if not, kill off the odd ones
+31 SET (X,Y)=""
SET C=0
FOR
SET X=$ORDER(BUDOPV(X))
IF X'=+X
QUIT
SET C=C+1
Begin DoDot:1
+32 IF C=1
SET Y=X
QUIT
+33 IF $$FMDIFF^XLFDT(X,Y)<11
KILL BUDOPV(X)
QUIT
+34 SET Y=X
End DoDot:1
+35 ;now count them and see if there are 4 of them
+36 SET BUDOPV=0
SET X=0
FOR
SET X=$ORDER(BUDOPV(X))
IF X'=+X
QUIT
SET BUDOPV=BUDOPV+1
+37 IF BUDOPV>2
SET Y="1^IPV: total #: "_BUDOPV
SET X=""
FOR
SET X=$ORDER(BUDOPV(X))
IF X'=+X
QUIT
SET Y=Y_" "_BUDOPV(X)
+38 IF BUDOPV>2
QUIT Y
+39 QUIT "0^"_(3-BUDOPV)_" IPV"
+40 ;
MMR(P,BDATE,EDATE) ;EP
+1 ;first check for contraindications
+2 ;dx first
MMRC ;
+1 NEW BUDG,%,X,BUDZ,BUDC,BUDX,G,N
+2 KILL BUDG
SET %=P_"^LAST DX [BUD MMR CONTRAINDICATIONS;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+3 IF $DATA(BUDG(1))
QUIT "1^MMR CONTRA DX: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U))
+4 SET X=$$PLTAX^BUD1DU(P,"BUD MMR CONTRAINDICATIONS")
IF X
QUIT "1^MMR CONTRA DX: "_$PIECE(X,U,2)_" on Problem List"
+5 SET G=""
+6 SET X=0
FOR
SET X=$ORDER(^GMR(120.8,"B",P,X))
IF X'=+X!(G)
QUIT
Begin DoDot:1
+7 ;Q:$P($P($G(^GMR(120.8,X,0)),U,4),".")>EDATE ;entered after 2ND birthday
+8 SET N=$PIECE($GET(^GMR(120.8,X,0)),U,2)
SET N=$$UP^XLFSTR(N)
+9 ;quit if anaphylactic is not a reaction/sign/symptom
IF '$$ANAREACT(X)
QUIT
+10 IF N["NEOMYCIN"
SET G="1^MMR Contraindiction: "_$$DATE^BUD1UTL1($PIECE($PIECE($GET(^GMR(120.8,X,0)),U,4),"."))_" Allergy Tracking: "_N
End DoDot:1
+11 IF G]""
QUIT G
+12 FOR BUDZ=3,94,5,7,6
SET X=$$MMRCONT(P,BUDZ,EDATE)
IF X]""
QUIT
+13 IF X]""
QUIT "1^MMR Contraindication: "_$PIECE(X,U,2)_" on "_$$DATE^BUD1UTL1($PIECE(X,U,1))_" Immunization Package"
MMREVID ;
+1 ;any evidence of MMR?
+2 KILL BUDG
SET %=P_"^LAST DX [BGP MEASLES EVIDENCE;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+3 IF $DATA(BUDG(1))
QUIT "1^MMR Evidence: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U))
+4 ;S BUDMEAS=1,BUDVALUE=BUDVALUE_" MEASLES EVIDENCE DX: "_$P(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($P(BUDG(1),U,1))
+5 ;
+6 SET X=$$PLTAX^BUD1DU(P,"BGP MEASLES EVIDENCE")
+7 ;S BUDMEAS=1,BUDVALUE=BUDVALUE_" MEASLES EVIDENCE PROB LIST: "_$P(X,U,2)
IF X
QUIT "1^MMR Evidence: "_$PIECE(X,U,2)_" on "_$$DATE^BUD1UTL1($PIECE(X,U,1))_" problem list"
+8 ;no codes for MMR, only individual
MMRI ;
+1 KILL BUDC,BUDG,BUDX
+2 KILL ^TMP($JOB,"CPT")
+3 ;set to null for all
SET (BUDMMR,BUDMUMPS,BUDRUB,BUDMEAS)=""
+4 ;first gather up all cpt codes that relate in any way to MMR and store in ^TMP
+5 SET ED=9999999-EDATE
SET BD=9999999-BDATE
SET G=0
+6 FOR
SET ED=$ORDER(^AUPNVSIT("AA",P,ED))
IF ED=""!($PIECE(ED,".")>BD)
QUIT
Begin DoDot:1
+7 SET V=0
FOR
SET V=$ORDER(^AUPNVSIT("AA",P,ED,V))
IF V'=+V
QUIT
Begin DoDot:2
+8 IF '$DATA(^AUPNVSIT(V,0))
QUIT
+9 IF '$DATA(^AUPNVCPT("AD",V))
QUIT
+10 SET X=0
FOR
SET X=$ORDER(^AUPNVCPT("AD",V,X))
IF X'=+X
QUIT
Begin DoDot:3
+11 SET Y=$PIECE(^AUPNVCPT(X,0),U)
SET Y=$PIECE($$CPT^ICPTCOD(Y),U,2)
IF Y=+Y
IF $TEXT(@Y)]""
SET ^TMP($JOB,"CPT",9999999-$PIECE(ED,"."),Y)=""
End DoDot:3
End DoDot:2
End DoDot:1
+12 ;get all immunizations
+13 SET C="3^94"
+14 ;before 2nd birthday
KILL BUDX
DO GETIMMS(P,BDATE,EDATE,C,.BUDX)
+15 ;HAD 1 MMR
IF $DATA(BUDX)
SET D=$ORDER(BUDX(0))
QUIT "1^MMR "_BUDX(D)
+16 SET D=0
FOR
SET D=$ORDER(^TMP($JOB,"CPT",D))
IF D'=+D
QUIT
SET Y=""
FOR
SET Y=$ORDER(^TMP($JOB,"CPT",D,Y))
IF Y=""
QUIT
Begin DoDot:1
+17 IF Y=90707!(Y=90710)!(Y=90708)
SET BUDMMR="CPT: "_Y_" on "_$$DATE^BUD1UTL1(D)
End DoDot:1
+18 IF BUDMMR]""
QUIT "1^MMR "_BUDMMR
+19 ;
+20 KILL BUDG
SET %=P_"^ALL PROCEDURE 99.45;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+21 IF $DATA(BUDG(1))
QUIT "1^MMR PROCEDURE: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U))
+22 ;now check individuals
MR ;see if one M/R, Mumps or R/M
+1 SET BUDVALUE=""
ME SET C=5
+1 KILL BUDX
DO GETIMMS(P,BDATE,EDATE,C,.BUDX)
+2 IF $DATA(BUDX)
SET BUDMEAS=1
SET D=$ORDER(BUDX(0))
SET BUDVALUE=BUDVALUE_" MEASLES "_BUDX(D)
+3 SET D=0
FOR
SET D=$ORDER(^TMP($JOB,"CPT",D))
IF D'=+D
QUIT
SET Y=""
FOR
SET Y=$ORDER(^TMP($JOB,"CPT",D,Y))
IF Y=""
QUIT
Begin DoDot:1
+4 IF Y=90705!(Y=90708)
SET BUDMEAS=1
SET BUDVALUE=BUDVALUE_" MEASLES CPT "_Y_" on "_$$DATE^BUD1UTL1(D)
End DoDot:1
+5 KILL BUDG
SET %=P_"^ALL PROCEDURE 99.45;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+6 IF $DATA(BUDG(1))
SET BUDMEAS=1
SET BUDVALUE=BUDVALUE_" MEASLES PROCEDURE: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
+7 IF BUDMEAS=""
KILL BUDG
SET %=P_"^LAST DX [BGP MEASLES EVIDENCE;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
IF $DATA(BUDG(1))
SET BUDMEAS=1
SET BUDVALUE=BUDVALUE_" MEASLES EVIDENCE DX: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
+8 IF BUDMEAS=""
SET X=$$PLTAX^BUD1DU(P,"BGP MEASLES EVIDENCE")
IF X
SET BUDMEAS=1
SET BUDVALUE=BUDVALUE_" MEASLES EVIDENCE PROB LIST: "_$PIECE(X,U,2)
+9 IF BUDMEAS
IF BUDMUMPS
IF BUDRUB
QUIT "1^"_BUDVALUE
MU SET C=7
+1 DO GETIMMS(P,BDATE,EDATE,C,.BUDX)
+2 IF $DATA(BUDX)
SET BUDMUMPS=1
SET D=$ORDER(BUDX(0))
SET BUDVALUE=BUDVALUE_" MUMPS "_BUDX(D)
+3 SET D=0
FOR
SET D=$ORDER(^TMP($JOB,"CPT",D))
IF D'=+D
QUIT
SET Y=""
FOR
SET Y=$ORDER(^TMP($JOB,"CPT",D,Y))
IF Y=""
QUIT
Begin DoDot:1
+4 IF Y=90704!(Y=90710)
SET BUDMUMPS=1
SET BUDVALUE=BUDVALUE_" MUMPS CPT "_Y_" on "_$$DATE^BUD1UTL1(D)
End DoDot:1
+5 KILL BUDG
SET %=P_"^ALL PROCEDURE 99.46;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+6 IF $DATA(BUDG(1))
SET BUDMUMPS=1
SET BUDVALUE=BUDVALUE_" MUMPS PROCEDURE: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
+7 IF BUDMUMPS=""
KILL BUDG
SET %=P_"^LAST DX [BGP MUMPS EVIDENCE;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
IF $DATA(BUDG(1))
SET BUDMUMPS=1
SET BUDVALUE=BUDVALUE_" MUMPS EVIDENCE DX: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
+8 IF BUDMUMPS=""
SET X=$$PLTAX^BUD1DU(P,"BGP MUMPS EVIDENCE")
IF X
SET BUDMUMPS=1
SET BUDVALUE=BUDVALUE_" MUMPS EVIDENCE PROB LIST: "_$PIECE(X,U,2)
+9 IF BUDMEAS
IF BUDMUMPS
IF BUDRUB
QUIT "1^"_BUDVALUE
RUB SET C=6
+1 DO GETIMMS(P,BDATE,EDATE,C,.BUDX)
+2 IF $DATA(BUDX)
SET BUDRUB=1
SET D=$ORDER(BUDX(0))
SET BUDVALUE=BUDVALUE_" RUBELLA "_BUDX(D)
+3 SET D=0
FOR
SET D=$ORDER(^TMP($JOB,"CPT",D))
IF D'=+D
QUIT
SET Y=""
FOR
SET Y=$ORDER(^TMP($JOB,"CPT",D,Y))
IF Y=""
QUIT
Begin DoDot:1
+4 IF Y=90706!(Y=90707)!(Y=90708)!(Y=90710)
SET BUDRUB=1
SET BUDVALUE=BUDVALUE_" RUBELLA CPT "_Y_" on "_$$DATE^BUD1UTL1(D)
End DoDot:1
+5 KILL BUDG
SET %=P_"^ALL PROCEDURE 99.47;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
+6 IF $DATA(BUDG(1))
SET BUDRUB=1
SET BUDVALUE=BUDVALUE_" RUBELLA PROCEDURE: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
+7 IF BUDRUB=""
KILL BUDG
SET %=P_"^LAST DX [BGP RUBELLA EVIDENCE;DURING "_BDATE_"-"_EDATE
SET E=$$START1^APCLDF(%,"BUDG(")
IF $DATA(BUDG(1))
SET BUDRUB=1
SET BUDVALUE=BUDVALUE_" RUBELLA EVIDENCE DX: "_$PIECE(BUDG(1),U,2)_" on "_$$DATE^BUD1UTL1($PIECE(BUDG(1),U,1))
+8 IF BUDRUB=""
SET X=$$PLTAX^BUD1DU(P,"BGP RUBELLA EVIDENCE")
IF X
SET BUDRUB=1
SET BUDVALUE=BUDVALUE_" RUBELLA EVIDENCE PROB LIST: "_$PIECE(X,U,2)
+9 IF BUDMEAS
IF BUDMUMPS
IF BUDRUB
QUIT "1^"_BUDVALUE
+10 IF 'BUDMEAS
IF 'BUDMUMPS
IF 'BUDRUB
QUIT "0^1 MEASLES MUMPS RUBBELLA"
+11 QUIT "0^"_$SELECT('BUDMEAS:" 1 MEASLES",1:"")_$SELECT('BUDMUMPS:" 1 MUMPS",1:"")_$SELECT('BUDRUB:" 1 RUBELLA",1:"")
+12 ;
90707 ;;
90710 ;;
90708 ;;
90705 ;;
90704 ;;
90706 ;;