BGP0C1 ; IHS/CMI/LAB - calc CMS measures 26 Sep 2004 11:28 AM 04 May 2009 2:38 PM 02 Nov 2008 10:20 AM ;
;;10.0;IHS CLINICAL REPORTING;;JUN 18, 2010
;
PROC ;EP
D ^APCDCHKJ
S BGPBT=$H
S BGPJ=$J,BGPH=$H
K ^XTMP("BGP0C1",BGPJ,BGPH),BGPCOUNT
D XTMP^BGP0UTL("BGP0C1","CRS CMS Report")
S BGPSD=$$FMADD^XLFDT(BGPBD,-1),BGPSD=BGPSD_".9999"
F S BGPSD=$O(^AUPNVINP("B",BGPSD)) Q:BGPSD=""!($P(BGPSD,".")>BGPED) D
.S BGPVINP=0 F S BGPVINP=$O(^AUPNVINP("B",BGPSD,BGPVINP)) Q:BGPVINP'=+BGPVINP S BGPVSIT=$P($G(^AUPNVINP(BGPVINP,0)),U,3) I BGPVSIT D PROC1
S BGPET=$H
Q
;
PROC1 ;current time period
K BGPEXCL
Q:'$D(^AUPNVSIT(BGPVSIT,0))
S BGPVSIT0=^AUPNVSIT(BGPVSIT,0)
Q:$P(BGPVSIT0,U,7)'="H"
Q:$P(BGPVSIT0,U,11)
Q:'$P(BGPVSIT0,U,9)
Q:$P(BGPVSIT0,U,6)'=BGPHOSP
Q:$P(BGPVSIT0,U,3)="C"
S DFN=$P(BGPVSIT0,U,5)
Q:$P($G(^DPT(DFN,0)),U)["DEMO,PATIENT"
I $P($G(^BGPSITE(DUZ(2),0)),U,12) Q:$D(^DIBT($P(^BGPSITE(DUZ(2),0),U,12),1,DFN))
I BGPBEN=1,$$BEN^AUPNPAT(DFN,"C")'="01" Q ;must be Indian/Alaskan Native
I BGPBEN=2,$$BEN^AUPNPAT(DFN,"C")="01" Q ;must not be I/A
S BGPIND=0 F S BGPIND=$O(BGPPLSTL(BGPIND)) Q:BGPIND'=+BGPIND D
.S BGPPLSTL=0 F S BGPPLSTL=$O(BGPPLSTL(BGPIND,BGPPLSTL)) Q:BGPPLSTL'=+BGPPLSTL D
..X ^BGPCMSMT(BGPPLSTL,2)
Q
AMIALL ;EP
;was there an AMI pov on this visit
Q:'$$AMIDX^BGP0CU(BGPVSIT)
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
S ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=""
Q
;
AMI1 ;EP
S BGPEX=""
Q:'$$AMIDX^BGP0CU(BGPVSIT)
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
;EXCLUSION 1 DISCHARGE TYPE
I $$DEATHAMA^BGP0CU(BGPVINP),$$DODA^BGP0CU(BGPVSIT,BGPVINP) S BGPEX=1 ;ama or death and day of or day after admission
;EXCLUSION 2 DODA
I $$DDA^BGP0CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|2" ;discharged on day of arrival
;EXCLUSION 3 ASA ALLERGY
I $$ASAALLEG^BGP0CU1(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP)) S BGPEX=BGPEX_"|3" ;has aspirin allergy documented through discharge date
;EXCLUSION 4 WARFARIN RX
K BGPDATA
D WARRX^BGP0CU1(DFN,$$FMADD^XLFDT($P($P(^AUPNVSIT(BGPVSIT,0),U),"."),-180),$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),1,.BGPDATA)
I $D(BGPDATA) S BGPEX=BGPEX_"|4" ;has warfarin meds on admission date
AMI1A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
AMI2 ;EP
S BGPEX=""
Q:'$$AMIDX^BGP0CU(BGPVSIT)
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
I $$DEATHAMA^BGP0CU(BGPVINP) S BGPEX=5 ;ama or death and day of or day after admission
I $$ASAALLEG^BGP0CU1(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP)) S BGPEX=BGPEX_"|3" ;has aspirin allergy
K BGPDATA
D WARRX^BGP0CU1(DFN,$P($P(^AUPNVINP(BGPVINP,0),U),"."),$P($P(^AUPNVINP(BGPVINP,0),U),"."),1,.BGPDATA)
I $D(BGPDATA) S BGPEX=BGPEX_"|4" ;has warfarin meds on discharge
AMI2A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
AMI3 ;EP
S BGPEX=""
Q:'$$AMIDX^BGP0CU(BGPVSIT)
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
K BGPDATA S BGPLVSD=0
D LVSD^BGP0CU1(DFN,$$FMADD^XLFDT($$DSCH^BGP0CU(BGPVINP),-365),$$DSCH^BGP0CU(BGPVINP),.BGPDATA)
I $D(BGPDATA) S BGPLVSD=1
K BGPDATA S BGPEJEC=0
D EJECFRAC^BGP0CU1(DFN,$$FMADD^XLFDT($$DSCH^BGP0CU(BGPVINP),-365),$$DSCH^BGP0CU(BGPVINP),.BGPDATA)
I $D(BGPDATA) S BGPEJEC=1
I 'BGPLVSD,'BGPEJEC Q ;no lsvd or ejection fraction
I $$DEATHAMA^BGP0CU(BGPVINP) S BGPEX=5 ;ama or death and day of or day after admission
I $$ACEALLEG^BGP0CU1(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP)),$$ARBALLEG^BGP0CU1(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP)) S BGPEX=BGPEX_"|6"
I $$SAORSTEN^BGP0CU1(DFN,$$FMADD^XLFDT($$DSCH^BGP0CU(BGPVINP),-365),$$DSCH^BGP0CU(BGPVINP)) S BGPEX=BGPEX_"|7"
AMI3A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
AMI4 ;EP
S BGPEX=""
Q:'$$AMIDX^BGP0CU(BGPVSIT)
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
K BGPDATA
D SMOKER^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(^AUPNVSIT(BGPVSIT,0),U),"."),-365),$$DSCH^BGP0CU(BGPVINP),.BGPDATA)
I '$D(BGPDATA) Q ;not a smoker
I $$DEATHAMA^BGP0CU(BGPVINP) S BGPEX=5 ;ama or death
AMI4A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
AMI5 ;EP
S BGPEX=""
Q:'$$AMIDX^BGP0CU(BGPVSIT)
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
I $$DEATHAMA^BGP0CU(BGPVINP) S BGPEX=5 ;ama or death and day of or day after admission
I $$BETAALEG^BGP0CU2(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP)) S BGPEX=BGPEX_"|8" ;has BETA allergy
;K BGPDATA S BGPBRADY="",BGPC=0
;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS BRADYCARDIA DXS")
;I $D(BGPDATA) S BGPBRADY=1
;on active med for beta blocker?
;S BGPBETA=""
;K BGPDATA
;D BETARX^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(^AUPNVSIT(BGPVSIT,0),U),"."),-180),$$DSCH^BGP0CU(BGPVINP),1,.BGPDATA)
;I $D(BGPDATA) S BGPBETA=1
;I '$D(BGPDATA) S E=+$$CODEN^ICPTCOD("G8009") S BGPBETA=$$CPTI^BGP0DU(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),E),BGPBETA=+BGPBETA
;I BGPBRADY,'BGPBETA S BGPEX=BGPEX_"|9"
;K BGPDATA
;S BGP23RD=""
;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS 2/3 HEART BLOCK DXS")
;I $D(BGPDATA) S BGP23RD=1
;S BGPPACE=$$PACE^BGP0CU2(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
;I BGP23RD,'BGPPACE S BGPEX=BGPEX_"|0"
AMI5A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
AMI6 ;EP
S BGPEX=""
Q:'$$AMIDX^BGP0CU(BGPVSIT)
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
I $P($P(^AUPNVSIT(BGPVSIT,0),U),".")=$P($P(^AUPNVINP(BGPVINP,0),U),".") S BGPEX=2
I $$DEATHAMA^BGP0CU(BGPVINP),$$DODA^BGP0CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|1" ;ama or death and day of or day after admission
I $$BETAALEG^BGP0CU2(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP)) S BGPEX=BGPEX_"|8" ;has BETA allergy
;K BGPDATA S BGPBRADY="",BGPC=0
;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS BRADYCARDIA DXS")
;I $D(BGPDATA) S BGPBRADY=1
;on active med for beta blocker?
;S BGPBETA=""
;K BGPDATA
;D BETARX^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(^AUPNVSIT(BGPVSIT,0),U),"."),-180),$$DSCH^BGP0CU(BGPVINP),1,.BGPDATA)
;I $D(BGPDATA) S BGPBETA=1
;I '$D(BGPDATA) S E=+$$CODEN^ICPTCOD("G8009") S BGPBETA=$$CPTI^BGP0DU(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),E),BGPBETA=+BGPBETA
;I BGPBRADY,'BGPBETA S BGPEX=BGPEX_"|9"
;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS HEART FAILURE DXS")
;I $D(BGPDATA) S BGPEX=BGPEX_"|A" ;heart failure on visit
;K BGPDATA
;S BGP23RD=""
;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS 2/3 HEART BLOCK DXS")
;I $D(BGPDATA) S BGP23RD=1
;S BGPPACE=$$PACE^BGP0CU2(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
;I BGP23RD,'BGPPACE S BGPEX=BGPEX_"|0"
;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS CIRCULATORY SHOCK DXS")
;I $D(BGPDATA) S BGPEX=BGPEX_"|B" ;circulatory on visit
AMI6A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
AMI7A ;EP
S BGPEX=""
Q:'$$AMIDX^BGP0CU(BGPVSIT)
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
K BGPST1,BGPLBDX,BGPLBPC
S BGPST1=$$LASTDX^BGP0UTL1(DFN,"BGP ST ELEVATION DX",$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP))
S BGPLBDX=$$LBBBDX^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP))
D LBBBPROC^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP),.BGPLBPC)
I 'BGPST1&('BGPLBDX!('$D(BGPLBPC))) Q ;no st1 or lbbb DX AND PROCEDURE
S BGPFIB=""
K BGPDATA
D TARX^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(^AUPNVSIT(BGPVSIT,0),U),"."),-180),$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),1,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),.BGPDATA)
K BGPUD
D IVUD^BGP0CU1(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH^BGP0CU(BGPVINP),$O(^ATXAX("B","BGP CMS THROMBOLYTIC MEDS",0)),.BGPUD,"",$O(^ATXAX("B","BGP THROMBOLYTIC AGENT CLASS",0)))
S BGPTAPRO=$$LASTPRCI^BGP0UTL1(DFN,"99.10",$P($P(BGPVSIT0,U),"."),$$DSCH^BGP0CU(BGPVINP))
I '$D(BGPDATA),'$D(BGPUD),'BGPTAPRO Q ;no fibrom meds
AMI7AW ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
AMI8A ;EP
S BGPEX=""
Q:'$$AMIDX^BGP0CU(BGPVSIT)
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
K BGPST1,BGPLBDX,BGPLBPC
S BGPST1=$$LASTDX^BGP0UTL1(DFN,"BGP ST ELEVATION DX",$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP))
S BGPLBDX=$$LBBBDX^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP))
D LBBBPROC^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP),.BGPLBPC)
I 'BGPST1&('BGPLBDX!('$D(BGPLBPC))) Q ;no st1 or lbbb DX AND PROCEDURE
S BGPPCI=$$LASTPRCI^BGP0UTL1(DFN,"00.66",$P($P(BGPVSIT0,U),"."),$$DSCH^BGP0CU(BGPVINP))
I 'BGPPCI Q ;no PCI
AMI8AW ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
BGP0C1 ; IHS/CMI/LAB - calc CMS measures 26 Sep 2004 11:28 AM 04 May 2009 2:38 PM 02 Nov 2008 10:20 AM ;
+1 ;;10.0;IHS CLINICAL REPORTING;;JUN 18, 2010
+2 ;
PROC ;EP
+1 DO ^APCDCHKJ
+2 SET BGPBT=$HOROLOG
+3 SET BGPJ=$JOB
SET BGPH=$HOROLOG
+4 KILL ^XTMP("BGP0C1",BGPJ,BGPH),BGPCOUNT
+5 DO XTMP^BGP0UTL("BGP0C1","CRS CMS Report")
+6 SET BGPSD=$$FMADD^XLFDT(BGPBD,-1)
SET BGPSD=BGPSD_".9999"
+7 FOR
SET BGPSD=$ORDER(^AUPNVINP("B",BGPSD))
IF BGPSD=""!($PIECE(BGPSD,".")>BGPED)
QUIT
Begin DoDot:1
+8 SET BGPVINP=0
FOR
SET BGPVINP=$ORDER(^AUPNVINP("B",BGPSD,BGPVINP))
IF BGPVINP'=+BGPVINP
QUIT
SET BGPVSIT=$PIECE($GET(^AUPNVINP(BGPVINP,0)),U,3)
IF BGPVSIT
DO PROC1
End DoDot:1
+9 SET BGPET=$HOROLOG
+10 QUIT
+11 ;
PROC1 ;current time period
+1 KILL BGPEXCL
+2 IF '$DATA(^AUPNVSIT(BGPVSIT,0))
QUIT
+3 SET BGPVSIT0=^AUPNVSIT(BGPVSIT,0)
+4 IF $PIECE(BGPVSIT0,U,7)'="H"
QUIT
+5 IF $PIECE(BGPVSIT0,U,11)
QUIT
+6 IF '$PIECE(BGPVSIT0,U,9)
QUIT
+7 IF $PIECE(BGPVSIT0,U,6)'=BGPHOSP
QUIT
+8 IF $PIECE(BGPVSIT0,U,3)="C"
QUIT
+9 SET DFN=$PIECE(BGPVSIT0,U,5)
+10 IF $PIECE($GET(^DPT(DFN,0)),U)["DEMO,PATIENT"
QUIT
+11 IF $PIECE($GET(^BGPSITE(DUZ(2),0)),U,12)
IF $DATA(^DIBT($PIECE(^BGPSITE(DUZ(2),0),U,12),1,DFN))
QUIT
+12 ;must be Indian/Alaskan Native
IF BGPBEN=1
IF $$BEN^AUPNPAT(DFN,"C")'="01"
QUIT
+13 ;must not be I/A
IF BGPBEN=2
IF $$BEN^AUPNPAT(DFN,"C")="01"
QUIT
+14 SET BGPIND=0
FOR
SET BGPIND=$ORDER(BGPPLSTL(BGPIND))
IF BGPIND'=+BGPIND
QUIT
Begin DoDot:1
+15 SET BGPPLSTL=0
FOR
SET BGPPLSTL=$ORDER(BGPPLSTL(BGPIND,BGPPLSTL))
IF BGPPLSTL'=+BGPPLSTL
QUIT
Begin DoDot:2
+16 XECUTE ^BGPCMSMT(BGPPLSTL,2)
End DoDot:2
End DoDot:1
+17 QUIT
AMIALL ;EP
+1 ;was there an AMI pov on this visit
+2 IF '$$AMIDX^BGP0CU(BGPVSIT)
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 SET ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=""
+5 QUIT
+6 ;
AMI1 ;EP
+1 SET BGPEX=""
+2 IF '$$AMIDX^BGP0CU(BGPVSIT)
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 ;EXCLUSION 1 DISCHARGE TYPE
+5 ;ama or death and day of or day after admission
IF $$DEATHAMA^BGP0CU(BGPVINP)
IF $$DODA^BGP0CU(BGPVSIT,BGPVINP)
SET BGPEX=1
+6 ;EXCLUSION 2 DODA
+7 ;discharged on day of arrival
IF $$DDA^BGP0CU(BGPVSIT,BGPVINP)
SET BGPEX=BGPEX_"|2"
+8 ;EXCLUSION 3 ASA ALLERGY
+9 ;has aspirin allergy documented through discharge date
IF $$ASAALLEG^BGP0CU1(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
SET BGPEX=BGPEX_"|3"
+10 ;EXCLUSION 4 WARFARIN RX
+11 KILL BGPDATA
+12 DO WARRX^BGP0CU1(DFN,$$FMADD^XLFDT($PIECE($PIECE(^AUPNVSIT(BGPVSIT,0),U),"."),-180),$PIECE($PIECE(^AUPNVSIT(BGPVSIT,0),U),"."),1,.BGPDATA)
+13 ;has warfarin meds on admission date
IF $DATA(BGPDATA)
SET BGPEX=BGPEX_"|4"
AMI1A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
AMI2 ;EP
+1 SET BGPEX=""
+2 IF '$$AMIDX^BGP0CU(BGPVSIT)
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 ;ama or death and day of or day after admission
IF $$DEATHAMA^BGP0CU(BGPVINP)
SET BGPEX=5
+5 ;has aspirin allergy
IF $$ASAALLEG^BGP0CU1(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
SET BGPEX=BGPEX_"|3"
+6 KILL BGPDATA
+7 DO WARRX^BGP0CU1(DFN,$PIECE($PIECE(^AUPNVINP(BGPVINP,0),U),"."),$PIECE($PIECE(^AUPNVINP(BGPVINP,0),U),"."),1,.BGPDATA)
+8 ;has warfarin meds on discharge
IF $DATA(BGPDATA)
SET BGPEX=BGPEX_"|4"
AMI2A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
AMI3 ;EP
+1 SET BGPEX=""
+2 IF '$$AMIDX^BGP0CU(BGPVSIT)
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 KILL BGPDATA
SET BGPLVSD=0
+5 DO LVSD^BGP0CU1(DFN,$$FMADD^XLFDT($$DSCH^BGP0CU(BGPVINP),-365),$$DSCH^BGP0CU(BGPVINP),.BGPDATA)
+6 IF $DATA(BGPDATA)
SET BGPLVSD=1
+7 KILL BGPDATA
SET BGPEJEC=0
+8 DO EJECFRAC^BGP0CU1(DFN,$$FMADD^XLFDT($$DSCH^BGP0CU(BGPVINP),-365),$$DSCH^BGP0CU(BGPVINP),.BGPDATA)
+9 IF $DATA(BGPDATA)
SET BGPEJEC=1
+10 ;no lsvd or ejection fraction
IF 'BGPLVSD
IF 'BGPEJEC
QUIT
+11 ;ama or death and day of or day after admission
IF $$DEATHAMA^BGP0CU(BGPVINP)
SET BGPEX=5
+12 IF $$ACEALLEG^BGP0CU1(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
IF $$ARBALLEG^BGP0CU1(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
SET BGPEX=BGPEX_"|6"
+13 IF $$SAORSTEN^BGP0CU1(DFN,$$FMADD^XLFDT($$DSCH^BGP0CU(BGPVINP),-365),$$DSCH^BGP0CU(BGPVINP))
SET BGPEX=BGPEX_"|7"
AMI3A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
AMI4 ;EP
+1 SET BGPEX=""
+2 IF '$$AMIDX^BGP0CU(BGPVSIT)
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 KILL BGPDATA
+5 DO SMOKER^BGP0CU2(DFN,$$FMADD^XLFDT($PIECE($PIECE(^AUPNVSIT(BGPVSIT,0),U),"."),-365),$$DSCH^BGP0CU(BGPVINP),.BGPDATA)
+6 ;not a smoker
IF '$DATA(BGPDATA)
QUIT
+7 ;ama or death
IF $$DEATHAMA^BGP0CU(BGPVINP)
SET BGPEX=5
AMI4A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
AMI5 ;EP
+1 SET BGPEX=""
+2 IF '$$AMIDX^BGP0CU(BGPVSIT)
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 ;ama or death and day of or day after admission
IF $$DEATHAMA^BGP0CU(BGPVINP)
SET BGPEX=5
+5 ;has BETA allergy
IF $$BETAALEG^BGP0CU2(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
SET BGPEX=BGPEX_"|8"
+6 ;K BGPDATA S BGPBRADY="",BGPC=0
+7 ;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS BRADYCARDIA DXS")
+8 ;I $D(BGPDATA) S BGPBRADY=1
+9 ;on active med for beta blocker?
+10 ;S BGPBETA=""
+11 ;K BGPDATA
+12 ;D BETARX^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(^AUPNVSIT(BGPVSIT,0),U),"."),-180),$$DSCH^BGP0CU(BGPVINP),1,.BGPDATA)
+13 ;I $D(BGPDATA) S BGPBETA=1
+14 ;I '$D(BGPDATA) S E=+$$CODEN^ICPTCOD("G8009") S BGPBETA=$$CPTI^BGP0DU(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),E),BGPBETA=+BGPBETA
+15 ;I BGPBRADY,'BGPBETA S BGPEX=BGPEX_"|9"
+16 ;K BGPDATA
+17 ;S BGP23RD=""
+18 ;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS 2/3 HEART BLOCK DXS")
+19 ;I $D(BGPDATA) S BGP23RD=1
+20 ;S BGPPACE=$$PACE^BGP0CU2(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
+21 ;I BGP23RD,'BGPPACE S BGPEX=BGPEX_"|0"
AMI5A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
AMI6 ;EP
+1 SET BGPEX=""
+2 IF '$$AMIDX^BGP0CU(BGPVSIT)
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 IF $PIECE($PIECE(^AUPNVSIT(BGPVSIT,0),U),".")=$PIECE($PIECE(^AUPNVINP(BGPVINP,0),U),".")
SET BGPEX=2
+5 ;ama or death and day of or day after admission
IF $$DEATHAMA^BGP0CU(BGPVINP)
IF $$DODA^BGP0CU(BGPVSIT,BGPVINP)
SET BGPEX=BGPEX_"|1"
+6 ;has BETA allergy
IF $$BETAALEG^BGP0CU2(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
SET BGPEX=BGPEX_"|8"
+7 ;K BGPDATA S BGPBRADY="",BGPC=0
+8 ;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS BRADYCARDIA DXS")
+9 ;I $D(BGPDATA) S BGPBRADY=1
+10 ;on active med for beta blocker?
+11 ;S BGPBETA=""
+12 ;K BGPDATA
+13 ;D BETARX^BGP0CU2(DFN,$$FMADD^XLFDT($P($P(^AUPNVSIT(BGPVSIT,0),U),"."),-180),$$DSCH^BGP0CU(BGPVINP),1,.BGPDATA)
+14 ;I $D(BGPDATA) S BGPBETA=1
+15 ;I '$D(BGPDATA) S E=+$$CODEN^ICPTCOD("G8009") S BGPBETA=$$CPTI^BGP0DU(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),E),BGPBETA=+BGPBETA
+16 ;I BGPBRADY,'BGPBETA S BGPEX=BGPEX_"|9"
+17 ;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS HEART FAILURE DXS")
+18 ;I $D(BGPDATA) S BGPEX=BGPEX_"|A" ;heart failure on visit
+19 ;K BGPDATA
+20 ;S BGP23RD=""
+21 ;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS 2/3 HEART BLOCK DXS")
+22 ;I $D(BGPDATA) S BGP23RD=1
+23 ;S BGPPACE=$$PACE^BGP0CU2(DFN,$$DOB^AUPNPAT(DFN),$$DSCH^BGP0CU(BGPVINP))
+24 ;I BGP23RD,'BGPPACE S BGPEX=BGPEX_"|0"
+25 ;D ALLDXS^BGP0CU2(DFN,$P($P(^AUPNVSIT(BGPVSIT,0),U),"."),$$DSCH^BGP0CU(BGPVINP),.BGPDATA,BGPC,"BGP CMS CIRCULATORY SHOCK DXS")
+26 ;I $D(BGPDATA) S BGPEX=BGPEX_"|B" ;circulatory on visit
AMI6A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
AMI7A ;EP
+1 SET BGPEX=""
+2 IF '$$AMIDX^BGP0CU(BGPVSIT)
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 KILL BGPST1,BGPLBDX,BGPLBPC
+5 SET BGPST1=$$LASTDX^BGP0UTL1(DFN,"BGP ST ELEVATION DX",$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP))
+6 SET BGPLBDX=$$LBBBDX^BGP0CU2(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP))
+7 DO LBBBPROC^BGP0CU2(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP),.BGPLBPC)
+8 ;no st1 or lbbb DX AND PROCEDURE
IF 'BGPST1&('BGPLBDX!('$DATA(BGPLBPC)))
QUIT
+9 SET BGPFIB=""
+10 KILL BGPDATA
+11 DO TARX^BGP0CU2(DFN,$$FMADD^XLFDT($PIECE($PIECE(^AUPNVSIT(BGPVSIT,0),U),"."),-180),$PIECE($PIECE(^AUPNVSIT(BGPVSIT,0),U),"."),1,$PIECE($PIECE(^AUPNVSIT(BGPVSIT,0),U),"."),.BGPDATA)
+12 KILL BGPUD
+13 DO IVUD^BGP0CU1(DFN,$PIECE($PIECE(BGPVSIT0,U),"."),$$DSCH^BGP0CU(BGPVINP),$ORDER(^ATXAX("B","BGP CMS THROMBOLYTIC MEDS",0)),.BGPUD,"",$ORDER(^ATXAX("B","BGP THROMBOLYTIC AGENT CLASS",0)))
+14 SET BGPTAPRO=$$LASTPRCI^BGP0UTL1(DFN,"99.10",$PIECE($PIECE(BGPVSIT0,U),"."),$$DSCH^BGP0CU(BGPVINP))
+15 ;no fibrom meds
IF '$DATA(BGPDATA)
IF '$DATA(BGPUD)
IF 'BGPTAPRO
QUIT
AMI7AW ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
AMI8A ;EP
+1 SET BGPEX=""
+2 IF '$$AMIDX^BGP0CU(BGPVSIT)
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 KILL BGPST1,BGPLBDX,BGPLBPC
+5 SET BGPST1=$$LASTDX^BGP0UTL1(DFN,"BGP ST ELEVATION DX",$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP))
+6 SET BGPLBDX=$$LBBBDX^BGP0CU2(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP))
+7 DO LBBBPROC^BGP0CU2(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$$DSCH^BGP0CU(BGPVINP),.BGPLBPC)
+8 ;no st1 or lbbb DX AND PROCEDURE
IF 'BGPST1&('BGPLBDX!('$DATA(BGPLBPC)))
QUIT
+9 SET BGPPCI=$$LASTPRCI^BGP0UTL1(DFN,"00.66",$PIECE($PIECE(BGPVSIT0,U),"."),$$DSCH^BGP0CU(BGPVINP))
+10 ;no PCI
IF 'BGPPCI
QUIT
AMI8AW ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP0C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT