Active Patient Count For Date Range

This simple query tells you how many patients have charge entries in their ledgers between two dates.
The keyword DISTINCT in the COUNT() function eliminates duplicates.

SELECT
   COUNT(DISTINCT ptnum)
FROM
   sos.journal
WHERE
   trantype = 'S'
   AND amount > 0
   AND trandate BETWEEN '2004-01-01' AND '2004-12-31'

Here’s a variation using the rv_charges view that breaks down the patient count by rendering provider. In
this case, we use rv_charges as an easy way to get to the provider code associated with the charges:

SELECT
   provcode AS "Provider", 
   COUNT(DISTINCT ptnum) AS "Clients Seen"
FROM
   sos.rv_charges
WHERE
   amount > 0
   AND trandate BETWEEN '2004-01-01' AND '2004-12-31'
GROUP BY
   provcode

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.