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

BGPMUH13.m

Go to the documentation of this file.
  1. BGPMUH13 ; IHS/MSC/MGH - MU measure NQF0374-VTE-4 ;02-Mar-2011 16:23;DU
  1. ;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
  1. ;meaningful use hospital measure VTE-4 - Platelet Count Monitoring for Patients given IV UFH
  1. ENTRY ;PEP VTE-4 - Platelet Count Monitoring for Patients given IV UFH
  1. N START,END,BGPIEN,DFN,BGPVST,BGPAGEE,VTE,BGPUFHIP,DEN,EXC,NUM,BGPDIS
  1. N BGPCHOL,BGPLIPID,BGPBIRTH,BGPADMIT,BGPDD
  1. ;Start by finding all admissions during the reporting period
  1. S START=BGPBDATE
  1. S END=BGPEDATE_".2359"
  1. F S START=$O(^DGPM("B",START)) Q:START=""!(START>END) D
  1. .S BGPIEN="" F S BGPIEN=$O(^DGPM("B",START,BGPIEN)) Q:BGPIEN="" D
  1. ..Q:$P($G(^DGPM(BGPIEN,0)),U,2)'=1 ;Only include admissions
  1. ..S DFN=$P($G(^DGPM(BGPIEN,0)),U,3)
  1. ..S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
  1. ..S BGPBIRTH=$$DOB^AUPNPAT(DFN)
  1. ..Q:DFN=""
  1. ..S BGPACTUP=$$ACTUPAP^BGPMUEHD(DFN,BGPBDATE,BGPEDATE,BGPBEN)
  1. ..I 'BGPACTUP,'$G(BGPXPXPX),'$G(BGPIISO) Q
  1. ..S BGPVST=$P($G(^DGPM(BGPIEN,0)),U,27) ;Get the visit
  1. ..Q:BGPVST=""
  1. ..S BGPDIS=$P($G(^DGPM(BGPIEN,0)),U,17) ;Don't use if pt is still an inpt
  1. ..Q:BGPDIS=""
  1. ..;Get the admit time & discharge times
  1. ..S BGPADMIT=$P($G(^DGPM(BGPIEN,0)),U,1)
  1. ..S BGPDD=$P($G(^DGPM(BGPDIS,0)),U,1)
  1. ..;Check for a diagnosis of VTE
  1. ..S VTE=0,UFHRX=0,DEN=0,EXC=0,NUM=0
  1. ..S BGPVDX=$$VSTPOVB^BGPMUUT3(DFN,BGPVST,"BGPMU VTE DX")
  1. ..I +BGPVDX S VTE=1
  1. ..Q:'VTE
  1. ..;Get discharge date
  1. ..S BGPDD=$P($G(^DGPM(BGPDIS,0)),U,1)
  1. ..;Pt must have been administered IV UFH during the visit
  1. ..S BGPUFHIP=$$FIND^BGPMUUT4(DFN,"BGPMU UFH THERAPY NDCS",$P($G(^DGPM(BGPIEN,0)),U,1),"IV",$P($G(^DGPM(BGPDIS,0)),U,1))
  1. ..Q:'BGPUFHIP
  1. ..S DEN=1_U_BGPVST_";"_BGPIEN_";"_$P(BGPVDX,U,2)
  1. ..;Next check for exclusions
  1. ..S EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST,BGPDIS)
  1. ..;If no exclusions see if they have Platelet monitoring around IV UFH admin
  1. ..I EXC="" S NUM=$$NUMER(DFN,BGPVST,BGPIEN,BGPDIS)
  1. ..;Now add it all up
  1. ..D TOTAL(BGPIEN)
  1. Q
  1. TOTAL(BGPIEN) ;add up the totals
  1. N PTCNT,EXCCT,DENCT,NUMCT,TOTALS,DATE,PTDATA,NOTCT
  1. S TOTALS=$G(^TMP("BGPMU0374",$J,BGPMUTF,"TOT"))
  1. S DENCT=+$G(^TMP("BGPMU0374",$J,BGPMUTF,"DEN"))
  1. S NUMCT=+$G(^TMP("BGPMU0374",$J,BGPMUTF,"NUM"))
  1. S EXCCT=+$G(^TMP("BGPMU0374",$J,BGPMUTF,"EXC"))
  1. S NOTCT=+$G(^TMP("BGPMU0374",$J,BGPMUTF,"NOT"))
  1. S PTCNT=TOTALS
  1. S PTCNT=PTCNT+1
  1. S DATE=$$DATE^BGPMUUTL($P($G(^DGPM(BGPIEN,0)),U,1))
  1. ; DATA STRING FOR OUTPUT
  1. ; DFN ^ VISIT DATE ^ EXCLUSION REASON ^ DENOMINATOR CRITERIA ^ NUMERATOR CRITERIA
  1. ; EXCLUSION = EXCLUSION REASON
  1. ; DENOMINATOR = VISIT IEN ; MOVEMENT IEN ; VTE DX DATA
  1. ; NUMERATOR = IV UFH DATE ; PLATELET TEST 1 DATE ; PLATELET 2 DATE ; PLATELET 3 DATE
  1. S PTDATA=DFN_U_DATE_U_$P(EXC,U,2)_U_$P(DEN,U,2)_U_$P(NUM,U,2)
  1. S DENCT=DENCT+1 S ^TMP("BGPMU0374",$J,BGPMUTF,"DEN")=DENCT
  1. I EXC'="" D
  1. .S EXCCT=EXCCT+1 S ^TMP("BGPMU0374",$J,BGPMUTF,"EXC")=EXCCT
  1. .I BGPMUTF="C" S ^TMP("BGPMU0374",$J,"PAT",BGPMUTF,"EXC",PTCNT)=PTDATA
  1. I EXC="" D
  1. .I +NUM=1 D
  1. ..S NUMCT=NUMCT+1 S ^TMP("BGPMU0374",$J,BGPMUTF,"NUM")=NUMCT
  1. ..S ^TMP("BGPMU0374",$J,"PAT",BGPMUTF,"NUM",PTCNT)=PTDATA_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
  1. .I +NUM=0 D
  1. ..S NOTCT=NOTCT+1 S ^TMP("BGPMU0374",$J,BGPMUTF,"NOT")=NOTCT
  1. ..S ^TMP("BGPMU0374",$J,"PAT",BGPMUTF,"NOT",PTCNT)=PTDATA_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)
  1. S ^TMP("BGPMU0374",$J,BGPMUTF,"TOT")=PTCNT
  1. S BGPICARE("MU.VTE.0374.1",BGPMUTF,DFN)=1_U_+$G(NUM)_U_+EXC_U_DATE_";"_$P($G(NUM),U,3)_";"_$P(EXC,U,2)
  1. Q
  1. EXCLUDE(DFN,BGPIEN,BGPVST,BGPDIS) ;See if there are exclusions
  1. N REASON,BGPLOS,BGPHOS,BGPCLIN,BGPUFHIP,BGPATH,DTYPE1,DTYPE2,VTECPT,VTEICD,VTERCODE
  1. S REASON=""
  1. I BGPAGEE<18 S REASON="1^AGE" Q REASON
  1. ;Check for LOS
  1. S BGPLOS=$$LOS^BGPMUH08(BGPIEN,BGPDIS)
  1. I BGPLOS>120 S REASON="1^LOS" Q REASON
  1. ;Check for hospice care
  1. S BGPHOS=$$HOSPICE^BGPMUH08(DFN,BGPVST)
  1. I +BGPHOS S REASON=BGPHOS Q REASON
  1. ;Check for clinical trials
  1. S BGPCLIN=$$TRIAL^BGPMUH08(DFN,BGPVST)
  1. I +BGPCLIN S REASON=BGPCLIN Q REASON
  1. ;Check if IV UFH wasn't performed - this definitely doesn't make sense now that Den inclusion logic checks this SAME thing
  1. S BGPUFHIP=$$FIND^BGPMUUT4(DFN,"BGPMU UFH THERAPY NDCS",$P($G(^DGPM(BGPIEN,0)),U,1),"IV",$P($G(^DGPM(BGPDIS,0)),U,1))
  1. I 'BGPUFHIP S REASON="1^No IV UFH" Q REASON
  1. ;Check if VTE diagnostic procedure performed - exclude if none performed
  1. ;S VTEICD=$$VSTICD0^BGPMUUT3(DFN,BGPVST,"BGPMU VTE TEST ICD0") ;not in ORT
  1. S VTERCODE=$$FIND^BGPMUUT7(DFN,"BGPMU VTE TEST CPT",BGPADMIT,BGPDD)
  1. S VTECPT=$$VSTCPT^BGPMUUT1(DFN,BGPVST,"BGPMU VTE TEST CPT")
  1. ;I 'VTECPT&('VTERCODE)&('VTEICD) S REASON="1^No VTE Test" Q REASON
  1. I 'VTECPT&('VTERCODE) S REASON="1^No VTE Test" Q REASON
  1. Q REASON
  1. NUMER(DFN,BGPVST,BGPIEN,BGPDIS) ;Check to see if pt is in the numerator
  1. N %,UFHIP,PLATES,DAYB4,DAYAFTER,DAY3,DONE,PLATE1,PLATE2,PLATE3,VSTDT,DISDT,ADMINDT
  1. S (%,UFHIP,PLATE1,PLATE2,PLATE3)=0
  1. S VSTDT=$P($G(^DGPM(BGPIEN,0)),U,1)
  1. S DISDT=$P($G(^DGPM(BGPDIS,0)),U,1)
  1. ;Check if IV UFH was performed
  1. S UFHIP=$$FIND^BGPMUUT4(DFN,"BGPMU UFH THERAPY NDCS",$P($G(^DGPM(BGPIEN,0)),U,1),"IV",$P($G(^DGPM(BGPDIS,0)),U,1))
  1. ;shouldn't get here if no IV UFH since it's an exclusion criteria, but quit here if none for uniformity
  1. Q:'UFHIP %
  1. S ADMINDT=$P(UFHIP,U,3) ;;
  1. I +ADMINDT D
  1. .D LAB^BGPMUUT5(.PLATES,DFN,"BGPMU LAB LOINC PLATELETS",VSTDT,DISDT)
  1. .S DAYB4=$P(9999999-$$FMADD^XLFDT(ADMINDT,-1),".",1),DAYAFTER=$P(9999999-$$FMADD^XLFDT(ADMINDT,1),".",1),DAY3=$P(9999999-$$FMADD^XLFDT(ADMINDT,3),".",1)
  1. .;S PLATE1=$O(PLATES(DAYB4))
  1. .S I="" F S I=$O(PLATES(I)) Q:I="" D
  1. ..I $P(I,".",1)=DAYB4 S PLATE1=PLATES(I)
  1. ..I $P(I,".",1)=DAYAFTER S PLATE2=PLATES(I)
  1. ..I $P(I,".",1)=DAY3 S PLATE3=PLATES(I)
  1. .;I +PLATE1 S PLATE2=$O(PLATES(DAY3)) I PLATE2>DAYAFTER S PLATE2=""
  1. .;I +PLATE2 S PLATE3=$O(PLATES("")) I PLATE3>DAY3 S PLATE3=""
  1. I +UFHIP,+PLATE1,+PLATE2,+PLATE3 S %=1
  1. Q %_U_$P(UFHIP,U,2)_";"_PLATE1_";"_PLATE2_";"_PLATE3_U_BGPDD