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

BGPMUAD1.m

Go to the documentation of this file.
BGPMUAD1 ; IHS/MSC/MGH - Print MI measure NQF0421 and NQF0013 ;22-Mar-2011 09:53;DU
 ;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
 ;Delimeted outptu
BMI(CNT) ;EP
 D P1
 K ^TMP("BGPMU0421",$J)
 Q
P1 ;Write individual measure
 N X,Y,Z,LIST1,LIST2,LIST3
 N DEN1,NUM1,DEN2,NUM2,PC1,PC2,EXC1,EXC2,STRING1,STRING2,STRING3
 N PRD1,PRD2,PRD3,PRD4,PRD5,PRD6,PRD7,PRD8,PRN1,PRN2,PRN3,PRN4,PRN5,PRN6,PRN7,PRN8
 S STRING1=$$421("C")
 S STRING2=$$421("P")
 S STRING3=$$421("B")
 D SUMMARY1^BGPMUAP1(STRING1,STRING2,STRING3)
 ;First population
 S PRD1=$P(STRING1,U,5)-$P(STRING2,U,5) I PRD1>0 S PRD1="+"_PRD1
 S PRD2=$P(STRING1,U,6)-$P(STRING2,U,6) I PRD2>0 S PRD2="+"_PRD2
 S PRD3=$P(STRING1,U,7)-$P(STRING2,U,7) I PRD3>0 S PRD3="+"_PRD3
 S PRD7=$P(STRING1,U,16)-$P(STRING2,U,16) I PRD7>0 S PRD7="+"_PRD7
 S PRN1=$P(STRING1,U,5)-$P(STRING3,U,5) I PRN1>0 S PRN1="+"_PRN1
 S PRN2=$P(STRING1,U,6)-$P(STRING3,U,6) I PRN2>0 S PRN2="+"_PRN2
 S PRN3=$P(STRING1,U,7)-$P(STRING3,U,7) I PRN3>0 S PRN3="+"_PRN3
 S PRN7=$P(STRING1,U,16)-$P(STRING3,U,16) I PRN7>0 S PRN7="+"_PRN7
 ;second population
 S PRD4=$P(STRING1,U,12)-$P(STRING2,U,12) I PRD4>0 S PRD4="+"_PRD4
 S PRD5=$P(STRING1,U,13)-$P(STRING2,U,13) I PRD5>0 S PRD5="+"_PRD5
 S PRD6=$P(STRING1,U,14)-$P(STRING2,U,14) I PRD6>0 S PRD6="+"_PRD6
 S PRD8=$P(STRING1,U,18)-$P(STRING2,U,18) I PRD8>0 S PRD8="+"_PRD8
 S PRN4=$P(STRING1,U,12)-$P(STRING3,U,12) I PRN4>0 S PRN4="+"_PRN4
 S PRN5=$P(STRING1,U,13)-$P(STRING3,U,13) I PRN5>0 S PRN5="+"_PRN5
 S PRN6=$P(STRING1,U,14)-$P(STRING3,U,14) I PRN6>0 S PRN6="+"_PRN6
 S PRN8=$P(STRING1,U,18)-$P(STRING3,U,18) I PRN8>0 S PRN8="+"_PRN8
 S X=U_"REPORT PERIOD"_U_"%"_U_"PREV YR PERIOD"_U_"%"_U_"CHG FROM PREV YR"_U_"BASE YEAR"_U_"%"_U_"CHG FROM BASE"
 D S^BGPMUDEL(X,2,1)
 S X="Denominator 1" D S^BGPMUDEL(X,2,1)
 S X="Pts 65+"_U_$P(STRING1,U,1)_U_U_$P(STRING2,U,1)_U_U_U_$P(STRING3,U,1) D S^BGPMUDEL(X,1,1)
 S X="# Excluded (Exc)"_U_$P(STRING1,U,4)_U_U_$P(STRING2,U,4)_U_U_U_$P(STRING3,U,4)
 D S^BGPMUDEL(X,1,1)
 S X="Pts 65+ - Exc"_U_$P(STRING1,U,3)_U_U_$P(STRING2,U,3)_U_U_U_$P(STRING3,U,3)
 D S^BGPMUDEL(X,1,1)
 S X="# w/normal BMI/followup"_U_$P(STRING1,U,2)_U_$P(STRING1,U,5)_U_$P(STRING2,U,2)_U_$P(STRING2,U,5)_U_PRD1_U_$P(STRING3,U,2)_U_$P(STRING3,U,5)_U_PRN1
 D S^BGPMUDEL(X,2,1)
 S X="# No BMI/followup"_U_$P(STRING1,U,15)_U_$P(STRING1,U,16)_U_$P(STRING2,U,15)_U_$P(STRING2,U,16)_U_PRD7_U_$P(STRING3,U,15)_U_$P(STRING3,U,16)_U_PRN7
 D S^BGPMUDEL(X,2,1)
 S X="Denominator 2" D S^BGPMUDEL(X,2,1)
 S X="Pts 18-64"_U_$P(STRING1,U,8)_U_U_$P(STRING2,U,8)_U_U_U_$P(STRING3,U,8) D S^BGPMUDEL(X,1,1)
 S X="# with exclusions:"_U_$P(STRING1,U,11)_U_U_$P(STRING2,U,11)_U_U_U_$P(STRING3,U,11)
 D S^BGPMUDEL(X,1,1)
 S X="Pts 65+ - Exc"_U_$P(STRING1,U,10)_U_U_$P(STRING2,U,10)_U_U_U_$P(STRING3,U,10)
 D S^BGPMUDEL(X,1,1)
 S X="# w/normal BMI/followup"_U_$P(STRING1,U,9)_U_$P(STRING1,U,12)_U_$P(STRING2,U,9)_U_$P(STRING2,U,12)_U_PRD4_U_$P(STRING3,U,9)_U_$P(STRING3,U,12)_U_PRN4
 D S^BGPMUDEL(X,2,1)
 S X="# No BMI/followup"_U_$P(STRING1,U,17)_U_$P(STRING1,U,18)_U_$P(STRING2,U,17)_U_$P(STRING2,U,18)_U_PRD8_U_$P(STRING3,U,17)_U_$P(STRING3,U,18)_U_PRN8
 D S^BGPMUDEL(X,2,1)
 I $D(BGPLIST(BGPIC)) D P2
 Q
