There are two versions of this SQL: Firebird and MySQL. The MySQL version only applies to clients who are have migrated to MySQL.. All other Practices should continue to use the Firebird version of this code. Click to expand and copy the code you need. If you are unsure which code to use, please check with your Practice Administrator. |
About
This report displays all completed visits on the schedule for infants 30 days old or less on the day of the appointment, for an appointment date range you specify.
A sample image of this SQL report run in the Database Viewer is shown below:
Caveats
Visit status must be “completed.”
SQL Code: Firebird
To highlight and copy the code below to your clipboard, simply click the Copy button.
select patno, appt_date, birthdat, code1, fname, lname from schedule inner join register on register.patno = schedule.patno where cast(appt_date as date)-birthdat <= 30 and visit_status = 'Completed' and appt_date between :start_date and :end_date order by appt_date, patno
SQL Code: MySQL
To highlight and copy the code below to your clipboard, simply click the Copy button.
select schedule.patno, cast(appt_date as date) as appt_date, cast(birthdat as date) as dob, code1, fname, lname from schedule inner join register on register.patno = schedule.patno where visit_status = 'Completed' and datediff(appt_date,birthdat ) <=30 and appt_date between :start_date and :end_date order by appt_date, patno