Patient List by Rendering Provider

Here is a query that will show the patient on the list for every provider who ever provided services for
that patient (so that patient could show up on multiple lists). The output is sorted by rendering provider,
but there are no page breaks or other fancy stuff.
SELECT DISTINCT
   d.provcode,
   a.lastname, 
   a.firstname, 
   a.id
FROM
   sos.patients a 
   JOIN sos.journal b 
   JOIN sos.jcharges c 
   JOIN sos.providers d
WHERE
   a.flag = 0
GROUP BY
   provcode,
   lastname, 
   firstname, 
   id
ORDER BY
   provcode, 
   lastname, 
   firstname, 
   id
"a.flag = 0" restricts the output to active patients
If you wanted to output a single provider you would add this on the line below "a.flag"
AND d.provcode = 'ABC'

Leave a Reply

Your email address will not be published. Required fields are marked *

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.