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

BGP8PC11.m

Go to the documentation of this file.
BGP8PC11 ; IHS/CMI/LAB - measure I2 ; 02 Feb 2018  11:25 AM
 ;;18.1;IHS CLINICAL REPORTING;;MAY 25, 2018;Build 66
 ;
DEP ;EP
 I 'BGPIPCUP S BGPSTOP=1 Q  ;must be ipc up
 I BGPAGEB<12 S BGPSTOP=1 Q  ;must be 12 or older at beginning of time period
 S (BGPD1,BGPN1)=0
 S BGPDEP="",BGPVALUE=""
 S BGPD1=1  ;meet denominator
 S BGPDEP=$$DEPSCR(DFN,BGPBDATE,BGPEDATE) I $P(BGPDEP,U)=1 S BGPN1=1 G DEPE
 S BGPDEP=$$DEPDX(DFN,BGPBDATE,BGPEDATE) I $P(BGPDEP,U)=1 S BGPN1=1
DEPE ;
 S BGPVALUE="IPCUP|||"
 I BGPN1 S BGPVALUE=BGPVALUE_"***"_$P(BGPDEP,U,3)_" "_$P(BGPDEP,U,5)
 ;I BGPN1 W !,DFN," ",BGPVALUE
 K BGPDEP,BGPDSE
 Q
DEPSCR(P,BDATE,EDATE) ;EP
 NEW BGPDEPS,BGPG,%,E,Y,X,BGPC,D,V,BGPP,T
 S BGPDEPS=""
 I $G(P)="" Q ""
 K BGPG S %=P_"^LAST EXAM 36;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(%,"BGPG(")
 I $D(BGPG(1)) S BGPDEPS=1_"^DEP SCRN^"_$$DATE^BGP8UTL($P(BGPG(1),U))_U_$P(BGPG(1),U)_U_"Ex 36" Q BGPDEPS
 K BGPG
 S Y="BGPG("
 S X=P_"^LAST DX [BGP DEPRESSION SCRN DXS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 I $D(BGPG(1)) S BGPDEPS=1_U_"POV "_$P(BGPG(1),U,2)_" DEP"_U_$$DATE^BGP8UTL($P(BGPG(1),U))_U_$P(BGPG(1),U)_U_"POV "_$P(BGPG(1),U,2) Q BGPDEPS
 ;
 S Y=$$CPT^BGP8DU(DFN,BDATE,EDATE,$O(^ATXAX("B","BGP DEPRESSION SCREEN CPTS",0)),5)
 I Y S BGPDEPS=1_U_"CPT "_$P(Y,U,2)_U_$$DATE^BGP8UTL($P(Y,U,1))_U_$P(Y,U,1)_U_"CPT "_$P(Y,U,2)
 I BGPDEPS Q BGPDEPS
 ;now add in v measurements
 S BGPC=$$LASTITEM^BGP8DU(P,BDATE,EDATE,"MEASUREMENT","PHQ2")
 I $P(BGPC,U,2) S BGPDEPS=1_U_"Meas "_$P(BGPC,U,3)_U_$$DATE^BGP8UTL($P(BGPC,U,2))_U_$P(BGPC,U,2)_U_"Meas "_$P(BGPC,U,3) Q BGPDEPS
 S BGPC=$$LASTITEM^BGP8DU(P,BDATE,EDATE,"MEASUREMENT","PHQ9")
 I $P(BGPC,U,2) S BGPDEPS=1_U_"Meas "_$P(BGPC,U,3)_U_$$DATE^BGP8UTL($P(BGPC,U,2))_U_$P(BGPC,U,2)_U_"Meas "_$P(BGPC,U,3) Q BGPDEPS
 S BGPC=$$LASTITEM^BGP8DU(P,BDATE,EDATE,"MEASUREMENT","PHQT")
 I $P(BGPC,U,2) S BGPDEPS=1_U_"Meas "_$P(BGPC,U,3)_U_$$DATE^BGP8UTL($P(BGPC,U,2))_U_$P(BGPC,U,2)_U_"Meas "_$P(BGPC,U,3) Q BGPDEPS
BHSCR ;
 S D=0,BGPC="",E=9999999-BDATE,D=9999999-EDATE-1_".99" F  S D=$O(^AMHREC("AE",P,D)) Q:D'=+D!($P(D,".")>E)!(BGPC)  S V=0 F  S V=$O(^AMHREC("AE",P,D,V)) Q:V'=+V!(BGPC)  D
 .I $P($G(^AMHREC(V,14)),U,5)="P"!($P($G(^AMHREC(V,14)),U,5)="N") S BGPC=1_U_"BH Dep Exam"_U_$$DATE^BGP8UTL(9999999-D)_U_(9999999-D)_U_"BH Exam 36"
 .Q:BGPC
 .S X=0 F  S X=$O(^AMHRPRO("AD",V,X)) Q:X'=+X!(BGPC)  S BGPP=$P($G(^AMHRPRO(X,0)),U) D
 ..Q:'BGPP
 ..S BGPP=$P($G(^AMHPROB(BGPP,0)),U)
 ..I BGPP=14.1 S BGPC=1_U_"BH 14.1"_U_$$DATE^BGP8UTL(9999999-D)_U_(9999999-D)_U_"BH POV 14.1" Q
 .Q:BGPC
 .S X=0 F  S X=$O(^AMHRMSR("AD",V,X)) Q:X'=+X!(BGPC)  S BGPP=$P($G(^AMHRMSR(X,0)),U) D
 ..Q:'BGPP
 ..S BGPP=$P($G(^AUTTMSR(BGPP,0)),U)
 ..I BGPP="PHQ2"!(BGPP="PHQ9")!(BGPP="PHQT") S BGPC=1_U_"BH "_BGPP_U_$$DATE^BGP8UTL(9999999-D)_U_(9999999-D)_U_"BH Meas "_BGPP
 .Q:BGPC
 .S X=0 F  S X=$O(^AMHRPROC("AD",V,X)) Q:X'=+X!(BGPC)  S BGPP=$P($G(^AMHRPROC(X,0)),U) D
 ..Q:'BGPP
 ..Q:'$$ICD^BGP8UTL2(BGPP,$O(^ATXAX("B","BGP DEPRESSION SCREEN CPTS",0)),1)
 ..S BGPC=1_U_"BH CPT: "_$P(^ICPT(BGPP,0),U,1)_U_$$DATE^BGP8UTL(9999999-D)_U_(9999999-D)_U_"BH CPT "_$P(^ICPT(BGPP,0),U,1)
 I BGPC]"" S BGPDEPS=BGPC
 Q BGPDEPS
