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

BGPMUG04.m

Go to the documentation of this file.
BGPMUG04 ; IHS/MSC/MMT - MI measure NQF0047 ;20-Aug-2011 14:56;DU
 ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
 ;Code to collect meaningful use report for Asthma Pharm Therapy
ENTRY ;EP
 N START,END,BGPNUM,BGPDEN,STRING,STRING2
 N IEN,INV,VISIT,DATA,VDATE,VALUE,EXC,FIRST,VIEN,RESULT
 N CNT,NUM,ASTHENC,ASTHMA,ASTDT,ASTPL
 S (BGPDEN,BGPNUM,NUM,EXC,RESULT)=0
 S START=9999999-BGPBDATE,END=9999999-BGPEDATE,VALUE=0
 S START=START_".2359"
 ;Pts must be between 5 and 40 years
 ;No need to check further if no age match
 Q:BGPAGEE<5!(BGPAGEE>40)
 ;First check for Asthma Dx since this will eliminate many pts
 S ASTHMA=$$ASTHMA(DFN,BGPEDATE)
 Q:'ASTHMA
 S CNT=0
 S FIRST=END-0.1 F  S FIRST=$O(^AUPNVSIT("AA",DFN,FIRST)) Q:FIRST=""!($P(FIRST,".",1)>START)  D
 .S IEN=0 F  S IEN=$O(^AUPNVSIT("AA",DFN,FIRST,IEN)) Q:'+IEN  D
 ..;Check provider, Only visits for chosen provider
 ..Q:'$$PRV^BGPMUUT1(IEN,BGPPROV)
 ..S ASTENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU ASTHMA ENCOUNT EM")
 ..I +ASTENC D VSTSTORE Q
 Q:CNT<2
 ;check to see if they are in the numerator
 S NUM=$$NUM(DFN,BGPBDATE,BGPEDATE)
 I '+NUM D
 .S EXC=$$EXCLUDE(DFN,BGPBDATE,BGPEDATE)
 D TOTAL(DFN,ASTHMA,NUM,EXC)
 Q
VSTSTORE ;Store compliant visit into array
 S CNT=CNT+1
 S VDATE=$P($G(^AUPNVSIT(IEN,0)),U,1)
 S VIEN(CNT)=IEN_U_VDATE
 S STRING(CNT)=$$DATE^BGPMUUTL(VDATE)
 Q
TOTAL(DFN,ASTHMA,NUM,EXC) ;See where this patient ends up
 N PTCNT,EXCCT,DENCT,NUMCT,NOTNUM,TOTALS,DEN,DXTIME
 S TOTALS=$G(^TMP("BGPMU0047",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0047",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0047",$J,BGPMUTF,"NUM"))
 S EXCCT=+$G(^TMP("BGPMU0047",$J,BGPMUTF,"EXC"))
 S NOTNUM=+$G(^TMP("BGPMU0047",$J,BGPMUTF,"NOT"))
 S PTCNT=TOTALS
 S PTCNT=PTCNT+1
 S DENCT=DENCT+1 S ^TMP("BGPMU0047",$J,BGPMUTF,"DEN")=DENCT
 S DEN="AST:"_$$DATE^BGPMUUTL($P(ASTHMA,U,3))
 I $D(STRING(1)) S DEN=DEN_";EN:"_STRING(1)
 I $D(STRING(2)) S DEN=DEN_";EN:"_STRING(2)
 I +NUM D
 .S NUMCT=NUMCT+1 S ^TMP("BGPMU0047",$J,BGPMUTF,"NUM")=NUMCT
 .I BGPMUTF="C" S ^TMP("BGPMU0047",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DEN_U_"M:MED "_$$DATE^BGPMUUTL($P(NUM,U,3))
 I +EXC D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0047",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0047",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_DEN_U_"Excluded"
 I +NUM=0&(EXC=0) D
 .S NOTNUM=NOTNUM+1 S ^TMP("BGPMU0047",$J,BGPMUTF,"NOT")=NOTNUM
 .I BGPMUTF="C" S ^TMP("BGPMU0047",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DEN_U_"NM:"
 S ^TMP("BGPMU0047",$J,BGPMUTF,"TOT")=PTCNT
 ;Setup iCare array for patient
 S BGPICARE("MU.EP.0047.1",BGPMUTF)=1_U_+NUM_U_+EXC_U_DEN_";"_$P(NUM,U,2)_";"_$P(NUM,U,3)
 Q
ASTHMA(DFN,EDATE) ;Find if patient had a PROBLEM of Asthma on or before the end date
 N ASTHMA
 S ASTHMA=0
 S ASTPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU ASTHMA DX ICD","C")
 Q:'ASTPL ASTHMA
 ;check date of problem
 Q:$P($P(ASTPL,U,3),".")>EDATE ASTHMA
 ;check problem classification
 S CLASS=$P($G(^AUPNPROB($P(ASTPL,U,4),0)),U,15)
 ;I (CLASS="MILD PERSISTENT")!(CLASS="MODERATE PERSISTENT")!(CLASS="SEVERE PERSISTENT") D
 I CLASS=2!(CLASS=3)!(CLASS=4) D
 .S ASTHMA=ASTPL
 Q ASTHMA
NUM(DFN,BGPBDATE,BGPEDATE) ;Look for PRESCRIPTION
 N FOUND
 S FOUND=$$FIND^BGPMUUT8(DFN,"BGPMU ASTHMA MEDS NDCS",BGPBDATE,"",BGPEDATE)
 Q FOUND
EXCLUDE(DFN,BGPBDATE,BGPEDATE) ;Look for exclusions
 N EFOUND
 S EFOUND=0
 ;Next check for allergy
 S ALLER=$$ALLER^BGPMUA10("NT200","")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 S ALLER=$$ALLER^BGPMUA10("RE100","")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 S ALLER=$$ALLER^BGPMUA10("RE101","")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 S ALLER=$$ALLER^BGPMUA10("RE102","")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 S ALLER=$$ALLER^BGPMUA10("RE103","")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 S ALLER=$$ALLER^BGPMUA10("RE104","")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 S ALLER=$$ALLER^BGPMUA10("RE105","")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 S ALLER=$$ALLER^BGPMUA10("RE108","")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 S ALLER=$$ALLER^BGPMUA10("RE109","")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 ;Check for refusals
 S TAX="BGPMU ASTHMA MEDS NDCS"
 S BGPBIRTH=$$DOB^AUPNPAT(DFN)
 S REF=$$MEDREF^BGPMUUT2(DFN,BGPBIRTH,BGPEDATE,TAX)
 I +REF S EFOUND=1_U_$P(REF,U,1) G EXCQ
EXCQ Q EFOUND