We are currently updating the OP Help Center content for the release of OP 14.19 or OP 19. OP 19 is a member of the certified OP 14 family of products (official version is 14.19.1), which you may see in your software (such as in Help > About) and in the Help Center tabs labeled 14.19. You may also notice that the version number in content and videos may not match the version of your software, and some procedural content may not match the workflow in your software. We appreciate your patience and understanding as we make these enhancements.

SQL: ASQ Survey Count by Age 3 (Current 3 Year Olds)


This report shows the total number of surveys with a certain name, done before a certain age, for all active patients between a certain age range.

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


In this example, active patients between ages 3 and 4 are checked to see how many ASQs they’ve had by the time they are 1095 days old (1095/365 = third birthday).

  • You can edit the age range by changing the line:
  • age >=3 and age <4
  • You can change the title(s) of the surveys by changing the line
  • where (title like '%ASQ%' or title like '%Ages and Stages%')
  • You can change the maximum age in days for the survey by changing the line
  • where (admin_date-birthdat) <= 1095


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

select * from
select register.patno, birthdat, datediff(month, 
dateadd(day,-extract(day from birthdat)+1,birthdat), 
dateadd(day,-extract (day from birthdat)+1,cast('today' as date))
)/12  as age, status_pat, total_asq from register

left outer join

select patno, count(title) as total_asq from
select register.patno, TITLE, admin_date, status_pat from register
left outer join (select register.patno, admin_date, questionhead_id from quest_result_header inner join register on register.patno = quest_result_header.patno where (admin_date-birthdat) <= 1095   ) qrh on qrh.patno = register.patno
left outer join (select questionhead_id, title from quest_Questionnaire_header ) qqh on qqh.questionhead_id =  qrh.questionhead_id
where (title like '%ASQ%' or title like '%Ages and Stages%')
group by patno
) a on a.patno = register.patno
where status_pat = 'ACTIVE' and 
age >=3 and age <4

order by patno