[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gnumed-devel] Statistics
From: |
Karsten Hilbert |
Subject: |
Re: [Gnumed-devel] Statistics |
Date: |
Sat, 9 Feb 2013 09:24:21 +0100 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Fri, Feb 08, 2013 at 11:51:25PM +0000, Jim Busser wrote:
> >> How do I know how many patients I have seen in a day, month,
> >
> > Which one ? Or maybe you need to be a bit more specific
> > which time ranges you want to aggregate and which you want
> > to compare.
> >
> >> or last year
> >
> > select count(1)
> > from dem.identity d_i
> > where
> > d_i.pk in (
> > select fk_patient from clin.encounter
> > where
> > fk_type in (select pk from clin.encounter_type where
> > description in ('list', 'of', 'interesting', 'types')
> > and
> > started between 'year-01-01' and 'year-12-31'
> > )
> > ;
>
> Will the above count an individual patient more than once,
> in the case where they had more than one encounter in the
> interval of interest (and thereby generating the 'volume' of
> patients seen, not distinct patients)?
Ah, indeed. That's why I often ask for clarification as to
what's actually meant. Yes, this counts *encounters*, not
patients. One would need to DISTINCT ON fk_patient:
select count(1)
from dem.identity d_i
where
d_i.pk in (
select distinct fk_patient from clin.encounter
where
fk_type in (select pk from clin.encounter_type where
description in ('list', 'of', 'interesting', 'types'))
and
started between 'year-01-01' and 'year-12-31'
)
;
Untested.
Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
- Re: [Gnumed-devel] Statistics, Vaibhav Banait, 2013/02/09
- Re: [Gnumed-devel] Statistics, Karsten Hilbert, 2013/02/10
- Re: [Gnumed-devel] Statistics, Rogerio Luz Coelho, 2013/02/13
- Re: [Gnumed-devel] Statistics, Karsten Hilbert, 2013/02/13
- Re: [Gnumed-devel] Statistics, Rogerio Luz Coelho, 2013/02/13
- Re: [Gnumed-devel] Statistics, Karsten Hilbert, 2013/02/13
- Re: [Gnumed-devel] Statistics, Rogerio Luz Coelho, 2013/02/13