421(TF) ;Get the numbers for this measure
 N ARRAY,DEN1,NUM1,EXC1,DEN2,NUM2,EXC2,NOT1,NOT2,PC1,PC11,PC2,PC14,PC24,PC21,PC13,PC23,NNUM1,NNUM2
 S DEN1=+$G(^TMP("BGPMU0421",$J,TF,"DEN",1))
 S NUM1=+$G(^TMP("BGPMU0421",$J,TF,"NUM",1))
 S NOT1=+$G(^TMP("BGPMU0421",$J,TF,"NOT",1))
 S EXC1=+$G(^TMP("BGPMU0421",$J,TF,"EXC",1))
 S DEN2=+$G(^TMP("BGPMU0421",$J,TF,"DEN",2))
 S NUM2=+$G(^TMP("BGPMU0421",$J,TF,"NUM",2))
 S EXC2=+$G(^TMP("BGPMU0421",$J,TF,"EXC",2))
 S NOT2=+$G(^TMP("BGPMU0421",$J,TF,"NOT",2))
 S NNUM1=DEN1-EXC1
 S NNUM2=DEN2-EXC2
 I DEN1=0 S (PC1,PC11,PC13,PC14)=0
 I DEN1>0 D
 .S PC1=$$ROUND^BGPMUA01((NUM1/NNUM1),3)*100
 .S PC11=$$ROUND^BGPMUA01((NNUM1/DEN1),3)*100
 .S PC13=$$ROUND^BGPMUA01((EXC1/DEN1),3)*100
 .S PC14=$$ROUND^BGPMUA01((NOT1/NNUM1),3)*100
 I DEN2=0 S (PC2,PC21,PC23,PC24)=0
 I DEN2>0 D
 .S PC2=$$ROUND^BGPMUA01((NUM2/NNUM2),3)*100
 .S PC21=$$ROUND^BGPMUA01((NNUM2/DEN2),3)*100
 .S PC23=$$ROUND^BGPMUA01((EXC2/DEN2),3)*100
 .S PC24=$$ROUND^BGPMUA01((NOT2/NNUM2),3)*100
 S ARRAY=DEN1_U_NUM1_U_NNUM1_U_EXC1_U_PC1_U_PC11_U_PC13_U_DEN2_U_NUM2_U_NNUM2_U_EXC2_U_PC2_U_PC21_U_PC23
 S ARRAY=ARRAY_U_NOT1_U_PC14_U_NOT2_U_PC24
 Q ARRAY
