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

BGP8PC62.m

Go to the documentation of this file.
BGP8PC62 ; IHS/CMI/LAB - measure I2 ; 02 Feb 2018  11:25 AM
 ;;18.1;IHS CLINICAL REPORTING;**1**;MAY 25, 2018;Build 65
 ;
MMR(P) ;
 NEW A730,X,Y,Z,TCVX,TCPT,C,BGPIMMS,D,V,BGPZ
 S TCVX=$O(^ATXAX("B","BGP IPC MMR CVX CODES",0))
 S TCPT=$O(^ATXAX("B","BGP IPC MMR CPT CODES",0))
 S A730=$$FMADD^XLFDT($$DOB^AUPNPAT(P),730)
 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
 .Q:'$D(^ATXAX(TCVX,21,"B",I))
 .S D=$P($P($G(^AUPNVIMM(X,12)),U,1),".")
 .I D="" S V=$P(^AUPNVIMM(X,0),U,3) I V S D=$P($P($G(^AUPNVSIT(V,0)),U),".")
 .Q:D>A730
 .S BGPIMMS(D)=Y
 .Q
 ;go through and set into array if 1 days apart
 S X="",Y="",C=0 F  S X=$O(BGPIMMS(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<1 K BGPIMMS(X) Q
 .S Y=X
 ;see if there are 1 of them, if there are quit
 S BGPIMMS=0,X=0 F  S X=$O(BGPIMMS(X)) Q:X'=+X  S BGPIMMS=BGPIMMS+1
 I BGPIMMS>0 Q 1_U_"1 MMR"
 ;now get cpts
 S G="",X=0
 F  S X=$O(^AUPNVCPT("AC",P,X)) Q:X=""  D
 .Q:'$D(^AUPNVCPT(X,0))
 .S Y=$P(^AUPNVCPT(X,0),U)
 .Q:'$$ICD^BGP8UTL2(Y,TCPT,1)
 .S V=$P(^AUPNVCPT(X,0),U,3) Q:'V
 .S D=$$VD^APCLV(V)
 .Q:D>A730
 .S BGPIMMS(D)=""
 ;get tran codes
 S X=0 F  S X=$O(^AUPNVTC("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVTC(X,0))
 .S Y=$P(^AUPNVTC(X,0),U,7) Q:'Y
 .Q:'$$ICD^BGP8UTL2(Y,TCPT,1)
 .S V=$P(^AUPNVTC(X,0),U,3) Q:'V
 .S D=$$VD^APCLV(V)
 .Q:D>A730
 .S BGPIMMS(D)=""
 ;
 ;go through and set into array if 1 days apart
 S X="",Y="",C=0 F  S X=$O(BGPIMMS(X)) Q:X'=+X  S C=C+1 D
 .I C=1 S Y=X Q
 .I $$FMDIFF^XLFDT(X,Y)<1 K BGPIMMS(X) Q
 .S Y=X
 ;see if there are 3 of them, if there are quit
 S BGPIMMS=0,X=0 F  S X=$O(BGPIMMS(X)) Q:X'=+X  S BGPIMMS=BGPIMMS+1
 I BGPIMMS>0 Q 1_U_"1 MMR"
 ;NOW CHECK FOR CONTRAINDICATION
 ;IMM PKG ANAPHYLACTIS
 S BGPZ=0
 F  S BGPZ=$O(^ATXAX(TCVX,21,"B",BGPZ)) Q:BGPZ=""!(X]"")  D
 .S X=$$ANNECONT(P,BGPZ,A730)
 I X]"" Q 1_U_"MMR CONTRA ANAPHYLACTIC/NEOMYCIN"
 S X=$$ANSNMMR(P,A730) I X Q 1_U_"MMR CONTRA ANAPHYLACTIC REACTION"
 S X=$$DIS^BGP8PC65(P,A730) I X Q 1_U_"MMR CONTRA DIS IMMUNE SYS"
 S X=$$HIV^BGP8PC65(P,A730) I X Q 1_U_"MMR CONTRA HIV"
 S X=$$MNLHT^BGP8PC65(P,A730) I X Q 1_U_"MMR CONTRA NEOPLASM"
 S X=$$EVIDMMR(P,A730) I X Q 1_U_"EVIDENCE OF M/M/R"
 Q ""
ANSNMMR(P,EDATE) ;
 ;V POV OR PROBLEM LIST
 NEW X,Y,Z,G,T,S,D,I
 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=292927007 S I=1 Q
 .Q
 I I Q I
 ;NOW V POV SNOMED
 ;NOW SNOMED USING ASNC
 S G="",I=""
 S S="" F  S S=$O(^AUPNVPOV("ASNC",P,S)) Q:S=""!(G)  D
 .S I=0
 .I S=292927007 S I=1
 .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=1
 I G Q G
 ;REFUSAL FILE
 S I="" F  S I=$O(^AUPNPREF("AA",P,9002318.4,I)) Q:I=""!(G)  D
 .I I'=292927007 Q   ;IF IT'S SNOMED, MUST BE THAT ONE
 .S ID=0 F  S ID=$O(^AUPNPREF("AA",P,9002318.4,I,ID)) Q:ID=""!(G)  D
 ..S D=9999999-ID
 ..Q:D>EDATE
 ..S G=1
 Q G
ANNECONT(P,C,ED) ;EP - ANALPHYLAXIS/NEOMYCIN CONTRAINDICATION
 NEW X,G,Y,R,D
 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_"Contra Anaphylaxis"
 .I $P(^BICONT(R,0),U,1)="Neomycin Allergy" S G=D_U_"Contra: Neomycin Allergy"
 .I $P(^BICONT(R,0),U,1)="Immune Deficiency" S G=D_U_"Contra: Immune Deficiency"
 Q G
EVIDMMR(P,EDATE) ;
 ;is there measles evidence
 ;V POV OR PROBLEM LIST
 NEW X,Y,Z,G,T,S,D,E,R,L,J,ME,MU,RU
 S (ME,MU,RU)=""
 I $$PLTAXND^BGP8DU(P,"BGP IPC MEASLES DXS",EDATE,0) S ME=1
 I $$IPLSNOND^BGP8DU(P,"PXRM BGP IPC MEASLES EVID",EDATE,0) S ME=1
 I $$LASTDX^BGP8UTL1(P,"BGP IPC MEASLES DXS",$$DOB^AUPNPAT(P),EDATE) S ME=1
 ;NOW V POV SNOMED
 ;NOW SNOMED USING ASNC
 S T="PXRM BGP IPC MEASLES EVID"
 S G=""
 S S=0 F  S S=$O(^XTMP("BGPSNOMEDSUBSET",$J,T,S)) Q:S=""!(ME)  D
 .Q:'$D(^AUPNVPOV("ASNC",P,S))
 .S D=0 F  S D=$O(^AUPNVPOV("ASNC",P,S,D)) Q:D=""!(ME)  D
 ..S Y=9999999-D
 ..Q:Y>EDATE
 ..S ME=1
 I ME G MU
 ;lab tests?
MLT ;
 S E=9999999-EDATE S D=E-1 F  S D=$O(^AUPNVLAB("AE",P,D)) Q:D'=+D!(ME)  D
 .S L=0 F  S L=$O(^AUPNVLAB("AE",P,D,L)) Q:L'=+L!(ME)  D
 ..S X=0 F  S X=$O(^AUPNVLAB("AE",P,D,L,X)) Q:X'=+X!(ME)  D
 ...Q:'$D(^AUPNVLAB(X,0))
 ...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
 ...Q:'$$LOINCME(J)
 ...S R=$P(^AUPNVLAB(X,0),U,4)
 ...S R=+R
 ...I R'<1.10 S ME=1
 ...Q
 I 'ME Q ""  ;since no measles and have to have all 3 might as well quit now
MU ;is there evidence of mumps?
 I $$PLTAXND^BGP8DU(P,"BGP IPC MUMPS DXS",EDATE,0) S MU=1
 I $$IPLSNOND^BGP8DU(P,"PXRM BGP IPC MUMPS EVID",EDATE,0) S MU=1
 I $$LASTDX^BGP8UTL1(P,"BGP IPC MUMPS DXS",$$DOB^AUPNPAT(P),EDATE) S MU=1
 ;NOW V POV SNOMED
 ;NOW SNOMED USING ASNC
 S T="PXRM BGP IPC MUMPS EVID"
 S G=""
 S S=0 F  S S=$O(^XTMP("BGPSNOMEDSUBSET",$J,T,S)) Q:S=""!(MU)  D
 .Q:'$D(^AUPNVPOV("ASNC",P,S))
 .S D=0 F  S D=$O(^AUPNVPOV("ASNC",P,S,D)) Q:D=""!(MU)  D
 ..S Y=9999999-D
 ..Q:Y>EDATE
 ..S MU=1
 I MU G RU
 ;lab tests?
MULT ;
 S E=9999999-EDATE S D=E-1 F  S D=$O(^AUPNVLAB("AE",P,D)) Q:D'=+D!(MU)  D
 .S L=0 F  S L=$O(^AUPNVLAB("AE",P,D,L)) Q:L'=+L!(MU)  D
 ..S X=0 F  S X=$O(^AUPNVLAB("AE",P,D,L,X)) Q:X'=+X!(MU)  D
 ...Q:'$D(^AUPNVLAB(X,0))
 ...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
 ...Q:'$$LOINCMU(J)
 ...S R=$P(^AUPNVLAB(X,0),U,4)
 ...S R=+R
 ...I R'<1.10 S MU=1
 ...Q
 I 'MU Q ""  ;since no MUMPS and have to have all 3 might as well quit now
RU ;
 ;is there evidence of RUBELLA?
 I $$PLTAXND^BGP8DU(P,"BGP IPC RUBELLA DXS",EDATE,0) S RU=1
 I $$IPLSNOND^BGP8DU(P,"PXRM BGP IPC RUBELLA EVID",EDATE,0) S RU=1
 I $$LASTDX^BGP8UTL1(P,"BGP IPC RUBELLA DXS",$$DOB^AUPNPAT(P),EDATE) S RU=1
 ;NOW V POV SNOMED
 ;NOW SNOMED USING ASNC
 S T="PXRM BGP IPC RUBELLA EVID"
 S G=""
 S S=0 F  S S=$O(^XTMP("BGPSNOMEDSUBSET",$J,T,S)) Q:S=""!(MU)  D
 .Q:'$D(^AUPNVPOV("ASNC",P,S))
 .S D=0 F  S D=$O(^AUPNVPOV("ASNC",P,S,D)) Q:D=""!(MU)  D
 ..S Y=9999999-D
 ..Q:Y>EDATE
 ..S RU=1
 I RU Q 1
 ;lab tests?
RULT ;
 S E=9999999-EDATE S D=E-1 F  S D=$O(^AUPNVLAB("AE",P,D)) Q:D'=+D!(RU)  D
 .S L=0 F  S L=$O(^AUPNVLAB("AE",P,D,L)) Q:L'=+L!(RU)  D
 ..S X=0 F  S X=$O(^AUPNVLAB("AE",P,D,L,X)) Q:X'=+X!(RU)  D
 ...Q:'$D(^AUPNVLAB(X,0))
 ...S J=$P($G(^AUPNVLAB(X,11)),U,13) Q:J=""
 ...Q:'$$LOINCRU(J)
 ...S R=$P(^AUPNVLAB(X,0),U,4)
 ...S R=+R
 ...I R'<1.10 S RU=1
 ...Q
 I 'RU Q ""  ;since no RUBELLA and have to have all 3 might as well quit now
 Q 1
LOINCME(A) ;is this a measles loinc code
 NEW %
 S %=$P($G(^LAB(95.3,A,0)),U)_"-"_$P($G(^LAB(95.3,A,0)),U,15)
 I %="21500-4" Q 1
 I %="21501-2" Q 1
 I %="22501-1" Q 1
 I %="22502-9" Q 1
 Q ""
LOINCMU(A) ;is this a MUMPS loinc code
 NEW %
 S %=$P($G(^LAB(95.3,A,0)),U)_"-"_$P($G(^LAB(95.3,A,0)),U,15)
 I %="21401-5" Q 1
 I %="22416-2" Q 1
 I %="22417-0" Q 1
 I %="6477-4" Q 1
 Q ""
LOINCRU(A) ;is this a RUBELLA loinc code
 NEW %
 S %=$P($G(^LAB(95.3,A,0)),U)_"-"_$P($G(^LAB(95.3,A,0)),U,15)
 I %="41763-4" Q 1
 I %="46110-3" Q 1
 Q ""