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

BGP9D74.m

Go to the documentation of this file.
BGP9D74 ; IHS/CMI/LAB - measure 1,2,3,4 05 Apr 2008 1:44 PM ;
 ;;9.0;IHS CLINICAL REPORTING;;JUL 1, 2009
 ;
IEFR ;EP
 S (BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9)=0
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7)=0
 I BGPAGEB<65 S BGPSTOP=1 Q
 S BGPD2=1 ;user pop
 I BGPACTCL S BGPD1=1  ;active clinical
 I BGPAGEB>64,BGPAGEB<75,BGPD1 S BGPD3=1
 I BGPAGEB>74,BGPAGEB<85,BGPD1 S BGPD4=1
 I BGPAGEB>84,BGPD1 S BGPD5=1
 S BGPVALUE=""
 S BGPFREX=$$FALLEX(DFN,BGPBDATE,BGPEDATE)
 I BGPFREX S BGPN2=1,BGPVALUE=$P(BGPFREX,U,2)_"-"_$P(BGPFREX,U,3)
 S BGPDHF=$$DHF(DFN,BGPBDATE,BGPEDATE)
 I BGPDHF S BGPN3=1,BGPVALUE=BGPVALUE_$S(BGPVALUE]"":";",1:"")_$P(BGPDHF,U,2)_"-"_$P(BGPDHF,U,3)
 S BGPFID=$$FID(DFN,BGPBDATE,BGPEDATE)
 I BGPFID S BGPN4=1,BGPVALUE=BGPVALUE_$S(BGPVALUE]"":";",1:"")_$P(BGPFID,U,2)_"-"_$P(BGPFID,U,3)
 S BGPAGM=$$AGM(DFN,BGPBDATE,BGPEDATE)
 I BGPAGM S BGPN5=1,BGPVALUE=BGPVALUE_$S(BGPVALUE]"":";",1:"")_$P(BGPAGM,U,2)_"-"_$P(BGPAGM,U,3)
 S BGPREFEX=$$REFFRE(DFN,BGPBDATE,BGPEDATE)
 I BGPREFEX S BGPN6=1,BGPVALUE=BGPVALUE_$S(BGPVALUE]"":";",1:"")_$P(BGPREFEX,U,2)_"-"_$P(BGPREFEX,U,3)
 S BGPVALUE=$S(BGPRTYPE=5:"",1:"UP")_$S(BGPD1:";AC",1:"")_"|||"_BGPVALUE
 I BGPN2!(BGPN3)!(BGPN4)!(BGPN5)!(BGPN6) S BGPN1=1
 K X,Y,Z,%,A,B,C,D,E,H,BDATE,EDATE,P,V,S,F,T,BGPG
 Q
IEDA ;EP
 S (BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9)=0
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7)=0
 K BGPNUMV  ;FOR ELDER 20 NUMERATORS
 I BGPAGEB<65 S BGPSTOP=1 Q
 S BGPD4=1  ;user pop
 I BGPACTCL S BGPD1=1  ;active clinical
 I BGPRTYPE=5,'BGPD1 S BGPSTOP=1 Q  ;elder only wants active clinical
 I BGPD1,BGPSEX="M" S BGPD2=1
 I BGPD1,BGPSEX="F" S BGPD3=1
 I BGPD4,BGPSEX="M" S BGPD5=1
 I BGPD4,BGPSEX="F" S BGPD6=1
 I BGPAGEB>64,BGPAGEB<75,BGPD1 S BGPD7=1
 I BGPAGEB>74,BGPAGEB<85,BGPD1 S BGPD8=1
 I BGPAGEB>84,BGPD1 S BGPD9=1
 K BGPMEDS,BGPDAE
 D GETDAE(DFN,BGPBDATE,BGPEDATE,.BGPDAE,.BGPNUMV)
 S X=0,C=0,J="" F  S X=$O(BGPDAE(X)) Q:X'=+X  S C=C+1,J=J_$S(J]"":";",1:"")_$P(BGPDAE(X),U,2)_"-"_$$DATE^BGP9UTL($P(BGPDAE(X),U,3))_"("_$P(BGPDAE(X),U,4)_")"
 I C>0 S BGPN1=1
 I C>1 S BGPN2=1
 F X=1:1:18 I '$D(BGPNUMV(X)) S BGPNUMV(X)=0
 S BGPVALUE="UP"
 I BGPRTYPE=3!(BGPRTYPE=5) S BGPVALUE=""
 S BGPVALUE=BGPVALUE_$S(BGPD1:";AC",1:"")_"|||"_C_" drugs: "_J
 K BGPMEDS,BGPMEDS1,J,X,C,Y,BGPDAE
 K ^TMP($J,"MEDS")
 Q
