BGPD1B ; IHS/CMI/LAB - ind 1b ;
;;7.0;IHS CLINICAL REPORTING;;JAN 24, 2007
;
I1B ;EP - indicator 1B
S BGPSEX=$P(^DPT(DFN,0),U,2),BGPSEX=$S(BGPSEX="M":1,1:2)
S D=$$FMADD^XLFDT(BGPEDATE,-365)
S BGPDMLY=$$DM(DFN,D,BGPEDATE)
D SAGE(BGPRPT,$S(BGPTIME=1:11,BGPTIME=0:41,BGPTIME=8:81,1:"999"),1,BGPSEX,BGPDMLY)
S BGPAGEEP=$S(BGPAGEE<15:2,BGPAGEE>14&(BGPAGEE<20):3,BGPAGEE>19&(BGPAGEE<25):4,BGPAGEE>24&(BGPAGEE<35):5,BGPAGEE>34&(BGPAGEE<45):6,BGPAGEE>44&(BGPAGEE<55):7,BGPAGEE>54&(BGPAGEE<65):8,BGPAGEE>64:9,1:"")
D SAGE(BGPRPT,$S(BGPTIME=1:11,BGPTIME=0:41,BGPTIME=8:81,1:999),BGPAGEEP,BGPSEX,BGPDMLY)
I BGPDMLY,$D(BGPLIST(2)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",2,$S($P($G(^AUPNPAT(DFN,11)),U,18)]"":$P(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$P(^DPT(DFN,0),U,2),BGPAGEE,DFN)=""
Q
SAGE(R,N,P,S,V) ;set age into file
I 'V Q ;no value
NEW X,Y
S X=$P($G(^BGPD(R,N)),U,P)
S $P(X,"!",S)=$P(X,"!",S)+V
S $P(^BGPD(R,N),U,P)=X
Q
S(R,N,P,V) ;
I 'V Q ;no value to add
S $P(^BGPD(R,N),U,P)=$P($G(^BGPD(R,N)),U,P)+V
Q
DM(P,BDATE,EDATE) ;is patient diabetic 1 or 0
I $G(P)="" Q ""
;check povs
NEW X,E,BGPG,Y
K BGPG
S Y="BGPG("
S X=P_"^LAST DX [SURVEILLANCE DIABETES;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
I $D(BGPG(1)) Q 1 ;has a dx
Q 0
;
;
BGPD1B ; IHS/CMI/LAB - ind 1b ;
+1 ;;7.0;IHS CLINICAL REPORTING;;JAN 24, 2007
+2 ;
I1B ;EP - indicator 1B
+1 SET BGPSEX=$PIECE(^DPT(DFN,0),U,2)
SET BGPSEX=$SELECT(BGPSEX="M":1,1:2)
+2 SET D=$$FMADD^XLFDT(BGPEDATE,-365)
+3 SET BGPDMLY=$$DM(DFN,D,BGPEDATE)
+4 DO SAGE(BGPRPT,$SELECT(BGPTIME=1:11,BGPTIME=0:41,BGPTIME=8:81,1:"999"),1,BGPSEX,BGPDMLY)
+5 SET BGPAGEEP=$SELECT(BGPAGEE<15:2,BGPAGEE>14&(BGPAGEE<20):3,BGPAGEE>19&(BGPAGEE<25):4,BGPAGEE>24&(BGPAGEE<35):5,BGPAGEE>34&(BGPAGEE<45):6,BGPAGEE>44&(BGPAGEE<55):7,BGPAGEE>54&(BGPAGEE<65):8,BGPAGEE>64:9,1:"")
+6 DO SAGE(BGPRPT,$SELECT(BGPTIME=1:11,BGPTIME=0:41,BGPTIME=8:81,1:999),BGPAGEEP,BGPSEX,BGPDMLY)
+7 IF BGPDMLY
IF $DATA(BGPLIST(2))
IF BGPTIME=1
SET ^XTMP("BGPD",BGPJ,BGPH,"LIST",2,$SELECT($PIECE($GET(^AUPNPAT(DFN,11)),U,18)]"":$PIECE(^AUPNPAT(DFN,11),U,18),1:"UNKNOWN"),$PIECE(^DPT(DFN,0),U,2),BGPAGEE,DFN)=""
+8 QUIT
SAGE(R,N,P,S,V) ;set age into file
+1 ;no value
IF 'V
QUIT
+2 NEW X,Y
+3 SET X=$PIECE($GET(^BGPD(R,N)),U,P)
+4 SET $PIECE(X,"!",S)=$PIECE(X,"!",S)+V
+5 SET $PIECE(^BGPD(R,N),U,P)=X
+6 QUIT
S(R,N,P,V) ;
+1 ;no value to add
IF 'V
QUIT
+2 SET $PIECE(^BGPD(R,N),U,P)=$PIECE($GET(^BGPD(R,N)),U,P)+V
+3 QUIT
DM(P,BDATE,EDATE) ;is patient diabetic 1 or 0
+1 IF $GET(P)=""
QUIT ""
+2 ;check povs
+3 NEW X,E,BGPG,Y
+4 KILL BGPG
+5 SET Y="BGPG("
+6 SET X=P_"^LAST DX [SURVEILLANCE DIABETES;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE)
SET E=$$START1^APCLDF(X,Y)
+7 ;has a dx
IF $DATA(BGPG(1))
QUIT 1
+8 QUIT 0
+9 ;
+10 ;