SQL: Food Insecurity Review

About

Gives the results of the most recent Food Insecurity risk assessment for patients seen in the office between a date range you specify.

A sample image of this SQL report run in the Database Viewer is shown below:


Caveats

  • The Food Insecurity risk assessment must be labeled exactly “Food Insecurity.”
  • The patient had either a well note or an encounter note during the date range you specify.
  • The risk assessment could have been completed at any time, not necessarily in the date range you specify.


Code

To highlight and copy the code below to your clipboard, simply click the Copy button.

select ras.patno, fname, lname, hphone, porgfnm as parent_first, porglnm as parent_last, visit_date, ras.create_date as risk_date, question_text, answer_code, answer_text from risk_question rq
inner join risk_assessment ras on ras.risk_question_id = rq.op_id
inner join risk_answer ra on ra.risk_question_id = ras.risk_question_id and ra.id = ras.risk_answer_id
inner join
(select patno, date1 as visit_date from enc_note where date1 between :Start_date and :end_date
union
select patno, date1 as visit_date from physical where date1 between :Start_date and :end_date) e on e.patno = ras.patno
inner join register on register.patno = ras.patno
where rq.question_text = 'Food Insecurity'