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

BGPMUG01.m

Go to the documentation of this file.
BGPMUG01 ; IHS/MSC/MMT - MI measure NQF0086 ;10-Jan-2012 10:05;MMT
 ;;12.1;IHS CLINICAL REPORTING;;MAY 17, 2012;Build 66
 ;Code to collect meaningful use report for POAG optic nerve exam
ENTRY ;EP
 N START,END,BGPNUM,BGPDEN,BGPBIRTH,STRING,STRING2
 N IEN,INV,VISIT,DATA,VDATE,VALUE,EXCEPT,FIRST,VIEN,RESULT
 N CNT,NUM,EXC,POAGENC,POAGDX,POAGPL,POAG
 S (BGPDEN,BGPNUM,RESULT)=0
 S START=9999999-BGPBDATE,END=9999999-BGPEDATE,VALUE=0
 S START=START_".2359"
 S (POAG,EXC,NUM)=0
 ;Pts must be 18+
 ;No need to check further if no age match
 Q:BGPAGEE<18
 S BGPBIRTH=$$DOB^AUPNPAT(DFN)
 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 POAGENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU ENC POAG COMBINED")
 ..I +POAGENC D
 ...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:CNT<2  ;Pt only counts if they had at least 2 visits with the EP
 S POAGDX=$$LASTDX^BGPMUUT2(DFN,BGPBIRTH,$P($P(VIEN(1),U,2),"."),"BGPMU POAG DX")
 I +POAGDX S POAG=1_U_$P(POAGDX,U,3)
 E  D
 .S POAGPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU POAG DX","C",$P($P(VIEN(1),U,2),"."))
 .S:+POAGPL POAG=1_U_$P(POAGPL,U,3)
 I +POAG D
 .;If the patient has POAG, check to see if they are in the numerator
 .S NUM=$$NUM(DFN,BGPBDATE,BGPEDATE)
 .;If not in the numerator,see if they are an exception
 .I +NUM=0 S EXC=$$EXCEPT(DFN,BGPBDATE,BGPEDATE)
 .D TOTAL(DFN,POAG,NUM,EXC)
 Q
TOTAL(DFN,POAG,NUM,EXC) ;See where this patient ends up
 N PTCNT,EXCCT,DENCT,NUMCT,NOTNUM,TOTALS,DEN,DXTIME
 S TOTALS=$G(^TMP("BGPMU0086",$J,BGPMUTF,"TOT"))
 S DENCT=+$G(^TMP("BGPMU0086",$J,BGPMUTF,"DEN"))
 S NUMCT=+$G(^TMP("BGPMU0086",$J,BGPMUTF,"NUM"))
 S EXCCT=+$G(^TMP("BGPMU0086",$J,BGPMUTF,"EXC"))
 S NOTNUM=+$G(^TMP("BGPMU0086",$J,BGPMUTF,"NOT"))
 S PTCNT=TOTALS
 S PTCNT=PTCNT+1
 S (DEN,DXTIME)=""
 S DENCT=DENCT+1 S ^TMP("BGPMU0086",$J,BGPMUTF,"DEN")=DENCT
 I $P(POAG,U,2)'="" S DXTIME=$$DATE^BGPMUUTL($P(POAG,U,2))
 S DEN="POAG:"_DXTIME
 I $D(STRING(1)) S DEN=DEN_";EN:"_STRING(1)
 I $D(STRING(2)) S DEN=DEN_";EN:"_STRING(2)
 I +NUM D
 .S NUMCT=NUMCT+1 S ^TMP("BGPMU0086",$J,BGPMUTF,"NUM")=NUMCT
 .I BGPMUTF="C" S ^TMP("BGPMU0086",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_DEN_U_"M:"_$P(NUM,U,2)_";"_$P(NUM,U,3)
 I +EXC D
 .S EXCCT=EXCCT+1 S ^TMP("BGPMU0086",$J,BGPMUTF,"EXC")=EXCCT
 .I BGPMUTF="C" S ^TMP("BGPMU0086",$J,"PAT",BGPMUTF,"EXC",PTCNT)=DFN_U_DEN_U_"Excluded"
 I +NUM=0&(EXC=0) D
 .S NOTNUM=NOTNUM+1 S ^TMP("BGPMU0086",$J,BGPMUTF,"NOT")=NOTNUM
 .I BGPMUTF="C" S ^TMP("BGPMU0086",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_DEN_U_"NM:"
 S ^TMP("BGPMU0086",$J,BGPMUTF,"TOT")=PTCNT
 ;Setup iCare array for patient
 S BGPICARE("MU.EP.0086.1",BGPMUTF)=1_U_+NUM_U_+EXC_U_DEN_";"_$P(NUM,U,2)_";"_$P(NUM,U,3)
 Q
NUM(DFN,BGPBDATE,BGPEDATE) ;Look for evidence of a optic nerve evaluation done by the EP
 N FOUND,VCNT,EXMPRC,CLINPTR,CLINCODE
 S FOUND=0
 ;Check to make sure procedure done during a CLINIC 17 or 18 visit with the EP
 S VCNT=""
 F  S VCNT=$O(VIEN(VCNT)) Q:(VCNT="")!(+FOUND)  D
 .S EXMPRC=$$VSTCPT^BGPMUUT1(DFN,$P(VIEN(VCNT),U),"BGPMU POAG NERVE EVAL CPT")
 .I +EXMPRC D
 ..S CLINPTR=$P($G(^AUPNVCPT($P(EXMPRC,U,4),12)),U,3)
 ..Q:CLINPTR=""
 ..S CLINCODE=$P(^DIC(40.7,CLINPTR,0),U,2)
 ..I (CLINCODE=17)!(CLINCODE=18) S FOUND=EXMPRC
 .Q:+FOUND
 .S EXMPRC=$$VSTICD0^BGPMUUT3(DFN,$P(VIEN(VCNT),U),"BGPMU POAG NERVE EVAL ICD0")
 .I +EXMPRC D
 ..S CLINPTR=$P($G(^AUPNVPRC($P(EXMPRC,U,4),12)),U,3)
 ..Q:CLINPTR=""
 ..S CLINCODE=$P(^DIC(40.7,CLINPTR,0),U,2)
 ..I (CLINCODE=17)!(CLINCODE=18) S FOUND=EXMPRC
 Q FOUND
EXCEPT(DFN,BGPBDATE,BGPEDATE) ;See if this patient has exceptions
 N EFOUND,NMI
 S EFOUND=0
 S NMI=$$REFTAX^BGPMUUT2(DFN,81,"BGPMU POAG NERVE EVAL CPT",BGPBIRTH,BGPEDATE)
 Q:+NMI&($P(NMI,U,3)="N") 1_U_$P(NMI,U,4)_U_$P(NMI,U,2)
 S NMI=$$REFTAX^BGPMUUT2(DFN,80.1,"BGPMU POAG NERVE EVAL ICD0",BGPBIRTH,BGPEDATE)
 Q:+NMI&($P(NMI,U,3)="N") 1_U_$P(NMI,U,4)_U_$P(NMI,U,2)
 Q EFOUND