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

BGPMUF08.m

Go to the documentation of this file.
BGPMUF08 ; IHS/MSC/MGH - MI measure NQF0084 ;20-Jul-2011 14:56;DU
 ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
 ;Code to collect meaningful use report for Heart Failure, Warfarin w/A-Fib
ENTRY ;EP
 N START,END,BGPNUM,BGPDEN,BGPNUM,STRING,STRING2,PTBIRTH
 N IEN,INV,VISIT,DATA,VDATE,VALUE,EXCEPT,FIRST,VIEN,EXCEPT,RESULT
 N CNT,NUM,OUTENC,NFENC,HFDX
 S (BGPDEN,BGPNUM,RESULT)=0
 S START=9999999-BGPBDATE,END=9999999-BGPEDATE,VALUE=0
 S START=START_".2359"
 S (HFDX,EXC,NUM)=0
 ;Pts must be >18
 ;No need to check further if no age match
 Q:BGPAGEE<18
 S CNT=0
 S PTBIRTH=$$DOB^AUPNPAT(DFN,"")
 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 OUTENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU BP EM")
 ..S NFENC=""
 ..S:'+OUTENC NFENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU NURSING FAC EM")
 ..I (+OUTENC)!(+NFENC) D
 ...S CNT=CNT+1
 ...S VDATE=$P($G(^AUPNVSIT(IEN,0)),U,1)
 ...S VIEN(CNT)=IEN_U_VDATE
 Q:CNT<2
 ;Next check to see if the patient is in the denominator
 S HFDX=$$HFAFIB(DFN,BGPBDATE,BGPEDATE,CNT)
 I +HFDX D
 .;If the patient has had heart failure w/A-Fib, check to see if they are in the numerator
 .S NUM=$$NUM(DFN,BGPBDATE,BGPEDATE)
 .;If not in the numerator see if they are an exception
 .I NUM=0 S EXC=$$EXCEPT(DFN,BGPBDATE,BGPEDATE)
 .D TOTAL(DFN,HFDX,NUM,EXC)
 Q
