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

BGPMUH08.m

Go to the documentation of this file.
BGPMUH08 ; IHS/MSC/MGH - MI measure NQF0440-STK-8 ;02-Mar-2011 16:19;DU
 ;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
 ;ED meaningful use hospital measured
 ; print output routine is BGPMUHP4
 ; delimited output routine is BGPMUHD3
ENTRY ;PEP  Stroke Measure 8 - stroke education
 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)
 ..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 BGPADM=$P($$GET1^DIQ(9000010,BGPVST_",",.01,"I"),".",1) ;get admin date
 ..S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPADM)
 ..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
 ..;S BGPISDX=$$VSTPOV^BGPMUUT3(DFN,BGPVST,"BGPMU ISCHEMIC STROKE DX")     ;ZSAT
 ..;S BGPHSDX=$$VSTPOV^BGPMUUT3(DFN,BGPVST,"BGPMU HEMORRHAGIC STROKE DX")  ;ZSAT
 ..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
 ..I +BGPISDX S STROKE=1
 ..I +BGPHSDX S STROKE=1
 ..;Next check for exclusions
 ..I +STROKE D
 ...S EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST)
 ...;If no exclusions see if they had the education coded
 ...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("BGPMU0440",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0440",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0440",$J,BGPMUTF,"NUM"))
 S NOTCT=+$G(^TMP("BGPMU0440",$J,BGPMUTF,"NOT"))
 S EXCCT=+$G(^TMP("BGPMU0440",$J,BGPMUTF,"EXC"))
 S PTCNT=TOTALS
 S PTCNT=PTCNT+1
 S DATE=$$DATE^BGPMUUTL($P($G(^DGPM(BGPIEN,0)),U,1))
 S DENCT=DENCT+1 S ^TMP("BGPMU0440",$J,BGPMUTF,"DEN")=DENCT
 I EXC'="" D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0440",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0440",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_$P(EXC,U,2)
 I EXC="" D
 .S ^TMP("BGPMU0440",$J,"PAT",BGPMUTF,"DEN",PTCNT)=DFN_U_DATE
 .I +NUM=1 D
 ..S NUMCT=NUMCT+1 S ^TMP("BGPMU0440",$J,BGPMUTF,"NUM")=NUMCT
 ..S ^TMP("BGPMU0440",$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("BGPMU0440",$J,BGPMUTF,"NOT")=NOTCT
 ..S ^TMP("BGPMU0440",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
 S ^TMP("BGPMU0440",$J,BGPMUTF,"TOT")=PTCNT
 S BGPICARE("MU.STK.0435.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
 S REASON=""
 I BGPAGEE<18 S REASON="1^AGE" Q REASON
 ;Check for LOS
 S BGPLOS=$$LOS(BGPIEN,BGPDIS)
 I BGPLOS>120 S REASON="1^LOS" Q REASON
 ;Check for hospice care
 S BGPHOS=$$HOSPICE(DFN,BGPVST)
 I +BGPHOS S REASON=BGPHOS Q REASON
 ;Check for clinical trials
 S BGPCLIN=$$TRIAL(DFN,BGPVST)
 I +BGPCLIN S REASON=BGPCLIN Q REASON
 ;Check for elective carotid intervention procedure
 S BGPECI=$$ELECTIVE(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 EDU,ETOPIC,D,Y,BDATE,EDATE,LIT,LIT2,%,EIEN,ICD,BGPMU,TNAME
 S BDATE=$P($G(^DGPM(BGPIEN,0)),U,1)
 S EDATE=$P($G(^DGPM(BGPDIS,0)),U,1)
 S (%,ETOPIC,LIT,LIT2)=0
 ;Find all the patient ed topics from admission to discharge
 ;Loop through the array and look for stroke education
 S EIEN="" F  S EIEN=$O(^AUPNVPED("AD",BGPVST,EIEN)) Q:EIEN=""!(%'=0)  D
 .S ETOPIC=$P($G(^AUPNVPED(EIEN,0)),U,1)
 .Q:'ETOPIC
 .Q:'$D(^AUTTEDT(ETOPIC,0))
 .;Quit if you find the specific stroke eduction topic
 .S TNAME=$P($G(^AUTTEDT(ETOPIC,0)),U,1)
 .S TTIME=$P($G(^AUPNVPED(EIEN,12)),U,1)
 .I TNAME="STROK-LITERATURE" S %=1_U_TNAME_U_TTIME Q
 .I $P(TNAME,"-",2)="LITERATURE" D
 ..;Check for diagnoses related literature
 ..S ICD=$P(TNAME,"-",1)
 ..I +ICD S LIT=$$EDLOOP(ICD,"BGPMU ISCHEMIC STROKE DX")
 ..I +LIT S %=LIT_U_TTIME
 ..I +ICD S LIT2=$$EDLOOP(ICD,"BGPMU HEMORRHAGIC STROKE DX")
 ..I +LIT2 S %=LIT2_U_TTIME
 S:+% $P(%,U,3)=EDATE
 Q %
EDLOOP(ICD,TAX) ;Find ed code in taxonomy
 N BGPTX,X,%,CODE
 S %=0
 S BGPTX=$O(^ATXAX("B",TAX,0))
 S X=0 F  S X=$O(^ATXAX(BGPTX,21,X)) Q:X=""!(%'=0)  D
 .S CODE=$P($G(^ATXAX(BGPTX,21,X,0)),U,1)
 .I CODE=ICD S %=1_U_CODE_"-LITERATURE"
 Q %
LOS(BGPIEN,BGPDIS) ;Return the length of stay
 N DAYS,X1,X2,X
 S DAYS=0
 S X2=$P($G(^DGPM(BGPIEN,0)),U,1)
 S X1=$P($G(^DGPM(BGPDIS,0)),U,1)
 D ^%DTC S DAYS=X
 Q DAYS
HOSPICE(DFN,BGPVST) ;Return if hospice DX/problem was found for this patient
 N COMFORT,BGPTDX,BGPTPROB,BGPTCPT
 S COMFORT=0
 S BGPTDX=$$VSTPOVB^BGPMUUT3(DFN,BGPVST,"BGPMU TERMINAL")
 I +BGPTDX S COMFORT=BGPTDX
 S BGPTPROB=$$PLTAX^BGPMUUT1(DFN,"BGPMU TERMINAL","C")
 I +BGPTPROB S COMFORT=BGPTPROB
 S BGPTCPT=$$VSTCPT^BGPMUUT1(DFN,BGPVST,"BGPMU PALLIATIVE CARE CPT")
 I +BGPTCPT S COMFORT=BGPTCPT
 Q COMFORT
TRIAL(DFN,BGPVST) ;Return if patient is on a clinical trial
 N CLIN,BGPCDX,BGPCPROB
 S CLIN=0
 S BGPCDX=$$VSTPOVB^BGPMUUT3(DFN,BGPVST,"BGPMU CLINICAL TRIAL DX")
 I +BGPCDX S CLIN=BGPCDX
 S BGPCPROB=$$PLTAX^BGPMUUT1(DFN,"BGPMU CLINICAL TRIAL DX","C")
 I +BGPCPROB S CLIN=BGPCPROB
 Q CLIN
ELECTIVE(DFN,BGPVST,BGPIEN) ;Return if pt was admitted for an elective carotic interventions procedures
 N PROC,TYPE,BGPCPT,BGPICD0
 S PROC=0
 S TYPE=$$GET1^DIQ(405,BGPIEN,9999999.05)
 I TYPE="ELECTIVE" D
 .S BGPICD0=$$VSTICD0^BGPMUUT3(DFN,BGPVST,"BGPMU CAROTID INTER ICD0")
 .I +BGPICD0 S PROC=BGPICD0
 Q PROC