BGPMUH14 ; IHS/MSC/MMT - MU measure NQF0375-VTE-5 ;02-Mar-2011 16:24;DU
;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
;meaningful use hospital measure VTE-5 - Pt Education for Warfarin
ENTRY ;PEP VTE-5 - Pt Education for Warfarin
N START,END,BGPIEN,DFN,BGPVST,BGPVDX,BGPVPROB,BGPAGEE,BGPBIRTH,VTE,EXC,NUM,BGPDIS
N DTYPE1,DTYPE2,WARFIP,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=""
..S DTYPE2=+$P($G(^DGPM(BGPDIS,"IHS")),U,7)
..I DTYPE2'="",DTYPE2'=1,DTYPE2'=6,DTYPE2'=50 Q
..;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,EXC=0,NUM=0
..S BGPVDX=$$VSTPOVB^BGPMUUT3(DFN,BGPVST,"BGPMU VTE DX")
..;S BGPVDX=$$LASTDX^BGPMUUT2(DFN,BGPBIRTH,BGPEDATE,"BGPMU VTE DX")
..I +BGPVDX S VTE=1
..Q:'VTE
..;Check for Warfarin administered as an IP during admission
..S WARFIP=$$FIND^BGPMUUT4(DFN,"BGPMU WARFARIN NDCS",$P($G(^DGPM(BGPIEN,0)),U,1),"UD",$P($G(^DGPM(BGPDIS,0)),U,1))
..Q:'WARFIP
..;Next check for exclusions
..S EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST)
..;If no exclusions see if they were given the proper Pt Education
..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,NOTCT
S TOTALS=$G(^TMP("BGPMU0375",$J,BGPMUTF,"TOT"))
S DENCT=+$G(^TMP("BGPMU0375",$J,BGPMUTF,"DEN"))
S NUMCT=+$G(^TMP("BGPMU0375",$J,BGPMUTF,"NUM"))
S EXCCT=+$G(^TMP("BGPMU0375",$J,BGPMUTF,"EXC"))
S NOTCT=+$G(^TMP("BGPMU0375",$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("BGPMU0375",$J,BGPMUTF,"DEN")=DENCT
I EXC'="" D
.S EXCCT=EXCCT+1 S ^TMP("BGPMU0375",$J,BGPMUTF,"EXC")=EXCCT
.I BGPMUTF="C" S ^TMP("BGPMU0375",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_$P(EXC,U,2)
I EXC="" D
.I +NUM=1 D
..S NUMCT=NUMCT+1 S ^TMP("BGPMU0375",$J,BGPMUTF,"NUM")=NUMCT
..S ^TMP("BGPMU0375",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)_U_$P(BGPVDX,U,2)_";"_$P(WARFIP,U,2)
.I +NUM=0 D
..S NOTCT=NOTCT+1 S ^TMP("BGPMU0375",$J,BGPMUTF,"NOT")=NOTCT
..S ^TMP("BGPMU0375",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DATE_U_$P(NUM,U,3)_U_$P(NUM,U,2)_U_$P(BGPVDX,U,2)_";"_$P(WARFIP,U,2)
S ^TMP("BGPMU0375",$J,BGPMUTF,"TOT")=PTCNT
S BGPICARE("MU.VTE.0375.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) ;See if there are exclusions
N REASON,BGPLOS,BGPCLIN,EDATE,DISCHKDT,WARFDIS,VTEICD,VTECPT,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 clinical trials
S BGPCLIN=$$TRIAL^BGPMUH08(DFN,BGPVST)
I +BGPCLIN S REASON=BGPCLIN Q REASON
;Check for no Warfarin as a discharge Med
S EDATE=$P($G(^DGPM(BGPDIS,0)),U,1)
S DISCHKDT=$$FMADD^XLFDT(EDATE,1),$P(DISCHKDT,".",2)="0001"
S WARFDIS=$$FIND^BGPMUUT4(DFN,"BGPMU WARFARIN NDCS",DISCHKDT,"OP")
I 'WARFDIS S REASON="No Warf Rx" 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 CPT Chk" Q REASON
I 'VTECPT&('VTERCODE) S REASON="1^No VTE CPT Chk" Q REASON
Q REASON
NUMER(DFN,BGPVST,BGPIEN,BGPDIS) ;Check to see if pt is in the numerator
N EDU,ETOPIC,D,Y,LIT,LIT2,%,EIEN,ICD,BGPMU,TNAME,MEDTOP,NUTRTOP,TOPLAST
;Compliance Issues: Patient education code of M-[any code] or any code with -M
;-AND-
;Dietary Advice: any patient education code with -N or -MNT
;
S (%,ETOPIC)=0
S (MEDTOP,NUTRTOP)=""
;Find all the patient ed topics from admission to discharge
;Loop through the array and look for M-, -M, -N or -MNT
S EIEN="" F S EIEN=$O(^AUPNVPED("AD",BGPVST,EIEN)) Q:EIEN=""!(%'=0) D
.S ETOPIC=$P($G(^AUPNVPED(EIEN,0)),U,1)
.Q:'ETOPIC
.Q:'$D(^AUTTEDT(ETOPIC,0))
.;Quit if you find the specific stroke eduction topic
.S TNAME=$P($G(^AUTTEDT(ETOPIC,0)),U,1)
.S TOPLAST=$L(TNAME,"-")
.I MEDTOP=""&(($P(TNAME,"-",1)="M")!($P(TNAME,"-",TOPLAST)="M")!($E($P(TNAME,"-",TOPLAST),1,10)="MEDICATION")) S MEDTOP=1_U_TNAME
.I NUTRTOP=""&(($P(TNAME,"-",TOPLAST)="MNT")!($P(TNAME,"-",TOPLAST)="MEDICAL NUTRITION THERAPY")) S NUTRTOP=1_U_TNAME
.I NUTRTOP=""&(($P(TNAME,"-",TOPLAST)="N")!($P(TNAME,"-",TOPLAST)="NUTRITION")) S NUTRTOP=1_U_TNAME
I +MEDTOP,+NUTRTOP S %=1_U_$P(MEDTOP,U,2)_";"_$P(NUTRTOP,U,2)_U_$P($G(^DGPM(BGPDIS,0)),U,1)
Q %
BGPMUH14 ; IHS/MSC/MMT - MU measure NQF0375-VTE-5 ;02-Mar-2011 16:24;DU
+1 ;;11.0;IHS CLINICAL REPORTING;**4**;JAN 06, 2011;Build 84
+2 ;meaningful use hospital measure VTE-5 - Pt Education for Warfarin
ENTRY ;PEP VTE-5 - Pt Education for Warfarin
+1 NEW START,END,BGPIEN,DFN,BGPVST,BGPVDX,BGPVPROB,BGPAGEE,BGPBIRTH,VTE,EXC,NUM,BGPDIS
+2 NEW DTYPE1,DTYPE2,WARFIP,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 SET DTYPE2=+$PIECE($GET(^DGPM(BGPDIS,"IHS")),U,7)
+20 IF DTYPE2'=""
IF DTYPE2'=1
IF DTYPE2'=6
IF DTYPE2'=50
QUIT
+21 ;Get the admit time & discharge times
+22 SET BGPADMIT=$PIECE($GET(^DGPM(BGPIEN,0)),U,1)
+23 SET BGPDD=$PIECE($GET(^DGPM(BGPDIS,0)),U,1)
+24 ;Check for a diagnosis of VTE
+25 SET VTE=0
SET EXC=0
SET NUM=0
+26 SET BGPVDX=$$VSTPOVB^BGPMUUT3(DFN,BGPVST,"BGPMU VTE DX")
+27 ;S BGPVDX=$$LASTDX^BGPMUUT2(DFN,BGPBIRTH,BGPEDATE,"BGPMU VTE DX")
+28 IF +BGPVDX
SET VTE=1
+29 IF 'VTE
QUIT
+30 ;Check for Warfarin administered as an IP during admission
+31 SET WARFIP=$$FIND^BGPMUUT4(DFN,"BGPMU WARFARIN NDCS",$PIECE($GET(^DGPM(BGPIEN,0)),U,1),"UD",$PIECE($GET(^DGPM(BGPDIS,0)),U,1))
+32 IF 'WARFIP
QUIT
+33 ;Next check for exclusions
+34 SET EXC=$$EXCLUDE(DFN,BGPIEN,BGPVST)
+35 ;If no exclusions see if they were given the proper Pt Education
+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,NOTCT
+2 SET TOTALS=$GET(^TMP("BGPMU0375",$JOB,BGPMUTF,"TOT"))
+3 SET DENCT=+$GET(^TMP("BGPMU0375",$JOB,BGPMUTF,"DEN"))
+4 SET NUMCT=+$GET(^TMP("BGPMU0375",$JOB,BGPMUTF,"NUM"))
+5 SET EXCCT=+$GET(^TMP("BGPMU0375",$JOB,BGPMUTF,"EXC"))
+6 SET NOTCT=+$GET(^TMP("BGPMU0375",$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 SET DENCT=DENCT+1
SET ^TMP("BGPMU0375",$JOB,BGPMUTF,"DEN")=DENCT
+11 IF EXC'=""
Begin DoDot:1
+12 SET EXCCT=EXCCT+1
SET ^TMP("BGPMU0375",$JOB,BGPMUTF,"EXC")=EXCCT
+13 IF BGPMUTF="C"
SET ^TMP("BGPMU0375",$JOB,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_$PIECE(EXC,U,2)
End DoDot:1
+14 IF EXC=""
Begin DoDot:1
+15 IF +NUM=1
Begin DoDot:2
+16 SET NUMCT=NUMCT+1
SET ^TMP("BGPMU0375",$JOB,BGPMUTF,"NUM")=NUMCT
+17 SET ^TMP("BGPMU0375",$JOB,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DATE_U_$PIECE(NUM,U,3)_U_$PIECE(NUM,U,2)_U_$PIECE(BGPVDX,U,2)_";"_$PIECE(WARFIP,U,2)
End DoDot:2
+18 IF +NUM=0
Begin DoDot:2
+19 SET NOTCT=NOTCT+1
SET ^TMP("BGPMU0375",$JOB,BGPMUTF,"NOT")=NOTCT
+20 SET ^TMP("BGPMU0375",$JOB,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DATE_U_$PIECE(NUM,U,3)_U_$PIECE(NUM,U,2)_U_$PIECE(BGPVDX,U,2)_";"_$PIECE(WARFIP,U,2)
End DoDot:2
End DoDot:1
+21 SET ^TMP("BGPMU0375",$JOB,BGPMUTF,"TOT")=PTCNT
+22 SET BGPICARE("MU.VTE.0375.1",BGPMUTF,DFN)=1_U_+$GET(NUM)_U_+EXC_U_DATE_";"_$PIECE($GET(NUM),U,3)_";"_$PIECE(EXC,U,2)
+23 QUIT
EXCLUDE(DFN,BGPIEN,BGPVST) ;See if there are exclusions
+1 NEW REASON,BGPLOS,BGPCLIN,EDATE,DISCHKDT,WARFDIS,VTEICD,VTECPT,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 clinical trials
+8 SET BGPCLIN=$$TRIAL^BGPMUH08(DFN,BGPVST)
+9 IF +BGPCLIN
SET REASON=BGPCLIN
QUIT REASON
+10 ;Check for no Warfarin as a discharge Med
+11 SET EDATE=$PIECE($GET(^DGPM(BGPDIS,0)),U,1)
+12 SET DISCHKDT=$$FMADD^XLFDT(EDATE,1)
SET $PIECE(DISCHKDT,".",2)="0001"
+13 SET WARFDIS=$$FIND^BGPMUUT4(DFN,"BGPMU WARFARIN NDCS",DISCHKDT,"OP")
+14 IF 'WARFDIS
SET REASON="No Warf Rx"
QUIT REASON
+15 ;Check if VTE diagnostic procedure performed - exclude if none performed
+16 ;S VTEICD=$$VSTICD0^BGPMUUT3(DFN,BGPVST,"BGPMU VTE TEST ICD0") ;not in ORT
+17 SET VTERCODE=$$FIND^BGPMUUT7(DFN,"BGPMU VTE TEST CPT",BGPADMIT,BGPDD)
+18 SET VTECPT=$$VSTCPT^BGPMUUT1(DFN,BGPVST,"BGPMU VTE TEST CPT")
+19 ;I 'VTECPT&('VTERCODE)&('VTEICD) S REASON="1^No VTE CPT Chk" Q REASON
+20 IF 'VTECPT&('VTERCODE)
SET REASON="1^No VTE CPT Chk"
QUIT REASON
+21 QUIT REASON
NUMER(DFN,BGPVST,BGPIEN,BGPDIS) ;Check to see if pt is in the numerator
+1 NEW EDU,ETOPIC,D,Y,LIT,LIT2,%,EIEN,ICD,BGPMU,TNAME,MEDTOP,NUTRTOP,TOPLAST
+2 ;Compliance Issues: Patient education code of M-[any code] or any code with -M
+3 ;-AND-
+4 ;Dietary Advice: any patient education code with -N or -MNT
+5 ;
+6 SET (%,ETOPIC)=0
+7 SET (MEDTOP,NUTRTOP)=""
+8 ;Find all the patient ed topics from admission to discharge
+9 ;Loop through the array and look for M-, -M, -N or -MNT
+10 SET EIEN=""
FOR
SET EIEN=$ORDER(^AUPNVPED("AD",BGPVST,EIEN))
IF EIEN=""!(%'=0)
QUIT
Begin DoDot:1
+11 SET ETOPIC=$PIECE($GET(^AUPNVPED(EIEN,0)),U,1)
+12 IF 'ETOPIC
QUIT
+13 IF '$DATA(^AUTTEDT(ETOPIC,0))
QUIT
+14 ;Quit if you find the specific stroke eduction topic
+15 SET TNAME=$PIECE($GET(^AUTTEDT(ETOPIC,0)),U,1)
+16 SET TOPLAST=$LENGTH(TNAME,"-")
+17 IF MEDTOP=""&(($PIECE(TNAME,"-",1)="M")!($PIECE(TNAME,"-",TOPLAST)="M")!($EXTRACT($PIECE(TNAME,"-",TOPLAST),1,10)="MEDICATION"))
SET MEDTOP=1_U_TNAME
+18 IF NUTRTOP=""&(($PIECE(TNAME,"-",TOPLAST)="MNT")!($PIECE(TNAME,"-",TOPLAST)="MEDICAL NUTRITION THERAPY"))
SET NUTRTOP=1_U_TNAME
+19 IF NUTRTOP=""&(($PIECE(TNAME,"-",TOPLAST)="N")!($PIECE(TNAME,"-",TOPLAST)="NUTRITION"))
SET NUTRTOP=1_U_TNAME
End DoDot:1
+20 IF +MEDTOP
IF +NUTRTOP
SET %=1_U_$PIECE(MEDTOP,U,2)_";"_$PIECE(NUTRTOP,U,2)_U_$PIECE($GET(^DGPM(BGPDIS,0)),U,1)
+21 QUIT %