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

BGPMUH10.m

Go to the documentation of this file.
BGPMUH10 ;IHS/MSC/MGH - MI measure NQF0371-VTE-1 ;02-Mar-2011 16:06;MGH
 ;;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
 ;
ENTRY ;PEP  Vte measure 1 NQF0371- VTE started in 24hrs of arrival
 ; Print routine    - VTE1^BGPMUHP6
 ; Delimited output - VTE1^BGPMUHD5
 N START,END,BGPIEN,DFN,BGPVST,BGPISDX,BGPHSDX,BGPAGEE,BGPIPROB,BGPHPROB,SECOND,EXC,NUM,BGPDIS
 N BGPER,BGPADMIT,BGPDD
 ;Start by finding all admissions during the reporting period
 S START=BGPBDATE,NUM=0
 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))
 ..;Get the end of the second day
 ..S SECOND=$$FMADD^XLFDT(BGPADMIT,2),SECOND=SECOND_".2359"
 ..S EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST,BGPDIS)
 ..;If no exclusions see if they had VTE prophylaxis
 ..I EXC="" S NUM=$$NUMER(DFN,BGPADMIT,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("BGPMU0371",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0371",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0371",$J,BGPMUTF,"NUM"))
 S EXCCT=+$G(^TMP("BGPMU0371",$J,BGPMUTF,"EXC"))
 S NOTCT=+$G(^TMP("BGPMU0371",$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("BGPMU0371",$J,BGPMUTF,"DEN")=DENCT
 I EXC'="" D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0371",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0371",$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("BGPMU0371",$J,BGPMUTF,"NUM")=NUMCT
 ..S ^TMP("BGPMU0371",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
 .I +NUM=0 D
 ..S ^TMP("BGPMU0371",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
 ..S NOTCT=NOTCT+1 S ^TMP("BGPMU0371",$J,BGPMUTF,"NOT")=NOTCT
 S ^TMP("BGPMU0371",$J,BGPMUTF,"TOT")=PTCNT
 S BGPICARE("MU.VTE.0371.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,BGPALL,BGPREF,BGWARD,BGPISDX,BGPHSDX,BGPVTE,BGPTS
 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 ICU AND Refusal of VTE Prophylaxis AND Reason for no VTE Prophylaxis
 ;  ICU
 S BGWARD=$$ICUADM(DFN,BGPIEN,BGPADMIT,BGPDIS)
 ;  refusal of VTE med
 S ICUADMIT=$P($P(BGWARD,U,2),".",1)
 S FIRST=$$FMADD^XLFDT(ICUADMIT,+1)
 S MED=$$MEDREF^BGPMUUT2(DFN,ICUADMIT,FIRST_".2359","BGPMU VTE PROPHYLAXIS")
 ; OR refusal of device application
 ;   CPT code check
 S CPT=$$REFTAX^BGPMUUT2(DFN,81,"BGPMU VTE DEVICES CPT",ICUADMIT,FIRST_".2359")
 ;   ICD0 code check
 S ICD0=$$REFTAX^BGPMUUT2(DFN,80.1,"BGPMU VTE DEVICES ICD0",BGPADMIT,FIRST_".2359")
 ;  Reason for no VTE prophylaxis
 S MECH=$$VSTPOVB^BGPMUUT3(DFN,BGPVST,"BGPMU VTE EXCLUDE-MECH DX")
 I 'MECH S MECH=$$PLTAX^BGPMUUT1(DFN,"BGPMU VTE EXCLUDE-MECH DX")
 I (+BGWARD)&(+MED!+CPT!+ICD0)&(+MECH) S REASON="1^ICU/"_$S(+MED:"MED:"_MED,+CPT:"CPT:"_CPT,+ICD0:"ICD:"_ICD0,1:"")_"/"_MECH Q REASON
 ;
 ;Check for OB or behavioral health admissions
 ;S BGPTS=$$TS(DFN,BGPIEN,BGPDIS)
 S BGPTS=$$TS(DFN,BGPVST,BGPIEN)
 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 stroke
 S BGPISDX=$$VSTPOVA^BGPMUUT3(DFN,BGPVST,"BGPMU ISCHEMIC STROKE DX")
 I +BGPISDX S REASON=BGPISDX Q REASON
 S BGPHSDX=$$VSTPOVA^BGPMUUT3(DFN,BGPVST,"BGPMU HEMORRHAGIC STROKE DX")
 I +BGPHSDX S REASON=BGPHSDX Q REASON
 ;Check for a diagnosis of VTE
 S BGPVTE=$$VSTPOVA^BGPMUUT3(DFN,BGPVST,"BGPMU VTE DX")
 I +BGPVTE S REASON=BGPVTE Q REASON
 Q REASON
NUMER(DFN,ADMIT,VST) ;Check to see if pt is in the numerator
 N TAX,MEDDTE,ENDDT,VTE,MEDIEN,STATUS,DRUG,DISPENSE,CPT,MED
 N TEDS,FIRST,GIVEN,NOTGIV,PROP,PHARM,PHARMP,MECH,MECHP,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 diagnosis for whom VTE is not appropriate
 S PHARM=$$VSTPOVB^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(PHARM,U,2)_U_BGPDD Q VTE
 S MECH=$$VSTPOVB^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=MECHP_U_BGPDD Q VTE
 ;Check for refusal of VTE med
 S MED=$$MEDREF^BGPMUUT2(DFN,$P(ADMIT,"."),FIRST,"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
 S FIRST=$P(FIRST,".",1)_".2359"
 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
 Q VTE
TS(DFN,BGPVST,BGPIEN) ;Check the treating specialty
 N IEN,TYPE,INV,TSIEN,TSDATA,TS,TN,OBDX,TSFLD
 S IEN=BGPIEN,INV="",TS=0
 S OBDX=$$VSTPOV^BGPMUUT3(DFN,BGPVST,"BGPMU VTE OB DXS")
 I +OBDX S TS=OBDX Q TS
 S INV="" F  S INV=$O(^DGPM("ATS",DFN,IEN,INV)) Q:INV=""!(+TS)  D
 .S TSIEN="" F  S TSIEN=$O(^DGPM("ATS",DFN,IEN,INV,TSIEN)) Q:TSIEN=""!(+TS)  D
 ..S TSDATA=$G(^DIC(45.7,TSIEN,0))
 ..Q:TSDATA=""
 ..S TN=$$GET1^DIQ(45.7,TSIEN,.01)
 ..S TS=$S(TN["MENTAL HEALTH":1,TN["ALCOHOLISM":1,TN["BEHAVIORAL HEALTH":1,TN["SUBSTANCE ABUSE":1,1:0)
 Q TS
ICUADM(DFN,IEN,ADMIT,DISC) ;Check for ward location
 ; ICU admission check for day of or day after 
 N WARDM,TIME,TRF,TYPE,FIRST,TDATE,WARD
 S WARDM=0
 S WARD=$$GET1^DIQ(405,IEN,.06)
 I WARD["ICU" S WARDM="1^"_ADMIT G ICULOS
 ;Check for transfer movements
 S TRF=IEN F  S TRF=$O(^DGPM("C",DFN,TRF)) Q:TRF=""!(+WARD)  D
 .S TYPE=$P($G(^DGPM(TRF,0)),U,2)
 .I TYPE=2 D    ;This was a transfer movement
 ..S WARD=$$GET1^DIQ(405,TRF,.06)
 ..I WARD["ICU" D
 ...S FIRST=$$FMADD^XLFDT(ADMIT,+1),TDATE=$P($G(^DGPM(TRF,0)),U,1)
 ...I $P(TDATE,".",1)=$P(ADMIT,".",1)!($P(TDATE,".",1)=$P(FIRST,".",1)) S WARDM="1^"_$P(TDATE,".",1)
 Q:'WARDM 0
ICULOS ;NOW CHECK LOS
 N ICULOS,TRF,TYPE,FIRST,TDATE,CNT,ARRAY,WARD,TIME
 S ICULOS=0,CNT=0
 S WARD=$$GET1^DIQ(405,IEN,.06)
 S CNT=CNT+1
 S ARRAY(CNT)=WARD_U_ADMIT          ;Keep track of all admits to ICU
 ;Get all transfer movements
 S TRF=IEN F  S TRF=$O(^DGPM("C",DFN,TRF)) Q:TRF=""  D
 .S TYPE=$P($G(^DGPM(TRF,0)),U,2)
 .I TYPE=2 D    ;This was a transfer movement
 ..S WARD=$$GET1^DIQ(405,TRF,.06)
 ..S CNT=CNT+1
 ..S TDATE=$P($G(^DGPM(TRF,0)),U,1)
 ..S ARRAY(CNT)=WARD_U_TDATE
 ;Now loop through all the admits and transfers looking for an ICU
 N I,X1,X2,J
 S I=0 F  S I=$O(ARRAY(I)) Q:'+I  D
 .I $P(ARRAY(I),U,1)["ICU" D
 .I I+1>CNT S X1=DISC
 .E  S J=I+1,X1=$P(ARRAY(J),U,2)
 .S X2=$P(ARRAY(I),U,2)
 .S TIME=$$FMDIFF^XLFDT(X1,X2,1)
 .S ICULOS=TIME
 Q $S(+ICULOS:WARDM,1:0)  ; 0=false; "1"=true;  <Admit or transfer to ICU day of or day after admission> AND <ICU LOS is greater or equal to 1 day>