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

BGPMUF09.m

Go to the documentation of this file.
BGPMUF09 ; IHS/MSC/MGH - MI measure NQF0052 ;10-Aug-2011 14:56;DU
 ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
 ;Code to collect meaningful use report for LOW BACK PAIN
ENTRY ;EP
 N START,END,BGPNUM,BGPDEN,BGPNUM,STRING,STRING2
 N IEN,INV,VISIT,DATA,VDATE,VALUE,FIRST,VIEN,RESULT
 N CNT,DEN,NUM,ERENC,OUTENC,VENC,ORTHENC,LBPENC
 S (BGPDEN,BGPNUM,RESULT)=0
 S START=9999999-BGPBDATE,END=9999999-BGPEDATE,VALUE=0
 S START=START_".2359"
 S (DEN,NUM)=0
 ;Pts must be >18 and <49
 ;No need to check further if no age match
 Q:BGPAGEE<18!(BGPAGEE>49)
 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 Low Back Pain visits for chosen provider
 ..Q:'$$PRV^BGPMUUT1(IEN,BGPPROV)
 ..S LBPENC=$$VSTPOV^BGPMUUT3(DFN,IEN,"BGPMU BACK PAIN DX")
 ..Q:'+LBPENC
 ..;Count this visit if Low Back Pain Dx AND proper encounter code
 ..S ERENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU DIAB ED ENCOUNTER CPT")
 ..I +ERENC D VSTSTORE Q
 ..S OUTENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU ENCOUNTER OUTPT")
 ..I +OUTENC D VSTSTORE Q
 ..S VENC=$$VSTPOV^BGPMUUT3(DFN,IEN,"BGPMU ENC OUTPATIENT ICD")
 ..I +VENC D VSTSTORE Q
 ..S ORTHENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU ENC ORTHO CPT")
 ..I +ORTHENC D VSTSTORE Q
 Q:'$D(VIEN)
 ;Next check to see if the patient has any Dx within certain timeframes prior to first LBP visit
 ;  **Earliest LBP visit will be the last one in VIEN array (VIEN(CNT))
 S DEN=$$DEN(DFN,.VIEN,CNT,BGPBDATE,BGPEDATE)
 I +DEN D
 .;If the patient has LBP, check to see if they are in the numerator
 .S NUM=$$NUM(DFN,.VIEN,CNT,BGPBDATE,BGPEDATE)
 .D TOTAL(DFN,DEN,NUM)
 Q
VSTSTORE ;Store compliant visit into array
 ;Count this visit if Low Back Pain Dx AND proper encounter code
 S CNT=CNT+1
 S VDATE=$P($P($G(^AUPNVSIT(IEN,0)),U,1),".")
 S VIEN(CNT)=IEN_U_VDATE_U_$P($P(LBPENC,U,3),".")
 Q
