BGPMUD10 ; IHS/MSC/SAT - MI measure NQF0385 ;08-Sep-2011 14:56
;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
;
; BGPMUD01 = tobacco use assessment 0028a
; BGPMUD02 = tobacco use cessation 0028b
; BGPMUD03 = Heart Failure w/ACE Inhibitor or ARB 0081
; BGPMUD04 = Prenatal HIV Screening 0012
; BGPMUD05 = Prenatal Anti-D Immune Globulin 0014
; BGPMUD06 = Control High Blood Pressure 0018
; BGPMUD07 = SMOKING CESSATION MEDICAL ASSIST 0027
; BGPMUD08 = Chlamydia Measure 0033
; BGPMUD09 = Antidepressant Medication Management 0105
; BGPMUD10 = Oncology Colon Cancer Stage III 0385
;
;Code to collect meaningful use report for Oncology Colon Cancer Stage III 0385
ENTRY ;EP
N START,END,BGPNUM,STRING,STRING2
N IEN,INV,RFOUND,VISIT,DATA,VDATE,VALUE,EXCEPT,FIRST,VIEN
N CNT,DIAB,NUM,DIAB,DIABDX,OUTENC,OPHENC,NONENC,VENC,INENC,ERENC
N BGPEN,BGPEND,BGPEXC,BGPH
N BGPDEN,BGPNOT,BGPNUM
N DEPV1,DEPVA
S (BGPDEN,BGPEN,BGPEXC,BGPNUM,BGPNOT)=""
S BGPEND=0
;Pts must be >=18 at the end of the reporting period
S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
;No need to check further if no age match
Q:BGPAGEE<18
;
;look for 2 encounters with EP
S START=9999999-BGPBDATE,END=9999999-BGPEDATE,VALUE=0
S START=START_".2359"
S FIRST=END-0.1 F S FIRST=$O(^AUPNVSIT("AA",DFN,FIRST)) Q:FIRST=""!($P(FIRST,".",1)>START) D
.S VIEN=0 F S VIEN=$O(^AUPNVSIT("AA",DFN,FIRST,VIEN)) Q:'+VIEN D
..S BGPDT=$P($P($G(^AUPNVSIT(VIEN,0)),U,1),".",1)
..;Check provider, determine if there are visits with E&M codes
..I $$PRV^BGPMUUT1(VIEN,BGPPROV) D
...I $$EM1(DFN,VIEN,0) D
....S:$L(BGPEN,";")'>1 BGPEN=$S(BGPEN'="":BGPEN_";",1:"")_"EN:"_$$DATE^BGPMUUTL($P(BGPDT,".",1))
....S BGPEND=$S(BGPDT>BGPEND:BGPDT,1:BGPEND)
;
Q:$L(BGPEN,";")'>1
S X=0
S X=$$LASTDX^BGPMUUT2(DFN,0,BGPEND,"BGPMU ONC COLON CANCER DX")
S:'+X X=$$PLTAX^BGPMUD09(DFN,"BGPMU ONC COLON CANCER DX","C",0,BGPEND)
S:'+X X=$$LASTDX^BGPMUUT2(DFN,0,BGPEND,"BGPMU ONC COLON CANCER HIST DX")
S:'+X X=$$PLTAX^BGPMUD09(DFN,"BGPMU ONC COLON CANCER HIST DX","I",0,BGPEND)
Q:'+X
S BGPDEN="CCDX:"_$$DATE^BGPMUUTL($P(X,U,3))
S X=0
S X=$$CPT^BGPMUUT1(DFN,0,BGPEND,"BGPMU STAGE III COLON CAN CPT")
Q:'+X
S BGPDEN=BGPDEN_";"_"CCST:"_$$DATE^BGPMUUTL($P(X,U,3))_";"_BGPEN ;patient is in the denominator
;
;check PRESCRIPTION for colon cancer chemotherapy meds
S X=$$FIND^BGPMUUT4(DFN,"BGPMU COLON CANCER CHEMO NDCS",BGPBDATE,"",BGPEDATE)
I +X S BGPNUM="M:MED "_$$DATE^BGPMUUTL($P(X,U,3)) ;patient is in the numerator
I '+X S BGPNOT="NM:"
;
;check exclusions
S X=0
I '+X S BGPEXC=$$EXCLUDE(DFN)
I BGPEXC'="" S BGPNOT=""
;
D TOTAL(DFN)
Q
;
TOTAL(DFN) ;See where this patient ends up
N PTCNT,EXCCT,DENCT,NUMCT1,NUMCT2,NOTNUM1,NOTNUM2,TOTALS
S TOTALS=$G(^TMP("BGPMU0385",$J,BGPMUTF,"TOT"))
S DENCT=+$G(^TMP("BGPMU0385",$J,BGPMUTF,"DEN",1))
S NUMCT1=+$G(^TMP("BGPMU0385",$J,BGPMUTF,"NUM",1))
S NOTNUM1=+$G(^TMP("BGPMU0385",$J,BGPMUTF,"NOT",1))
S EXCCT=+$G(^TMP("BGPMU0385",$J,BGPMUTF,"EXC",1))
S PTCNT=TOTALS
S PTCNT=PTCNT+1
S DENCT=DENCT+1 S ^TMP("BGPMU0385",$J,BGPMUTF,"DEN",1)=DENCT
;
I BGPNOT'="" D
.S NOTNUM1=NOTNUM1+1 S ^TMP("BGPMU0385",$J,BGPMUTF,"NOT",1)=NOTNUM1
.I BGPMUTF="C" S ^TMP("BGPMU0385",$J,"PAT",BGPMUTF,"NOT",1,PTCNT)=DFN_U_BGPDEN_U_BGPNOT
;
I BGPNUM'="" D
.S NUMCT1=NUMCT1+1 S ^TMP("BGPMU0385",$J,BGPMUTF,"NUM",1)=NUMCT1
.I BGPMUTF="C" S ^TMP("BGPMU0385",$J,"PAT",BGPMUTF,"NUM",1,PTCNT)=DFN_U_BGPDEN_U_BGPNUM
;
I BGPEXC'="" D
.S EXCCT=EXCCT+1 S ^TMP("BGPMU0385",$J,BGPMUTF,"EXC",1)=EXCCT
.I BGPMUTF="C" S ^TMP("BGPMU0385",$J,"PAT",BGPMUTF,"EXC",1,PTCNT)=DFN_U_BGPDEN_U_BGPEXC
S ^TMP("BGPMU0385",$J,BGPMUTF,"TOT")=PTCNT
;Setup iCare array for patient
; BGPICARE(INDICATOR_ID,Timeframe)=Denom Flag
; ^ Num Flag ^ Excl Flag ^ Denom disp ; Num disp ^ Excl disp
S BGPICARE("MU.EP.0385.1",BGPMUTF)=1_U_(BGPNUM'="")_U_(BGPEXC'="")_U_BGPDEN_";"_$S(BGPNUM'="":BGPNUM,1:"")_U_$S(BGPEXC="":BGPEXC,1:"")
Q
;
EM1(DFN,VIEN,FLG) ;check visit for at least 1 E&M code indicating outpatient
N BGPI,BGPTMP
S BGP2=0
S X=+$$VSTCPT^BGPMUUT1(DFN,VIEN,"BGPMU ENC OFFICE VISIT")
S:+X BGP2=1
Q BGP2
;
EXCLUDE(DFN) ;check PATIENT ALLERGIES for allergy to IUD
N BGPALL,BGPH
S BGPALL=""
S X=0
S BGPH="" F S BGPH=$O(^GMR(120.8,"B",DFN,BGPH)) Q:BGPH="" D Q:X=1
.S BGPALL=$P(^GMR(120.8,BGPH,0),U,2)
.I (BGPALL="AMINOGLUTETHIMIDE")!(BGPALL="ANASTROZOLE")!(BGPALL="CAPECITABINE")!(BGPALL="EXEMESTANE")!(BGPALL="FLUOROURACIL")!(BGPALL="LEUCOVORIN") D
..S X=1
Q:+X "Excluded"
;checks of VPOV and PROBLEM for Matastatic sites, Acute renal insufficiency, Neutropenia, Leukopenia
S X=0
S X=$$LASTDX^BGPMUUT2(DFN,0,BGPEND,"BGPMU 0385 EXCLUSIONS DX")
Q:+X "Excluded"
S:'+X X=$$PLTAX^BGPMUD09(DFN,"BGPMU 0385 EXCLUSIONS DX","C",0,BGPEND)
Q:+X "Excluded"
;check Health Factors
S X=0
S X=$$HF^BGPMUD07(DFN,"BGPMU ECOG POOR")
Q:+X "Excluded"
;check refusals
S X=0
S X=$$MEDREF^BGPMUUT2(DFN,0,BGPEN_".2359","BGPMU COLON CANCER CHEMO NDCS")
Q:+X "Excluded"
Q ""
;
TEST ; debug target
S U="^"
S DT=$$DT^XLFDT()
S DFN=65 ; DFN = patient code from VA PATIENT file
S BGPBDATE=3100101 ; BGPBDATE = begin date of report
S BGPEDATE=3101231 ; BGPEDATE = end date of report
S BGPPROV=2 ; BGPPROV = provider code from NEW PERSON file
S BGPMUTF="C" ; BGPMUTF = timeframe variable - "C"=current year; "P"=previous year; "B"=baseline year
D ENTRY
Q
BGPMUD10 ; IHS/MSC/SAT - MI measure NQF0385 ;08-Sep-2011 14:56
+1 ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
+2 ;
+3 ; BGPMUD01 = tobacco use assessment 0028a
+4 ; BGPMUD02 = tobacco use cessation 0028b
+5 ; BGPMUD03 = Heart Failure w/ACE Inhibitor or ARB 0081
+6 ; BGPMUD04 = Prenatal HIV Screening 0012
+7 ; BGPMUD05 = Prenatal Anti-D Immune Globulin 0014
+8 ; BGPMUD06 = Control High Blood Pressure 0018
+9 ; BGPMUD07 = SMOKING CESSATION MEDICAL ASSIST 0027
+10 ; BGPMUD08 = Chlamydia Measure 0033
+11 ; BGPMUD09 = Antidepressant Medication Management 0105
+12 ; BGPMUD10 = Oncology Colon Cancer Stage III 0385
+13 ;
+14 ;Code to collect meaningful use report for Oncology Colon Cancer Stage III 0385
ENTRY ;EP
+1 NEW START,END,BGPNUM,STRING,STRING2
+2 NEW IEN,INV,RFOUND,VISIT,DATA,VDATE,VALUE,EXCEPT,FIRST,VIEN
+3 NEW CNT,DIAB,NUM,DIAB,DIABDX,OUTENC,OPHENC,NONENC,VENC,INENC,ERENC
+4 NEW BGPEN,BGPEND,BGPEXC,BGPH
+5 NEW BGPDEN,BGPNOT,BGPNUM
+6 NEW DEPV1,DEPVA
+7 SET (BGPDEN,BGPEN,BGPEXC,BGPNUM,BGPNOT)=""
+8 SET BGPEND=0
+9 ;Pts must be >=18 at the end of the reporting period
+10 SET BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
+11 ;No need to check further if no age match
+12 IF BGPAGEE<18
QUIT
+13 ;
+14 ;look for 2 encounters with EP
+15 SET START=9999999-BGPBDATE
SET END=9999999-BGPEDATE
SET VALUE=0
+16 SET START=START_".2359"
+17 SET FIRST=END-0.1
FOR
SET FIRST=$ORDER(^AUPNVSIT("AA",DFN,FIRST))
IF FIRST=""!($PIECE(FIRST,".",1)>START)
QUIT
Begin DoDot:1
+18 SET VIEN=0
FOR
SET VIEN=$ORDER(^AUPNVSIT("AA",DFN,FIRST,VIEN))
IF '+VIEN
QUIT
Begin DoDot:2
+19 SET BGPDT=$PIECE($PIECE($GET(^AUPNVSIT(VIEN,0)),U,1),".",1)
+20 ;Check provider, determine if there are visits with E&M codes
+21 IF $$PRV^BGPMUUT1(VIEN,BGPPROV)
Begin DoDot:3
+22 IF $$EM1(DFN,VIEN,0)
Begin DoDot:4
+23 IF $LENGTH(BGPEN,";")'>1
SET BGPEN=$SELECT(BGPEN'="":BGPEN_";",1:"")_"EN:"_$$DATE^BGPMUUTL($PIECE(BGPDT,".",1))
+24 SET BGPEND=$SELECT(BGPDT>BGPEND:BGPDT,1:BGPEND)
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+25 ;
+26 IF $LENGTH(BGPEN,";")'>1
QUIT
+27 SET X=0
+28 SET X=$$LASTDX^BGPMUUT2(DFN,0,BGPEND,"BGPMU ONC COLON CANCER DX")
+29 IF '+X
SET X=$$PLTAX^BGPMUD09(DFN,"BGPMU ONC COLON CANCER DX","C",0,BGPEND)
+30 IF '+X
SET X=$$LASTDX^BGPMUUT2(DFN,0,BGPEND,"BGPMU ONC COLON CANCER HIST DX")
+31 IF '+X
SET X=$$PLTAX^BGPMUD09(DFN,"BGPMU ONC COLON CANCER HIST DX","I",0,BGPEND)
+32 IF '+X
QUIT
+33 SET BGPDEN="CCDX:"_$$DATE^BGPMUUTL($PIECE(X,U,3))
+34 SET X=0
+35 SET X=$$CPT^BGPMUUT1(DFN,0,BGPEND,"BGPMU STAGE III COLON CAN CPT")
+36 IF '+X
QUIT
+37 ;patient is in the denominator
SET BGPDEN=BGPDEN_";"_"CCST:"_$$DATE^BGPMUUTL($PIECE(X,U,3))_";"_BGPEN
+38 ;
+39 ;check PRESCRIPTION for colon cancer chemotherapy meds
+40 SET X=$$FIND^BGPMUUT4(DFN,"BGPMU COLON CANCER CHEMO NDCS",BGPBDATE,"",BGPEDATE)
+41 ;patient is in the numerator
IF +X
SET BGPNUM="M:MED "_$$DATE^BGPMUUTL($PIECE(X,U,3))
+42 IF '+X
SET BGPNOT="NM:"
+43 ;
+44 ;check exclusions
+45 SET X=0
+46 IF '+X
SET BGPEXC=$$EXCLUDE(DFN)
+47 IF BGPEXC'=""
SET BGPNOT=""
+48 ;
+49 DO TOTAL(DFN)
+50 QUIT
+51 ;
TOTAL(DFN) ;See where this patient ends up
+1 NEW PTCNT,EXCCT,DENCT,NUMCT1,NUMCT2,NOTNUM1,NOTNUM2,TOTALS
+2 SET TOTALS=$GET(^TMP("BGPMU0385",$JOB,BGPMUTF,"TOT"))
+3 SET DENCT=+$GET(^TMP("BGPMU0385",$JOB,BGPMUTF,"DEN",1))
+4 SET NUMCT1=+$GET(^TMP("BGPMU0385",$JOB,BGPMUTF,"NUM",1))
+5 SET NOTNUM1=+$GET(^TMP("BGPMU0385",$JOB,BGPMUTF,"NOT",1))
+6 SET EXCCT=+$GET(^TMP("BGPMU0385",$JOB,BGPMUTF,"EXC",1))
+7 SET PTCNT=TOTALS
+8 SET PTCNT=PTCNT+1
+9 SET DENCT=DENCT+1
SET ^TMP("BGPMU0385",$JOB,BGPMUTF,"DEN",1)=DENCT
+10 ;
+11 IF BGPNOT'=""
Begin DoDot:1
+12 SET NOTNUM1=NOTNUM1+1
SET ^TMP("BGPMU0385",$JOB,BGPMUTF,"NOT",1)=NOTNUM1
+13 IF BGPMUTF="C"
SET ^TMP("BGPMU0385",$JOB,"PAT",BGPMUTF,"NOT",1,PTCNT)=DFN_U_BGPDEN_U_BGPNOT
End DoDot:1
+14 ;
+15 IF BGPNUM'=""
Begin DoDot:1
+16 SET NUMCT1=NUMCT1+1
SET ^TMP("BGPMU0385",$JOB,BGPMUTF,"NUM",1)=NUMCT1
+17 IF BGPMUTF="C"
SET ^TMP("BGPMU0385",$JOB,"PAT",BGPMUTF,"NUM",1,PTCNT)=DFN_U_BGPDEN_U_BGPNUM
End DoDot:1
+18 ;
+19 IF BGPEXC'=""
Begin DoDot:1
+20 SET EXCCT=EXCCT+1
SET ^TMP("BGPMU0385",$JOB,BGPMUTF,"EXC",1)=EXCCT
+21 IF BGPMUTF="C"
SET ^TMP("BGPMU0385",$JOB,"PAT",BGPMUTF,"EXC",1,PTCNT)=DFN_U_BGPDEN_U_BGPEXC
End DoDot:1
+22 SET ^TMP("BGPMU0385",$JOB,BGPMUTF,"TOT")=PTCNT
+23 ;Setup iCare array for patient
+24 ; BGPICARE(INDICATOR_ID,Timeframe)=Denom Flag
+25 ; ^ Num Flag ^ Excl Flag ^ Denom disp ; Num disp ^ Excl disp
+26 SET BGPICARE("MU.EP.0385.1",BGPMUTF)=1_U_(BGPNUM'="")_U_(BGPEXC'="")_U_BGPDEN_";"_$SELECT(BGPNUM'="":BGPNUM,1:"")_U_$SELECT(BGPEXC="":BGPEXC,1:"")
+27 QUIT
+28 ;
EM1(DFN,VIEN,FLG) ;check visit for at least 1 E&M code indicating outpatient
+1 NEW BGPI,BGPTMP
+2 SET BGP2=0
+3 SET X=+$$VSTCPT^BGPMUUT1(DFN,VIEN,"BGPMU ENC OFFICE VISIT")
+4 IF +X
SET BGP2=1
+5 QUIT BGP2
+6 ;
EXCLUDE(DFN) ;check PATIENT ALLERGIES for allergy to IUD
+1 NEW BGPALL,BGPH
+2 SET BGPALL=""
+3 SET X=0
+4 SET BGPH=""
FOR
SET BGPH=$ORDER(^GMR(120.8,"B",DFN,BGPH))
IF BGPH=""
QUIT
Begin DoDot:1
+5 SET BGPALL=$PIECE(^GMR(120.8,BGPH,0),U,2)
+6 IF (BGPALL="AMINOGLUTETHIMIDE")!(BGPALL="ANASTROZOLE")!(BGPALL="CAPECITABINE")!(BGPALL="EXEMESTANE")!(BGPALL="FLUOROURACIL")!(BGPALL="LEUCOVORIN")
Begin DoDot:2
+7 SET X=1
End DoDot:2
End DoDot:1
IF X=1
QUIT
+8 IF +X
QUIT "Excluded"
+9 ;checks of VPOV and PROBLEM for Matastatic sites, Acute renal insufficiency, Neutropenia, Leukopenia
+10 SET X=0
+11 SET X=$$LASTDX^BGPMUUT2(DFN,0,BGPEND,"BGPMU 0385 EXCLUSIONS DX")
+12 IF +X
QUIT "Excluded"
+13 IF '+X
SET X=$$PLTAX^BGPMUD09(DFN,"BGPMU 0385 EXCLUSIONS DX","C",0,BGPEND)
+14 IF +X
QUIT "Excluded"
+15 ;check Health Factors
+16 SET X=0
+17 SET X=$$HF^BGPMUD07(DFN,"BGPMU ECOG POOR")
+18 IF +X
QUIT "Excluded"
+19 ;check refusals
+20 SET X=0
+21 SET X=$$MEDREF^BGPMUUT2(DFN,0,BGPEN_".2359","BGPMU COLON CANCER CHEMO NDCS")
+22 IF +X
QUIT "Excluded"
+23 QUIT ""
+24 ;
TEST ; debug target
+1 SET U="^"
+2 SET DT=$$DT^XLFDT()
+3 ; DFN = patient code from VA PATIENT file
SET DFN=65
+4 ; BGPBDATE = begin date of report
SET BGPBDATE=3100101
+5 ; BGPEDATE = end date of report
SET BGPEDATE=3101231
+6 ; BGPPROV = provider code from NEW PERSON file
SET BGPPROV=2
+7 ; BGPMUTF = timeframe variable - "C"=current year; "P"=previous year; "B"=baseline year
SET BGPMUTF="C"
+8 DO ENTRY
+9 QUIT