DEPDX(P,BDATE,EDATE) ;EP
 I $G(P)="" Q ""
 NEW BGPG,BGPDEP,BGPV,Y,X,E,D,V,BGPC,BGPP,I,Z,BGPPC
 K BGPG,BGPDEP
 S BGPV=""
 S Y="BGPG("
 S X=P_"^LAST 1 DX [BGP MOOD DISORDERS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 I $D(BGPG(1))  Q 1_U_U_$$DATE^BGP8UTL($P(BGPG(1),U))_U_U_"POV "_$P(BGPG(1),U,2)
 ;
 S BGPC=0,E=9999999-BDATE,D=9999999-EDATE-1_".99" F  S D=$O(^AMHREC("AE",P,D)) Q:D'=+D!($P(D,".")>E)!(BGPC>0)  S V=0 F  S V=$O(^AMHREC("AE",P,D,V)) Q:V'=+V!(BGPC>0)  D
 .S X=0 F  S X=$O(^AMHRPRO("AD",V,X)) Q:X'=+X!(BGPC>1)  S BGPP=$P($G(^AMHRPRO(X,0)),U) D
 ..Q:'BGPP
 ..S BGPPC=$P($G(^AMHPROB(BGPP,0)),U)
 ..I BGPPC=14 S BGPC=BGPC+1,BGPDEP(D)=BGPP Q
 ..I BGPPC=15 S BGPC=BGPC+1,BGPDEP(D)=BGPP Q
 ..;GET ICD CODE
 ..S I=$P(^AMHPROB(BGPP,0),U,17)
 ..I I="" S I=$P(^AMHPROB(BGPP,0),U,5)
 ..Q:I=""
 ..S Z=+$$CODEN^BGP8UTL2(I,80)
 ..I Z'>0 Q
 ..I $$ICD^BGP8UTL2(Z,$O(^ATXAX("B","BGP MOOD DISORDERS",0)),9) S BGPC=BGPC+1,BGPDEP(D)=BGPPC Q
 ..Q
 S X=$O(BGPDEP(0))
 I BGPC>0 Q 1_"^^"_$$FMTE^XLFDT((9999999-$P(X,".")))_"^^BH POV "_BGPDEP(X)
 Q ""