What are the SQL queries to pull up the last 10 patients I diagnosed with diabetes, sorting from mor

Discussion in 'General Discussion' started by Jason, Sep 17, 2007.

  1. Jason

    Jason Developer / Handyman Staff Member

    What are the SQL queries to pull up the last 10 patients I diagnosed (in the diagnosis table) with diabetes, sorting from more recent to last



    I wrote the wrong name on a referral. I know the patient was recently diagnosed with diabetes.



    Is there a way to retrieve the info I want ?



  2. Graham

    Graham Developer Staff Member

    select u.fnames, u.surname from users u, diagnoses d where u.uid = d.patient and d.ic9 like '250.%' and d.created > '15-Aug-2007' order by d.created DESC


    this assumes you're using IC9
  3. Jason

    Jason Developer / Handyman Staff Member

    thx. I want mostly the word diabetes ... not the IC9.




    doesnt work.



  4. Graham

    Graham Developer Staff Member

    Or, try Reports/Query/Examples - example 1 and change it to diabetes
  5. Jason

    Jason Developer / Handyman Staff Member

    am i putting this in the right spot ?

    Attached Files:

  6. Graham

    Graham Developer Staff Member

    Yes ....


  7. Jason

    Jason Developer / Handyman Staff Member

    select u.fnames, u.surname from users u, diagnoses d where u.uid = d.patient and d.diagnosis like '%diabetes%' and d.created > '15-Aug-2005' order by d.created DESC

    Works.



  8. Graham

    Graham Developer Staff Member

Share This Page