BGP8C3 ; IHS/CMI/LAB - calc CMS measures 26 Sep 2004 11:28 AM 04 May 2008 2:38 PM ;
;;8.0;IHS CLINICAL REPORTING;**2**;MAR 12, 2008
;
PNALL ;EP
;was there pneumonia on this visit?
Q:$$PNEUMODX^BGP8CU(BGPVSIT)=""
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
S ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=""
Q
;
PN1 ;EP
S BGPEX=""
Q:$$PNEUMODX^BGP8CU(BGPVSIT)="" ;no pneumonia dx
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
;exclusions
I $$DDA^BGP8CU(BGPVSIT,BGPVINP) S BGPEX=1 ;discharged on day of arrival, exclusion 1
I $$DEATHAMA^BGP8CU(BGPVINP),$$DODA^BGP8CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|2" ;death/ama, discharged day of or day after arrival
S BGPADMER="",BGPERPN=""
I '$$ADMDX^BGP8CU(BGPVINP,"BGP CMS PNEUMONIA DXS") S BGPADMER="|3" ;no admitting dx of pneumonia
I '$$ERPNEU^BGP8CU(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$P($P(BGPVSIT0,U),"."),"BGP CMS PNEUMONIA DXS") S BGPERPN="|4"
I BGPADMER]""&(BGPERPN]"") S BGPEX=BGPADMER_BGPERPN
I $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN1A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
PN2 ;EP
S BGPEX=""
Q:$$PNEUMODX^BGP8CU(BGPVSIT)="" ;no pneumonia dx
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<65 Q ; no one under 18 at admission date
;exclusions
I $$DEATHAMA^BGP8CU(BGPVINP) S BGPEX=BGPEX_"|9" ;death/ama, discharged day of or day after arrival
I $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN2A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
PN3B ;EP
S BGPEX=""
Q:$$PNEUMODX^BGP8CU(BGPVSIT)="" ;no pneumonia dx
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
S BGPERBC=""
K BGPDATA
D ERBC^BGP8CU3(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$P($P(BGPVSIT0,U),"."),.BGPDATA)
I $D(BGPDATA) S BGPERBC=1
S BGPANTIH=""
K BGPDATA
D ANTIRX^BGP8CU3(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH^BGP8CU(BGPVINP),.BGPDATA)
I $D(BGPDATA) S BGPANTIH=1
I 'BGPANTIH!('BGPERBC) Q ;S BGPEX="|6"
;exclusions
I $$DDA^BGP8CU(BGPVSIT,BGPVINP) S BGPEX=1 ;discharged on day of arrival, exclusion 1
S BGPADMER="",BGPERPN=""
I '$$ADMDX^BGP8CU(BGPVINP,"BGP CMS PNEUMONIA DXS") S BGPADMER="|3" ;no admitting dx of pneumonia
I '$$ERPNEU^BGP8CU(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$P($P(BGPVSIT0,U),"."),"BGP CMS PNEUMONIA DXS") S BGPERPN="|4"
I BGPADMER]""&(BGPERPN]"") S BGPEX=BGPADMER_BGPERPN
I $$DEATHAMA^BGP8CU(BGPVINP) S BGPEX=BGPEX_"|9" ;death/ama, discharged day of or day after arrival
I $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN3A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
PN4 ;EP
S BGPEX=""
Q:$$PNEUMODX^BGP8CU(BGPVSIT)="" ;no pneumonia dx
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
K BGPDATA
D SMOKER^BGP8CU2(DFN,$$FMADD^XLFDT($P($P(^AUPNVSIT(BGPVSIT,0),U),"."),-365),$$DSCH^BGP8CU(BGPVINP),.BGPDATA)
I '$D(BGPDATA) Q ;not a smoker
;exclusions
I $$DEATHAMA^BGP8CU(BGPVINP) S BGPEX=BGPEX_"|9" ;death/ama, discharged day of or day after arrival
I $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN4A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
PN5B ;EP
S BGPEX=""
Q:$$PNEUMODX^BGP8CU(BGPVSIT)="" ;no pneumonia dx
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
;exclusions
I $$DDA^BGP8CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|1" ;discharged on day of arrival, exclusion 1
S BGPADMER="",BGPERPN=""
I '$$ADMDX^BGP8CU(BGPVINP,"BGP CMS PNEUMONIA DXS") S BGPADMER="|3" ;no admitting dx of pneumonia
I '$$ERPNEU^BGP8CU(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$P($P(BGPVSIT0,U),"."),"BGP CMS PNEUMONIA DXS") S BGPERPN="|4"
I BGPADMER]""&(BGPERPN]"") S BGPEX=BGPADMER_BGPERPN
I $$DEATHAMA^BGP8CU(BGPVINP),$$DODA^BGP8CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|2" ;death/ama, discharged day of or day after arrival
I $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP)) S BGPEX=BGPEX_"|5"
S BGPANTIH=""
K BGPDATA,BGPY
D ANTIRX^BGP8CU3(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH^BGP8CU(BGPVINP),.BGPDATA)
I '$D(BGPDATA) S BGPEX=BGPEX_"|7"
D GETMEDS^BGP8CU(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-180),$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),"BGP CMS ANTIBIOTIC MEDS","BGP CMS ANTIBIOTIC MEDS NDC","BGP CMS ANTIBIOTICS MEDS CLASS",1,"","",0,1)
I $G(BGPY)]"" S BGPEX=BGPEX_"|8"
PN5BA ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
PN6 ;EP
S BGPEX=""
Q:$$PNEUMODX^BGP8CU(BGPVSIT)="" ;no pneumonia dx
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q ; no one under 18 at admission date
;exclusions
I $$DDA^BGP8CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|1" ;discharged on day of arrival, exclusion 1
S BGPADMER="",BGPERPN=""
I '$$ADMDX^BGP8CU(BGPVINP,"BGP CMS PNEUMONIA DXS") S BGPADMER="|3" ;no admitting dx of pneumonia
I '$$ERPNEU^BGP8CU(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-1),$P($P(BGPVSIT0,U),"."),"BGP CMS PNEUMONIA DXS") S BGPERPN="|4"
I BGPADMER]""&(BGPERPN]"") S BGPEX=BGPADMER_BGPERPN
I $$DEATHAMA^BGP8CU(BGPVINP),$$DODA^BGP8CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|2" ;death/ama, discharged day of or day after arrival
I $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP)) S BGPEX=BGPEX_"|5"
K BGPDATA
I $$HIV^BGP8CU4(DFN,$$DOB^AUPNPAT(DFN),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|A"
I $$SYSCHEMO^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|B"
I $$SYSIMMUN^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|C"
I $$LEUKEMIA^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|D"
I $$LYMPHOMA^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|K"
I $$RADTHER^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|E"
I $$PRIORHOS^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-14),$P($P(BGPVSIT0,U),"."),BGPVSIT) S BGPEX=BGPEX_"|F"
I $$HOS2DAYS^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|G"
I $$NURSHOME^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|H"
I $$CHRDIAL^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-30),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|I"
I $$WOUNDCAR^BGP8CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-30),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|J"
PN6BA ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
PN7 ;EP
S BGPEX=""
Q:$$PNEUMODX^BGP8CU(BGPVSIT)="" ;no pneumonia dx
I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<50 Q ; no one under 18 at admission date
S M=$E($$DSCH^BGP8CU(BGPVINP),4,5)
I +M>2,+M<10 Q ;only 10 through 2 months
;exclusions
I $$DEATHAMA^BGP8CU(BGPVINP) S BGPEX=BGPEX_"|9" ;death/ama, discharged day of or day after arrival
I $$LASTDXI^BGP8UTL1(DFN,"487.0",$P($P(BGPVSIT0,U),"."),$$DSCH^BGP8CU(BGPVINP),"HI") S BGPEX=BGPEX_"|L"
I $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN7A ;
I $G(BGPEXCL),BGPEX]"" Q
S ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
Q
;
BGP8C3 ; IHS/CMI/LAB - calc CMS measures 26 Sep 2004 11:28 AM 04 May 2008 2:38 PM ;
+1 ;;8.0;IHS CLINICAL REPORTING;**2**;MAR 12, 2008
+2 ;
PNALL ;EP
+1 ;was there pneumonia on this visit?
+2 IF $$PNEUMODX^BGP8CU(BGPVSIT)=""
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 SET ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=""
+5 QUIT
+6 ;
PN1 ;EP
+1 SET BGPEX=""
+2 ;no pneumonia dx
IF $$PNEUMODX^BGP8CU(BGPVSIT)=""
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 ;exclusions
+5 ;discharged on day of arrival, exclusion 1
IF $$DDA^BGP8CU(BGPVSIT,BGPVINP)
SET BGPEX=1
+6 ;death/ama, discharged day of or day after arrival
IF $$DEATHAMA^BGP8CU(BGPVINP)
IF $$DODA^BGP8CU(BGPVSIT,BGPVINP)
SET BGPEX=BGPEX_"|2"
+7 SET BGPADMER=""
SET BGPERPN=""
+8 ;no admitting dx of pneumonia
IF '$$ADMDX^BGP8CU(BGPVINP,"BGP CMS PNEUMONIA DXS")
SET BGPADMER="|3"
+9 IF '$$ERPNEU^BGP8CU(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$PIECE($PIECE(BGPVSIT0,U),"."),"BGP CMS PNEUMONIA DXS")
SET BGPERPN="|4"
+10 IF BGPADMER]""&(BGPERPN]"")
SET BGPEX=BGPADMER_BGPERPN
+11 IF $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP))
SET BGPEX=BGPEX_"|5"
PN1A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
PN2 ;EP
+1 SET BGPEX=""
+2 ;no pneumonia dx
IF $$PNEUMODX^BGP8CU(BGPVSIT)=""
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<65
QUIT
+4 ;exclusions
+5 ;death/ama, discharged day of or day after arrival
IF $$DEATHAMA^BGP8CU(BGPVINP)
SET BGPEX=BGPEX_"|9"
+6 IF $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP))
SET BGPEX=BGPEX_"|5"
PN2A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
PN3B ;EP
+1 SET BGPEX=""
+2 ;no pneumonia dx
IF $$PNEUMODX^BGP8CU(BGPVSIT)=""
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 SET BGPERBC=""
+5 KILL BGPDATA
+6 DO ERBC^BGP8CU3(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$PIECE($PIECE(BGPVSIT0,U),"."),.BGPDATA)
+7 IF $DATA(BGPDATA)
SET BGPERBC=1
+8 SET BGPANTIH=""
+9 KILL BGPDATA
+10 DO ANTIRX^BGP8CU3(DFN,$PIECE($PIECE(BGPVSIT0,U),"."),$$DSCH^BGP8CU(BGPVINP),.BGPDATA)
+11 IF $DATA(BGPDATA)
SET BGPANTIH=1
+12 ;S BGPEX="|6"
IF 'BGPANTIH!('BGPERBC)
QUIT
+13 ;exclusions
+14 ;discharged on day of arrival, exclusion 1
IF $$DDA^BGP8CU(BGPVSIT,BGPVINP)
SET BGPEX=1
+15 SET BGPADMER=""
SET BGPERPN=""
+16 ;no admitting dx of pneumonia
IF '$$ADMDX^BGP8CU(BGPVINP,"BGP CMS PNEUMONIA DXS")
SET BGPADMER="|3"
+17 IF '$$ERPNEU^BGP8CU(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$PIECE($PIECE(BGPVSIT0,U),"."),"BGP CMS PNEUMONIA DXS")
SET BGPERPN="|4"
+18 IF BGPADMER]""&(BGPERPN]"")
SET BGPEX=BGPADMER_BGPERPN
+19 ;death/ama, discharged day of or day after arrival
IF $$DEATHAMA^BGP8CU(BGPVINP)
SET BGPEX=BGPEX_"|9"
+20 IF $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP))
SET BGPEX=BGPEX_"|5"
PN3A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
PN4 ;EP
+1 SET BGPEX=""
+2 ;no pneumonia dx
IF $$PNEUMODX^BGP8CU(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^BGP8CU2(DFN,$$FMADD^XLFDT($PIECE($PIECE(^AUPNVSIT(BGPVSIT,0),U),"."),-365),$$DSCH^BGP8CU(BGPVINP),.BGPDATA)
+6 ;not a smoker
IF '$DATA(BGPDATA)
QUIT
+7 ;exclusions
+8 ;death/ama, discharged day of or day after arrival
IF $$DEATHAMA^BGP8CU(BGPVINP)
SET BGPEX=BGPEX_"|9"
+9 IF $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP))
SET BGPEX=BGPEX_"|5"
PN4A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
PN5B ;EP
+1 SET BGPEX=""
+2 ;no pneumonia dx
IF $$PNEUMODX^BGP8CU(BGPVSIT)=""
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 ;exclusions
+5 ;discharged on day of arrival, exclusion 1
IF $$DDA^BGP8CU(BGPVSIT,BGPVINP)
SET BGPEX=BGPEX_"|1"
+6 SET BGPADMER=""
SET BGPERPN=""
+7 ;no admitting dx of pneumonia
IF '$$ADMDX^BGP8CU(BGPVINP,"BGP CMS PNEUMONIA DXS")
SET BGPADMER="|3"
+8 IF '$$ERPNEU^BGP8CU(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$PIECE($PIECE(BGPVSIT0,U),"."),"BGP CMS PNEUMONIA DXS")
SET BGPERPN="|4"
+9 IF BGPADMER]""&(BGPERPN]"")
SET BGPEX=BGPADMER_BGPERPN
+10 ;death/ama, discharged day of or day after arrival
IF $$DEATHAMA^BGP8CU(BGPVINP)
IF $$DODA^BGP8CU(BGPVSIT,BGPVINP)
SET BGPEX=BGPEX_"|2"
+11 IF $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP))
SET BGPEX=BGPEX_"|5"
+12 SET BGPANTIH=""
+13 KILL BGPDATA,BGPY
+14 DO ANTIRX^BGP8CU3(DFN,$PIECE($PIECE(BGPVSIT0,U),"."),$$DSCH^BGP8CU(BGPVINP),.BGPDATA)
+15 IF '$DATA(BGPDATA)
SET BGPEX=BGPEX_"|7"
+16 DO GETMEDS^BGP8CU(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-180),$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),"BGP CMS ANTIBIOTIC MEDS","BGP CMS ANTIBIOTIC MEDS NDC","BGP CMS ANTIBIOTICS MEDS CLASS",1,"","",0,1)
+17 IF $GET(BGPY)]""
SET BGPEX=BGPEX_"|8"
PN5BA ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
PN6 ;EP
+1 SET BGPEX=""
+2 ;no pneumonia dx
IF $$PNEUMODX^BGP8CU(BGPVSIT)=""
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<18
QUIT
+4 ;exclusions
+5 ;discharged on day of arrival, exclusion 1
IF $$DDA^BGP8CU(BGPVSIT,BGPVINP)
SET BGPEX=BGPEX_"|1"
+6 SET BGPADMER=""
SET BGPERPN=""
+7 ;no admitting dx of pneumonia
IF '$$ADMDX^BGP8CU(BGPVINP,"BGP CMS PNEUMONIA DXS")
SET BGPADMER="|3"
+8 IF '$$ERPNEU^BGP8CU(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-1),$PIECE($PIECE(BGPVSIT0,U),"."),"BGP CMS PNEUMONIA DXS")
SET BGPERPN="|4"
+9 IF BGPADMER]""&(BGPERPN]"")
SET BGPEX=BGPADMER_BGPERPN
+10 ;death/ama, discharged day of or day after arrival
IF $$DEATHAMA^BGP8CU(BGPVINP)
IF $$DODA^BGP8CU(BGPVSIT,BGPVINP)
SET BGPEX=BGPEX_"|2"
+11 IF $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP))
SET BGPEX=BGPEX_"|5"
+12 KILL BGPDATA
+13 IF $$HIV^BGP8CU4(DFN,$$DOB^AUPNPAT(DFN),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|A"
+14 IF $$SYSCHEMO^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-90),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|B"
+15 IF $$SYSIMMUN^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-90),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|C"
+16 IF $$LEUKEMIA^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-90),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|D"
+17 IF $$LYMPHOMA^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-90),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|K"
+18 IF $$RADTHER^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-90),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|E"
+19 IF $$PRIORHOS^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-14),$PIECE($PIECE(BGPVSIT0,U),"."),BGPVSIT)
SET BGPEX=BGPEX_"|F"
+20 IF $$HOS2DAYS^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-90),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|G"
+21 IF $$NURSHOME^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-90),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|H"
+22 IF $$CHRDIAL^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-30),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|I"
+23 IF $$WOUNDCAR^BGP8CU4(DFN,$$FMADD^XLFDT($PIECE($PIECE(BGPVSIT0,U),"."),-30),$PIECE($PIECE(BGPVSIT0,U),"."))
SET BGPEX=BGPEX_"|J"
PN6BA ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;
PN7 ;EP
+1 SET BGPEX=""
+2 ;no pneumonia dx
IF $$PNEUMODX^BGP8CU(BGPVSIT)=""
QUIT
+3 ; no one under 18 at admission date
IF $$AGE^AUPNPAT(DFN,$PIECE($PIECE(BGPVSIT0,U),"."))<50
QUIT
+4 SET M=$EXTRACT($$DSCH^BGP8CU(BGPVINP),4,5)
+5 ;only 10 through 2 months
IF +M>2
IF +M<10
QUIT
+6 ;exclusions
+7 ;death/ama, discharged day of or day after arrival
IF $$DEATHAMA^BGP8CU(BGPVINP)
SET BGPEX=BGPEX_"|9"
+8 IF $$LASTDXI^BGP8UTL1(DFN,"487.0",$PIECE($PIECE(BGPVSIT0,U),"."),$$DSCH^BGP8CU(BGPVINP),"HI")
SET BGPEX=BGPEX_"|L"
+9 IF $$LASTDX^BGP8UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP8CU(BGPVINP))
SET BGPEX=BGPEX_"|5"
PN7A ;
+1 IF $GET(BGPEXCL)
IF BGPEX]""
QUIT
+2 SET ^XTMP("BGP8C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$PIECE(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
+3 QUIT
+4 ;