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

BGP8PC17.m

Go to the documentation of this file.
BGP8PC17 ; IHS/CMI/LAB - measure I2 ; 02 Feb 2018  11:25 AM
 ;;18.1;IHS CLINICAL REPORTING;;MAY 25, 2018;Build 66
 ;
TEST ;
 S DFN=0 F  S DFN=$O(^AUPNPAT(DFN)) Q:DFN'=+DFN  S BGPIPCUP=1,BGPBDATE=3120101,BGPEDATE=DT,BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE) D MTA
 Q
MTA ;EP
 I 'BGPIPCUP S BGPSTOP=1 Q  ;must be ipc up
 I BGPAGEB<5 S BGPSTOP=1 Q  ;must be 5 or older
 ;
 S (BGPN1,BGPD1)=""
 I '$$ASSEV^BGP8D22(DFN,BGPEDATE) S BGPSTOP=1 Q  ;not persistent asthma
 ;EXCLUSIONS
 ;REFUSAL FOR MED IN PQA CONTROLLER MEDS
 I $$REFMED(DFN,BGPBDATE,BGPEDATE) S BGPSTOP=1 Q  ;refused controller med
 I $$MEDALG(DFN,BGPEDATE) S BGPSTOP=1 Q
 S BGPD1=1
 S BGPVAL=$$CONT(DFN,BGPBDATE,BGPEDATE)
 I $P(BGPVAL,U,1) S BGPN1=1
 S BGPVALUE="IPCUP|||"
 I BGPN1 S BGPVALUE=BGPVALUE_"*** "_$P(BGPVAL,U,2)_" "_$P(BGPVAL,U,3)
MTAX ;
 K BGPVAL
 Q
REFMED(P,BDATE,EDATE) ;
 NEW F,D,I,X,Y,G,T,ID,D
 S T=$O(^ATXAX("B","BGP PQA CONTROLLER MEDS",0))
 S F=50,G=""
 S I=0 F  S I=$O(^AUPNPREF("AA",P,F,I)) Q:I'=+I!(G)  D
 .I '$D(^ATXAX(T,21,"B",I)) Q  ;not a drug we are interested in
 .S ID=0 F  S ID=$O(^AUPNPREF("AA",P,F,I,ID)) Q:ID'=+ID!(G)  D
 ..S D=9999999-ID
 ..Q:D<BDATE
 ..Q:D>EDATE
 ..S X=0 F  S X=$O(^AUPNPREF("AA",P,F,I,ID,X)) Q:X'=+X!(G)  D
 ...S R=$P($G(^AUPNPREF(X,0)),U,7)
 ...I R'="R",R'="N" Q
 ...S G=1
 Q G
MEDALG(P,EDATE) ;
 NEW BGPC,X,N,G,I,T,S
 S BGPC=0,G=""
 S T=$O(^ATXAX("B","BGP PQA CONTROLLER MEDS",0))
 S S=$O(^BGPSNOMR("B","ASTHMA DRUGS",0))
 S X=0 F  S X=$O(^GMR(120.8,"B",P,X)) Q:X'=+X!(G)  D
 .Q:$P($P($G(^GMR(120.8,X,0)),U,4),".")>EDATE  ;entered after discharge date
 .S N=$P($G(^GMR(120.8,X,0)),U,3)
 .I $P(N,";",2)="PSDRUG(" S I=+N I $D(^ATXAX(T,21,"B",I)) S G=1 Q  ;MUST BE A DRUG
 .S N=$P(^GMR(120.8,X,0),U,2)
 .I N]"",$D(^BGPSNOMR(S,11,"B",N)) S G=1 Q
 Q G
CONT(P,BDATE,EDATE) ;controller meds (at least 2)
 NEW A,C,G,V1D,BGPMEDS1,T
 K BGPMEDS1,^TMP($J,"A")
 D GETMEDS^BGP8UTL2(P,BDATE,EDATE,"BGP PQA CONTROLLER MEDS","BGP PQA CONTROLLER NDC",,,.BGPMEDS1)
 S G=""
 I '$D(BGPMEDS1) Q G  ; no CONTROLLER meds
 S A=0,C="",T=0 F  S A=$O(BGPMEDS1(A)) Q:A'=+A!(C)  D
 .S M=$P(BGPMEDS1(A),U,4)  ;IEN OF V MED
 .Q:'$D(^AUPNVMED(M,0))
 .I $$UP^XLFSTR($P($G(^AUPNVMED(M,11)),U))["RETURNED TO STOCK" K BGPMEDS1(A) Q
 .;I $$STATDC(M) K BGPMEDS1(A) Q  ;d/c'ed BY PROVIDER OR EDIT
 .S V=$P(BGPMEDS1(A),U,5)
 .S V1D=$$VD^APCLV(V)
 .S C=1_U_""_$$DATE^BGP8UTL(V1D)_" "_$$VAL^XBDIQ1(9000010.14,M,.01)
 Q C