TOTAL(DFN,HFDX,NUM,EXC) ;See where this patient ends up
 N PTCNT,EXCCT,DENCT,NUMCT,NOTNUM,TOTALS,DEN
 S TOTALS=$G(^TMP("BGPMU0084",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0084",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0084",$J,BGPMUTF,"NUM"))
 S EXCCT=+$G(^TMP("BGPMU0084",$J,BGPMUTF,"EXC"))
 S NOTNUM=+$G(^TMP("BGPMU0084",$J,BGPMUTF,"NOT"))
 S PTCNT=TOTALS
 S PTCNT=PTCNT+1
 S (DEN,DXTIME)=""
 S DENCT=DENCT+1 S ^TMP("BGPMU0084",$J,BGPMUTF,"DEN")=DENCT
 S DEN="HF:"_$$DATE^BGPMUUTL($P(HFDX,U,2))
 S DEN=DEN_";AF:"_$$DATE^BGPMUUTL($P(HFDX,U,3))
 I $D(VIEN(1)) S DEN=DEN_";EN:"_$$DATE^BGPMUUTL($P(VIEN(1),U,2))
 I $D(VIEN(2)) S DEN=DEN_";EN:"_$$DATE^BGPMUUTL($P(VIEN(2),U,2))
 I +NUM D
 .S NUMCT=NUMCT+1 S ^TMP("BGPMU0084",$J,BGPMUTF,"NUM")=NUMCT
 .I BGPMUTF="C" S ^TMP("BGPMU0084",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DEN_U_"M:MED "_$$DATE^BGPMUUTL($P(NUM,U,2))
 I +EXC D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0084",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0084",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_DEN_U_"Excluded"
 I +NUM=0&(EXC=0) D
 .S NOTNUM=NOTNUM+1 S ^TMP("BGPMU0084",$J,BGPMUTF,"NOT")=NOTNUM
 .I BGPMUTF="C" S ^TMP("BGPMU0084",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DEN_U_"NM:"
 S ^TMP("BGPMU0084",$J,BGPMUTF,"TOT")=PTCNT
 ;Setup iCare array for patient
 S BGPICARE("MU.EP.0084.1",BGPMUTF)=1_U_+NUM_U_+EXC_U_DEN_";"_$P(NUM,U,2)_";"_$P(NUM,U,3)
 Q
HFAFIB(DFN,BGPBDATE,BGPEDATE,CNT) ;look for Heart Failure W/A-Fib diagnosis
 N FOUND,DXHF,PLHF,DXAF,PLAF,DX1,DX2
 S FOUND=0,DX1=0,DX2=0
 ;Check for the patient having a DX or Problem of Heart Failure (ever)
 S DXHF=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HEART FAILURE DX")
 I +DXHF S DX1=DXHF
 E  D
 .S PLHF=$$PLTAX^BGPMUUT1(DFN,"BGPMU HEART FAILURE DX","C",BGPEDATE)
 .I +PLHF S DX1=PLHF
 Q:DX1=0 0
 ;Now check for DX or Problem of Atrial Fibrillation
 S DXAF=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HF AFIB DX")
 I +DXAF S DX2=DXAF
 E  D
 .S PLAF=$$PLTAX^BGPMUUT1(DFN,"BGPMU HF AFIB DX","C",BGPEDATE)
 .I +PLAF S DX2=PLAF
 Q:DX2=0 0
 S FOUND=1_U_$P(DX1,U,3)_U_$P(DX2,U,3)
 Q FOUND
NUM(DFN,BGPBDATE,BGPEDATE) ;Look for Warfarin PRESCRIPTION
 N FOUND,WARFRX
 S FOUND=0
 S WARFRX=$$FIND^BGPMUUT8(DFN,"BGPMU WARFARIN NDCS",BGPBDATE,"",BGPEDATE)
 Q:'WARFRX FOUND
 S FOUND=1_U_$P(WARFRX,U,3)
 Q FOUND
EXCEPT(DFN,BGPBDATE,BGPEDATE) ;See if this patient has exceptions
 N EFOUND
 S EFOUND=0
 ;Next check for allergy
 S ALLER=$$ALLER^BGPMUA10("BL110","WARFARIN")
 I +ALLER S EFOUND=1_U_$P(ALLER,U,1) G EXCQ
 ;Check for refusals
 S TAX="BGPMU WARFARIN NDCS"
 S REF=$$REF^BGPMUA10(.VIEN,TAX,BGPEDATE)
 I +REF S EFOUND=1_U_$P(REF,U,1) G EXCQ
 S EXCDX=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HF ANEMIA DX")
 I +EXCDX S EFOUND=1_U_$P(EXCDX,U,3) G EXCQ
 S EXCPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU HF ANEMIA DX","C",BGPEDATE)
 I +EXCPL S EFOUND=1_U_$P(EXCPL,U,3) G EXCQ
 S EXCDX=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HF GI BLEED DX")
 I +EXCDX S EFOUND=1_U_$P(EXCDX,U,3) G EXCQ
 S EXCPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU HF GI BLEED DX","C",BGPEDATE)
 I +EXCPL S EFOUND=1_U_$P(EXCPL,U,3) G EXCQ
 S EXCDX=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HF IC HEMORRHAGE DX")
 I +EXCDX S EFOUND=1_U_$P(EXCDX,U,3) G EXCQ
 S EXCPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU HF IC HEMORRHAGE DX","C",BGPEDATE)
 I +EXCPL S EFOUND=1_U_$P(EXCPL,U,3) G EXCQ
 S EXCDX=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HF LEUKEMIA DX")
 I +EXCDX S EFOUND=1_U_$P(EXCDX,U,3) G EXCQ
 S EXCPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU HF LEUKEMIA DX","C",BGPEDATE)
 I +EXCPL S EFOUND=1_U_$P(EXCPL,U,3) G EXCQ
 S EXCDX=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HF HEMATURIA DX")
 I +EXCDX S EFOUND=1_U_$P(EXCDX,U,3) G EXCQ
 S EXCPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU HF HEMATURIA DX","C",BGPEDATE)
 I +EXCPL S EFOUND=1_U_$P(EXCPL,U,3) G EXCQ
 S EXCDX=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HF HEMOPTYSIS DX")
 I +EXCDX S EFOUND=1_U_$P(EXCDX,U,3) G EXCQ
 S EXCPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU HF HEMOPTYSIS DX","C",BGPEDATE)
 I +EXCPL S EFOUND=1_U_$P(EXCPL,U,3) G EXCQ
 S EXCDX=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HF HEMORRHAGE DX")
 I +EXCDX S EFOUND=1_U_$P(EXCDX,U,3) G EXCQ
 S EXCPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU HF HEMORRHAGE DX","C",BGPEDATE)
 I +EXCPL S EFOUND=1_U_$P(EXCPL,U,3) G EXCQ
 S EXCDX=$$LASTDX^BGPMUUT2(DFN,PTBIRTH,BGPEDATE,"BGPMU HF LIVER DISORDER DX")
 I +EXCDX S EFOUND=1_U_$P(EXCDX,U,3) G EXCQ
 S EXCPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU HF LIVER DISORDER DX","C",BGPEDATE)
 I +EXCPL S EFOUND=1_U_$P(EXCPL,U,3) G EXCQ
EXCQ Q EFOUND