IBFR ;EP
 S (BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9)=0
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7,BGPN8,BGPN9)=0
 S (BGPV2,BGPV3,BGPV4,BGPV5,BGPV6)=""
 S BGPADAY=$$FMDIFF^XLFDT(BGPBDATE,$P(^DPT(DFN,0),U,3))
 I BGPADAY<45 S BGPSTOP=1 Q
 I BGPADAY>394 S BGPSTOP=1 Q
 I 'BGPACTCL S BGPSTOP=1 Q
 S BGPD1=1
 K BGPBFR
 D GETIFC(DFN,BGPBDATE,BGPEDATE,.BGPBFR)
 I $D(BGPBFR) S BGPN1=1  ;has a screening
 ;n2
 D
 .S X=44,G="" K Z F  S X=$O(BGPBFR(X)) Q:X'=+X!(X>89)  S Z($$ABS^XLFMTH(X-60))=X
 .Q:'$D(Z)
 .S X=$O(Z("")),X=Z(X)  ;this is the lowest/closest to 60 days
 .S BGPN2=1
 .S Y=BGPBFR(X)
 .I +Y=1!(+Y=2) S BGPN6=1
 .S BGPV2="2 MOS: "_$$EXTSET^XBFUNC(9000010.44,.01,+Y)_"-"_X_" DO-"_$$DATE^BGP9UTL($P(Y,U,2))
 .S G=1
 D
 .S X=164,G="" K Z F  S X=$O(BGPBFR(X)) Q:X'=+X!(X>209)  S Z($$ABS^XLFMTH(X-180))=X
 .Q:'$D(Z)
 .S X=$O(Z("")),X=Z(X)  ;this is the lowest/closest to 180 days
 .S BGPN3=1
 .S Y=BGPBFR(X)
 .I +Y=1!(+Y=2) S BGPN7=1
 .S BGPV3="6 MOS: "_$$EXTSET^XBFUNC(9000010.44,.01,+Y)_"-"_X_" DO-"_$$DATE^BGP9UTL($P(Y,U,2))
 .S G=1
 D
 .S X=254,G="" K Z F  S X=$O(BGPBFR(X)) Q:X'=+X!(X>299)  S Z($$ABS^XLFMTH(X-270))=X
 .Q:'$D(Z)
 .S X=$O(Z("")),X=Z(X)  ;this is the lowest/closest to 270 days
 .S BGPN4=1
 .S Y=BGPBFR(X)
 .I +Y=1!(+Y=2) S BGPN8=1
 .S BGPV4="9 MOS: "_$$EXTSET^XBFUNC(9000010.44,.01,+Y)_"-"_X_" DO-"_$$DATE^BGP9UTL($P(Y,U,2))
 .S G=1
 D
 .S X=349,G="" K Z F  S X=$O(BGPBFR(X)) Q:X'=+X!(X>394)  S Z($$ABS^XLFMTH(X-365))=X
 .Q:'$D(Z)
 .S X=$O(Z("")),X=Z(X)  ;this is the lowest/closest to 365 days
 .S BGPN5=1
 .S Y=BGPBFR(X)
 .I +Y=1!(+Y=2) S BGPN9=1
 .S BGPV5="1 YR: "_$$EXTSET^XBFUNC(9000010.44,.01,+Y)_"-"_X_" DO-"_$$DATE^BGP9UTL($P(Y,U,2))
 .S G=1
 S BGPVALUE=$S(BGPN1=1:"scrn",1:"")
 S BGPVALUE=BGPVALUE_$S(BGPV2]"":";",1:"")_BGPV2
 S BGPVALUE=BGPVALUE_$S(BGPV3]"":";",1:"")_BGPV3
 S BGPVALUE=BGPVALUE_$S(BGPV4]"":";",1:"")_BGPV4
 S BGPVALUE=BGPVALUE_$S(BGPV5]"":";",1:"")_BGPV5
 S BGPVALUE="AC|||"_BGPVALUE
 K BGPV1,BGPV2,BGPV3,BGPV4,BGPV5,BGPV6,BGPBFR
 Q
