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

BGP9C3.m

Go to the documentation of this file.
BGP9C3 ; IHS/CMI/LAB - calc CMS measures 26 Sep 2004 11:28 AM 04 May 2008 2:38 PM ;
 ;;9.0;IHS CLINICAL REPORTING;;JUL 1, 2009
 ;
PNALL ;EP
 ;was there pneumonia on this visit?
 Q:$$PNEUMODX^BGP9CU(BGPVSIT)=""
 I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q  ; no one under 18 at admission date
 S ^XTMP("BGP9C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=""
 Q
 ;
PN1 ;EP
 S BGPEX=""
 Q:$$PNEUMODX^BGP9CU(BGPVSIT)=""  ;no pneumonia dx
 I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q  ; no one under 18 at admission date
 ;exclusions
 I $$DDA^BGP9CU(BGPVSIT,BGPVINP) S BGPEX=1  ;discharged on day of arrival, exclusion 1
 I $$DEATHAMA^BGP9CU(BGPVINP),$$DODA^BGP9CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|2"  ;death/ama, discharged day of or day after arrival
 S BGPADMER="",BGPERPN=""
 I '$$ADMDX^BGP9CU(BGPVINP,"BGP CMS PNEUMONIA DXS") S BGPADMER="|3"  ;no admitting dx of pneumonia
 I '$$ERPNEU^BGP9CU(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^BGP9UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP9CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN1A ;
 I $G(BGPEXCL),BGPEX]"" Q
 S ^XTMP("BGP9C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
 Q
 ;
PN2 ;EP
 S BGPEX=""
 Q:$$PNEUMODX^BGP9CU(BGPVSIT)=""  ;no pneumonia dx
 I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<65 Q  ; no one under 18 at admission date
 ;exclusions
 I $$DEATHAMA^BGP9CU(BGPVINP) S BGPEX=BGPEX_"|9"  ;death/ama, discharged day of or day after arrival
 I $$LASTDX^BGP9UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP9CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN2A ;
 I $G(BGPEXCL),BGPEX]"" Q
 S ^XTMP("BGP9C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
 Q
 ;
PN3B ;EP
 S BGPEX=""
 Q:$$PNEUMODX^BGP9CU(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^BGP9CU3(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^BGP9CU3(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH^BGP9CU(BGPVINP),.BGPDATA)
 I $D(BGPDATA) S BGPANTIH=1
 I 'BGPANTIH!('BGPERBC) Q  ;S BGPEX="|6"
 ;exclusions
 I $$DDA^BGP9CU(BGPVSIT,BGPVINP) S BGPEX=1  ;discharged on day of arrival, exclusion 1
 S BGPADMER="",BGPERPN=""
 I '$$ADMDX^BGP9CU(BGPVINP,"BGP CMS PNEUMONIA DXS") S BGPADMER="|3"  ;no admitting dx of pneumonia
 I '$$ERPNEU^BGP9CU(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^BGP9CU(BGPVINP) S BGPEX=BGPEX_"|9"  ;death/ama, discharged day of or day after arrival
 I $$LASTDX^BGP9UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP9CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN3A ;
 I $G(BGPEXCL),BGPEX]"" Q
 S ^XTMP("BGP9C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
 Q
 ;
PN4 ;EP
 S BGPEX=""
 Q:$$PNEUMODX^BGP9CU(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^BGP9CU2(DFN,$$FMADD^XLFDT($P($P(^AUPNVSIT(BGPVSIT,0),U),"."),-365),$$DSCH^BGP9CU(BGPVINP),.BGPDATA)
 I '$D(BGPDATA) Q  ;not a smoker
 ;exclusions
 I $$DEATHAMA^BGP9CU(BGPVINP) S BGPEX=BGPEX_"|9"  ;death/ama, discharged day of or day after arrival
 I $$LASTDX^BGP9UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP9CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN4A ;
 I $G(BGPEXCL),BGPEX]"" Q
 S ^XTMP("BGP9C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
 Q
 ;
PN5B ;EP
 S BGPEX=""
 Q:$$PNEUMODX^BGP9CU(BGPVSIT)=""  ;no pneumonia dx
 I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q  ; no one under 18 at admission date
 ;exclusions
 I $$DDA^BGP9CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|1"  ;discharged on day of arrival, exclusion 1
 S BGPADMER="",BGPERPN=""
 I '$$ADMDX^BGP9CU(BGPVINP,"BGP CMS PNEUMONIA DXS") S BGPADMER="|3"  ;no admitting dx of pneumonia
 I '$$ERPNEU^BGP9CU(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^BGP9CU(BGPVINP),$$DODA^BGP9CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|2"  ;death/ama, discharged day of or day after arrival
 I $$LASTDX^BGP9UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP9CU(BGPVINP)) S BGPEX=BGPEX_"|5"
 S BGPANTIH=""
 K BGPDATA,BGPY
 D ANTIRX^BGP9CU3(DFN,$P($P(BGPVSIT0,U),"."),$$DSCH^BGP9CU(BGPVINP),.BGPDATA)
 I '$D(BGPDATA) S BGPEX=BGPEX_"|7"
 D GETMEDS^BGP9CU(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("BGP9C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
 Q
 ;
PN6 ;EP
 S BGPEX=""
 Q:$$PNEUMODX^BGP9CU(BGPVSIT)=""  ;no pneumonia dx
 I $$AGE^AUPNPAT(DFN,$P($P(BGPVSIT0,U),"."))<18 Q  ; no one under 18 at admission date
 ;exclusions
 I $$DDA^BGP9CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|1"  ;discharged on day of arrival, exclusion 1
 S BGPADMER="",BGPERPN=""
 I '$$ADMDX^BGP9CU(BGPVINP,"BGP CMS PNEUMONIA DXS") S BGPADMER="|3"  ;no admitting dx of pneumonia
 I '$$ERPNEU^BGP9CU(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^BGP9CU(BGPVINP),$$DODA^BGP9CU(BGPVSIT,BGPVINP) S BGPEX=BGPEX_"|2"  ;death/ama, discharged day of or day after arrival
 I $$LASTDX^BGP9UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP9CU(BGPVINP)) S BGPEX=BGPEX_"|5"
 K BGPDATA
 I $$HIV^BGP9CU4(DFN,$$DOB^AUPNPAT(DFN),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|A"
 I $$SYSCHEMO^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|B"
 I $$SYSIMMUN^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|C"
 I $$LEUKEMIA^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|D"
 I $$LYMPHOMA^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|K"
 I $$RADTHER^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|E"
 I $$PRIORHOS^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-14),$P($P(BGPVSIT0,U),"."),BGPVSIT) S BGPEX=BGPEX_"|F"
 I $$HOS2DAYS^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|G"
 I $$NURSHOME^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-90),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|H"
 I $$CHRDIAL^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-30),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|I"
 I $$WOUNDCAR^BGP9CU4(DFN,$$FMADD^XLFDT($P($P(BGPVSIT0,U),"."),-30),$P($P(BGPVSIT0,U),".")) S BGPEX=BGPEX_"|J"
