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

BGPD30.m

Go to the documentation of this file.
  1. BGPD30 ; IHS/CMI/LAB - indicator 30 ;
  1. ;;7.0;IHS CLINICAL REPORTING;;JAN 24, 2007
  1. ;
  1. I30 ;EP ;EP - indicator 30
  1. ;Q:'$D(BGPIND(26))
  1. S BGPSEX=$P(^DPT(DFN,0),U,2),BGPSEX=$S(BGPSEX="M":1,1:2)
  1. I BGPAGEB>11&(BGPAGEB<18) D
  1. .D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),2,BGPSEX,1)
  1. .S BGPP=$$TOBACCO(DFN,BGPEDATE)
  1. .I BGPP]"" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),4,BGPSEX,1)
  1. .I BGPP["CURRENT" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),6,BGPSEX,1)
  1. .I BGPP["SMOKER IN HOME" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),8,BGPSEX,1)
  1. .I $D(BGPLIST(26)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",26,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP
  1. I BGPAGEB>17&(BGPAGEB<35) D
  1. .D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),3,BGPSEX,1)
  1. .S BGPP=$$TOBACCO(DFN,BGPEDATE)
  1. .I BGPP]"" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),5,BGPSEX,1)
  1. .I BGPP["CURRENT" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),7,BGPSEX,1)
  1. .I BGPP["SMOKER IN HOME" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),9,BGPSEX,1)
  1. .I $D(BGPLIST(26)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",26,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP
  1. I BGPAGEB>34&(BGPAGEB<55) D
  1. .D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),11,BGPSEX,1)
  1. .S BGPP=$$TOBACCO(DFN,BGPEDATE)
  1. .I BGPP]"" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),12,BGPSEX,1)
  1. .I BGPP["CURRENT" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),13,BGPSEX,1)
  1. .I BGPP["SMOKER IN HOME" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),14,BGPSEX,1)
  1. .I $D(BGPLIST(26)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",26,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP
  1. I BGPAGEB>54 D
  1. .D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),15,BGPSEX,1)
  1. .S BGPP=$$TOBACCO(DFN,BGPEDATE)
  1. .I BGPP]"" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),16,BGPSEX,1)
  1. .I BGPP["CURRENT" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),17,BGPSEX,1)
  1. .I BGPP["SMOKER IN HOME" D SAGE(BGPRPT,$S(BGPTIME=1:19,BGPTIME=0:49,BGPTIME=8:89,1:999),18,BGPSEX,1)
  1. .I $D(BGPLIST(26)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",26,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=BGPP
  1. Q
  1. SAGE(R,N,P,S,V) ;set age into file
  1. I 'V Q ;no value
  1. NEW X,Y
  1. S X=$P($G(^BGPD(R,N)),U,P)
  1. S $P(X,"!",S)=$P(X,"!",S)+V
  1. S $P(^BGPD(R,N),U,P)=X
  1. Q
  1. S(R,N,P,V) ;
  1. I 'V Q ;no value to add
  1. S $P(^BGPD(R,N),U,P)=$P($G(^BGPD(R,N)),U,P)+V
  1. Q
  1. ;
  1. TOBACCO(P,EDATE) ;EP
  1. ;get last health factor in date range from V Health Factors
  1. ;if none, check health status and check date
  1. I '$G(P) Q ""
  1. NEW BGPTOB,BGP,X,E
  1. K BGPTOB
  1. D TOBACCO1
  1. I $D(BGPTOB) Q BGPTOB
  1. D TOBACCO0
  1. I $D(BGPTOB) Q BGPTOB
  1. Q ""
  1. TOBACCO1 ;check for tobacco documented in health factors
  1. K BGPTOB S BGPTOB=$$LASTHF(P,"TOBACCO",EDATE)
  1. Q
  1. TOBACCO0 ;lookup in health status
  1. S (X,Y)=0 F S X=$O(^AUPNHF("AA",P,X)) Q:X'=+X!(Y) I $$VAL^XBDIQ1(9999999.64,X,.03)="TOBACCO" S Y=X
  1. Q:'Y
  1. S E=$O(^AUPNHF("AA",P,Y,E)) Q:'E
  1. I (9999999-E)>EDATE Q ;documented after time frame
  1. S Y=$P(^AUTTHF(Y,0),U)
  1. I Y["NON" S BGPTOB="NEVER USED" Q
  1. I Y["SMOKE FREE HOME" S BGPTOB="NEVER USED" Q
  1. I Y["PREVIOUS" S BGPTOB="PAST USE" Q
  1. I Y="SMOKER IN HOME" S BGPTOB="SMOKER IN HOME" Q
  1. S BGPTOB="CURRENT USER"
  1. Q
  1. ;
  1. LASTHF(P,C,EDATE) ;EP - get last factor in category C for patient P
  1. I '$G(P) Q ""
  1. I $G(C)="" Q ""
  1. I $G(F)="" S F=""
  1. S C=$O(^AUTTHF("B",C,0)) ;ien of category passed
  1. I '$G(C) Q ""
  1. NEW H,D,O S H=0 K O
  1. F S H=$O(^AUTTHF("AC",C,H)) Q:'+H D
  1. . Q:'$D(^AUPNVHF("AA",P,H))
  1. . S D="" F S D=$O(^AUPNVHF("AA",P,H,D)) Q:D'=+D D
  1. .. Q:(9999999-D)>EDATE ;after time frame
  1. .. S O(D)=$O(^AUPNVHF("AA",P,H,D,""))
  1. . Q
  1. S D=$O(O(0))
  1. I D="" Q D
  1. Q $$VAL^XBDIQ1(9000010.23,O(D),.01)
  1. ;
  1. ;;