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