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

BGPMUH11.m

Go to the documentation of this file.
BGPMUH11 ;IHS/MSC/MGH - MI measure NQF0372-VTE-2 ;02-Mar-2011 15:59;DU
 ;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
 ;ED meaningful use hospital measures
 ;BGPMUH10 - VTE Measure 1 - VTE started in 24hrs of arrival
 ;BGPMUH11 - VTE Measure 2 - VTE started in 24hrs of arrival to ICU
ENTRY ;PEP  Vte measure 2 - VTE started in 24hrs of arrival to ICU
 ; Print routine    - VTE2^BGPMUHP6
 ; Delimited output - VTE2^BGPMUHD5
 N START,END,BGPIEN,DFN,BGPVST,BGPISDX,BGPHSDX,BGPAGEE,BGPIPROB,BGPHPROB,SECOND,EXC,NUM,BGPDIS
 N BGPER,BGPADTMI,BDPDD,BGWARD,BGPDD,BGPADMIT,BGPDD
 S BGWARD=0
 ;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 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 age at admission
 ..S BGPAGEE=$$AGE^AUPNPAT(DFN,$P(BGPADMIT,".",1))
 ..;Check for ICU
 ..S BGPWARD=$$ICUADM^BGPMUH10(DFN,BGPIEN,BGPADMIT,BGPDIS)
 ..Q:'BGPWARD
 ..S EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST,BGPDIS,.BGWARD)
 ..;If no exclusions see if they had tPA given in correct time frame
 ..I EXC="" S NUM=$$NUMER(DFN,BGPADMIT,BGWARD,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("BGPMU0372",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0372",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0372",$J,BGPMUTF,"NUM"))
 S EXCCT=+$G(^TMP("BGPMU0372",$J,BGPMUTF,"EXC"))
 S NOTCT=+$G(^TMP("BGPMU0372",$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("BGPMU0372",$J,BGPMUTF,"DEN")=DENCT
 I EXC'="" D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0372",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0372",$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("BGPMU0372",$J,BGPMUTF,"NUM")=NUMCT
 ..S ^TMP("BGPMU0372",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
 .I +NUM=0 D
 ..S ^TMP("BGPMU0372",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
 ..S NOTCT=NOTCT+1 S ^TMP("BGPMU0372",$J,BGPMUTF,"NOT")=NOTCT
 S ^TMP("BGPMU0372",$J,BGPMUTF,"TOT")=PTCNT
 S BGPICARE("MU.VTE.0372.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,BGWARD) ;See if there are exclusions
 N REASON,BGPLOS,BGPHOS,BGPCLIN,BGPECI,BGPALL,BGPREF,BGPTS,BGPVTE
 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
 I BGPLOS<2 S REASON="1^LOS" Q REASON
 ;Check for OB
 S BGPTS=$$TS(DFN,BGPIEN,BGPDIS)
 I +BGPTS S REASON=BGPTS Q REASON
 ;Check for palliative Care
 S BGPHOS=$$HOSPICE^BGPMUH06(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 a diagnosis of VTE
 S BGPVTE=$$VSTPOV^BGPMUUT3(DFN,BGPVST,"BGPMU VTE DX")
 I +BGPVTE S REASON=BGPVTE Q REASON
 Q REASON
NUMER(DFN,ADMIT,BGWARD,VST) ;Check to see if pt is in the numerator
 N TAX,MEDDTE,ENDDT,VTE,MEDIEN,STATUS,DRUG,DISPENSE
 N TEDS,FIRST,GIVEN,NOTGIV,PROP,PHARM,PHARMP,MECH,MECHP,CPT,MED,ICD0
 S VTE=0
 ;First, see if the pt has CPT for procedure in first 24hrs
 S FIRST=$$FMADD^XLFDT(ADMIT,+1)
 S TEDS=$$PALCPT^BGPMUUT3(DFN,VST,"BGPMU VTE DEVICES CPT",ADMIT)
 I +TEDS S VTE=TEDS_U_BGPDD Q VTE
 ;See, if the pt has ICD0 for procedures in first 24hrs
 S PROP=$$PALICD0^BGPMUUT3(DFN,VST,"BGP VTE DEVICES ICD0",ADMIT)
 I +PROP S VTE=PROP_U_BGPDD Q VTE
 ;See if the VTE CPT code was entered
 S GIVEN=$$PALCPT^BGPMUUT3(DFN,VST,"BGPMU VTE GIVEN CPT",ADMIT)
 I +GIVEN S VTE=GIVEN_U_BGPDD Q VTE
 ;Check for code that patient is not eligible
 S NOTGIV=$$PALCPT^BGPMUUT3(DFN,VST,"BGPMU VTE NOT GIVEN CPT",ADMIT)
 I +NOTGIV S VTE=$P(NOTGIV,U,1)_U_"NMI "_$P(NOTGIV,U,2)_U_BGPDD Q VTE
 ;Check diagnoses for whom VTE is not appropriate
 S PHARM=$$VSTPOV^BGPMUUT3(DFN,BGPVST,"BGPMU VTE EXCLUDE PHARM DXS")
 I +PHARM S VTE=$P(PHARM,U,1)_U_"NMI "_$P(PHARM,U,2)_U_BGPDD Q VTE
 S PHARMP=$$PLTAX^BGPMUUT1(DFN,"BGPMU VTE EXCLUDE PHARM DXS")
 I +PHARMP S VTE=$P(PHARMP,U,1)_U_"NMI "_$P(PHARMP,U,2)_U_BGPDD Q VTE
 S MECH=$$VSTPOV^BGPMUUT3(DFN,BGPVST,"BGPMU VTE EXCLUDE-MECH DX")
 I +MECH S VTE=$P(MECH,U,1)_U_"NMI "_$P(MECH,U,2)_U_BGPDD Q VTE
 S MECHP=$$PLTAX^BGPMUUT1(DFN,"BGPMU VTE EXCLUDE-MECH DX")
 I +MECHP S VTE=$P(MECHP,U,1)_U_"NMI "_$P(MECHP,U,2)_U_BGPDD Q VTE
 ;Check for refusal of VTE med
 S MED=$$MEDREF^BGPMUUT2(DFN,$P(ADMIT,"."),$P(FIRST,".")_".2359","BGPMU VTE PROPHYLAXIS")
 I +MED S VTE=$P(MED,U,1)_U_"REF "_$P(MED,U,2)_U_BGPDD Q VTE
 ;Check for refusals of procedures
 S CPT=$$REFTAX^BGPMUUT2(DFN,81,"BGPMU VTE DEVICES CPT",$P(ADMIT,"."),$P(FIRST,"."))
 I +CPT S VTE=$P(CPT,U,1)_U_"REF "_$P(CPT,U,2)_U_BGPDD Q VTE
 S ICD0=$$REFTAX^BGPMUUT2(DFN,80.1,"BGPMU VTE DEVICES ICD0",$P(ADMIT,"."),$P(FIRST,"."))
 I +ICD0 S VTE=$P(ICD0,U,1)_U_"REF "_$P(ICD0,U,2)_U_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>FIRST)!(+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)
 ....I +VTE S VTE=$P(VTE,U,1)_U_"MED "_$P(VTE,U,2)_U_BGPDD
 I VTE=0&(BGWARD=1) S EXC="1^ICULOS"
 Q VTE
TS(DFN,BGPIEN,BGPDIS) ;Check the treating specialty
 N IEN,TYPE,OBDX,TS
 S IEN=BGPIEN,TS=0
 S OBDX=$$VSTPOV^BGPMUUT3(DFN,BGPVST,"BGPMU VTE OB DXS")
 I +OBDX S TS=OBDX
 Q TS