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

BGP5D86.m

Go to the documentation of this file.
BGP5D86 ; IHS/CMI/LAB - measure C 06 Nov 2009 2:26 PM ;
 ;;15.1;IHS CLINICAL REPORTING;;MAY 06, 2015;Build 143
 ;
IRAR ;EP
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9,BGPD10,BGPD11,BGPD12)=0
 I 'BGPACTCL S BGPSTOP=1 Q
 I BGPAGEB<16 S BGPSTOP=1 Q  ;must be 16 or older
 I '$$RHEUAR^BGP5D862(DFN,BGPBDATE,BGPEDATE) S BGPSTOP=1 Q  ;no OSTEOARTHRITIS
 S BGPV=$$MEDSPRE^BGP5D863(DFN,BGPBDATE,BGPEDATE)
 I '$P(BGPV,U) S BGPSTOP=1 K ^TMP($J,"A"),BGPMEDS1 Q  ;no meds prescribed per logic
 S BGPN1=0
 I BGPACTCL S BGPD1=1
 I BGPACTUP S BGPD2=1
 I 'BGPD1 S BGPSTOP=1 Q
 K BGPIRZ,BGPIRV
 I $P(BGPV,U,2) D
 .S BGPCBC=$$CBC^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPLFT=$$LFT^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPCREAT=$$CREAT^BGP5D22(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("A")=0,BGPIRV("A")="NSAID: "
 .I BGPCBC,BGPLFT,BGPCREAT S BGPIRZ("A")=1 ;,BGPIRV("A")=BGPIRV("A")_$$DATE^BGP5UTL($P(BGPCREAT,U,2))_" CREAT, "_$$DATE^BGP5UTL($P(BGPCBC,U,2))_" CBC, "_$$DATE^BGP5UTL($P(BGPLFT,U,2))_" LFT"  ;NA MEDS AND HAS CBC,LFT
 .I BGPCREAT S BGPIRV("A")=BGPIRV("A")_$$DATE^BGP5UTL($P(BGPCREAT,U,2))_" CREAT"
 .I BGPCBC S BGPIRV("A")=BGPIRV("A")_$S(BGPIRV("A")]"":", ",1:"") S BGPIRV("A")=BGPIRV("A")_$$DATE^BGP5UTL($P(BGPCBC,U,2))_" CBC"
 .I BGPLFT S BGPIRV("A")=BGPIRV("A")_$S(BGPIRV("A")]"":", ",1:"") S BGPIRV("A")=BGPIRV("A")_$$DATE^BGP5UTL($P(BGPLFT,U,2))_" LFT"
 I $P(BGPV,U,3) D
 .S BGPGOLD=$$GOLDLAB^BGP5D864(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("B")=0,BGPIRV("B")="IM Gold: "
 .I BGPGOLD S BGPIRZ("B")=1,BGPIRV("B")=BGPIRV("B")_" "_$P(BGPGOLD,U,2)
 .I 'BGPGOLD S BGPIRV("B")=$P(BGPGOLD,U,2)
 I $P(BGPV,U,4) D
 .S BGPCBC=$$CBC4^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("C")=0,BGPIRV("C")="AZATHIOPRINE: "
 .I BGPCBC S BGPIRZ("C")=1,BGPIRV("C")=BGPIRV("C")_"has 4 CBC's"
 .I 'BGPCBC S BGPIRV("C")=BGPIRV("C")_" does not have 4 CBC's"
 I $P(BGPV,U,5) D
 .S BGPCBC=$$CBC6^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("D")=0,BGPIRV("D")="Leflunomide: "
 .I BGPCBC S BGPIRV("D")=BGPIRV("D")_"has 6 CBC's"
 .I 'BGPCBC S BGPIRV("D")=BGPIRV("D")_" does not have 6 CBC's"
 .S BGPSERUM=$$SERUM6^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .I BGPSERUM S BGPIRV("D")=BGPIRV("D")_" has 6 Serum Creatinine's"
 .I 'BGPSERUM S BGPIRV("D")=BGPIRV("D")_" does not have 6 Serum Creatinine's"
 .S BGPLFT=$$LFT6^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .I BGPLFT S BGPIRV("D")=BGPIRV("D")_" has 6 LFT's"
 .I 'BGPLFT S BGPIRV("D")=BGPIRV("D")_" does not have 6 LFT's"
 .I BGPCBC,BGPSERUM,BGPLFT S BGPIRZ("D")=1
 I $P(BGPV,U,6) D
 .S BGPCBC=$$CBC6^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("E")=0,BGPIRV("E")="Methotrexate: "
 .I BGPCBC S BGPIRV("E")=BGPIRV("E")_"has 6 CBC's"
 .I 'BGPCBC S BGPIRV("E")=BGPIRV("E")_" does not have 6 CBC's"
 .S BGPSERUM=$$SERUM6^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .I BGPSERUM S BGPIRV("E")=BGPIRV("E")_" has 6 Serum Creatinine's"
 .I 'BGPSERUM S BGPIRV("E")=BGPIRV("E")_" does not have 6 Serum Creatinine's"
 .S BGPLFT=$$LFT6^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .I BGPLFT S BGPIRV("E")=BGPIRV("E")_" has 6 LFT's"
 .I 'BGPLFT S BGPIRV("E")=BGPIRV("E")_" does not have 6 LFT's"
 .I BGPCBC,BGPSERUM,BGPLFT S BGPIRZ("E")=1
 I $P(BGPV,U,7) D
 .S BGPCBC=$$CBC^BGP5D861(DFN,$$FMADD^XLFDT(BGPEDATE,-180),BGPEDATE)
 .S BGPIRZ("F")=0,BGPIRV("F")="Cycolsporin: "
 .I BGPCBC S BGPIRV("F")=BGPIRV("F")_"has CBC Past 180 days"
 .I 'BGPCBC S BGPIRV("F")=BGPIRV("F")_" does not have CBC past 180 days"
 .S BGPLFT=$$LFT^BGP5D861(DFN,$$FMADD^XLFDT(BGPBDATE,-180),BGPEDATE)
 .I BGPLFT S BGPIRV("F")=BGPIRV("F")_" has LFT past 180 days"
 .I 'BGPLFT S BGPIRV("F")=BGPIRV("F")_" does not have LFT 180 days"
 .S BGPPOT=$$POT^BGP5D861(DFN,$$FMADD^XLFDT(BGPBDATE,-180),BGPEDATE)
 .I BGPPOT S BGPIRV("F")=BGPIRV("F")_" has Potassium in 180 days"
 .I 'BGPPOT S BGPIRV("F")=BGPIRV("F")_" does not have Potassium"
 .S BGPSERUM=$$SERUM12^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .I BGPSERUM S BGPIRV("F")=BGPIRV("F")_" has 12 serum creatinine"
 .I 'BGPSERUM S BGPIRV("F")=BGPIRV("F")_" does not have 12 serum creatinine"
 .I BGPCBC,BGPSERUM,BGPLFT,BGPPOT S BGPIRZ("F")=1
 I $P(BGPV,U,8) D
 .S BGPCBC=$$CBC4^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("G")=0,BGPIRV("G")="Oral Gold: "
 .I BGPCBC S BGPIRV("G")=BGPIRV("G")_"has 4 CBC's"
 .I 'BGPCBC S BGPIRV("G")=BGPIRV("G")_" does not have 6 CBC's"
 .S BGPUP=$$UP4^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .I BGPUP S BGPIRV("G")=BGPIRV("G")_" has 4 Urine Proteins"
 .I 'BGPUP S BGPIRV("G")=BGPIRV("G")_" does not have 4 Urine Protein's"
 .I BGPCBC,BGPUP S BGPIRZ("G")=1
 I $P(BGPV,U,9) D
 .S BGPCBC=$$CBC^BGP5D861(DFN,$$FMADD^XLFDT(BGPEDATE,-180),BGPEDATE)
 .S BGPIRZ("H")=0,BGPIRV("H")="Mycophenolate: "
 .I BGPCBC S BGPIRV("H")=BGPIRV("H")_"has CBC Past 180 days"
 .I 'BGPCBC S BGPIRV("H")=BGPIRV("H")_" does not have CBC past 180 days"
 .I BGPCBC S BGPIRZ("H")=1
 I $P(BGPV,U,10) D
 .S BGPCBC=$$CBC4^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("I")=0,BGPIRV("I")="Penicillamine: "
 .I BGPCBC S BGPIRV("I")=BGPIRV("I")_"has 4 CBC's"
 .I 'BGPCBC S BGPIRV("I")=BGPIRV("I")_" does not have 6 CBC's"
 .S BGPUP=$$UP4^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .I BGPUP S BGPIRV("I")=BGPIRV("I")_" has 4 Urine Proteins"
 .I 'BGPUP S BGPIRV("I")=BGPIRV("I")_" does not have 4 Urine Protein's"
 .I BGPCBC,BGPUP S BGPIRZ("I")=1
 I $P(BGPV,U,11) D
 .S BGPCBC=$$CBC4^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("J")=0,BGPIRV("J")="Sulfasalazine: "
 .I BGPCBC S BGPIRZ("J")=1,BGPIRV("J")=BGPIRV("J")_"has 4 CBC's"
 .I 'BGPCBC S BGPIRV("J")=BGPIRV("J")_" does not have 4 CBC's"
 I $P(BGPV,U,12) D
 .S BGPGLU=$$GLUCOSE^BGP5D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("K")=0,BGPIRV("K")="Glucocorticoids: "
 .I BGPGLU S BGPIRZ("K")=1,BGPIRV("K")=BGPIRV("K")_$$DATE^BGP5UTL($P(BGPGLU,U,2))_" Glucose"
 .I 'BGPGLU S BGPIRV("K")=BGPIRV("K")_" does not have Glucose"
 S BGPN1=1 S X="" F  S X=$O(BGPIRZ(X)) Q:X=""  I BGPIRZ(X)=0 S BGPN1=0
 S BGPVALUE=$S(BGPD1:"AC",1:"")_"|||"
 S BGPVALUE=BGPVALUE_$S(BGPN1:"YES: ",1:"NO: ") S X="" F  S X=$O(BGPIRV(X)) Q:X=""  S BGPVALUE=BGPVALUE_$S($P(BGPVALUE,U,2)]"":"; ",1:""),BGPVALUE=BGPVALUE_BGPIRV(X)
 K X,Y,Z,%,A,B,C,D,E,H,BDATE,EDATE,P,V,S,F,T
 K ^TMP($J,"A")
 Q
 ;
