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

BGP3EL4.m

Go to the documentation of this file.
BGP3EL4 ; IHS/CMI/LAB - measure 1,2,3,4 05 Apr 2010 1:44 PM ;
 ;;13.0;IHS CLINICAL REPORTING;;NOV 20, 2012;Build 81
 ;
I18 ;EP
 S (BGPD1,BGPD2,BGPD3,BGPD4,BGPD5)=0
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7)=0
 I BGPAGEB<55 S BGPSTOP=1 Q
 I 'BGPACTCL S BGPSTOP=1 Q
 S BGPD1=1
 I BGPAGEB>54,BGPAGEB<65 S BGPD2=1
 I BGPAGEB>64,BGPAGEB<75 S BGPD3=1
 I BGPAGEB>74,BGPAGEB<85 S BGPD4=1
 I BGPAGEB>84 S BGPD5=1
 D CHEL^BGP3D73
 S BGPVALUE="AC|||"_$P(BGPVALUE,"|||",2)
 K X,Y,Z,%,A,B,C,D,E,H,BDATE,EDATE,P,V,S,F,T,BGPLDL
 Q
 ;
PALLCARE ;EP 
 S (BGPD1,BGPD2,BGPD3,BGPD4,BGPD5,BGPD6,BGPD7,BGPD8,BGPD9,BGPD10)=0
 S (BGPN1,BGPN2,BGPN3,BGPN4,BGPN5,BGPN6,BGPN7)=0
 I BGPAGEB<55 S BGPSTOP=1 Q
 I 'BGPACTCL S BGPSTOP=1 Q
 S BGPD1=1
 I BGPAGEB>54,BGPAGEB<65 S BGPD2=1
 I BGPAGEB>64,BGPAGEB<75 S BGPD3=1
 I BGPAGEB>74,BGPAGEB<85 S BGPD4=1
 I BGPAGEB>84 S BGPD5=1
 S BGPVAL=$$PCV^BGP3D24(DFN,BGPBDATE,BGPEDATE)  ;return #visits^list string
 S BGPN1=$P(BGPVAL,U)
 ;S BGPCANCE=$$CANCER^BGP3D24(DFN,BGPBDATE,BGPEDATE)
 ;I BGPCANCE S BGPD6=1 D
 ;.I BGPAGEB>54,BGPAGEB<65 S BGPD7=1
 ;.I BGPAGEB>64,BGPAGEB<75 S BGPD8=1
 ;.I BGPAGEB>74,BGPAGEB<85 S BGPD9=1
 ;.I BGPAGEB>84 S BGPD10=1
 ;S BGPVAL=$$PCV(DFN,BGPBDATE,BGPEDATE)  ;return #visits^list string
 S BGPN1=$P(BGPVAL,U)
 ;I BGPCANCE,BGPN1>1 S BGPN5=1
 S BGPVALUE="AC"_"|||"_BGPN1_$S(BGPN1'=1:" visits: ",1:" visit: ")_$P(BGPVAL,U,2)
 K BGPVAL
 Q
 ;
FUNCTION(P,BDATE,EDATE) ;EP
 S BD=(9999999-BDATE)
 S ED=(9999999-EDATE)-1
 K BGPG
 S (BGP1,BGP2)=0
 F  S ED=$O(^AUPNVELD("AA",P,ED)) Q:ED=""!(ED>BD)  D
 .S BGPX=0 F  S BGPX=$O(^AUPNVELD("AA",P,ED,BGPX)) Q:BGPX'=+BGPX  D
 ..S Y=^AUPNVELD(BGPX,0)
 ..I $P(Y,U,4)]"" S:'$O(BGPG("TLT",0)) BGPG("TLT",ED)="",BGP1=1
 ..I $P(Y,U,5)]"" S:'$O(BGPG("BATH",0)) BGPG("BATH",ED)="",BGP1=1
 ..I $P(Y,U,6)]"" S:'$O(BGPG("DRES",0)) BGPG("DRES",ED)="",BGP1=1
 ..I $P(Y,U,7)]"" S:'$O(BGPG("XFER",0)) BGPG("XFER",ED)="",BGP1=1
 ..I $P(Y,U,8)]"" S:'$O(BGPG("FEED",0)) BGPG("FEED",ED)="",BGP1=1
 ..I $P(Y,U,9)]"" S:'$O(BGPG("CONT",0)) BGPG("CONT",ED)="",BGP1=1
 ..I $P(Y,U,11)]"" S:'$O(BGPG("FIN",0)) BGPG("FIN",ED)="",BGP2=1
 ..I $P(Y,U,12)]"" S:'$O(BGPG("COOK",0)) BGPG("COOK",ED)="",BGP2=1
 ..I $P(Y,U,13)]"" S:'$O(BGPG("SHOP",0)) BGPG("SHOP",ED)="",BGP2=1
 ..I $P(Y,U,14)]"" S:'$O(BGPG("HSWK",0)) BGPG("HSWK",ED)="",BGP2=1
 ..I $P(Y,U,15)]"" S:'$O(BGPG("MEDS",0)) BGPG("MEDS",ED)="",BGP2=1
 ..I $P(Y,U,16)]"" S:'$O(BGPG("TRNS",0)) BGPG("TRNS",ED)="",BGP2=1
 K BGPV
 S X="" F  S X=$O(BGPG(X)) Q:X=""  S ED=$O(BGPG(X,0)) S:$D(BGPV(ED)) BGPV(ED)=BGPV(ED)_", " S BGPV(ED)=$G(BGPV(ED))_X
 S BGPQ=""
 S BGPQ=$S((BGP1+BGP2)=2:1,1:0)_U
 S Y=0 F  S Y=$O(BGPV(Y)) Q:Y'=+Y  D
 .S $P(BGPQ,U,2)=$P(BGPQ,U,2)_$$DATE^BGP3UTL((9999999-Y))_" "_BGPV(Y)_" "
 K BGPV,BGPG
 Q BGPQ
 ;