GETDAE(P,BDATE,EDATE,BGPRET,BGPRET1) ;EP
 ;get all meds in all taxonomies
 K BGPMEDS,BGPMEDST,BGPRET,BGPRET1
 K BGPMEDS1 S BGPXXX="ANTIANXIETY",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS ANTIANXIETY MEDS","BGP HEDIS ANTIANXIETY NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(1)=1
 K BGPMEDS1 S BGPXXX="ANTIEMETIC",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS ANTIEMETIC MEDS","BGP HEDIS ANTIEMETIC NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(2)=1
 K BGPMEDS1 S BGPXXX="ANALGESIC",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS ANALGESIC MEDS","BGP HEDIS ANALGESIC NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(3)=1
 K BGPMEDS1 S BGPXXX="ANTIHISTAMINE",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS ANTIHISTAMINE MEDS","BGP HEDIS ANTIHISTAMINE NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(4)=1
 K BGPMEDS1 S BGPXXX=" ANTIPSYCHOTIC",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS ANTIPSYCHOTIC MEDS","BGP HEDIS ANTIPSYCHOTIC NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(5)=1
 K BGPMEDS1 S BGPXXX="AMPHETAMINE",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS AMPHETAMINE MEDS","BGP HEDIS AMPHETAMINE NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(6)=1
 K BGPMEDS1 S BGPXXX="BARBITURATE",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS BARBITURATE MEDS","BGP HEDIS BARBITURATE NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(7)=1
 K BGPMEDS1 S BGPXXX="BENZODIAZEPINE",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS BENZODIAZEPINE MEDS","BGP HEDIS BENZODIAZEPINE NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(8)=1
 K BGPMEDS1 S BGPXXX="OTHER BENZODIAZEPNE",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS OTHER BENZODIAZEPINE","BGP HEDIS OTHER BENZO NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(9)=1
 K BGPMEDS1 S BGPXXX="CALCIUM CHANNEL",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS CALCIUM CHANNEL MEDS","BGP HEDIS CALCIUM CHANNEL NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(10)=1
 K BGPMEDS1 S BGPXXX="GASTRO ANTISPASM",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS GASTRO ANTISPASM MED","BGP HEDIS GASTRO ANTISPASM NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(11)=1
 K BGPMEDS1 S BGPXXX="BELLADONNA",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS BELLADONNA ALKA MEDS","BGP HEDIS BELLADONNA ALKA NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(12)=1
 K BGPMEDS1 S BGPXXX="SKL MUSCLE",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS SKL MUSCLE RELAX MED","BGP HEDIS SKL MUSCLE RELAX NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(13)=1
 K BGPMEDS1 S BGPXXX="ORAL ESTROGEN",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS ORAL ESTROGEN MEDS","BGP HEDIS ORAL ESTROGEN NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(14)=1
 K BGPMEDS1 S BGPXXX="ORAL HYPOGLYCEMIC",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS ORAL HYPOGLYCEMIC RX","BGP HEDIS ORAL HYPOGLYCEMIC ND",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(15)=1
 K BGPMEDS1 S BGPXXX="NARCOTIC",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS NARCOTIC MEDS","BGP HEDIS NARCOTIC NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(16)=1
 K BGPMEDS1 S BGPXXX="VASODILATOR",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS VASODILATOR MEDS","BGP HEDIS VASODILATOR NDC",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(17)=1
 K BGPMEDS1 S BGPXXX="OTHER MEDS",BGPGOT=0 D GETMEDS^BGP9UTL2(P,BGPBDATE,BGPEDATE,"BGP HEDIS OTHER MEDS AVOID ELD","BGP HEDIS OTHER NDC AVOID ELD",,,.BGPMEDS1)
 D ADDINMED
 I BGPGOT S BGPRET1(18)=1
 K BGPMEDS1
 Q
ADDINMED ;
 S X=0 F  S X=$O(BGPMEDS1(X)) Q:X'=+X  D
 .S Y=$P(BGPMEDS1(X),U,4)  ;vmed ien
 .S D=$P(^AUPNVMED(Y,0),U,1)  ;drug ien
 .;DAYS SUPPLY MUST BE >0
 .S E=$P(^AUPNVMED(Y,0),U,8) ;date discontinued
 .S S=$P(^AUPNVMED(Y,0),U,7) ;DAYS SUPPLY
 .Q:'S
 .I E,E'>$P(BGPMEDS1(X),U,1) Q  ;at least one day
 .S $P(BGPRET(D),U)=$P($G(BGPRET(D)),U)+1
 .S $P(BGPRET(D),U,2)=$P(^PSDRUG(D,0),U)
 .S $P(BGPRET(D),U,3)=$P(BGPMEDS1(X),U,1)  ;LAST FILL
 .S $P(BGPRET(D),U,4)=BGPXXX
 .S BGPGOT=1
 .Q
 Q