P2 ;Do the Details
 N PT,NODE,NAME,VST,BMI,FOL,X,PTCT
 S PTCT=0
 S X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT ****" D S^BGPMUDEL(X,2,1)
 S X="Patients 18+ with at least 1 encounter with the EP during the reporting period." D S^BGPMUDEL(X,1,1)
 S X="with documented BMI and follow-up, if any." D S^BGPMUDEL(X,1,1)
 S X="Patients who do not meet the numerator criteria are listed first (NM:)," D S^BGPMUDEL(X,2,1)
 S X="by patients who do meet the numerator criteria (M:)." D S^BGPMUDEL(X,1,1)
 S X="The following are the abbreviations used in the denominator column" D S^BGPMUDEL(X,2,1)
 S X="EN=Encounter" D S^BGPMUDEL(X,1,1)
 S X="Patients 65+" D S^BGPMUDEL(X,2,1)
 S X="PATIENT NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR" D S^BGPMUDEL(X,2,1)
 I BGPLIST="D"!(BGPLIST="A") D
 .K BGPARR
 .D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",1,""NOT"")")
 .S PT=0 F  S PT=$O(BGPARR(PT)) Q:PT=""  D
 ..S PTCT=PTCT+1
 ..S NODE=$G(BGPARR(PT))
 ..D DATA(NODE)
 I BGPLIST="N"!(BGPLIST="A") D
 .K BGPARR
 .D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",1,""NUM"")")
 .S PT=0 F  S PT=$O(BGPARR(PT)) Q:PT=""  D
 ..S PTCT=PTCT+1
 ..S NODE=$G(BGPARR(PT))
 ..D DATA(NODE)
 I BGPLIST="A" D
 .K BGPARR
 .D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",1,""EXC"")")
 .S PT=0 F  S PT=$O(BGPARR(PT)) Q:PT=""  D
 ..S PTCT=PTCT+1
 ..S NODE=$G(BGPARR(PT))
 ..D DATA(NODE)
 S X="Total # of patients on list: "_PTCT D S^BGPMUDEL(X,2,1)
 S X="Patients 18-64" D S^BGPMUDEL(X,2,1)
 S X="PATIENT NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR" D S^BGPMUDEL(X,2,1)
 S PTCT=0
 I BGPLIST="D"!(BGPLIST="A") D
 .K BGPARR
 .D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",2,""NOT"")")
 .S PT=0 F  S PT=$O(BGPARR(PT)) Q:PT=""  D
 ..S PTCT=PTCT+1
 ..S NODE=$G(BGPARR(PT))
 ..D DATA(NODE)
 .K BGPARR
 .D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",2,""NUM"")")
 .S PT=0 F  S PT=$O(BGPARR(PT)) Q:PT=""  D
 ..S PTCT=PTCT+1
 ..S NODE=$G(BGPARR(PT))
 ..D DATA(NODE)
 I BGPLIST="A" D
 .K BGPARR
 .D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0421"","_$J_",""PAT"",""C"",2,""EXC"")")
 .S PT=0 F  S PT=$O(BGPARR(PT)) Q:PT=""  D
 ..S PTCT=PTCT+1
 ..S NODE=$G(BGPARR(PT))
 ..D DATA(NODE)
 S X="Total # of patients on list: "_PTCT D S^BGPMUDEL(X,2,1)
 Q
