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

BGPD1.m

Go to the documentation of this file.
BGPD1 ; IHS/CMI/LAB - IHS area GPRA ;
 ;;7.0;IHS CLINICAL REPORTING;;JAN 24, 2007
 ;
PROC ;EP
 S BGPBT=$H
 D JRNL
 S BGPJ=$J,BGPH=$H
 ;calculate 3 years before end of each time frame
 S BGP3YE=$$FMADD^XLFDT(BGPED,-1096)
 S BGPP3YE=$$FMADD^XLFDT(BGPPED,-1096)
 S BGPB3YE=$$FMADD^XLFDT(BGPBED,-1096)
 F X=1:1:18 S $P(^BGPD(BGPRPT,10),U,X)="0!0",$P(^BGPD(BGPRPT,40),U,X)="0!0",$P(^BGPD(BGPRPT,80),U,X)="0!0" ;indicator 1
 F X=1:1:4 S $P(^BGPD(BGPRPT,18),U,X)="0!0",$P(^BGPD(BGPRPT,48),U,X)="0!0",$P(^BGPD(BGPRPT,88),U,X)="0!0"
 S ^BGPD(BGPRPT,480,0)="^90240.048A^0^0"
 S ^BGPD(BGPRPT,880,0)="^90240.088A^0^0"
 S ^BGPD(BGPRPT,180,0)="^90240.018A^0^0"
 S DFN=0 F  S DFN=$O(^AUPNPAT(DFN)) Q:DFN'=+DFN  D PROC1,PROCPR,PROC98
 S DIK="^BGPD(" D IXALL^DIK
 K DIK
 S BGPET=$H
 Q
 ;
JRNL ;
 N (DT,U) S %=$$NOJOURN^ZIBGCHAR("BGPD")
 Q
PROC1 ;current time period
 S (BGPDMPAT,BGPMBP,BGPLHGB,BGPHGBV,BGP2BD,BGP2CD,BGP4LP,BGP4TG,BGP4LDL,BGP4HDL,BGPUP,BGPACT)=""
 K BGPHV,BGPBPV ;kill glycemic value array
 S BGPHV(1)="",BGPHV(0)="",BGPHV(8)=""
 S BGPBPV(1)="",BGPBPV(0)="",BGPBPV(8)=""
 Q:$$BEN^AUPNPAT(DFN,"C")'="01"
 S DOD=$$DOD^AUPNPAT(DFN) I DOD]"",DOD<BGPED Q
 S X=$P($G(^AUPNPAT(DFN,11)),U,18) Q:X=""
 Q:'$D(BGPTAX($P(^AUPNPAT(DFN,11),U,18)))
 S X=$$LASTVD(DFN,BGP3YE,BGPED)
 Q:X=""  ;not an active user
 S BGPACT=1 ;an active user by end of time frame
 S BGPEDATE=BGPED,BGPTIME=1,BGPBDATE=BGPBD
 S BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE)
 S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
 D CALCIND
 Q
PROCPR ;
 S (BGPDMPAT,BGPMBP,BGPLHGB,BGPHGBV,BGP2BD,BGP2CD,BGP4LP,BGP4TG,BGP4LDL,BGP4HDL,BGPUP,BGPACT)=""
 Q:$$BEN^AUPNPAT(DFN,"C")'="01"
 S DOD=$$DOD^AUPNPAT(DFN) I DOD]"",DOD<BGPPED Q
 S X=$P($G(^AUPNPAT(DFN,11)),U,18) Q:X=""
 Q:'$D(BGPTAX($P(^AUPNPAT(DFN,11),U,18)))  ;not a community of interest)
 S X=$$LASTVD(DFN,BGPP3YE,BGPPED)
 Q:X=""  ;not an active user
 S BGPACT=1 ;an active user by end of time frame
 S BGPEDATE=BGPPED,BGPBDATE=BGPPBD,BGPTIME=0
 S BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE)
 S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
 D CALCIND
 Q
PROC98 ;
 S (BGPDMPAT,BGPMBP,BGPLHGB,BGPHGBV,BGP2BD,BGP2CD,BGP4LP,BGP4TG,BGP4LDL,BGP4HDL,BGPUP,BGPACT)=""
 Q:$$BEN^AUPNPAT(DFN,"C")'="01"
 S DOD=$$DOD^AUPNPAT(DFN) I DOD]"",DOD<BGPBED Q
 S X=$P($G(^AUPNPAT(DFN,11)),U,18) Q:X=""
 Q:'$D(BGPTAX($P(^AUPNPAT(DFN,11),U,18)))  ;not a community of interest)
 S X=$$LASTVD(DFN,BGPB3YE,BGPBED)
 Q:X=""  ;not an active user
 S BGPACT=1 ;an active user by end of time frame
 S BGPEDATE=BGPBED,BGPBDATE=BGPBBD,BGPTIME=8
 S BGPAGEB=$$AGE^AUPNPAT(DFN,BGPBDATE)
 S BGPAGEE=$$AGE^AUPNPAT(DFN,BGPEDATE)
 D CALCIND
 Q
