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.
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