DATA(NODE) ;GET DATA
 N NAME,HRN,DEN,NUM,AGE,DFN,SEX,COMM
 S DFN=$P(NODE,U,1)
 S NAME=$E($$GET1^DIQ(2,$P(NODE,U,1),.01),1,30)
 S HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
 S AGE=$$AGE^AUPNPAT(DFN,BGPED)
 S COMM=$$GET1^DIQ(9000001,DFN,1118)
 S SEX=$P(^DPT(DFN,0),U,2)
 S DEN=$P(NODE,U,2),NUM=$P(NODE,U,4)
 S X=NAME_U_HRN_U_COMM_U_SEX_U_AGE_U_DEN_U_NUM D S^BGPMUDEL(X,1,1)
 Q
DATA2(NODE) ;GET DATA
 N NAME,HRN,DEN,AGE,DFN,SEX,COMM
 S DFN=$P(NODE,U,1)
 S NAME=$E($$GET1^DIQ(2,$P(NODE,U,1),.01),1,30)
 S HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
 S AGE=$$AGE^AUPNPAT(DFN,BGPED)
 S COMM=$$GET1^DIQ(9000001,DFN,1118)
 S SEX=$P(^DPT(DFN,0),U,2)
 S DEN=$P(NODE,U,2),NUM=$P(NODE,U,3)
 S X=NAME_U_HRN_U_COMM_U_SEX_U_AGE_U_DEN_U_NUM D S^BGPMUDEL(X,1,1)
 Q
 ;Get printout for BP measure
BLOODP ;EP
 D BP1
 K ^TMP("BGPMU0013",$J)
 Q
BP1 ;Write individual measure
 N X,Y,Z,DEN,NUM,PC,STRING1,STRING2,PRD,PRN,PRD1,PRN1
 S STRING1=$$0013("C")
 S STRING2=$$0013("P")
 S STRING3=$$0013("B")
 D SUMMARY2^BGPMUAP1(STRING1,STRING2,STRING3)
 S PRD=$P(STRING1,U,4)-$P(STRING2,U,4) I PRD>0 S PRD="+"_PRD
 S PRD1=$P(STRING1,U,5)-$P(STRING2,U,5) I PRD1>0 S PRD1="+"_PRD1
 S PRN=$P(STRING1,U,4)-$P(STRING3,U,4) I PRN>0 S PRN="+"_PRN
 S PRN1=$P(STRING1,U,5)-$P(STRING3,U,5) I PRN1>0 S PRN="+"_PRN1
 S X=U_"REPORT PERIOD"_U_"%"_U_"PREV YR PERIOD"_U_"%"_U_"CHG FROM PREV YR"_U_"BASE YEAR"_U_"%"_U_"CHG FROM BASE"
 D S^BGPMUDEL(X,2,1)
 S X="Pts 18+ w/HTN"_U_$P(STRING1,U,1)_U_U_$P(STRING2,U,1)_U_U_U_$P(STRING3,U,1) D S^BGPMUDEL(X,2,1)
 S X="# w/=>2 BP recorded"_U_$P(STRING1,U,2)_U_$P(STRING1,U,4)_U_$P(STRING2,U,2)_U_$P(STRING2,U,4)_U_PRD_U_$P(STRING3,U,2)_U_$P(STRING3,U,4)_U_PRN
 D S^BGPMUDEL(X,2,1)
 S X="# w/o=> 2 BP recorded"_U_$P(STRING1,U,3)_U_$P(STRING1,U,5)_U_$P(STRING2,U,3)_U_$P(STRING2,U,5)_U_PRD1_U_$P(STRING3,U,3)_U_$P(STRING3,U,5)_U_PRN1
 D S^BGPMUDEL(X,1,1)
 I $D(BGPLIST(BGPIC)) D BP2
 Q
