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

BGPMUG07.m

Go to the documentation of this file.
BGPMUG07 ; IHS/MSC/MMT - MI measure NQF0389 ;06-Sep-2011 13:06;DU
 ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
 ;Code to collect meaningful use reports
ENTRY ;EP Entry point for Prostate Cancer
 N START,END,STRING
 N IEN,INV,VISIT,DATA,VDATE,VALUE,EXCEPT,FIRST,VIEN
 N CNT,DEN,NUM,EXC,OUTENC,PROSTDX
 S START=9999999-BGPBDATE,END=9999999-BGPEDATE,VALUE=0
 S START=START_".2359"
 S (STRING,STRING2)=""
 S (DEN,EXC,NUM)=0
 ;Must be Male
 Q:BGPSEX="F"
 ;First check for Prostate Cancer Dx since that will eliminate most patients
 S BGPBIRTH=$$DOB^AUPNPAT(DFN)
 S PROSTDX=$$PROSTATE(DFN,BGPBIRTH,BGPEDATE)
 Q:'PROSTDX
 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 PROSTATE OUTPT ENC")
 ..I +OUTENC D VSTSTORE Q
 ;Next check to see if the patient is in the denominator
 S DEN=$$DEN(DFN,BGPBDATE,BGPEDATE,CNT,.VIEN,PROSTDX)
 I +DEN D
 .;If the patient is in denominator, check to see if they are in the numerator
 .S NUM=$$NUM1(DFN,$P(PROSTDX,U,3),$P(DEN,U,2))
 .;If not in the numerator,see if they are an exception
 .I +NUM=0 S EXC=$$EXCEPT(DFN,$P(PROSTDX,U,3),$P(DEN,U,2),.VIEN)
 .D TOTAL1(DFN,DEN,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,DEN,NUM,EXC) ;See where this patient ends up
 N PTCNT,EXCCT,DENCT,NUMCT,NOTNUM,TOTALS,DXTIME
 S TOTALS=+$G(^TMP("BGPMU0389",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0389",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0389",$J,BGPMUTF,"NUM"))
 S EXCCT=+$G(^TMP("BGPMU0389",$J,BGPMUTF,"EXC"))
 S NOTNUM=+$G(^TMP("BGPMU0389",$J,BGPMUTF,"NOT"))
 S PTCNT=TOTALS
 S PTCNT=PTCNT+1
 S DENCT=DENCT+1 S ^TMP("BGPMU0389",$J,BGPMUTF,"DEN")=DENCT
 S DENSTR=$P(DEN,U,3)
 I +EXC D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0389",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0389",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_DENSTR_U_"Excluded"
 I +NUM D
 .S NUMCT=NUMCT+1 S ^TMP("BGPMU0389",$J,BGPMUTF,"NUM")=NUMCT
 .I BGPMUTF="C" S ^TMP("BGPMU0389",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DENSTR_U_"M:"_$P(NUM,U,2)
 I +NUM=0&(+EXC=0) D
 .S NOTNUM=NOTNUM+1 S ^TMP("BGPMU0389",$J,BGPMUTF,"NOT")=NOTNUM
 .I BGPMUTF="C" S ^TMP("BGPMU0389",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DENSTR_U_"NM:"_$P(NUM,U,2)
 S ^TMP("BGPMU0389",$J,BGPMUTF,"TOT")=PTCNT
 ;Setup iCare array for patient
 S BGPICARE("MU.EP.0389.1",BGPMUTF)=1_U_+NUM_U_+EXC_U_DENSTR_";"_$P(NUM,U,2)
 Q
PROSTATE(DFN,BDATE,EDATE) ;Look for Prostate Cancer V POV or PROBLEM
 N DX
 S DX=0
 S DX=$$LASTDX^BGPMUUT2(DFN,BDATE,EDATE,"BGPMU PROSTATE CANCER DX")
 I +DX Q 1_U_$P(DX,U,2,3)
 S DX=$$PLTAX^BGPMUUT1(DFN,"BGPMU PROSTATE CANCER DX","C",EDATE)
 I +DX Q 2_U_$P(DX,U,2,3)
 Q DX
DEN(DFN,BGPBDATE,BGPEDATE,CNT,VIEN,PROSTDX) ;Check if Pt is in denominator
 N TRTMNT,PROC,PROCDT,AJCC,ANTIG,VLABIEN,ANTIVAL,GLETST,GLEVAL,DATA
 K DATA
 S TRTMNT=0,ANTIVAL=""
 ;Treatment procedure done?
 S PROC=$$CPT^BGPMUUT1(DFN,BGPBDATE,BGPEDATE,"BGPMU PROSTATE CANCER TRMT CPT")
 G:'PROC DENQ
 S PROCDT=$P(PROC,U,3)
 ;Stage eval?
 S AJCC=$$CPT^BGPMUUT1(DFN,"",PROCDT,"BGPMU PROSTATE CANCER STAGE")
 G:'AJCC DENQ
 ;Antigen tested?
 S ANTIG=$$LOINC^BGPMUUT2(DFN,"",PROCDT,"BGPMU LAB LOINC PROSTATE ANTIG")
 I +ANTIG D
 .S VLABIEN=$P(ANTIG,U,2)
 .S ANTIVAL=$P($G(^AUPNVLAB(VLABIEN,0)),U,4)
 E  D
 .D LABCPT^BGPMUUT5(.DATA,DFN,"BGPMU LAB CPT PROSTATE ANTIGEN","",PROCDT)
 .S VAL="" S VAL=$O(DATA(VAL))
 .I +VAL D
 ..S ANTIVAL=$G(DATA(VAL))
 ..S ANTIG=(9999999-VAL)_U_ANTIVAL
 G:ANTIVAL="" DENQ
 ;Gleason test performed?
 S GLETST=$$LOINC^BGPMUUT2(DFN,"",PROCDT,"BGPMU LAB LOINC GLEASON TEST")
 G:'GLETST DENQ
 S VLABIEN=$P(GLETST,U,2)
 S GLEVAL=$P($G(^AUPNVLAB(VLABIEN,0)),U,4)
 G:GLEVAL="" DENQ
 ;check values and set return var
 S:(ANTIVAL<=10)&(GLEVAL<=6) TRTMNT=1_U_PROCDT_U_$$DENSTR(DFN)
DENQ Q TRTMNT
DENSTR(DFN) ;Generate display string for Denom
 N STRING
 S STRING="PCDX:"_$$DATE^BGPMUUTL($P(PROSTDX,U,3))
 S STRING=STRING_";PCTM:"_$$DATE^BGPMUUTL(PROCDT)
 S STRING=STRING_";AJCC:"_$$DATE^BGPMUUTL($P(AJCC,U,3))
 S STRING=STRING_";ANT:"_$$DATE^BGPMUUTL($P(ANTIG,U))
 S STRING=STRING_";GLE:"_$$DATE^BGPMUUTL($P(GLETST,U))
 Q STRING
NUM1(DFN,BDATE,EDATE) ;This one has backward Numerator logic - return 1 if NOT met
 N FOUND,PMED
 S FOUND=1
 ;Look for V RADIOLOGY event for bone scan study
 S SCAN=$$RAD^BGPMUUT1(DFN,BDATE,EDATE,"BGPMU PROSTATE BONE SCAN CPT",7)
 ;return TRUE if no bone scan study found
 I +SCAN Q 0_U_"BSDS:"_$$DATE^BGPMUUTL($P(SCAN,U))
 ;Look for ORDER for bone scan study
 S SCAN=$$FIND^BGPMUUT7(DFN,"BGPMU PROSTATE BONE SCAN CPT",BDATE,EDATE) ;RAD procedure check
 I +SCAN Q 0_U_"BSDS:"_$$DATE^BGPMUUTL($P(SCAN,U))
 Q FOUND
EXCEPT(DFN,BDATE,EDATE,VIEN) ;Check exclusion criteria
 N LAST,RESULT,OOP,RAD,CHEMO,METDX,METPL,PMED,ALLER,REF,TAX
 S RESULT=0
 S DX=$$LASTDX^BGPMUUT2(DFN,BDATE,EDATE,"BGPMU 0389 EXCLUSIONS DX")
 I +DX S RESULT=1 Q RESULT
 S DX=$$PLTAX^BGPMUUT1(DFN,"BGPMU 0389 EXCLUSIONS DX","C",EDATE)
 I +DX S RESULT=1 Q RESULT
 S PROC=$$CPT^BGPMUUT1(DFN,BDATE,EDATE,"BGPMU 0389 EXCLUSIONS CPT")
 I +PROC S RESULT=1 Q RESULT
 Q RESULT