I need a report to give to individual providers with active patients who have a birthday coming up in the next month. It would be helpful for the report to also include patient addresses. The intent is to use the report to mail birthday cards.
This is a pretty basic query. It uses the function MONTH( ) to return only those patients whose birth month matches the month specified in the WHERE clause. You must enter the month as a digit, where January is 1 and December is 12. The output is sorted by day of the month. Add an OUTPUT statement to save it as a CSV file to print onto labels using Word’s mail-merge feature. See http://www.sosoft.com/queries/how2010/ for more details about exporting the query results.
In this example, we are specifying May birthdates — MONTH(dob) = 5 — and primary provider code of ‘AB’ — priprvcode = ‘AB’.
SELECT dob,firstname, lastname, addr1, addr2, city, state, zip FROM sos.rv_patients WHERE MONTH(dob) = 5 AND flag = 0 AND priprvcode = 'AB' ORDER BY DAY(dob)