0013(TF) ;Get the numbers for this measure
 N ARRAY,DEN,NUM,PC1,PC2,NOT
 S DEN=+$G(^TMP("BGPMU0013",$J,TF,"DEN"))
 S NUM=+$G(^TMP("BGPMU0013",$J,TF,"NUM"))
 S NOT=+$G(^TMP("BGPMU0013",$J,TF,"NOT"))
 I DEN=0 S (PC1,PC2)=0
 I DEN>0 D
 .S PC1=$$ROUND^BGPMUA01((NUM/DEN),3)*100
 .S PC2=$$ROUND^BGPMUA01((NOT/DEN),3)*100
 S ARRAY=DEN_U_NUM_U_NOT_U_PC1_U_PC2
 Q ARRAY
BP2 ;Do the Details
 N PT,NODE,NAME,BP,PTCT
 S X="**** CONFIDENTIAL PATIENT INFORMATION COVERED BY PRIVACY ACT ****" D S^BGPMUDEL(X,2,1)
 S X="Hypertensive patients 18+ with at least 2 encounters with the EP during the" D S^BGPMUDEL(X,1,1)
 S X="reporting period, with => 2 documented BPs during the encounters, if any." D S^BGPMUDEL(X,1,1)
 S X="Patients who do not meet the numerator criteria are listed first (NM:)," D S^BGPMUDEL(X,2,1)
 S X="followed by patients who do meet the numerator criteria (M:)." D S^BGPMUDEL(X,1,1)
 S X="The following are the abbreviations used in the denominator and numerator" D S^BGPMUDEL(X,2,1)
 S X="columns: " D S^BGPMUDEL(X,1,1)
 S X="EN=Encounter" D S^BGPMUDEL(X,1,1)
 S PTCT=0
 S X="Details for pts in numerator  Age > 18" D S^BGPMUDEL(X,2,1)
 S X="NAME"_U_"HRN"_U_"COMMUNITY"_U_"SEX"_U_"AGE"_U_"DENOMINATOR"_U_"NUMERATOR" D S^BGPMUDEL(X,2,1)
 I BGPLIST="D"!(BGPLIST="A") D
 .K BGPARR
 .D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0013"","_$J_",""PAT"",""C"",""NOT"")")
 .S PT=0 F  S PT=$O(BGPARR(PT)) Q:PT=""  D
 ..S PTCT=PTCT+1
 ..S NODE=$G(BGPARR(PT))
 ..D DATA2(NODE)
 I BGPLIST="N"!(BGPLIST="A") D
 .K BGPARR
 .D PTLSORT^BGPMUUTL(.BGPARR,"^TMP(""BGPMU0013"","_$J_",""PAT"",""C"",""NUM"")")
 .S PT=0 F  S PT=$O(BGPARR(PT)) Q:PT=""  D
 ..S PTCT=PTCT+1
 ..S NODE=$G(BGPARR(PT))
 ..D DATA2(NODE)
 S X="Total # of patients on list: "_PTCT D S^BGPMUDEL(X,2,1)
 Q
XML0421 ;XML output for adi;t BMI measure
 ; BGPXML(i)=Population Number^Numerator Number^Denominator Count
 N STRING,TOTN,TOTD,TOTE
 S STRING=$$421("C")
 S TOTD=$P(STRING,U,1)+$P(STRING,U,8)
 S TOTN=$P(STRING,U,2)+$P(STRING,U,9)
 S TOTE=$P(STRING,U,4)+$P(STRING,U,11)
 S BGPXML(1)="128"_U_U_+TOTD_U_TOTN_U_TOTE
 K ^TMP("BGPMU0421",$J)
 Q
XML0013 ;XML output for hypertension measure
 ; BGPXML(i)=Population Number^Numerator Number^Denominator Count
 N STRING
 S STRING=$$0013("C")
 S BGPXML(1)="237"_U_U_+$P(STRING,U,1)_U_+$P(STRING,U,2)
 K ^TMP("BGPMU0013",$J)
 Q