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

BGPMUH15.m

Go to the documentation of this file.
BGPMUH15 ;IHS/MSC/MGH - MI measure NQF0376-VTE-6 ;02-Mar-2011 16:03;MGH
 ;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
 ;ED meaningful use hospital measures
ENTRY ;PEP  Vte measure 6 - VTE prophylaxis not given and pt got VTE
 N START,END,BGPIEN,DFN,BGPVST,BGPISDX,BGPHSDX,BGPAGEE,BGPIPROB,BGPHPROB,SECOND,EXC,NUM,BGPDIS
 N BGPER,BGPADTMI,BGPDD,EVDT,PDTE,ONADMIT,FIRST,EXCL,BGPVCODE,BGPRCODE,BGPVTE,BGPVTEPB,BGPVICD0
 ;Start by finding all admissions during the reporting period
 S START=BGPBDATE,EXCL=""
 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 BGPDIS=$P($G(^DGPM(BGPIEN,0)),U,17)  ;Don't use if pt is still an inpt
 ..Q:BGPDIS=""
 ..;Get the admit time & discharge times
 ..S BGPADMIT=$P($G(^DGPM(BGPIEN,0)),U,1)
 ..S BGPDD=$P($G(^DGPM(BGPDIS,0)),U,1)
 ..;Get patient age at admission
 ..S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPADMIT)
 ..;Look for DX of VTE
 ..S BGPVTE=$$VSTPOVB^BGPMUUT3(DFN,BGPVST,"BGPMU VTE DX")
 ..S BGPVCODE=$$VSTCPT^BGPMUUT1(DFN,BGPVST,"BGPMU VTE TEST CPT")
 ..S PROC=$P(BGPVCODE,U,3)
 ..;S BGPVICD0=$$VSTICD0^BGPMUUT3(DFN,BGPVST,"BGPMU VTE TEST ICD0")
 ..I +BGPVTE D             ;Must have DX of VTE
 ...;Now check to see if they were admitted with VTE
 ...S FIRST=$$FMADD^XLFDT(BGPADMIT,+1)
 ...S EXC=""
 ...S EVDT=$P(BGPVTE,U,3)           ;Event date of POV
 ...S ONADMIT=$P(BGPVTE,U,4)        ;Present on admission
 ...;I $P(EVDT,".",1)=$P(BGPADMIT,".",1)!($P(PDTE,".",1)=$P(BGPADMIT,".",1)) S EXC=1_U_"ADM"
 ...;I $P(EVDT,".",1)<$P(BGPADMIT,".",1)!($P(PDTE,".",1)<$P(BGPADMIT,".",1)) S EXC=1_U_"ADM"
 ...I ONADMIT="Y" S EXC=1_U_"ADM"
 ...I $P(EVDT,".",1)=$P(BGPADMIT,".",1) S EXC=1_U_"ADM"
 ...I $P(EVDT,".",1)<$P(BGPADMIT,".",1) S EXC=1_U_"ADM"
 ...I EXC="" S EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST,BGPDIS,BGPADMIT)
 ...;If no exclusions see if they had VTE
 ...I EXC="" S NUM=$$NUMER(DFN,BGPADMIT,PROC,BGPVST)
 ...;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("BGPMU0376",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0376",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0376",$J,BGPMUTF,"NUM"))
 S EXCCT=+$G(^TMP("BGPMU0376",$J,BGPMUTF,"EXC"))
 S NOTCT=+$G(^TMP("BGPMU0376",$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("BGPMU0376",$J,BGPMUTF,"DEN")=DENCT
 I EXC'="" D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0376",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0376",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_DATE_U_$P(EXC,U,2)
 I EXC="" D
 .I +NUM=0 D
 ..S NUMCT=NUMCT+1 S ^TMP("BGPMU0376",$J,BGPMUTF,"NUM")=NUMCT
 ..S ^TMP("BGPMU0376",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DATE_U_PROC
 .I +NUM=1 D
 ..S ^TMP("BGPMU0376",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DATE
 ..S NOTCT=NOTCT+1 S ^TMP("BGPMU0376",$J,BGPMUTF,"NOT")=NOTCT
 S ^TMP("BGPMU0376",$J,BGPMUTF,"TOT")=PTCNT
 S BGPICARE("MU.VTE.0376.1",BGPMUTF,DFN)=1_U_+$G(NUM)_U_+$G(EXC)_U_DATE_";"_$G(PROC)_";"_$P($G(EXC),U,2)
 Q
EXCLUDE(DFN,BGPIEN,BGPVST,BGPDIS,BGPADMIT) ;See if there are exclusions
 N REASON,BGPLOS,BGPHOS,BGPCLIN,BGPECI,BGPALL,BGPREF,MED,PHARM,PHARMP,MECH,MECHP,FIRST,CPT
 N BGPRCODE,BGPVCODE,BGPVICD0
 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 palliative Care
 S BGPHOS=$$HOSPICE^BGPMUH08(DFN,BGPVST)
 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 refusal of VTE med
 S FIRST=$$FMADD^XLFDT(BGPADMIT,+1)
 S MED=$$MEDREF^BGPMUUT2(DFN,$P(BGPADMIT,"."),$P(FIRST,".")_".2359","BGPMU VTE PROPHYLAXIS")
 I +MED S REASON=MED Q REASON
 ;Check for refusals of procedures
 S CPT=$$REFTAX^BGPMUUT2(DFN,81,"BGPMU VTE DEVICES CPT",$P(BGPADMIT,"."),$P(FIRST,"."))
 I +CPT S REASON=CPT Q REASON
 ;Check for refusal of ICD
 S ICD=$$REFTAX^BGPMUUT2(DFN,81.1,"BGPMU VTE DEVICES ICD0",$P(BGPADMIT,"."),$P(FIRST,"."))
 I +ICD S REASON=ICD Q REASON
 ;Check diagnoses for whom VTE is not appropriate
 S PHARM=$$VSTPOV^BGPMUUT3(DFN,BGPVST,"BGPMU VTE EXCLUDE PHARM DXS")
 I +PHARM S REASON=PHARM Q REASON
 S PHARMP=$$PLTAX^BGPMUUT1(DFN,"BGPMU VTE EXCLUDE PHARM DXS","C")
 I +PHARMP S REASON=PHARMP Q REASON
 S MECH=$$VSTPOVB^BGPMUUT3(DFN,BGPVST,"BGPMU VTE EXCLUDE-MECH DX")
 I +MECH S REASON=MECH Q REASON
 S MECHP=$$PLTAX^BGPMUUT1(DFN,"BGPMU VTE EXCLUDE-MECH DX","C")
 I +MECHP S REASON=MECHP Q REASON
 ;Check for confirmation codes
 S BGPRCODE=$$FIND^BGPMUUT7(DFN,"BGPMU VTE TEST CPT",BGPADMIT,BGPDD) ;RAD procedure check
 S BGPVCODE=$$VSTCPT^BGPMUUT1(DFN,BGPVST,"BGPMU VTE TEST CPT")
 ;S BGPVICD0=$$VSTICD0^BGPMUUT3(DFN,BGPVST,"BGPMU VTE TEST ICD0")   ;this is not in the ORT
 ;I ('+BGPRCODE)&('+BGPVCODE)&('+BGPVICD0) S REASON="1^no VTE test"
 I ('+BGPRCODE)&('+BGPVCODE) S REASON="1^no VTE test"
 Q REASON
NUMER(DFN,ADMIT,PROC,VST) ;Check to see if pt is in the numerator
 N TAX,MEDDTE,ENDDT,VTE,MEDIEN,STATUS,DRUG,DISPENSE
 N TEDS,FIRST,GIVEN,NOTGIV,RETURN,DEV
 S VTE=0,RETURN=0
 ;First, see if the pt has CPT for procedure in first 24hrs
 S FIRST=$$FMADD^XLFDT(ADMIT,+1)
 S TEDS=$$DTECPT^BGPMUUT3(DFN,VST,"BGPMU VTE DEVICES CPT",ADMIT,PROC)
 I +TEDS S VTE=TEDS S $P(VTE,U,3)=BGPDD Q VTE
 S DEV=$$DTECPT^BGPMUUT3(DFN,VST,"BGPMU VTE DEVICES ICD0",ADMIT,PROC)
 I +DEV S VTE=DEV S $P(VTE,U,3)=BGPDD Q VTE
 ;See if the VTE CPT code was entered
 ;DEV thinks this should be here, but it is not in the ORT
 ;S GIVEN=$$DTECPT^BGPMUUT3(DFN,VST,"BGPMU VTE GIVEN CPT",ADMIT,PROC)
 ;I +GIVEN S VTE=GIVEN S $P(VTE,U,3)=BGPDD Q VTE
 ;Check for code that patient is not eligible
 ;S NOTGIV=$$DTECPT^BGPMUUT3(DFN,VST,"BGPMU VTE NOT GIVEN CPT",ADMIT,PROC)
 ;I +NOTGIV S VTE=NOTGIV S $P(VTE,U,3)=BGPDD Q VTE
 ;Check for confirmation codes
 S BGPRCODE=$$FIND^BGPMUUT7(DFN,"BGPMU VTE TEST CPT",ADMIT,BGPDD) ;RAD procedure check
 S BGPVCODE=$$VSTCPT^BGPMUUT1(DFN,BGPVST,"BGPMU VTE TEST CPT")
 ;S BGPVICD0=$$VSTICD0^BGPMUUT3(DFN,BGPVST,"BGPMU VTE TEST ICD0") ;this is not in the ORT
 ;I (+BGPRCODE)!(+BGPVCODE)!(+BGPVICD0) S VTE=$S(BGPRCODE'="":BGPRCODE,BGPVICD0'="":BGPVICD0,1:BGPVCODE) S $P(VTE,U,3)=BGPDD Q VTE
 I (+BGPRCODE)!(+BGPVCODE) S VTE=$S(BGPRCODE'="":BGPRCODE,1:BGPVCODE) S $P(VTE,U,3)=BGPDD Q VTE
 ;Finally check for a BMCA code for antithrombotics
 S MEDDTE=ADMIT
 F  S MEDDTE=$O(^PSB(53.79,"AADT",DFN,MEDDTE)) Q:'+MEDDTE!(MEDDTE>PROC)!(+VTE)  D
 .S MEDIEN="" F  S MEDIEN=$O(^PSB(53.79,"AADT",DFN,MEDDTE,MEDIEN)) Q:'+MEDIEN!(+VTE)  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!(+VTE)  D
 ....S DRUG=$G(^PSB(53.79,MEDIEN,.5,DISPENSE,0))
 ....S DRUG=$P(DRUG,U,1)
 ....S TAX="BGPMU VTE PROPHYLAXIS"
 ....S VTE=$$NDC^BGPMUUT4(DRUG,TAX)
 ....S $P(VTE,U,3)=BGPDD
 Q VTE
TEST ;ZSAT
 ;S BGPBDATE=3110101
 ;S BGPEDATE=3110601
 ;S BGPBEN=3
 ;S DUZ("AG")="I"
 ;S U="^"
 ;D ENTRY
 Q