TDAP(P,EDATE) ;EP
 K BGPC,BGPG,BGPX
 ;gather up all immunizations, cpts, povs and check for 3 each ten days apart
 K BGPVARI
 ;get all immunizations
 S C="115"
 D GETIMMS^BGP5D32(P,EDATE,C,.BGPX)
 ;go through and set into array if 10 days apart
 I $O(BGPX(0)) Q 1_U_"Tdap"
 ;now get cpts
 S ED=9999999-EDATE-1,BD=9999999-$$DOB^AUPNPAT(P),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) I Y=90715 S BGPVARI(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) I Y=90715 S BGPVARI(9999999-$P(ED,"."))=""
 I $D(BGPVARI) Q 1_U_"Tdap"
 F BGPZ=115 S X=$$ANCONT^BGP5D31(P,BGPZ,EDATE) Q:X]""
 I X]"" Q 4_U_"Contra Tdap"
 ;now go to Refusals
 S B=$$DOB^AUPNPAT(P),E=EDATE,BGPNMI="",R=""
 F BGPIMM=115  D
 .S I=$O(^AUTTIMM("C",BGPIMM,0)) Q:'I
 .S X=0 F  S X=$O(^AUPNPREF("AA",P,9999999.14,I,X)) Q:X'=+X  S Y=0 F  S Y=$O(^AUPNPREF("AA",P,9999999.14,I,X,Y)) Q:Y'=+Y  S D=$P(^AUPNPREF(Y,0),U,3) I D'<B&(D'>E) I $P(^AUPNPREF(Y,0),U,7)="N" S BGPNMI=1 S R=1
 I R Q $S(BGPNMI:4,1:3)_U_$S(BGPNMI:"NMI Tdap",1:"Ref Tdap")
 F BGPIMM=90715  D
 .S I=+$$CODEN^ICPTCOD(BGPIMM) Q:'I
 .S X=0 F  S X=$O(^AUPNPREF("AA",P,81,I,X)) Q:X'=+X  S Y=0 F  S Y=$O(^AUPNPREF("AA",P,81,I,X,Y)) Q:Y'=+Y  S D=$P(^AUPNPREF(Y,0),U,3) I D'<B&(D'>E) I $P(^AUPNPREF(Y,0),U,7)="N" S BGPNMI=1 S R=1
 I R Q $S(BGPNMI:4,1:3)_U_$S(BGPNMI:"NMI Tdap",1:"Ref Tdap")
 ;now check Refusals in imm pkg
 ;F BGPIMM=115 S R=$$IMMREF^BGP5D32(P,BGPIMM,$$DOB^AUPNPAT(P),EDATE)+R
 ;I R Q 3_U_"Ref imm pkg Tdap"
