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

BGPMUA05.m

Go to the documentation of this file.
  1. BGPMUA05 ; IHS/MSC/MGH - MI measure NQF0013 ;22-Mar-2011 10:16;DU
  1. ;;11.1;IHS CLINICAL REPORTING SYSTEM;**1**;JUN 27, 2011;Build 106
  1. ;Code to collect meaningful use report for hypertension and BP reading
  1. ENTRY ;EP
  1. N START,END,BGPNUM,BGPDEN,AENC,BENC,STRING,STRING1,STRING2,BGPHYPER,BGPHYPL
  1. N IEN,INV,VISIT,WTIEN,DATA,VDATE,VALUE,EXCEPT,FIRST,REF,VIEN,EXCEPT,RESULT
  1. N BGPN1,BGPN3,RETVAL,BGPBII,BGPUNII,BGPMAS,AENC,BENC,CENC,CNT
  1. N BGPENC,ENSTRING,BGPBIRTH,BGPHYS2,BGPHYS1,BGPHYS3,BGPHYS4
  1. S (BGPDEN,NUM,RESULT)=0
  1. S START=9999999-BGPBDATE,END=9999999-BGPEDATE,VALUE=0
  1. S RETVAL="" ;Return value
  1. S (STRING,STRING2)=""
  1. ;Pts must be >18
  1. ;No need to check further if no age match
  1. Q:BGPAGEE<18
  1. S CNT=0
  1. S FIRST=END-0.1 F S FIRST=$O(^AUPNVSIT("AA",DFN,FIRST)) Q:FIRST=""!($P(FIRST,".",1)>START) D
  1. .S IEN=0 F S IEN=$O(^AUPNVSIT("AA",DFN,FIRST,IEN)) Q:'+IEN D
  1. ..;Check provider, Only visits for chosen provider
  1. ..Q:'$$PRV^BGPMUUT1(IEN,BGPPROV)
  1. ..;If the right provider, check and see if an appropriate CPT code exists
  1. ..S AENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU BP EM")
  1. ..S BENC=$$VSTCPT^BGPMUUT1(DFN,IEN,"BGPMU NURSING FAC EM")
  1. ..I (+AENC=1)!(+BENC=1) D
  1. ...S CNT=CNT+1
  1. ...S VDATE=$P($G(^AUPNVSIT(IEN,0)),U,1)
  1. ...S VIEN(CNT)=IEN_U_VDATE
  1. I CNT>1 D
  1. .;Patient Must have active DX of hypertension, EVER
  1. .;Check POV codes
  1. .S (STRING1,STRING2,ENSTRING)=""
  1. .S BGPBIRTH=$P(^DPT(DFN,0),U,3)
  1. .S BGPHYPER=$$LASTDX^BGPMUUT2(DFN,BGPBIRTH,BGPBDATE,"BGPMU HYPERTENSION DX")
  1. .I +BGPHYPER S VALUE=1,STRING1=$P(BGPHYPER,U,2)_" "_$$DATE^BGPMUUTL($P(BGPHYPER,U,3))
  1. .;Check problem list
  1. .N PDATE
  1. .S BGPHYPL=$$PLTAX^BGPMUUT1(DFN,"BGPMU HYPERTENSION DX","C")
  1. .I +BGPHYPL D
  1. ..S PDATE=$P(BGPHYPL,U,3)
  1. ..I PDATE<BGPBDATE S VALUE=1,STRING2=$P(BGPHYPL,U,2)_" "_$$DATE^BGPMUUTL($P(BGPHYPL,U,3))
  1. .;Patient has hypertension and 2 or more visits, now check for BP
  1. .I +VALUE D
  1. ..I STRING2'="" S ENSTRING=STRING2
  1. ..I STRING1'="" S ENSTRING=STRING1
  1. ..D BP(DFN,CNT,.ENSTRING,.VIEN,.BGPNUM)
  1. ..D TOTAL(DFN,ENSTRING,BGPNUM)
  1. Q
  1. BP(DFN,CNT,ENSTRING,VIEN,NUM) ;Find is pt has a BP on the chosen visits
  1. N IEN,MSR,MTYP,BP,BPCNT,SAVE,ARRAY,VST,VCNT
  1. S BP="",BPCNT=0,VCNT=0
  1. S MTYP="" S MTYP=$O(^AUTTMSR("B","BP",MTYP))
  1. Q:MTYP="" 0
  1. S NUM=0 F S NUM=$O(VIEN(NUM)) Q:NUM=""!(BPCNT>1) D
  1. .S IEN=$P(VIEN(NUM),U,1),SAVE=0
  1. .S MSR="" F S MSR=$O(^AUPNVMSR("AD",IEN,MSR)) Q:MSR=""!(+SAVE) D
  1. ..I $P($G(^AUPNVMSR(MSR,0)),U,1)=MTYP D
  1. ...S BPCNT=BPCNT+1,SAVE=1
  1. ...S ARRAY(IEN)=""
  1. ...I BPCNT=1 S BP="BP:"_$P($G(^AUPNVMSR(MSR,0)),U,4)_" "_$$DATE^BGPMUUTL($P($G(^AUPNVMSR(MSR,12)),U,1))
  1. ...I BPCNT=2 S BP=BP_";BP:"_$P($G(^AUPNVMSR(MSR,0)),U,4)_" "_$$DATE^BGPMUUTL($P($G(^AUPNVMSR(MSR,12)),U,1))
  1. ...S ENSTRING=ENSTRING_";EN:"_$$DATE^BGPMUUTL($P(VIEN(NUM),U,2))
  1. I BPCNT=2 S NUM=1_U_"M:"_BP
  1. I BPCNT<2 D
  1. .S NUM=0_U_"NM:"_BP
  1. .N CNT
  1. .I BPCNT=1 D
  1. ..S CNT=1
  1. ..S VST=0 F S VST=$O(VIEN(VST)) Q:VST=""!(CNT>1) D
  1. ...S IEN=$P(VIEN(VST),U,1)
  1. ...I '$D(ARRAY(IEN)) D
  1. ....S CNT=CNT+1
  1. ....S ENSTRING=ENSTRING_";EN:"_$$DATE^BGPMUUTL($P(VIEN(VST),U,2))
  1. .I BPCNT=0 D
  1. ..S CNT=0
  1. ..S VST=0 F S VST=$O(VIEN(VST)) Q:VST=""!(CNT>1) D
  1. ...S IEN=$P(VIEN(VST),U,1)
  1. ...S CNT=CNT+1
  1. ...S ENSTRING=ENSTRING_";EN:"_$$DATE^BGPMUUTL($P(VIEN(VST),U,2))
  1. Q
  1. TOTAL(DFN,ENSTRING,BGPNUM) ;See where this patient ends up
  1. N PTCNT,EXCCT,DENCT,NUMCT,TOTALS,NOTCT
  1. S TOTALS=$G(^TMP("BGPMU0013",$J,BGPMUTF,"TOT"))
  1. S DENCT=+$G(^TMP("BGPMU0013",$J,BGPMUTF,"DEN"))
  1. S NUMCT=+$G(^TMP("BGPMU0013",$J,BGPMUTF,"NUM"))
  1. S NOTCT=+$G(^TMP("BGPMU0013",$J,BGPMUTF,"NOT"))
  1. S PTCNT=TOTALS
  1. S PTCNT=PTCNT+1
  1. S DENCT=DENCT+1 S ^TMP("BGPMU0013",$J,BGPMUTF,"DEN")=DENCT
  1. I +BGPNUM D
  1. .S NUMCT=NUMCT+1 S ^TMP("BGPMU0013",$J,BGPMUTF,"NUM")=NUMCT
  1. .I BGPMUTF="C" S ^TMP("BGPMU0013",$J,"PAT",BGPMUTF,"NUM",PTCNT)=DFN_U_ENSTRING_U_$P(BGPNUM,U,2)
  1. I '+BGPNUM D
  1. .S NOTCT=NOTCT+1 S ^TMP("BGPMU0013",$J,BGPMUTF,"NOT")=NOTCT
  1. .I BGPMUTF="C" S ^TMP("BGPMU0013",$J,"PAT",BGPMUTF,"NOT",PTCNT)=DFN_U_ENSTRING_U_$P(BGPNUM,U,2)
  1. S ^TMP("BGPMU0013",$J,BGPMUTF,"TOT")=PTCNT
  1. ;Setup iCare array for patient
  1. S BGPICARE("MU.EP.0013.1",BGPMUTF)=1_U_+BGPNUM_U_""_U_$G(ENSTRING)_";"_$P(BGPNUM,U,2)
  1. Q