BGPMUH09 ; IHS/MSC/MGH - MU measure NQF0441-STK-10 ;02-Mar-2011 16:20;DU
;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
;meaningful use hospital measure STROKE-10 - Assessed for Rehabilitation
ENTRY ;PEP Stroke Measure 10 - assessed for rehab
N START,END,BGPIEN,DFN,BGPVST,BGPISDX,BGPHSDX,BGPAGEE,BGPIPROB,BGPHPROB,STROKE,EXC,NUM,BGPDIS
;Start by finding all admissions during the reporting period
S START=BGPBDATE
S END=BGPEDATE_".2359"
F S START=$O(^DGPM("B",START)) Q:START=""!(START>END) D
.S BGPIEN="" F S BGPIEN=$O(^DGPM("B",START,BGPIEN)) Q:BGPIEN="" D
..Q:$P($G(^DGPM(BGPIEN,0)),U,2)'=1 ;Only include admissions
..S DFN=$P($G(^DGPM(BGPIEN,0)),U,3)
..S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
..Q:DFN=""
..S BGPACTUP=$$ACTUPAP^BGPMUEHD(DFN,BGPBDATE,BGPEDATE,BGPBEN)
..I 'BGPACTUP,'$G(BGPXPXPX),'$G(BGPIISO) Q
..S BGPVST=$P($G(^DGPM(BGPIEN,0)),U,27) ;Get the visit
..Q:BGPVST=""
..S BGPDIS=$P($G(^DGPM(BGPIEN,0)),U,17) ;Don't use if pt is still an inpt
..Q:BGPDIS=""
..;Check for a diagnosis of stroke (both types for this measure)
..S STROKE=0,EXC=0,NUM=0
..;In These next two taxonomies almost all Stroke ICD9s are included
..;S BGPISDX=$$VSTPOVA^BGPMUUT3(DFN,BGPVST,"BGPMU ISCHEMIC STROKE DX")
..;S BGPHSDX=$$VSTPOVA^BGPMUUT3(DFN,BGPVST,"BGPMU HEMORRHAGIC STROKE DX")
..;************
..;S BGPIPROB=$$PLTAX^BGPMUUT1(DFN,"BGPMU ISCHEMIC STROKE DX","A")
..;S BGPHPROB=$$PLTAX^BGPMUUT1(DFN,"BGPMU HEMORRHAGIC STROKE DX","A")
..;Pt must have both a POV of stoke and it must be an active problem
..;I +BGPISDX&(+BGPIPROB) S STROKE=1
..;I +BGPHSDX&(+BGPHPROB) S STROKE=1
..;S:BGPISDX STROKE=1
..;S:BGPHSDX STROKE=1
..S:'STROKE STROKE=$$STROKE(DFN,BGPVST)
..;Next check for exclusions
..I +STROKE D
...S EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST)
...;If no exclusions see if they were assessed for rehabilitation
...I '+EXC S NUM=$$NUMER(DFN,BGPVST,BGPIEN,BGPDIS)
...;Now add it all up
...D TOTAL(BGPIEN)
Q
TOTAL(BGPIEN) ;add up the totals
N PTCNT,EXCCT,DENCT,NUMCT,TOTALS,DATE,NOTCT
S TOTALS=$G(^TMP("BGPMU0441",$J,BGPMUTF,"TOT"))
S DENCT=+$G(^TMP("BGPMU0441",$J,BGPMUTF,"DEN"))
S NUMCT=+$G(^TMP("BGPMU0441",$J,BGPMUTF,"NUM"))
S EXCCT=+$G(^TMP("BGPMU0441",$J,BGPMUTF,"EXC"))
S NOTCT=+$G(^TMP("BGPMU0441",$J,BGPMUTF,"NOT"))
S PTCNT=TOTALS
S PTCNT=PTCNT+1
S DATE=$$DATE^BGPMUUTL($P($G(^DGPM(BGPIEN,0)),U,1))
S DENCT=DENCT+1 S ^TMP("BGPMU0441",$J,BGPMUTF,"DEN")=DENCT
I +EXC D
.S EXCCT=EXCCT+1 S ^TMP("BGPMU0441",$J,BGPMUTF,"EXC")=EXCCT
.I BGPMUTF="C" S ^TMP("BGPMU0441",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_$P(EXC,U,2)
I '+EXC D
.I +NUM=1 D
..S NUMCT=NUMCT+1 S ^TMP("BGPMU0441",$J,BGPMUTF,"NUM")=NUMCT
..S ^TMP("BGPMU0441",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
.I +NUM=0 D
..S NOTCT=NOTCT+1 S ^TMP("BGPMU0441",$J,BGPMUTF,"NOT")=NOTCT
..S ^TMP("BGPMU0441",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
S ^TMP("BGPMU0441",$J,BGPMUTF,"TOT")=PTCNT
S BGPICARE("MU.STK.0441.1",BGPMUTF,DFN)=1_U_+$G(NUM)_U_+EXC_U_DATE_";"_$P($G(NUM),U,3)_";"_$P(EXC,U,2)
Q
EXCLUDE(DFN,BGPIEN,BGPVST) ;See if there are exclusions
N REASON,BGPLOS,BGPHOS,BGPCLIN,BGPECI,DTYPE1,DTYPE2
S REASON=""
I BGPAGEE<18 S REASON="1^AGE" Q REASON
;Check for LOS
S BGPLOS=$$LOS^BGPMUH08(BGPIEN,BGPDIS)
I BGPLOS>120 S REASON="1^LOS" Q REASON
;Check for discharge reasons
S DTYPE2=$P($G(^DGPM(BGPDIS,"IHS")),U,7)
I (DTYPE2="2")!(DTYPE2="3")!(DTYPE2="4")!(DTYPE2="5")!(DTYPE2="7")!(DTYPE2="43")!(DTYPE2="50")!(DTYPE2="51") S REASON="1^"_DTYPE2 Q REASON
;Check for expired
S DTYPE2=$P($G(^DGPM(BGPDIS,"IHS")),U,7)
I (DTYPE2="20")!(DTYPE2="40")!(DTYPE2="41")!(DTYPE2="42") S REASON="1^"_DTYPE2 Q REASON
;Check for hospice care
S BGPHOS=$$HOSPICE^BGPMUH08(DFN,BGPVST)
I +BGPHOS S REASON=BGPHOS Q REASON
;Check for clinical trials
S BGPCLIN=$$TRIAL^BGPMUH08(DFN,BGPVST)
I +BGPCLIN S REASON=BGPCLIN Q REASON
;Check for elective carotid intervention procedure
S BGPECI=$$ELECTIVE^BGPMUH08(DFN,BGPVST,BGPIEN)
I +BGPECI S REASON=BGPECI Q REASON
Q REASON
NUMER(DFN,BGPVST,BGPIEN,BGPDIS) ;Check to see if pt is in the numerator
N %
S %=$$VSTCPT^BGPMUUT1(DFN,BGPVST,"BGPMU REHAB ASSESS CPT")
I +% D
.S BGPDD=$P($G(^DGPM(BGPDIS,0)),U,1)
.S $P(%,U,3)=BGPDD
Q %
STROKE(DFN,BGPVST) ;Check for Stroke diagnoses
Q:'DFN 0
Q:'BGPVST 0
N IEN,M,ICD9,X,I,J,Y,STROKE
S (STROKE,IEN)=0
F S IEN=$O(^AUPNVPOV("AD",BGPVST,IEN)) Q:'IEN D
.;Quit if other patient
.Q:$P(^AUPNVPOV(IEN,0),U,2)'=DFN
.;Quit if modifier = C or D or M or O or P or S
.S M=$P(^AUPNVPOV(IEN,0),U,6)
.I $L(M),"CDMOPS"[M Q
.;Quit if diagnosis not primary
.Q:$P(^AUPNVPOV(IEN,0),U,12)="S"
.S ICD9=$P(^AUPNVPOV(IEN,0),U),ICD9=$P(^ICD9(ICD9,0),U)
.;Quit if ICD9 is not on list of Ischemic strokes or Homorrhagic strokes.
.F I=1:1 S X=$P($T(ICD9+I),";;",2) Q:X["END"!STROKE F J=1:1 S Y=$P(X,U,J) Q:'$L(Y)!STROKE D
..I Y["-" Q:ICD9<$P(Y,"-")!(ICD9>$P(Y,"-",2)) S STROKE=1 Q
..S:ICD9=Y STROKE=1
Q STROKE
ICD9 ;List of stroke ICD9 codes to be included in Denominator logic
;;433.0^433.00^433.01^433.1^433.10^433.11^433.2^433.20^433.21^433.3^433.30^433.31^433.8
;;433.80^433.81^433.9^433.90^433.91^434.0^434.00^434.01^434.1^434.10^434.11^434.9^434.90
;;434.91^435.8^435.9^436.^430-432.99
;;END
Q
BGPMUH09 ; IHS/MSC/MGH - MU measure NQF0441-STK-10 ;02-Mar-2011 16:20;DU
+1 ;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
+2 ;meaningful use hospital measure STROKE-10 - Assessed for Rehabilitation
ENTRY ;PEP Stroke Measure 10 - assessed for rehab
+1 NEW START,END,BGPIEN,DFN,BGPVST,BGPISDX,BGPHSDX,BGPAGEE,BGPIPROB,BGPHPROB,STROKE,EXC,NUM,BGPDIS
+2 ;Start by finding all admissions during the reporting period
+3 SET START=BGPBDATE
+4 SET END=BGPEDATE_".2359"
+5 FOR
SET START=$ORDER(^DGPM("B",START))
IF START=""!(START>END)
QUIT
Begin DoDot:1
+6 SET BGPIEN=""
FOR
SET BGPIEN=$ORDER(^DGPM("B",START,BGPIEN))
IF BGPIEN=""
QUIT
Begin DoDot:2
+7 ;Only include admissions
IF $PIECE($GET(^DGPM(BGPIEN,0)),U,2)'=1
QUIT
+8 SET DFN=$PIECE($GET(^DGPM(BGPIEN,0)),U,3)
+9 SET BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
+10 IF DFN=""
QUIT
+11 SET BGPACTUP=$$ACTUPAP^BGPMUEHD(DFN,BGPBDATE,BGPEDATE,BGPBEN)
+12 IF 'BGPACTUP
IF '$GET(BGPXPXPX)
IF '$GET(BGPIISO)
QUIT
+13 ;Get the visit
SET BGPVST=$PIECE($GET(^DGPM(BGPIEN,0)),U,27)
+14 IF BGPVST=""
QUIT
+15 ;Don't use if pt is still an inpt
SET BGPDIS=$PIECE($GET(^DGPM(BGPIEN,0)),U,17)
+16 IF BGPDIS=""
QUIT
+17 ;Check for a diagnosis of stroke (both types for this measure)
+18 SET STROKE=0
SET EXC=0
SET NUM=0
+19 ;In These next two taxonomies almost all Stroke ICD9s are included
+20 ;S BGPISDX=$$VSTPOVA^BGPMUUT3(DFN,BGPVST,"BGPMU ISCHEMIC STROKE DX")
+21 ;S BGPHSDX=$$VSTPOVA^BGPMUUT3(DFN,BGPVST,"BGPMU HEMORRHAGIC STROKE DX")
+22 ;************
+23 ;S BGPIPROB=$$PLTAX^BGPMUUT1(DFN,"BGPMU ISCHEMIC STROKE DX","A")
+24 ;S BGPHPROB=$$PLTAX^BGPMUUT1(DFN,"BGPMU HEMORRHAGIC STROKE DX","A")
+25 ;Pt must have both a POV of stoke and it must be an active problem
+26 ;I +BGPISDX&(+BGPIPROB) S STROKE=1
+27 ;I +BGPHSDX&(+BGPHPROB) S STROKE=1
+28 ;S:BGPISDX STROKE=1
+29 ;S:BGPHSDX STROKE=1
+30 IF 'STROKE
SET STROKE=$$STROKE(DFN,BGPVST)
+31 ;Next check for exclusions
+32 IF +STROKE
Begin DoDot:3
+33 SET EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST)
+34 ;If no exclusions see if they were assessed for rehabilitation
+35 IF '+EXC
SET NUM=$$NUMER(DFN,BGPVST,BGPIEN,BGPDIS)
+36 ;Now add it all up
+37 DO TOTAL(BGPIEN)
End DoDot:3
End DoDot:2
End DoDot:1
+38 QUIT
TOTAL(BGPIEN) ;add up the totals
+1 NEW PTCNT,EXCCT,DENCT,NUMCT,TOTALS,DATE,NOTCT
+2 SET TOTALS=$GET(^TMP("BGPMU0441",$JOB,BGPMUTF,"TOT"))
+3 SET DENCT=+$GET(^TMP("BGPMU0441",$JOB,BGPMUTF,"DEN"))
+4 SET NUMCT=+$GET(^TMP("BGPMU0441",$JOB,BGPMUTF,"NUM"))
+5 SET EXCCT=+$GET(^TMP("BGPMU0441",$JOB,BGPMUTF,"EXC"))
+6 SET NOTCT=+$GET(^TMP("BGPMU0441",$JOB,BGPMUTF,"NOT"))
+7 SET PTCNT=TOTALS
+8 SET PTCNT=PTCNT+1
+9 SET DATE=$$DATE^BGPMUUTL($PIECE($GET(^DGPM(BGPIEN,0)),U,1))
+10 SET DENCT=DENCT+1
SET ^TMP("BGPMU0441",$JOB,BGPMUTF,"DEN")=DENCT
+11 IF +EXC
Begin DoDot:1
+12 SET EXCCT=EXCCT+1
SET ^TMP("BGPMU0441",$JOB,BGPMUTF,"EXC")=EXCCT
+13 IF BGPMUTF="C"
SET ^TMP("BGPMU0441",$JOB,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_$PIECE(EXC,U,2)
End DoDot:1
+14 IF '+EXC
Begin DoDot:1
+15 IF +NUM=1
Begin DoDot:2
+16 SET NUMCT=NUMCT+1
SET ^TMP("BGPMU0441",$JOB,BGPMUTF,"NUM")=NUMCT
+17 SET ^TMP("BGPMU0441",$JOB,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DATE_U_$PIECE(NUM,U,3)_U_$PIECE(NUM,U,2)
End DoDot:2
+18 IF +NUM=0
Begin DoDot:2
+19 SET NOTCT=NOTCT+1
SET ^TMP("BGPMU0441",$JOB,BGPMUTF,"NOT")=NOTCT
+20 SET ^TMP("BGPMU0441",$JOB,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DATE_U_$PIECE(NUM,U,3)_U_$PIECE(NUM,U,2)
End DoDot:2
End DoDot:1
+21 SET ^TMP("BGPMU0441",$JOB,BGPMUTF,"TOT")=PTCNT
+22 SET BGPICARE("MU.STK.0441.1",BGPMUTF,DFN)=1_U_+$GET(NUM)_U_+EXC_U_DATE_";"_$PIECE($GET(NUM),U,3)_";"_$PIECE(EXC,U,2)
+23 QUIT
EXCLUDE(DFN,BGPIEN,BGPVST) ;See if there are exclusions
+1 NEW REASON,BGPLOS,BGPHOS,BGPCLIN,BGPECI,DTYPE1,DTYPE2
+2 SET REASON=""
+3 IF BGPAGEE<18
SET REASON="1^AGE"
QUIT REASON
+4 ;Check for LOS
+5 SET BGPLOS=$$LOS^BGPMUH08(BGPIEN,BGPDIS)
+6 IF BGPLOS>120
SET REASON="1^LOS"
QUIT REASON
+7 ;Check for discharge reasons
+8 SET DTYPE2=$PIECE($GET(^DGPM(BGPDIS,"IHS")),U,7)
+9 IF (DTYPE2="2")!(DTYPE2="3")!(DTYPE2="4")!(DTYPE2="5")!(DTYPE2="7")!(DTYPE2="43")!(DTYPE2="50")!(DTYPE2="51")
SET REASON="1^"_DTYPE2
QUIT REASON
+10 ;Check for expired
+11 SET DTYPE2=$PIECE($GET(^DGPM(BGPDIS,"IHS")),U,7)
+12 IF (DTYPE2="20")!(DTYPE2="40")!(DTYPE2="41")!(DTYPE2="42")
SET REASON="1^"_DTYPE2
QUIT REASON
+13 ;Check for hospice care
+14 SET BGPHOS=$$HOSPICE^BGPMUH08(DFN,BGPVST)
+15 IF +BGPHOS
SET REASON=BGPHOS
QUIT REASON
+16 ;Check for clinical trials
+17 SET BGPCLIN=$$TRIAL^BGPMUH08(DFN,BGPVST)
+18 IF +BGPCLIN
SET REASON=BGPCLIN
QUIT REASON
+19 ;Check for elective carotid intervention procedure
+20 SET BGPECI=$$ELECTIVE^BGPMUH08(DFN,BGPVST,BGPIEN)
+21 IF +BGPECI
SET REASON=BGPECI
QUIT REASON
+22 QUIT REASON
NUMER(DFN,BGPVST,BGPIEN,BGPDIS) ;Check to see if pt is in the numerator
+1 NEW %
+2 SET %=$$VSTCPT^BGPMUUT1(DFN,BGPVST,"BGPMU REHAB ASSESS CPT")
+3 IF +%
Begin DoDot:1
+4 SET BGPDD=$PIECE($GET(^DGPM(BGPDIS,0)),U,1)
+5 SET $PIECE(%,U,3)=BGPDD
End DoDot:1
+6 QUIT %
STROKE(DFN,BGPVST) ;Check for Stroke diagnoses
+1 IF 'DFN
QUIT 0
+2 IF 'BGPVST
QUIT 0
+3 NEW IEN,M,ICD9,X,I,J,Y,STROKE
+4 SET (STROKE,IEN)=0
+5 FOR
SET IEN=$ORDER(^AUPNVPOV("AD",BGPVST,IEN))
IF 'IEN
QUIT
Begin DoDot:1
+6 ;Quit if other patient
+7 IF $PIECE(^AUPNVPOV(IEN,0),U,2)'=DFN
QUIT
+8 ;Quit if modifier = C or D or M or O or P or S
+9 SET M=$PIECE(^AUPNVPOV(IEN,0),U,6)
+10 IF $LENGTH(M)
IF "CDMOPS"[M
QUIT
+11 ;Quit if diagnosis not primary
+12 IF $PIECE(^AUPNVPOV(IEN,0),U,12)="S"
QUIT
+13 SET ICD9=$PIECE(^AUPNVPOV(IEN,0),U)
SET ICD9=$PIECE(^ICD9(ICD9,0),U)
+14 ;Quit if ICD9 is not on list of Ischemic strokes or Homorrhagic strokes.
+15 FOR I=1:1
SET X=$PIECE($TEXT(ICD9+I),";;",2)
IF X["END"!STROKE
QUIT
FOR J=1:1
SET Y=$PIECE(X,U,J)
IF '$LENGTH(Y)!STROKE
QUIT
Begin DoDot:2
+16 IF Y["-"
IF ICD9<$PIECE(Y,"-")!(ICD9>$PIECE(Y,"-",2))
QUIT
SET STROKE=1
QUIT
+17 IF ICD9=Y
SET STROKE=1
End DoDot:2
End DoDot:1
+18 QUIT STROKE
ICD9 ;List of stroke ICD9 codes to be included in Denominator logic
+1 ;;433.0^433.00^433.01^433.1^433.10^433.11^433.2^433.20^433.21^433.3^433.30^433.31^433.8
+2 ;;433.80^433.81^433.9^433.90^433.91^434.0^434.00^434.01^434.1^434.10^434.11^434.9^434.90
+3 ;;434.91^435.8^435.9^436.^430-432.99
+4 ;;END
+5 QUIT