BGPMUHP1 ; IHS/MSC/JSM - MU EH measure output routines;13-May-2011 16:13;MGH
;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
; ED1^BGPMUHP1 = output routine for 0495 ED-1
; ED2^BGPMUHP1 = output routine for 0497 ED-2
;
; STK2^BGPMUHP2 = output routine for 0435 STK-2 Antithrombolytic Therapy at discharge
; STK3^BGPMUHP2 = output routine for 0436 STK-3 Anticoagulation Therapy at discharge
; STK4^BGPMUHP3 = output routine for 0437 STK-4 thrombolytic therapy within 3 hours
; STK5^BGPMUHP3 = output routine for 0438 STK-5 Antithrombolytic Therapy by end of day 2
; STK6^BGPMUHP4 = output routine for 0439 STK-6 Statin Medicine at Discharge
; STK8^BGPMUHP4 = output routine for 0440 STK-8 Educational Materials at discharge
; STK10^BGPMUHP5 = output routine for 0441 STK-10 Rehabilitation Service at discharge
;
; VTE1^BGPMUP6 = output routine for 0371 VTE-1 Prophylaxis within 24 hours
; VTE2^BGPMUP6 = output routine for 0372 VTE-2 Prophylaxis for ICU pts
; VTE3^BGPMUP7 = output routine for 0373 VTE-3 Anticoagulation overlap therapy
; VTE4^BGPMUP7 = output routine for 0374 VTE-4 Platelet monitoring for UFH
; VTE5^BGPMUP8 = output routine for 0375 VTE-5 VTE discharge instructions
; VTE6^BGPMUP8 = output routine for 0376 VTE-6 Potentially preventable VTE
;
ED1 ;EH output routine for 0495 ED-1 (BGPMUH01)
D P1
K ^TMP("BGPMU0495",$J)
Q
P1 ;Write individual measure
N X,Y,Z,LIST1,LIST2,LIST3
N POP1,POP2,POP3,STRING1,STRING2,STRING3,PRP1,PRP2,PRP3,PRB1,PRB2,PRB3
S STRING1=$$495("C")
S STRING2=$$495("P")
S STRING3=$$495("B")
S PRP1=$P(STRING1,U,1)-$P(STRING2,U,1)
S PRP2=$P(STRING1,U,2)-$P(STRING2,U,2)
S PRP3=$P(STRING1,U,3)-$P(STRING2,U,3)
S PRB1=$P(STRING1,U,1)-$P(STRING3,U,1)
S PRB2=$P(STRING1,U,2)-$P(STRING3,U,2)
S PRB3=$P(STRING1,U,3)-$P(STRING3,U,3)
;I $Y>(BGPIOSL-3) D HEADER^BGPMUPH Q:BGPQUIT
D HEADER^BGPMUPH Q:BGPQUIT
D HDRBLK^BGPMUPH
W !,"Median Elpsd Time (min)",?33,$P(STRING1,U,1),?44,$P(STRING2,U,1),?56,PRP1,?65,$P(STRING3,U,1),?72,PRB1
W !,"BTW ED Arrival &"
W !,"ED Departure -"
W !,"All ED Pts Excl"
W !,"Pts w/Mental Disorder"
W !,"or Observation Status"
W !
I $Y>(BGPIOSL-5) D HEADER^BGPMUPH Q:BGPQUIT
W !,"Median Elpsd Time (min)",?33,$P(STRING1,U,2),?44,$P(STRING2,U,2),?56,PRP2,?65,$P(STRING3,U,2),?72,PRB2
W !,"BTW ED Arrival &"
W !,"ED Departure -"
W !,"ED Observation Status"
W !,"Pts only"
W !
I $Y>(BGPIOSL-5) D HEADER^BGPMUPH Q:BGPQUIT
W !,"Median Elpsd Time (min)",?33,$P(STRING1,U,3),?44,$P(STRING2,U,3),?56,PRP3,?65,$P(STRING3,U,3),?72,PRB3
W !,"BTW ED Arrival &"
W !,"ED Departure -"
W !,"ED Mental Disorder"
W !,"Pts only"
I $D(BGPLIST(BGPIC)) D P1D
D SUM495^BGPMUHD8
Q
495(TF) ;Get the numbers for this measure
N ARRAY
S POP1=+$G(^TMP("BGPMU0495",$J,TF,"POP",1))
S POP2=+$G(^TMP("BGPMU0495",$J,TF,"POP",2))
S POP3=+$G(^TMP("BGPMU0495",$J,TF,"POP",3))
S ARRAY=POP1_U_POP2_U_POP3
Q ARRAY
P1D ;Do the Details
N POP,PT,PTCT
D HEADERL^BGPMUPH
W !!,"Elapsed times are stratified as follows: A) All ED patients excluding patients"
W !,"with mental disorders or placed into observation status, B) ED patients placed"
W !,"into observation status, and C) ED patients with a mental disorder."
W !!,"The following are the abbreviations used in the denominator and numerator"
W !,"columns:"
W !,"N/A=Not Applicable - No Denominators for this Measure"
W !,"ED=ED Patient, Excl Mental Disorder & Observation Status"
W !,"MD=ED Mental Disorder Patient"
W !,"OS=ED Observation Status Patient"
I $Y>(BGPIOSL-7) D HEADERL^BGPMUPH Q:BGPQUIT
W !!,"A) All ED patients excluding patients with mental disorders or placed into"
W !,"observation status"
;Patients not Mental health or Observation
W !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
S LINE="",$P(LINE,"-",79)="" W !,LINE
S POP=1,PTCT=0,BGPMUTF="C"
S PT=0 F S PT=$O(^TMP("BGPMU0495",$J,"C","POP",POP,"PAT",PT)) Q:'+PT D
.S PTCT=PTCT+1
.S NODE=$G(^TMP("BGPMU0495",$J,"C","POP",POP,"PAT",PT))
.D DATA(NODE)
W !!,"Total # of ED visits on list: "_PTCT
S PTCT=0
;"Observation Pts seen in ER"
I $Y>(BGPIOSL-7) D HEADERL^BGPMUPH Q:BGPQUIT
W !!,"B) ED patients placed into observation status"
W !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
S LINE="",$P(LINE,"-",79)="" W !,LINE
S POP=2
S PT=0 F S PT=$O(^TMP("BGPMU0495",$J,"C","POP",POP,"PAT",PT)) Q:'+PT D
.S PTCT=PTCT+1
.S NODE=$G(^TMP("BGPMU0495",$J,"C","POP",POP,"PAT",PT))
.D DATA(NODE)
W !!,"Total # of ED visits on list: "_PTCT
S PTCT=0
;Mental health patients seen in ER"
I $Y>(BGPIOSL-7) D HEADERL^BGPMUPH Q:BGPQUIT
W !!,"C) ED patients with a mental disorder"
W !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
S LINE="",$P(LINE,"-",79)="" W !,LINE
S POP=3
S PT=0 F S PT=$O(^TMP("BGPMU0495",$J,"C","POP",POP,"PAT",PT)) Q:'+PT D
.S PTCT=PTCT+1
.S NODE=$G(^TMP("BGPMU0495",$J,"C","POP",POP,"PAT",PT))
.D DATA(NODE)
W !!,"Total # of ED visits on list: "_PTCT
Q
;
ED2 ;EH output routine for 0497 ED-2 (BGPMUH01)
D P2
K ^TMP("BGPMU0497",$J)
Q
P2 ;Write individual measure
N X,Y,Z,LIST1,LIST2,LIST3
N POP1,POP2,POP3,STRING1,STRING2,STRING3,PRP1,PRP2,PRP3,PRB1,PRB2,PRB3
S STRING1=$$497("C")
S STRING2=$$497("P")
S STRING3=$$497("B")
S PRP1=$P(STRING1,U,1)-$P(STRING2,U,1)
S PRP2=$P(STRING1,U,2)-$P(STRING2,U,2)
S PRP3=$P(STRING1,U,3)-$P(STRING2,U,3)
S PRB1=$P(STRING1,U,1)-$P(STRING3,U,1)
S PRB2=$P(STRING1,U,2)-$P(STRING3,U,2)
S PRB3=$P(STRING1,U,3)-$P(STRING3,U,3)
;I $Y>(BGPIOSL-3) D HEADER^BGPMUPH Q:BGPQUIT
D HEADER^BGPMUPH Q:BGPQUIT
D HDRBLK^BGPMUPH
W !,"Median Elpsd Time (min)",?33,$P(STRING1,U,1),?44,$P(STRING2,U,1),?56,PRP1,?65,$P(STRING3,U,1),?72,PRB1
W !,"BTW ED Admit Decision"
W !,"& ED Departure -"
W !,"All ED Pts Excl Pts"
W !,"w/Mental Disorder or"
W !,"Observation Status"
W !
I $Y>(BGPIOSL-5) D HEADER^BGPMUPH Q:BGPQUIT
W !,"Median Elpsd Time (min)",?33,$P(STRING1,U,2),?44,$P(STRING2,U,2),?56,PRP2,?65,$P(STRING3,U,2),?72,PRB2
W !,"BTW ED Admit Decision"
W !,"& ED Departure -"
W !,"ED Observation Status"
W !,"Pts only"
W !
I $Y>(BGPIOSL-5) D HEADER^BGPMUPH Q:BGPQUIT
W !,"Median Elpsd Time (min)",?33,$P(STRING1,U,3),?44,$P(STRING2,U,3),?56,PRP3,?65,$P(STRING3,U,3),?72,PRB3
W !,"BTW ED Admit Decision"
W !,"& ED Departure -"
W !,"ED Mental Disorder"
W !,"Pts only"
I $D(BGPLIST(BGPIC)) D P2D
D SUM497^BGPMUHD8
Q
497(TF) ;Get the numbers for this measure
N ARRAY
S POP1=+$G(^TMP("BGPMU0497",$J,TF,"POP",1))
S POP2=+$G(^TMP("BGPMU0497",$J,TF,"POP",2))
S POP3=+$G(^TMP("BGPMU0497",$J,TF,"POP",3))
S ARRAY=POP1_U_POP2_U_POP3
Q ARRAY
P2D ;Do the Details
N POP,PT,PTCT
D HEADERL^BGPMUPH
W !!,"Elapsed times are stratified as follows: A) All ED patients excluding patients"
W !,"with mental disorders or placed into observation status, B) ED patients placed"
W !,"into observation status, and C) ED patients with a mental disorder."
W !!,"The following are the abbreviations used in the denominator and numerator"
W !,"columns:"
W !,"N/A=Not Applicable - No Denominators for this Measure"
W !,"ED=ED Patient, Excl Mental Disorder & Observation Status"
W !,"MD=ED Mental Disorder Patient"
W !,"OS=ED Observation Status Patient"
I $Y>(BGPIOSL-7) D HEADERL^BGPMUPH Q:BGPQUIT
W !!,"A) All ED patients excluding patients with mental disorders or placed into"
W !,"observation status"
;Patients not Mental health or Observation
W !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
S LINE="",$P(LINE,"-",79)="" W !,LINE
S POP=1,PTCT=0,BGPMUTF="C"
S PT=0 F S PT=$O(^TMP("BGPMU0497",$J,"C","POP",POP,"PAT",PT)) Q:'+PT D
.S PTCT=PTCT+1
.S NODE=$G(^TMP("BGPMU0497",$J,"C","POP",POP,"PAT",PT))
.D DATA(NODE)
W !!,"Total # of ED visits on list: "_PTCT
S PTCT=0
;Observation Pts seen in ER
I $Y>(BGPIOSL-7) D HEADERL^BGPMUPH Q:BGPQUIT
W !!,"B) ED patients placed into observation status"
W !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
S LINE="",$P(LINE,"-",79)="" W !,LINE
S POP=2
S PT=0 F S PT=$O(^TMP("BGPMU0497",$J,"C","POP",POP,"PAT",PT)) Q:'+PT D
.S PTCT=PTCT+1
.S NODE=$G(^TMP("BGPMU0497",$J,"C","POP",POP,"PAT",PT))
.D DATA(NODE)
W !!,"Total # of ED visits on list: "_PTCT
S PTCT=0
;Mental health patients seen in ER
I $Y>(BGPIOSL-7) D HEADERL^BGPMUPH Q:BGPQUIT
W !!,"C) ED patients with a mental disorder"
W !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
S LINE="",$P(LINE,"-",79)="" W !,LINE
S POP=3
S PT=0 F S PT=$O(^TMP("BGPMU0497",$J,"C","POP",POP,"PAT",PT)) Q:'+PT D
.S PTCT=PTCT+1
.S NODE=$G(^TMP("BGPMU0497",$J,"C","POP",POP,"PAT",PT))
.D DATA(NODE)
W !!,"Total # of ED visits on list: "_PTCT
Q
;
DATA(NODE) ;GET DATA
N NAME,HRN,DEN,NUM,AGE,DFN,COMM,SEX
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 DEN="N/A",NUM=$P(NODE,U,2)
S SEX=$P($G(^DPT(DFN,0)),U,2)
S COMM=$E($$GET1^DIQ(9000001,DFN,1118),1,10)
I $Y>(BGPIOSL-2) D
.D HEADERL^BGPMUPH Q:BGPQUIT
.W !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
.S LINE="",$P(LINE,"-",79)="" W !,LINE
W !,NAME,?25,HRN,?33,COMM,?44,SEX,?47,AGE,?51,DEN,?64,NUM
Q
;
XML495 ;Populate the BGPXML array with data for each population/numerator
; BGPXMLOUT(i)=Measure number^""^Denominator Count^Numerator Count^Exclusion Count
S BGPXML(1)="NQF_0495_1"_U_""_U_+$P($G(^TMP("BGPMU0495",$J,"C","POP",1)),U,2)_U_+$P($G(^TMP("BGPMU0495",$J,"C","POP",1)),U,1)
S BGPXML(2)="NQF_0495_2"_U_""_U_+$P($G(^TMP("BGPMU0495",$J,"C","POP",2)),U,2)_U_+$P($G(^TMP("BGPMU0495",$J,"C","POP",2)),U,1)
S BGPXML(3)="NQF_0495_3"_U_""_U_+$P($G(^TMP("BGPMU0495",$J,"C","POP",3)),U,2)_U_+$P($G(^TMP("BGPMU0495",$J,"C","POP",3)),U,1)
K ^TMP("BGPMU0495",$J)
Q
XML497 ;Populate the BGPXML array with data for each population/numerator
; BGPXMLOUT(i)=Measure number^""^Denominator Count^Numerator Count^Exclusion Count
S BGPXML(1)="NQF_0497_1"_U_""_U_+$P($G(^TMP("BGPMU0497",$J,"C","POP",1)),U,2)_U_+$P($G(^TMP("BGPMU0497",$J,"C","POP",1)),U,1)
S BGPXML(2)="NQF_0497_2"_U_""_U_+$P($G(^TMP("BGPMU0497",$J,"C","POP",2)),U,2)_U_+$P($G(^TMP("BGPMU0497",$J,"C","POP",2)),U,1)
S BGPXML(3)="NQF_0497_3"_U_""_U_+$P($G(^TMP("BGPMU0497",$J,"C","POP",3)),U,2)_U_+$P($G(^TMP("BGPMU0497",$J,"C","POP",3)),U,1)
K ^TMP("BGPMU0497",$J)
Q
BGPMUHP1 ; IHS/MSC/JSM - MU EH measure output routines;13-May-2011 16:13;MGH
+1 ;;14.1;IHS CLINICAL REPORTING;**1**;MAY 29, 2014;Build 2
+2 ; ED1^BGPMUHP1 = output routine for 0495 ED-1
+3 ; ED2^BGPMUHP1 = output routine for 0497 ED-2
+4 ;
+5 ; STK2^BGPMUHP2 = output routine for 0435 STK-2 Antithrombolytic Therapy at discharge
+6 ; STK3^BGPMUHP2 = output routine for 0436 STK-3 Anticoagulation Therapy at discharge
+7 ; STK4^BGPMUHP3 = output routine for 0437 STK-4 thrombolytic therapy within 3 hours
+8 ; STK5^BGPMUHP3 = output routine for 0438 STK-5 Antithrombolytic Therapy by end of day 2
+9 ; STK6^BGPMUHP4 = output routine for 0439 STK-6 Statin Medicine at Discharge
+10 ; STK8^BGPMUHP4 = output routine for 0440 STK-8 Educational Materials at discharge
+11 ; STK10^BGPMUHP5 = output routine for 0441 STK-10 Rehabilitation Service at discharge
+12 ;
+13 ; VTE1^BGPMUP6 = output routine for 0371 VTE-1 Prophylaxis within 24 hours
+14 ; VTE2^BGPMUP6 = output routine for 0372 VTE-2 Prophylaxis for ICU pts
+15 ; VTE3^BGPMUP7 = output routine for 0373 VTE-3 Anticoagulation overlap therapy
+16 ; VTE4^BGPMUP7 = output routine for 0374 VTE-4 Platelet monitoring for UFH
+17 ; VTE5^BGPMUP8 = output routine for 0375 VTE-5 VTE discharge instructions
+18 ; VTE6^BGPMUP8 = output routine for 0376 VTE-6 Potentially preventable VTE
+19 ;
ED1 ;EH output routine for 0495 ED-1 (BGPMUH01)
+1 DO P1
+2 KILL ^TMP("BGPMU0495",$JOB)
+3 QUIT
P1 ;Write individual measure
+1 NEW X,Y,Z,LIST1,LIST2,LIST3
+2 NEW POP1,POP2,POP3,STRING1,STRING2,STRING3,PRP1,PRP2,PRP3,PRB1,PRB2,PRB3
+3 SET STRING1=$$495("C")
+4 SET STRING2=$$495("P")
+5 SET STRING3=$$495("B")
+6 SET PRP1=$PIECE(STRING1,U,1)-$PIECE(STRING2,U,1)
+7 SET PRP2=$PIECE(STRING1,U,2)-$PIECE(STRING2,U,2)
+8 SET PRP3=$PIECE(STRING1,U,3)-$PIECE(STRING2,U,3)
+9 SET PRB1=$PIECE(STRING1,U,1)-$PIECE(STRING3,U,1)
+10 SET PRB2=$PIECE(STRING1,U,2)-$PIECE(STRING3,U,2)
+11 SET PRB3=$PIECE(STRING1,U,3)-$PIECE(STRING3,U,3)
+12 ;I $Y>(BGPIOSL-3) D HEADER^BGPMUPH Q:BGPQUIT
+13 DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+14 DO HDRBLK^BGPMUPH
+15 WRITE !,"Median Elpsd Time (min)",?33,$PIECE(STRING1,U,1),?44,$PIECE(STRING2,U,1),?56,PRP1,?65,$PIECE(STRING3,U,1),?72,PRB1
+16 WRITE !,"BTW ED Arrival &"
+17 WRITE !,"ED Departure -"
+18 WRITE !,"All ED Pts Excl"
+19 WRITE !,"Pts w/Mental Disorder"
+20 WRITE !,"or Observation Status"
+21 WRITE !
+22 IF $Y>(BGPIOSL-5)
DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+23 WRITE !,"Median Elpsd Time (min)",?33,$PIECE(STRING1,U,2),?44,$PIECE(STRING2,U,2),?56,PRP2,?65,$PIECE(STRING3,U,2),?72,PRB2
+24 WRITE !,"BTW ED Arrival &"
+25 WRITE !,"ED Departure -"
+26 WRITE !,"ED Observation Status"
+27 WRITE !,"Pts only"
+28 WRITE !
+29 IF $Y>(BGPIOSL-5)
DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+30 WRITE !,"Median Elpsd Time (min)",?33,$PIECE(STRING1,U,3),?44,$PIECE(STRING2,U,3),?56,PRP3,?65,$PIECE(STRING3,U,3),?72,PRB3
+31 WRITE !,"BTW ED Arrival &"
+32 WRITE !,"ED Departure -"
+33 WRITE !,"ED Mental Disorder"
+34 WRITE !,"Pts only"
+35 IF $DATA(BGPLIST(BGPIC))
DO P1D
+36 DO SUM495^BGPMUHD8
+37 QUIT
495(TF) ;Get the numbers for this measure
+1 NEW ARRAY
+2 SET POP1=+$GET(^TMP("BGPMU0495",$JOB,TF,"POP",1))
+3 SET POP2=+$GET(^TMP("BGPMU0495",$JOB,TF,"POP",2))
+4 SET POP3=+$GET(^TMP("BGPMU0495",$JOB,TF,"POP",3))
+5 SET ARRAY=POP1_U_POP2_U_POP3
+6 QUIT ARRAY
P1D ;Do the Details
+1 NEW POP,PT,PTCT
+2 DO HEADERL^BGPMUPH
+3 WRITE !!,"Elapsed times are stratified as follows: A) All ED patients excluding patients"
+4 WRITE !,"with mental disorders or placed into observation status, B) ED patients placed"
+5 WRITE !,"into observation status, and C) ED patients with a mental disorder."
+6 WRITE !!,"The following are the abbreviations used in the denominator and numerator"
+7 WRITE !,"columns:"
+8 WRITE !,"N/A=Not Applicable - No Denominators for this Measure"
+9 WRITE !,"ED=ED Patient, Excl Mental Disorder & Observation Status"
+10 WRITE !,"MD=ED Mental Disorder Patient"
+11 WRITE !,"OS=ED Observation Status Patient"
+12 IF $Y>(BGPIOSL-7)
DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+13 WRITE !!,"A) All ED patients excluding patients with mental disorders or placed into"
+14 WRITE !,"observation status"
+15 ;Patients not Mental health or Observation
+16 WRITE !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
+17 SET LINE=""
SET $PIECE(LINE,"-",79)=""
WRITE !,LINE
+18 SET POP=1
SET PTCT=0
SET BGPMUTF="C"
+19 SET PT=0
FOR
SET PT=$ORDER(^TMP("BGPMU0495",$JOB,"C","POP",POP,"PAT",PT))
IF '+PT
QUIT
Begin DoDot:1
+20 SET PTCT=PTCT+1
+21 SET NODE=$GET(^TMP("BGPMU0495",$JOB,"C","POP",POP,"PAT",PT))
+22 DO DATA(NODE)
End DoDot:1
+23 WRITE !!,"Total # of ED visits on list: "_PTCT
+24 SET PTCT=0
+25 ;"Observation Pts seen in ER"
+26 IF $Y>(BGPIOSL-7)
DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+27 WRITE !!,"B) ED patients placed into observation status"
+28 WRITE !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
+29 SET LINE=""
SET $PIECE(LINE,"-",79)=""
WRITE !,LINE
+30 SET POP=2
+31 SET PT=0
FOR
SET PT=$ORDER(^TMP("BGPMU0495",$JOB,"C","POP",POP,"PAT",PT))
IF '+PT
QUIT
Begin DoDot:1
+32 SET PTCT=PTCT+1
+33 SET NODE=$GET(^TMP("BGPMU0495",$JOB,"C","POP",POP,"PAT",PT))
+34 DO DATA(NODE)
End DoDot:1
+35 WRITE !!,"Total # of ED visits on list: "_PTCT
+36 SET PTCT=0
+37 ;Mental health patients seen in ER"
+38 IF $Y>(BGPIOSL-7)
DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+39 WRITE !!,"C) ED patients with a mental disorder"
+40 WRITE !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
+41 SET LINE=""
SET $PIECE(LINE,"-",79)=""
WRITE !,LINE
+42 SET POP=3
+43 SET PT=0
FOR
SET PT=$ORDER(^TMP("BGPMU0495",$JOB,"C","POP",POP,"PAT",PT))
IF '+PT
QUIT
Begin DoDot:1
+44 SET PTCT=PTCT+1
+45 SET NODE=$GET(^TMP("BGPMU0495",$JOB,"C","POP",POP,"PAT",PT))
+46 DO DATA(NODE)
End DoDot:1
+47 WRITE !!,"Total # of ED visits on list: "_PTCT
+48 QUIT
+49 ;
ED2 ;EH output routine for 0497 ED-2 (BGPMUH01)
+1 DO P2
+2 KILL ^TMP("BGPMU0497",$JOB)
+3 QUIT
P2 ;Write individual measure
+1 NEW X,Y,Z,LIST1,LIST2,LIST3
+2 NEW POP1,POP2,POP3,STRING1,STRING2,STRING3,PRP1,PRP2,PRP3,PRB1,PRB2,PRB3
+3 SET STRING1=$$497("C")
+4 SET STRING2=$$497("P")
+5 SET STRING3=$$497("B")
+6 SET PRP1=$PIECE(STRING1,U,1)-$PIECE(STRING2,U,1)
+7 SET PRP2=$PIECE(STRING1,U,2)-$PIECE(STRING2,U,2)
+8 SET PRP3=$PIECE(STRING1,U,3)-$PIECE(STRING2,U,3)
+9 SET PRB1=$PIECE(STRING1,U,1)-$PIECE(STRING3,U,1)
+10 SET PRB2=$PIECE(STRING1,U,2)-$PIECE(STRING3,U,2)
+11 SET PRB3=$PIECE(STRING1,U,3)-$PIECE(STRING3,U,3)
+12 ;I $Y>(BGPIOSL-3) D HEADER^BGPMUPH Q:BGPQUIT
+13 DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+14 DO HDRBLK^BGPMUPH
+15 WRITE !,"Median Elpsd Time (min)",?33,$PIECE(STRING1,U,1),?44,$PIECE(STRING2,U,1),?56,PRP1,?65,$PIECE(STRING3,U,1),?72,PRB1
+16 WRITE !,"BTW ED Admit Decision"
+17 WRITE !,"& ED Departure -"
+18 WRITE !,"All ED Pts Excl Pts"
+19 WRITE !,"w/Mental Disorder or"
+20 WRITE !,"Observation Status"
+21 WRITE !
+22 IF $Y>(BGPIOSL-5)
DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+23 WRITE !,"Median Elpsd Time (min)",?33,$PIECE(STRING1,U,2),?44,$PIECE(STRING2,U,2),?56,PRP2,?65,$PIECE(STRING3,U,2),?72,PRB2
+24 WRITE !,"BTW ED Admit Decision"
+25 WRITE !,"& ED Departure -"
+26 WRITE !,"ED Observation Status"
+27 WRITE !,"Pts only"
+28 WRITE !
+29 IF $Y>(BGPIOSL-5)
DO HEADER^BGPMUPH
IF BGPQUIT
QUIT
+30 WRITE !,"Median Elpsd Time (min)",?33,$PIECE(STRING1,U,3),?44,$PIECE(STRING2,U,3),?56,PRP3,?65,$PIECE(STRING3,U,3),?72,PRB3
+31 WRITE !,"BTW ED Admit Decision"
+32 WRITE !,"& ED Departure -"
+33 WRITE !,"ED Mental Disorder"
+34 WRITE !,"Pts only"
+35 IF $DATA(BGPLIST(BGPIC))
DO P2D
+36 DO SUM497^BGPMUHD8
+37 QUIT
497(TF) ;Get the numbers for this measure
+1 NEW ARRAY
+2 SET POP1=+$GET(^TMP("BGPMU0497",$JOB,TF,"POP",1))
+3 SET POP2=+$GET(^TMP("BGPMU0497",$JOB,TF,"POP",2))
+4 SET POP3=+$GET(^TMP("BGPMU0497",$JOB,TF,"POP",3))
+5 SET ARRAY=POP1_U_POP2_U_POP3
+6 QUIT ARRAY
P2D ;Do the Details
+1 NEW POP,PT,PTCT
+2 DO HEADERL^BGPMUPH
+3 WRITE !!,"Elapsed times are stratified as follows: A) All ED patients excluding patients"
+4 WRITE !,"with mental disorders or placed into observation status, B) ED patients placed"
+5 WRITE !,"into observation status, and C) ED patients with a mental disorder."
+6 WRITE !!,"The following are the abbreviations used in the denominator and numerator"
+7 WRITE !,"columns:"
+8 WRITE !,"N/A=Not Applicable - No Denominators for this Measure"
+9 WRITE !,"ED=ED Patient, Excl Mental Disorder & Observation Status"
+10 WRITE !,"MD=ED Mental Disorder Patient"
+11 WRITE !,"OS=ED Observation Status Patient"
+12 IF $Y>(BGPIOSL-7)
DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+13 WRITE !!,"A) All ED patients excluding patients with mental disorders or placed into"
+14 WRITE !,"observation status"
+15 ;Patients not Mental health or Observation
+16 WRITE !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
+17 SET LINE=""
SET $PIECE(LINE,"-",79)=""
WRITE !,LINE
+18 SET POP=1
SET PTCT=0
SET BGPMUTF="C"
+19 SET PT=0
FOR
SET PT=$ORDER(^TMP("BGPMU0497",$JOB,"C","POP",POP,"PAT",PT))
IF '+PT
QUIT
Begin DoDot:1
+20 SET PTCT=PTCT+1
+21 SET NODE=$GET(^TMP("BGPMU0497",$JOB,"C","POP",POP,"PAT",PT))
+22 DO DATA(NODE)
End DoDot:1
+23 WRITE !!,"Total # of ED visits on list: "_PTCT
+24 SET PTCT=0
+25 ;Observation Pts seen in ER
+26 IF $Y>(BGPIOSL-7)
DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+27 WRITE !!,"B) ED patients placed into observation status"
+28 WRITE !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
+29 SET LINE=""
SET $PIECE(LINE,"-",79)=""
WRITE !,LINE
+30 SET POP=2
+31 SET PT=0
FOR
SET PT=$ORDER(^TMP("BGPMU0497",$JOB,"C","POP",POP,"PAT",PT))
IF '+PT
QUIT
Begin DoDot:1
+32 SET PTCT=PTCT+1
+33 SET NODE=$GET(^TMP("BGPMU0497",$JOB,"C","POP",POP,"PAT",PT))
+34 DO DATA(NODE)
End DoDot:1
+35 WRITE !!,"Total # of ED visits on list: "_PTCT
+36 SET PTCT=0
+37 ;Mental health patients seen in ER
+38 IF $Y>(BGPIOSL-7)
DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+39 WRITE !!,"C) ED patients with a mental disorder"
+40 WRITE !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
+41 SET LINE=""
SET $PIECE(LINE,"-",79)=""
WRITE !,LINE
+42 SET POP=3
+43 SET PT=0
FOR
SET PT=$ORDER(^TMP("BGPMU0497",$JOB,"C","POP",POP,"PAT",PT))
IF '+PT
QUIT
Begin DoDot:1
+44 SET PTCT=PTCT+1
+45 SET NODE=$GET(^TMP("BGPMU0497",$JOB,"C","POP",POP,"PAT",PT))
+46 DO DATA(NODE)
End DoDot:1
+47 WRITE !!,"Total # of ED visits on list: "_PTCT
+48 QUIT
+49 ;
DATA(NODE) ;GET DATA
+1 NEW NAME,HRN,DEN,NUM,AGE,DFN,COMM,SEX
+2 SET DFN=$PIECE(NODE,U,1)
+3 SET NAME=$EXTRACT($$GET1^DIQ(2,$PIECE(NODE,U,1),.01),1,30)
+4 SET HRN=$$HRN^AUPNPAT(DFN,DUZ(2))
+5 SET AGE=$$AGE^AUPNPAT(DFN,BGPED)
+6 SET DEN="N/A"
SET NUM=$PIECE(NODE,U,2)
+7 SET SEX=$PIECE($GET(^DPT(DFN,0)),U,2)
+8 SET COMM=$EXTRACT($$GET1^DIQ(9000001,DFN,1118),1,10)
+9 IF $Y>(BGPIOSL-2)
Begin DoDot:1
+10 DO HEADERL^BGPMUPH
IF BGPQUIT
QUIT
+11 WRITE !!,"PATIENT NAME",?25,"HRN",?33,"COMMUNITY",?43,"SEX",?47,"AGE",?51,"DENOMINATOR",?64,"NUMERATOR"
+12 SET LINE=""
SET $PIECE(LINE,"-",79)=""
WRITE !,LINE
End DoDot:1
+13 WRITE !,NAME,?25,HRN,?33,COMM,?44,SEX,?47,AGE,?51,DEN,?64,NUM
+14 QUIT
+15 ;
XML495 ;Populate the BGPXML array with data for each population/numerator
+1 ; BGPXMLOUT(i)=Measure number^""^Denominator Count^Numerator Count^Exclusion Count
+2 SET BGPXML(1)="NQF_0495_1"_U_""_U_+$PIECE($GET(^TMP("BGPMU0495",$JOB,"C","POP",1)),U,2)_U_+$PIECE($GET(^TMP("BGPMU0495",$JOB,"C","POP",1)),U,1)
+3 SET BGPXML(2)="NQF_0495_2"_U_""_U_+$PIECE($GET(^TMP("BGPMU0495",$JOB,"C","POP",2)),U,2)_U_+$PIECE($GET(^TMP("BGPMU0495",$JOB,"C","POP",2)),U,1)
+4 SET BGPXML(3)="NQF_0495_3"_U_""_U_+$PIECE($GET(^TMP("BGPMU0495",$JOB,"C","POP",3)),U,2)_U_+$PIECE($GET(^TMP("BGPMU0495",$JOB,"C","POP",3)),U,1)
+5 KILL ^TMP("BGPMU0495",$JOB)
+6 QUIT
XML497 ;Populate the BGPXML array with data for each population/numerator
+1 ; BGPXMLOUT(i)=Measure number^""^Denominator Count^Numerator Count^Exclusion Count
+2 SET BGPXML(1)="NQF_0497_1"_U_""_U_+$PIECE($GET(^TMP("BGPMU0497",$JOB,"C","POP",1)),U,2)_U_+$PIECE($GET(^TMP("BGPMU0497",$JOB,"C","POP",1)),U,1)
+3 SET BGPXML(2)="NQF_0497_2"_U_""_U_+$PIECE($GET(^TMP("BGPMU0497",$JOB,"C","POP",2)),U,2)_U_+$PIECE($GET(^TMP("BGPMU0497",$JOB,"C","POP",2)),U,1)
+4 SET BGPXML(3)="NQF_0497_3"_U_""_U_+$PIECE($GET(^TMP("BGPMU0497",$JOB,"C","POP",3)),U,2)_U_+$PIECE($GET(^TMP("BGPMU0497",$JOB,"C","POP",3)),U,1)
+5 KILL ^TMP("BGPMU0497",$JOB)
+6 QUIT