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

BGPMUH09.m

Go to the documentation of this file.
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