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

BGPMUA13.m

Go to the documentation of this file.
BGPMUA13 ; IHS/MSC/MGH - MI measure NQF0387 ;01-Sep-2011 13:06;DU
 ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
 ;Code to collect meaningful use reports
ENTRY1 ;EP Entry point for breast cancer on Tamoxifen Aromatase
 N START,END,STRING
 N IEN,INV,VISIT,DATA,VDATE,VALUE,EXCEPT,FIRST,VIEN
 N CNT,BC,NUM,EXC,OUTENC
 S START=9999999-BGPBDATE,END=9999999-BGPEDATE,VALUE=0
 S START=START_".2359"
 S (STRING,STRING2)=""
 S (EXC,NUM)=0
 ;Pts must be >18 and <75
 ;No need to check further if no age match
 Q:BGPAGEE<18
 Q:BGPSEX="M"
 S CNT=0
 S FIRST=END-0.1 F  S FIRST=$O(^AUPNVSIT("AA",DFN,FIRST)) Q:FIRST=""!($P(FIRST,".",1)>START)  D
 .S IEN=0 F  S IEN=$O(^AUPNVSIT("AA",DFN,FIRST,IEN)) Q:'+IEN  D
 ..;Check provider, Only visits for chosen provider
 ..Q:'$$PRV^BGPMUUT1(IEN,BGPPROV)
 ..S OUTENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU ENC OFFICE VISIT")
 ..I +OUTENC D VSTSTORE Q
 Q:CNT<2
 ;Next check to see if the patient is in the denominator
 ;Denominator is that the pt had a diagnosis of breast cancer
 S BC=$$BREAST(DFN,BGPBDATE,BGPEDATE,CNT,.VIEN)
 I +BC D
 .;If the patient is in denominator, check to see if they are in the numerator
 .S NUM=$$NUM1(DFN,BGPBDATE,BGPEDATE)
 .;If not in the numerator,see if they are an exception
 .I +NUM=0 S EXC=$$EXCEPT(DFN,BGPBDATE,BGPEDATE,.VIEN)
 .D TOTAL1(DFN,BC,NUM,EXC)
 Q
VSTSTORE ;Store compliant visit in array
 S CNT=CNT+1
 S VDATE=$P($G(^AUPNVSIT(IEN,0)),U,1)
 S VIEN(CNT)=IEN_U_VDATE
 S STRING(CNT)=$$DATE^BGPMUUTL(VDATE)
 Q