TOTAL(DFN,DEN,NUM) ;See where this patient ends up
 N PTCNT,DENCT,NUMCT,NOTNUM,TOTALS,DENSTR,DXTIME
 S TOTALS=$G(^TMP("BGPMU0052",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0052",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0052",$J,BGPMUTF,"NUM"))
 S NOTNUM=+$G(^TMP("BGPMU0052",$J,BGPMUTF,"NOT"))
 S PTCNT=TOTALS
 S PTCNT=PTCNT+1
 S DENSTR=""
 S DENCT=DENCT+1 S ^TMP("BGPMU0052",$J,BGPMUTF,"DEN")=DENCT
 S DENSTR="LBP:"_$$DATE^BGPMUUTL($P(VIEN(CNT),U,3))
 S DENSTR=DENSTR_";EN:"_$$DATE^BGPMUUTL($P(VIEN(CNT),U,2))
 I +NUM D
 .S NUMCT=NUMCT+1 S ^TMP("BGPMU0052",$J,BGPMUTF,"NUM")=NUMCT
 .I BGPMUTF="C" S ^TMP("BGPMU0052",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DENSTR_U_"M:"_$P(NUM,U,2)_";"_$P(NUM,U,3)
 I +NUM=0 D
 .S NOTNUM=NOTNUM+1 S ^TMP("BGPMU0052",$J,BGPMUTF,"NOT")=NOTNUM
 .I BGPMUTF="C" S ^TMP("BGPMU0052",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DENSTR_U_"NM:"_$P(NUM,U,3)_";"_$P(NUM,U,2)
 S ^TMP("BGPMU0052",$J,BGPMUTF,"TOT")=PTCNT
 ;Setup iCare array for patient
 S BGPICARE("MU.EP.0052.1",BGPMUTF)=1_U_+NUM_U_""_U_DENSTR_";"_$P(NUM,U,2)_";"_$P(NUM,U,3)
 Q
DEN(DFN,VIEN,CNT,BGPBDATE,BGPEDATE) ;Check for conditions that would preclude denominator inclusion
 N LBPVDATE,PRIORST,PRIOREND,PRIORDX,PRIORPL
 S LBPVDATE=$P($P(VIEN(CNT),U,2),".")
 S PRIORST=$$FMADD^XLFDT(LBPVDATE,-180),PRIOREND=$$FMADD^XLFDT(LBPVDATE,-1)
 S PRIORDX=$$LASTDX^BGPMUUT2(DFN,PRIORST,PRIOREND,"BGPMU BACK PAIN DX")
 Q:+PRIORDX 0
 S PRIORPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU BACK PAIN DX","C",PRIOREND)
 Q:$P(PRIORPL,U,3)>=PRIORST 0
 S LBP2YR=$$FMADD^XLFDT(BGPEDATE,-730)
 ;Check for cancer Dx up to 2 years prior to period end
 S PRIORDX=$$LASTDX^BGPMUUT2(DFN,LBP2YR,BGPEDATE,"BGPMU CANCER DX")
 Q:+PRIORDX 0
 S PRIORPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU CANCER DX","C",BGPEDATE)
 Q:$P(PRIORPL,U,3)>=LBP2YR 0
 ;Check for trauma Dx up to 2 years prior to period end
 S PRIORDX=$$LASTDX^BGPMUUT2(DFN,LBP2YR,BGPEDATE,"BGPMU TRAUMA DX")
 Q:+PRIORDX 0
 S PRIORPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU TRAUMA DX","C",BGPEDATE)
 Q:$P(PRIORPL,U,3)>=LBP2YR 0
 ;Check for IV drug abuse Dx up to 2 years prior to period end
 S PRIORDX=$$LASTDX^BGPMUUT2(DFN,LBP2YR,BGPEDATE,"BGPMU IV DRUG ABUSE DX")
 Q:+PRIORDX 0
 S PRIORPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU IV DRUG ABUSE DX","C",BGPEDATE)
 Q:$P(PRIORPL,U,3)>=LBP2YR 0
 ;Check for neurologic impairment Dx up to 2 years prior to period end
 S PRIORDX=$$LASTDX^BGPMUUT2(DFN,LBP2YR,BGPEDATE,"BGPMU NEUROLOGIC DISORDER DX")
 Q:+PRIORDX 0
 S PRIORPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU NEUROLOGIC DISORDER DX","C",BGPEDATE)
 Q:$P(PRIORPL,U,3)>=LBP2YR 0
 Q 1
NUM(DFN,VIEN,CNT,BGPBDATE,BGPEDATE) ;Look for spinal imaging study
 N SPINAL,LBPDATE,LBPD28
 S LBPDATE=$P(VIEN(CNT),U,3),LBPD28=$$FMADD^XLFDT(LBPDATE,28)
 ;Look for V RADIOLOGY event for spinal study
 S SPINAL=$$RAD^BGPMUUT1(DFN,LBPDATE,LBPD28,"BGPMU SPINAL STUDY CPT",7)
 ;return TRUE if no spinal study found
 I +SPINAL Q 0_U_SPINAL
 ;Look for ORDER for spinal study
 S SPINAL=$$FIND^BGPMUUT7(DFN,"BGPMU SPINAL STUDY CPT",LBPDATE,LBPD28) ;RAD procedure check
 I +SPINAL Q 0_U_$P(SPINAL,U,2,3)
 Q 1