CALCIND ;
 D I1A
 I $D(BGPIND(1))!($D(BGPIND(2)))!($D(BGPIND(3)))!($D(BGPIND(4)))!($D(BGPIND(5)))!($D(BGPIND(6)))!($D(BGPIND(7)))!($D(BGPIND(8)))!($D(BGPIND(9)))!($D(BGPIND(10)))!($D(BGPIND(11)))!($D(BGPIND(12)))!($D(BGPIND(13)))!($D(BGPIND(14))) D
 .D I1
 .D I1B^BGPD1B
 .D I2A^BGPD2
 .D I2B^BGPD2
 .D I2C^BGPD2
 .D I3A^BGPD3
 .D I3B^BGPD3
 .D I3C^BGPD3
 .D I4A^BGPD4
 .D I4B^BGPD4
 .D I4C^BGPD4
 .D I5A^BGPD5
 .D I5B^BGPD5
 .D I5C^BGPD5
 I $D(BGPIND(15))!($D(BGPIND(16))) D I6^BGPD6
 I $D(BGPIND(16)) D I6A^BGPD6
 I $D(BGPIND(17)) D I7^BGPD7
 I $D(BGPIND(18))!($D(BGPIND(23))) D I8^BGPD8
 I $D(BGPIND(19)) D I12^BGPD12
 I $D(BGPIND(20)) D I13^BGPD13
 I $D(BGPIND(21)) D I14^BGPD14
 I $D(BGPIND(22)) D I22^BGPD22
 ;I $D(BGPIND(23)) D I23^BGPD23
 I $D(BGPIND(24)) D I24^BGPD24
 I $D(BGPIND(25)) D I29^BGPD29
 I $D(BGPIND(26)) D I30^BGPD30
 I $D(BGPIND(27)) D IA^BGPDA
 I $D(BGPIND(28)) D IB^BGPDB
 I $D(BGPIND(29)) D IC^BGPDC
 I $D(BGPIND(30)) D ID^BGPDD
 Q
I1A ;EP - indicator 1
 S BGPSEX=$P(^DPT(DFN,0),U,2),BGPSEX=$S(BGPSEX="M":1,1:2)
 D SAGE(BGPRPT,$S(BGPTIME=1:10,BGPTIME=0:40,BGPTIME=8:80,1:"999"),1,BGPSEX,BGPACT) ;set total denom for 1 prevalence
 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:10,BGPTIME=0:40,BGPTIME=8:80,1:999),BGPAGEEP,BGPSEX,1)
 Q
I1 ;
 S BGPDMPAT=$$DM(DFN,BGPEDATE)
 D SAGE(BGPRPT,$S(BGPTIME=1:10,BGPTIME=0:40,BGPTIME=8:80,1:"999"),10,BGPSEX,BGPDMPAT)
 S BGPAGEEP=$S(BGPAGEE<15:11,BGPAGEE>14&(BGPAGEE<20):12,BGPAGEE>19&(BGPAGEE<25):13,BGPAGEE>24&(BGPAGEE<35):14,BGPAGEE>34&(BGPAGEE<45):15,BGPAGEE>44&(BGPAGEE<55):16,BGPAGEE>54&(BGPAGEE<65):17,BGPAGEE>64:18,1:"")
 D SAGE(BGPRPT,$S(BGPTIME=1:10,BGPTIME=0:40,BGPTIME=8:80,1:999),BGPAGEEP,BGPSEX,BGPDMPAT)
 I BGPDMPAT,$D(BGPLIST(1)),BGPTIME=1 S ^XTMP("BGPD",BGPJ,BGPH,"LIST",1,$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,EDATE) ;EP 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 "_$$DOB^AUPNPAT(P,"E")_"-"_$$FMTE^XLFDT(EDATE) S E=$$START1^APCLDF(X,Y)
 I $D(BGPG(1)) Q 1  ;has a dx
 Q 0
 ;
LASTVD(P,BDATE,EDATE) ;
 I '$G(P) Q ""
 I '$D(^AUPNVSIT("AC",P)) Q ""
 NEW A,B,E,V,X,G
 K ^TMP($J,"A")
 S A="^TMP($J,""A"",",B=P_"^ALL VISITS;DURING "_$$FMTE^XLFDT(BDATE)_"-"_$$FMTE^XLFDT(EDATE),E=$$START1^APCLDF(B,A)
 I '$D(^TMP($J,"A",1)) Q ""
 S (X,G)=0 F  S X=$O(^TMP($J,"A",X)) Q:X'=+X!(G)  S V=$P(^TMP($J,"A",X),U,5) D
 .Q:'$D(^AUPNVSIT(V,0))
 .Q:'$P(^AUPNVSIT(V,0),U,9)
 .Q:$P(^AUPNVSIT(V,0),U,11)
 .Q:'$D(^AUPNVPRV("AD",V))
 .Q:"SAHO"'[$P(^AUPNVSIT(V,0),U,7)
 .Q:"V"[$P(^AUPNVSIT(V,0),U,3)
 .S G=1
 .Q
 Q G