TOTAL1(DFN,BC,NUM,EXC) ;See where this patient ends up
 N PTCNT,EXCCT,DENCT,NUMCT,NOTNUM,TOTALS,DXTIME,DEN
 S TOTALS=+$G(^TMP("BGPMU0387",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0387",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0387",$J,BGPMUTF,"NUM"))
 S EXCCT=+$G(^TMP("BGPMU0387",$J,BGPMUTF,"EXC"))
 S NOTNUM=+$G(^TMP("BGPMU0387",$J,BGPMUTF,"NOT"))
 S PTCNT=TOTALS
 S PTCNT=PTCNT+1
 S DEN=""
 S DENCT=DENCT+1 S ^TMP("BGPMU0387",$J,BGPMUTF,"DEN")=DENCT
 S DEN=$P(BC,U,2)_";"_$P(BC,U,3)
 I $D(STRING(1)) S DEN=DEN_";EN:"_STRING(1)
 I $D(STRING(2)) S DEN=DEN_";EN:"_STRING(2)
 I +EXC D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0387",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0387",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_DEN_U_"Excluded"
 I +NUM D
 .S NUMCT=NUMCT+1 S ^TMP("BGPMU0387",$J,BGPMUTF,"NUM")=NUMCT
 .I BGPMUTF="C" S ^TMP("BGPMU0387",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DEN_U_"M:"_$P(NUM,U,2)_";"_$P(NUM,U,3)
 I +NUM=0&(+EXC=0) D
 .S NOTNUM=NOTNUM+1 S ^TMP("BGPMU0387",$J,BGPMUTF,"NOT")=NOTNUM
 .I BGPMUTF="C" S ^TMP("BGPMU0387",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DEN_U_"NM:"_$P(NUM,U,2)_";"_$P(NUM,U,3)
 S ^TMP("BGPMU0387",$J,BGPMUTF,"TOT")=PTCNT
 ;Setup iCare array for patient
 S BGPICARE("MU.EP.0387.1",BGPMUTF)=1_U_+NUM_U_+EXC_U_DEN_";"_$P(NUM,U,2)_";"_$P(NUM,U,3)
 Q
BREAST(DFN,BGPBDATE,BGPEDATE,CNT,VIEN) ;Check patient for Breast Cancer
 N CANCER,LAST,DXA,DXB,HXA,HXB,STAGE,SAVE
 S LAST=0,CANCER=0,STAGE=0,SAVE=0
 S LAST=$P($P($G(VIEN(1)),U,2),".")
 ;First check for DX of breast cancer
 S DXA=$$LASTDX^BGPMUUT2(DFN,"",LAST,"BGPMU BREAST CANCER DX")
 I +DXA S SAVE=DXA S STAGE=$$STAGE(DFN,LAST)
 S DXB=$$PLTAX^BGPMUUT1(DFN,"BGPMU BREAST CANCER DX","C",LAST)
 I +DXB S SAVE=DXB S STAGE=$$STAGE(DFN,LAST)
 S HXA=$$LASTDX^BGPMUUT2(DFN,"",LAST,"BGPMU BREAST CANCER HISTORY DX")
 I +HXA S SAVE=HXA S STAGE=$$STAGE(DFN,LAST)
 S HXB=$$PLTAX^BGPMUUT1(DFN,"BGPMU BREAST CANCER HISTORY DX","I",LAST)
 I +HXB S SAVE=HXB S STAGE=$$STAGE(DFN,LAST)
 I +STAGE D
 .S CANCER=1_U_"BCDX:"_$$DATE^BGPMUUTL($P(SAVE,U,3))_U_$P(STAGE,U,2)
 Q CANCER
STAGE(DFN,LAST) ;Check for stage of breast cancer
 N STAGE1,STAGE2,A,B,C
 S (STAGE1,STAGE2)=0
 S A=$$CPT^BGPMUUT1(DFN,"",LAST,"BGPMU BREAST CANCER STAGE CPT")
 Q:'A 0
 S STAGE1="BCST:"_$$DATE^BGPMUUTL($P(A,U,3))
 S B=$$LASTDX^BGPMUUT2(DFN,"",LAST,"BGPMU BREAST CANCER ER ICD")
 I +B S STAGE2="BCP:"_$$DATE^BGPMUUTL($P(B,U,3)) G STAGEX
 S C=$$CPT^BGPMUUT1(DFN,"",LAST,"BGPMU BREAST CANCER ER CPT")
 I +C S STAGE2="BCP:"_$$DATE^BGPMUUTL($P(C,U,3))
STAGEX Q $S(STAGE2=0:0,1:1_U_STAGE1_";"_STAGE2)
NUM1(DFN,BGPBDATE,BGPEDATE) ;Look for wide range of items to satisfy this measure
 N FOUND,PMED
 S FOUND=0
 S PMED=$$FIND^BGPMUUT8(DFN,"BGPMU TAMOXIFEN AROMATASE NDCS",BGPBDATE,"",BGPEDATE)
 I +PMED S FOUND=1_U_"MED:"_$$DATE^BGPMUUTL($P(PMED,U,3))
 Q FOUND
EXCEPT(DFN,BGPBDATE,BGPEDATE,VIEN) ;Check Exception criteria
 N LAST,RESULT,OOP,RAD,CHEMO,METDX,METPL,PMED,ALLER,REF,TAX
 S RESULT=0
 S LAST=$P($P($G(VIEN(1)),U,2),".")
 S OOP=$$CPT^BGPMUUT1(DFN,"",LAST,"BGPMU BILATERAL OOPHORECTOMY")
 I +OOP S RESULT=OOP Q RESULT
 S RAD=$$CPT^BGPMUUT1(DFN,"",LAST,"BGPMU RADIATION THERAPY CPT")
 I +RAD S RESULT=RAD Q RESULT
 S CHEMO=$$CPT^BGPMUUT1(DFN,"",LAST,"BGPMU CHEMOTHERAPY CPTS")
 I +CHEMO S RESULT=CHEMO Q RESULT
 ;Check for metastisis
 S METDX=$$LASTDX^BGPMUUT2(DFN,"",LAST,"BGPMU BREAST CANCER METS DX")
 I +METDX S RESULT=METDX Q RESULT
 S METPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU BREAST CANCER METS DX","C",LAST)
 I +METPL S RESULT=METPL Q RESULT
 ;Check if on another drug
 S PMED=$$FIND^BGPMUUT8(DFN,"BGPMU GONODOTROPIN NDCS",BGPBDATE,"",BGPEDATE)
 I +PMED S RESULT=1_U_$P(PMED,U,2)_U_$P(PMED,U,3)
 ;Next check for allergy
 S ALLER=0
 S ALLER=$$ALLER^BGPMUA10("","TAMOXIFEN")
 I +ALLER S RESULT=1_U_$P(ALLER,U,1) Q RESULT
 S ALLER=0
 S ALLER=$$ALLER^BGPMUA10("","ANASTROZOLE")
 I +ALLER S RESULT=1_U_$P(ALLER,U,1) Q RESULT
 S ALLER=0
 S ALLER=$$ALLER^BGPMUA10("","EXEMESTANE")
 I +ALLER S RESULT=1_U_$P(ALLER,U,1) Q RESULT
 S ALLER=0
 S ALLER=$$ALLER^BGPMUA10("","LETROZOLE")
 I +ALLER S RESULT=1_U_$P(ALLER,U,1) Q RESULT
 ;Check for refusals
 S TAX="BGPMU TAMOXIFEN AROMATASE NDCS"
 S REF=$$MEDREF^BGPMUUT2(DFN,0,BGPEDATE,TAX)
 I +REF S RESULT=1_U_$P(REF,U,1) Q RESULT
 Q RESULT