GETIFC(P,BDATE,EDATE,BGPRET) ;EP
 K BGPRET,BGPG,C,X
 S X=0 F  S X=$O(^AUPNVIF("AC",P,X)) Q:X'=+X  D
 .Q:'$D(^AUPNVIF(X))
 .S V=$P(^AUPNVIF(X,0),U,3),C=$P(^AUPNVIF(X,0),U,1)
 .Q:V=""
 .Q:'$D(^AUPNVSIT(V,0))
 .S V=$P($P(^AUPNVSIT(V,0),U),".")
 .;I V<BDATE Q
 .;I V>EDATE Q
 .S BGPRET($$FMDIFF^XLFDT(V,$P(^DPT(P,0),U,3)))=C_U_V
 .Q
 Q
FALLEX(P,BDATE,EDATE) ;EP
 K BGPG S %=P_"^LAST EXAM 37;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)) Q 1_"^exam 37^"_$$DATE^BGP9UTL($P(BGPG(1),U))
 Q ""
DHF(P,BDATE,EDATE) ;EP
 K BGPG
 S Y="BGPG("
 S X=P_"^LAST DX V15.88;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 I $D(BGPG(1)) Q 1_U_"Hx of Fall DX: "_$P(BGPG(1),U,2)_U_$$DATE^BGP9UTL($P(BGPG(1),U))
 Q ""
FID(P,BDATE,EDATE) ;EP
 S Y="BGPG("
 K BGPG
 S X=P_"^ALL DX;DURING "_BDATE_-EDATE S E=$$START1^APCLDF(X,Y)
 S G=""
 S T=$O(^ATXAX("B","BGP FALL RELATED E-CODES",0))
 S X=0 F  S X=$O(BGPG(X)) Q:X'=+X!(G)  D
 .S Y=+$P(BGPG(X),U,4),D=$P(^AUPNVPOV(Y,0),U)
 .I $P(^AUPNVPOV(Y,0),U,9)="",$P(^AUPNVPOV(Y,0),U,18)="",$P(^AUPNVPOV(Y,0),U,19)="" Q
 .S E=$P(^AUPNVPOV(Y,0),U,9) I E,$$ICD^ATXCHK(E,T,9) S G=1_U_"Fall Injury: "_$P($$ICDDX^ICDCODE(E),U,2)_U_$$DATE^BGP9UTL($P(BGPG(X),U,1)) Q
 .S E=$P(^AUPNVPOV(Y,0),U,18) I E,$$ICD^ATXCHK(E,T,9) S G=1_U_"Fall Injury: "_$P($$ICDDX^ICDCODE(E),U,2)_U_$$DATE^BGP9UTL($P(BGPG(X),U,1)) Q
 .S E=$P(^AUPNVPOV(Y,0),U,19) I E,$$ICD^ATXCHK(E,T,9) S G=1_U_"Fall Injury: "_$P($$ICDDX^ICDCODE(E),U,2)_U_$$DATE^BGP9UTL($P(BGPG(X),U,1)) Q
 I G Q G
 Q ""
AGM(P,BDATE,EDATE) ;EP
 S BGPG=$$LASTDX^BGP9UTL1(P,"BGP ABNORMAL GAIT OR MOBILITY",BDATE,EDATE)
 I $P(BGPG,U) Q 1_U_"Abnormal Gait: "_$P(BGPG,U,2)_U_$$DATE^BGP9UTL($P(BGPG,U,3))
 Q ""
REFFRE(P,BDATE,EDATE) ;EP
 ;add refusal for exam 37
 S G=$$REFUSAL^BGP9UTL1(P,9999999.15,$O(^AUTTEXAM("C",37,0)),$$FMADD^XLFDT(EDATE,-365),EDATE)
 I $P(G,U)=1 Q 1_"^ref exam 37^"_$$DATE^BGP9UTL($P(G,U,2))
 Q ""