PHNV(P,BDATE,EDATE,HOMELOC) ;EP
 S HOMELOC=$G(HOMELOC)
 K ^TMP($J,"A") S A="^TMP($J,""A"","
 S B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(B,A)
 I '$D(^TMP($J,"A",1)) Q "0^0^0^0^0^0^0^0^0^0^0^0"
 S (X,Y)=0,C="0^0^0^0^0^0^0^0^0^0^0^0" F  S X=$O(^TMP($J,"A",X)) Q:X'=+X  S V=$P(^TMP($J,"A",X),U,5) D
 .;S Y=0 I $$CLINIC^APCLV(V,"C")=45 S Y=1 Q
 .S (D,Y,Z)=0
 .F  S D=$O(^AUPNVPRV("AD",V,D)) Q:D'=+D  S Q=$P(^AUPNVPRV(D,0),U) D
 ..Q:Q=""
 ..S %=$$VALI^XBDIQ1($S($P(^DD(9000010.06,.01,0),U,2)["200":200,1:6),Q,$S($P(^DD(9000010.06,.01,0),U,2)["200":53.5,1:2))
 ..I % S %=$P($G(^DIC(7,+%,9999999)),U)
 ..I %'=13,%'=91 Q  ;not a phn or driver
 ..S $P(C,U,1)=$P(C,U,1)+1
 ..I %=91 S $P(C,U,6)=$P(C,U,6)+1
 ..D HOME
 ..D AGE
 Q C
 ;
HOME ;
 S HV=0
 I $$CLINIC^APCLV(V,"C")=11 S $P(C,U,7)=$P(C,U,7)+1,HV=1 S:%=91 $P(C,U,12)=$P(C,U,12)+1 Q
 Q:HOMELOC=""
 I HOMELOC=$P(^AUPNVSIT(V,0),U,6) S $P(C,U,7)=$P(C,U,7)+1,HV=1 S:%=91 $P(C,U,12)=$P(C,U,12)+1 Q
 Q
AGE ;
 I BGPD2 S $P(C,U,2)=$P(C,U,2)+1 S:HV=1 $P(C,U,8)=$P(C,U,8)+1 Q
 I BGPD3 S $P(C,U,3)=$P(C,U,3)+1 S:HV=1 $P(C,U,9)=$P(C,U,9)+1 Q
 I BGPD4 S $P(C,U,4)=$P(C,U,4)+1 S:HV=1 $P(C,U,10)=$P(C,U,10)+1 Q
 I BGPD5 S $P(C,U,5)=$P(C,U,5)+1 S:HV=1 $P(C,U,11)=$P(C,U,11)+1 Q
 W BGPBOMB
 Q
TXBMD(P,BDATE,EDATE,HOSP) ;EP
 ;first see if there are any procedures in this date range
 S HOSP=$G(HOSP)
 K BGPG
 S BGPG=$$LASTPRC^BGP3UTL1(P,"BGP BMD PROCEDURES",BDATE,EDATE)
 I $P(BGPG,U)=1 Q 1_U_$$DATE^BGP3UTL($P(BGPG,U,3))_" PROC "_$P(BGPG,U,2)
 ;now check dx
 S BGPG=$$LASTDX^BGP3UTL1(P,"BGP BMD DXS",BDATE,EDATE)
 I $P(BGPG,U)=1 Q 1_U_$$DATE^BGP3UTL($P(BGPG,U,3))_"DX "_$P(BGPG,U,2)
 ;now check cpts
 S T=$O(^ATXAX("B","BGP BMD CPTS",0))
 S BGPG=$$CPT^BGP3DU(P,BDATE,EDATE,T,5)
 I BGPG]"" Q 1_U_$$DATE^BGP3UTL($P(BGPG,U,1))_" CPT "_$P(BGPG,U,2)
 S T=$O(^ATXAX("B","BGP BMD CPTS",0))
 S BGPG=$$TRAN^BGP3DU(P,BDATE,EDATE,T,5)
 I BGPG]"" Q 1_U_$$DATE^BGP3UTL($P(BGPG,U,1))_" CPT/TRAN "_$P(BGPG,U,2)
 ;now check RAD
 S T=$O(^ATXAX("B","BGP BMD CPTS",0))
 S BGPG=$$RAD^BGP3DU(P,BDATE,EDATE,T,5)
 I BGPG]"" Q 1_U_$$DATE^BGP3UTL($P(BGPG,U,1))_" RAD/CPT "_$P(BGPG,U,2)
 I HOSP Q ""
 ;now check all meds
 K ^TMP($J,"MEDS")
 S G=0 K BGPZ
 S Y="^TMP($J,""MEDS"",",X=P_"^ALL MED;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 S T=$O(^ATXAX("B","BGP HEDIS OSTEOPOROSIS DRUGS",0))
 S T1=$O(^ATXAX("B","BGP HEDIS OSTEOPOROSIS NDC",0))
 ;S T2="" I TAX3]"" S T2=$O(^ATXAX("B",TAX3,0))
 S X=0 F  S X=$O(^TMP($J,"MEDS",X)) Q:X'=+X!(G)  S Y=+$P(^TMP($J,"MEDS",X),U,4) D
 .Q:'$D(^AUPNVMED(Y,0))
 .Q:$$UP^XLFSTR($P($G(^AUPNVMED(Y,11)),U))["RETURNED TO STOCK"
 .S G=0
 .S D=$P(^AUPNVMED(Y,0),U)
 .S C=$P($G(^PSDRUG(D,0)),U,2)
 .;I C]"",T2,$D(^ATXAX(T2,21,"B",C)) S G=X
 .S C=$P($G(^PSDRUG(D,2)),U,4)
 .I C]"",T1,$D(^ATXAX(T1,21,"B",C)) S G=$P(^TMP($J,"MEDS",X),U)
 .I T,$D(^ATXAX(T,21,"B",D)) S G=$P(^TMP($J,"MEDS",X),U)_U_$P(^TMP($J,"MEDS",X),U,2)
 .Q
 K ^TMP($J,"MEDS")
 I G Q 1_U_$$DATE^BGP3UTL($P(G,U,1))_" Med "_$P(G,U,2)
 Q ""