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

BGPMUH06.m

Go to the documentation of this file.
BGPMUH06 ;IHS/MSC/MGH - MI measure NQF0438-STK-5 ;02-Mar-2011 16:05;MGH
 ;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
 ;ED meaningful use hospital measured
ENTRY ;PEP  Stroke Measure 5 - Antithrobtic therapy by end of 2nd day
 N START,END,BGPIEN,DFN,BGPVST,BGPISDX,BGPHSDX,BGPAGEE,BGPIPROB,BGPHPROB,STROKE,EXC,NUM,BGPDIS
 N BGPER,BGPADTMI,BDPDD,LKW,BGPADMIT,BGPDD,ADATE,SECOND
 ;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=""
 ..S BGPADMIT=$P($G(^DGPM(BGPIEN,0)),U,1)  ;Admit date/time
 ..S BGPDD=$P($G(^DGPM(BGPDIS,0)),U,1)     ;Discharge date/time
 ..;Check for a diagnosis of stroke
 ..S STROKE=0,EXC=0,NUM=0
 ..S BGPISDX=$$VSTPOVA^BGPMUUT3(DFN,BGPVST,"BGPMU ISCHEMIC STROKE DX")
 ..;S BGPIPROB=$$PLTAX^BGPMUUT1(DFN,"BGPMU ISCHEMIC 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 +BGPISDX S STROKE=1
 ..;Next check for exclusions
 ..I +STROKE D
 ...;See if there is an ER visit prior to admission
 ...S BGPER=$$ER(DFN,BGPADMIT)
 ...S EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST,BGPDIS)
 ...;If no exclusions see if they had antithrombolytics given in correct time frame
 ...I EXC="" S NUM=$$NUMER(DFN,BGPADMIT,SECOND)
 ...;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("BGPMU0438",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0438",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0438",$J,BGPMUTF,"NUM"))
 S EXCCT=+$G(^TMP("BGPMU0438",$J,BGPMUTF,"EXC"))
 S NOTCT=+$G(^TMP("BGPMU0438",$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("BGPMU0438",$J,BGPMUTF,"DEN")=DENCT
 I EXC'="" D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0438",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0438",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_DATE_U_$P(EXC,U,2)
 I EXC="" D
 .I +NUM=1 D
 ..S NUMCT=NUMCT+1 S ^TMP("BGPMU0438",$J,BGPMUTF,"NUM")=NUMCT
 ..S ^TMP("BGPMU0438",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
 .I +NUM=0 D
 ..S ^TMP("BGPMU0438",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
 ..S NOTCT=NOTCT+1 S ^TMP("BGPMU0438",$J,BGPMUTF,"NOT")=NOTCT
 S ^TMP("BGPMU0438",$J,BGPMUTF,"TOT")=PTCNT
 S BGPICARE("MU.STK.0438.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,BGPDIS) ;See if there are exclusions
 N REASON,BGPLOS,BGPHOS,BGPCLIN,BGPECI,DTYPE1,DTYPE2,BGPALL,BGPREF,BGPTPA
 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 if LOS < 2 days
 ;Find the end of hospital day 2
 S ADATE=$P(BGPADMIT,".",1)
 S SECOND=$$FMADD^XLFDT(ADATE,2),SECOND=SECOND_".2359"
 I BGPDD<SECOND S EXC="1^LOS"            ;Length of stay too short
 ;Check for palliative Care
 S BGPHOS=$$HOSPICE(DFN,BGPVST,BGPADMIT)
 I +BGPHOS S REASON=BGPHOS Q REASON
 ;Check for clinical trial
 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
 ;Check for allergies to warfarin
 S BGPALL=$$ALLER(DFN)
 I +BGPALL S REASON=BGPALL Q REASON
 ;Check for refusals
 S BGPREF=$$REF(DFN,BGPVST,BGPDIS)
 I +BGPREF S REASON=BGPREF Q REASON
 ;Check if they had tPA
 S BGPTPA=$$TPA(DFN,BGPADMIT,BGPDD)
 I +BGPTPA S REASON=BGPTPA
 Q REASON
HOSPICE(DFN,BGPVST,BGPADMT) ;Find palliative care patients
 N COMFORT,BGPTDX,BGPTPROB,BGPTCPT
 S COMFORT=0
 S BGPTDX=$$COMFORT^BGPMUUT3(DFN,BGPVST,"BGPMU TERMINAL",BGPADMIT,1)
 I +BGPTDX S COMFORT=BGPTDX
 S BGPTPROB=$$PLSTART^BGPMUUT3(DFN,"BGPMU TERMINAL","A",BGPADMIT)
 I +BGPTPROB S COMFORT=BGPTPROB
 S BGPTCPT=$$PALCPT^BGPMUUT3(DFN,BGPVST,"BGPMU PALLIATIVE CARE CPT",BGPADMIT)
 I +BGPTCPT S COMFORT=BGPTCPT
 Q COMFORT
ALLER(DFN) ;Find if pt has allergies to warfarin
 N AA,BB,X,Y,TEST
 S (AA,TEST)=0
 I '$D(^GMR(120.8,"B",DFN)) Q TEST
 F  S AA=$O(^GMR(120.8,"B",DFN,AA)) Q:AA'>0!(TEST=1)  D
 . I $P(^GMR(120.8,AA,0),"^",16)'=1 Q    ;Quit if not verified
 . I $D(^GMR(120.8,AA,"ER")),$P(^GMR(120.8,AA,"ER"),"^",1)=1 Q
 . S X=$P(^GMR(120.8,AA,0),"^",2) X ^%ZOSF("UPPERCASE")
 . I (Y["COUMADIN")!(Y["WARFARIN") S TEST="1^"_Y
 . S BB=0
 . F  S BB=$O(^GMR(120.8,AA,3,"B",BB)) Q:BB'>0  D
 . . I $P(^PS(50.605,BB,0),"^",1)="BL110" S TEST="1^"_Y
 Q TEST
REF(DFN,BGPVST,BGPDIS) ;Find refusals for this medication
 N ENDDT,X1,X2,X,MED,BGPEVT,DISDT
 S MED=0
 S BGPEVT=$P($G(^AUPNVSIT(BGPVST,0)),U,1)
 S DISDT=$P($G(^DGPM(BGPDIS,0)),U,1)
 S ENDDT=$$FMADD^XLFDT(DISDT,+1)
 S TAX="BGPMU ANTITHROMBOTIC NDCS"
 S MED=$$MEDREF^BGPMUUT2(DFN,BGPEVT,ENDDT,TAX)
 Q MED
TPA(DFN,ADMIT,DIS) ;Check to see if had tpa
 N TAX,MEDDTE,ENDDT,TPA,MEDIEN,STATUS,DRUG,BGPIDX,DISPENSE
 S TPA=0
 S MEDDTE=$$FMADD^XLFDT(ADMIT,-1)    ;Start time is 24hrs prior to admission
 S TAX="BGPMU TPA NDC CODES"
 S TPA=$$BCMA(DFN,MEDDTE,DIS,TAX)
 I TPA=0 D    ;Check non-VA meds
 .N N0,IEN,ST,ED,STATUS,BGPIDX,DC
 .S IEN=0 F  S IEN=$O(^PS(55,DFN,"NVA",IEN)) Q:'+IEN!(+TPA)  D
 ..S N0=$G(^PS(55,DFN,"NVA",IEN,0))
 ..S DC=$P(N0,U,7),ST=$P(N0,U,9),ED=$P(N0,U,10)
 ..S BGPIDX=$P(N0,U,2)
 ..I ST="" S ST=ED
 ..I ST>MEDDTE&(ST<DIS) S RESULT=$$NDC^BGPMUUT4(BGPIDX,TAX)
 Q TPA
ER(DFN,BGPADMIT,BGPVST) ;Find ER admit time since TPA is often given in the ER
 N VST,IEN,FOUND,ERDTE,NEW
 S FOUND=0,VST=0
 S IEN="" F  S IEN=$O(^AMERVSIT("AC",DFN,IEN),-1) Q:IEN=""!(+FOUND)  D
 .S ERDTE=$P($G(^AMERVSIT(IEN,0)),U,1)
 .S NEW=$$FMADD^XLFDT(BGPADMIT,-1)
 .I ERDTE>NEW&(ERDTE<BGPADMIT) S FOUND=1,VST=ERDTE
 Q VST
NUMER(DFN,ADMIT,SECOND) ;Find if pt in the numerator
 N TAX,RESULT
 S RESULT=0
 S TAX="BGPMU ANTITHROMBOTIC NDCS"
 S RESULT=$$BCMA(DFN,ADMIT,SECOND,TAX)
 S:+RESULT $P(RESULT,U,3)=BGPDD
 Q RESULT
BCMA(DFN,MEDDTE,ENDDT,TAX) ;Check to see if pt is in the numerator
 N MED,MEDIEN,STATUS,DRUG,DISPENSE
 S MED=0
 F  S MEDDTE=$O(^PSB(53.79,"AADT",DFN,MEDDTE)) Q:'+MEDDTE!(MEDDTE>ENDDT)!(+MED)  D
 .S MEDIEN="" F  S MEDIEN=$O(^PSB(53.79,"AADT",DFN,MEDDTE,MEDIEN)) Q:'+MEDIEN!(+MED)  D
 ..S STATUS=$P($G(^PSB(53.79,MEDIEN,0)),U,9)
 ..I STATUS="G"!(STATUS="I")!(STATUS="C") D         ;Drug given
 ...S DISPENSE=0 F  S DISPENSE=$O(^PSB(53.79,MEDIEN,.5,DISPENSE)) Q:'+DISPENSE!(+MED)  D
 ....S DRUG=$G(^PSB(53.79,MEDIEN,.5,DISPENSE,0))
 ....S DRUG=$P(DRUG,U,1)
 ....S MED=$$NDC^BGPMUUT4(DRUG,TAX)
 Q MED