TD ;
 K BGPC,BGPG,BGPX
 ;gather up all immunizations, cpts, povs and check for 3 each ten days apart
 K BGPVARI
 ;get all immunizations
 S C="9^113^138^139"
 D GETIMMS^BGP5D32(P,EDATE,C,.BGPX)
 ;go through and set into array if 10 days apart
 I $O(BGPX(0)) Q 1_U_"Td"
 ;now get cpts
 S ED=9999999-EDATE-1,BD=9999999-$$DOB^AUPNPAT(P),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) I Y=Y=90714!(Y=90718) S BGPVARI(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) I Y=Y=90714!(Y=90718) S BGPVARI(9999999-$P(ED,"."))=""
 I $D(BGPVARI) Q 1_U_"Td"
 K BGPG S %=P_"^ALL DX [BGP TD IZ DXS;DURING "_$$DOB^AUPNPAT(P)_"-"_EDATE,E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)) Q 1_U_"Td"
 F BGPZ=9,113,138,139 S X=$$ANCONT^BGP5D31(P,BGPZ,EDATE) Q:X]""
 I X]"" Q 4_U_"Contra Td"
 ;now go to Refusals
 S B=$$DOB^AUPNPAT(P),E=EDATE,BGPNMI="",R=""
 F BGPIMM=9,113,138,139 D
 .S I=$O(^AUTTIMM("C",BGPIMM,0)) Q:'I
 .S X=0 F  S X=$O(^AUPNPREF("AA",P,9999999.14,I,X)) Q:X'=+X  S Y=0 F  S Y=$O(^AUPNPREF("AA",P,9999999.14,I,X,Y)) Q:Y'=+Y  S D=$P(^AUPNPREF(Y,0),U,3) I D'<B&(D'>E) I $P(^AUPNPREF(Y,0),U,7)="N" S BGPNMI=1 S R=1
 I R Q $S(BGPNMI:4,1:3)_U_$S(BGPNMI:"NMI Td",1:"Ref Td")
 F BGPIMM=90714,90718  D
 .S I=+$$CODEN^ICPTCOD(BGPIMM) Q:'I
 .S X=0 F  S X=$O(^AUPNPREF("AA",P,81,I,X)) Q:X'=+X  S Y=0 F  S Y=$O(^AUPNPREF("AA",P,81,I,X,Y)) Q:Y'=+Y  S D=$P(^AUPNPREF(Y,0),U,3) I D'<B&(D'>E) I $P(^AUPNPREF(Y,0),U,7)="N" S BGPNMI=1 S R=1
 I R Q $S(BGPNMI:4,1:3)_U_$S(BGPNMI:"NMI Td",1:"Ref Td")
 ;now check Refusals in imm pkg
 ;F BGPIMM=9,113 S R=$$IMMREF^BGP5D32(P,BGPIMM,$$DOB^AUPNPAT(P),EDATE)+R
 ;I R Q 3_U_"Ref imm pkg Td"
 Q ""