Revision [258]

This is an old revision of ListNextTPReviews made by SethKrieger on 2009-09-21 15:29:36.
 

List Next Treatment Plan Reviews


Back to Query Directory


This query demonstrates the use of a subquery to create values in a column -- nextreviewdate, in this case. Adjust the date range as needed.



SELECT
    (SELECT MIN(nextreviewdate)
     FROM v_tpreviews
     WHERE ptepisodenum = b.ptepisodenum
      AND tpheadernum = c.tpheadernum
      AND spv_signandfinalize = 1
      AND rowstatus = 'O'
    ) AS nextreviewdate,
    (a.lastname+', '+a.firstname+' / '+a.id) AS "Patient",
    d.provcode AS "Primary Provider"
FROM
   patients a
   JOIN ptepisodes b ON a.ptnum = b.ptnum
   JOIN tpheaders c ON b.ptepisodenum = c.ptepisodenum
   LEFT OUTER JOIN providers d ON b.providernum = d.providernum
WHERE
   a.flag = 0
   AND b.currentflag = 1
   AND a.dischargedate IS NULL
   AND nextreviewdate BETWEEN '2009-09-01' AND '2009-09-30'
ORDER BY "NextReviewDate","Patient"




CategoryQueries
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki