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

BGP9D86.m

Go to the documentation of this file.
BGP9D86 ; IHS/CMI/LAB - measure C 06 Nov 2007 2:26 PM ;
 ;;9.0;IHS CLINICAL REPORTING;;JUL 1, 2009
 ;
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^BGP9D862(DFN,BGPBDATE,BGPEDATE) S BGPSTOP=1 Q  ;no OSTEOARTHRITIS
 S BGPV=$$MEDSPRE^BGP9D863(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^BGP9D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPLFT=$$LFT^BGP9D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPCREAT=$$CREAT^BGP9D22(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("A")=0,BGPIRV("A")="Has NSAID: "
 .I BGPCBC,BGPLFT,BGPCREAT S BGPIRZ("A")=1,BGPIRV("A")=BGPIRV("A")_" CREAT: "_$$DATE^BGP9UTL($P(BGPCREAT,U,2))_"CBC: "_$$DATE^BGP9UTL($P(BGPCBC,U,2))_" LFT: "_$$DATE^BGP9UTL($P(BGPLFT,U,2))  ;NA MEDS AND HAS CBC,LFT
 .I 'BGPCREAT S BGPIRV("A")=BGPIRV("A")_"No CREAT"
 .I 'BGPCBC S BGPIRV("A")=BGPIRV("A")_" No CBC"
 .I 'BGPLFT S BGPIRV("A")=BGPIRV("A")_" No LFT"
 I $P(BGPV,U,3) D
 .S BGPGOLD=$$GOLDLAB^BGP9D864(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("B")=0,BGPIRV("B")="Has IM Gold: "
 .I BGPGOLD S BGPIRZ("B")=1,BGPIRV("B")=BGPIRV("B")_"CBC/Urine Protein: "_$P(BGPGOLD,U,2)
 .I 'BGPGOLD S BGPIRV("B")=$P(BGPGOLD,U,2)
 I $P(BGPV,U,4) D
 .S BGPCBC=$$CBC4^BGP9D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("C")=0,BGPIRV("C")="Has 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^BGP9D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("D")=0,BGPIRV("D")="Has 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^BGP9D861(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^BGP9D861(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^BGP9D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("E")=0,BGPIRV("E")="Has 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^BGP9D861(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^BGP9D861(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^BGP9D861(DFN,$$FMADD^XLFDT(BGPEDATE,-180),BGPEDATE)
 .S BGPIRZ("F")=0,BGPIRV("F")="Has 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^BGP9D861(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^BGP9D861(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^BGP9D861(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^BGP9D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("G")=0,BGPIRV("G")="Has 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^BGP9D861(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^BGP9D861(DFN,$$FMADD^XLFDT(BGPEDATE,-180),BGPEDATE)
 .S BGPIRZ("H")=0,BGPIRV("H")="Has 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^BGP9D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("I")=0,BGPIRV("I")="Has 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^BGP9D861(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^BGP9D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("J")=0,BGPIRV("J")="Has 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^BGP9D861(DFN,BGPBDATE,BGPEDATE)
 .S BGPIRZ("K")=0,BGPIRV("K")="Has Glucocorticoids: "
 .I BGPGLU S BGPIRZ("K")=1,BGPIRV("K")=BGPIRV("K")_"has 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_" "_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^BGP9D32(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^BGP9D31(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) S:$P(^AUPNPREF(Y,0),U,7)="N" 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^BGP9D32(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"
 D GETIMMS^BGP9D32(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 V06.5;DURING "_$$DOB^AUPNPAT(P)_"-"_EDATE,E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)) Q 2_U_"Td"
 F BGPZ=9,113 S X=$$ANCONT^BGP9D31(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  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) S:$P(^AUPNPREF(Y,0),U,7)="N" 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^BGP9D32(P,BGPIMM,$$DOB^AUPNPAT(P),EDATE)+R
 I R Q 3_U_"ref imm pkg Td"
 Q ""