PN6BA ;
 I $G(BGPEXCL),BGPEX]"" Q
 S ^XTMP("BGP9C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
 Q
 ;
PN7 ;EP
 S BGPEX=""
 Q:$$PNEUMODX^BGP9CU(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^BGP9CU(BGPVINP),4,5)
 I +M>2,+M<10 Q  ;only 10 through 2 months
 ;exclusions
 I $$DEATHAMA^BGP9CU(BGPVINP) S BGPEX=BGPEX_"|9"  ;death/ama, discharged day of or day after arrival
 I $$LASTDXI^BGP9UTL1(DFN,"487.0",$P($P(BGPVSIT0,U),"."),$$DSCH^BGP9CU(BGPVINP),"HI") S BGPEX=BGPEX_"|L"
 I $$LASTDX^BGP9UTL1(DFN,"BGP CMS CYSTIC FIBROSIS DXS",$$DOB^AUPNPAT(DFN),$$DSCH^BGP9CU(BGPVINP)) S BGPEX=BGPEX_"|5"
PN7A ;
 I $G(BGPEXCL),BGPEX]"" Q
 S ^XTMP("BGP9C1",BGPJ,BGPH,"LIST",BGPIND,BGPPLSTL,$P(^DPT(DFN,0),U),DFN,BGPVSIT)=BGPEX
 Q
 ;