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: PCP Alignment

About

Shows all active patients, their PCPs, and who's done the most checkups on them beginning from a reference date you specify.

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

Caveats

  • Checkup attribution is defined as “well note with a certain rendering provider”.
  • PCP is who they’re assigned to in the Patient Register.
  • When a Patient has had several checkups amongst two or more provider, they will be shown only with the doc who has done the most.
  • In case or a two-way tie, the patient will show twice with an entry for both providers listed as Most Doc.
  • In case of a three-way tie, the patient will show three times with an entry for each providers listed as Most Doc.

Code

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

select  patno, s1.staffname as pcp, highest_count, s2.staffname as most_doc from
(


select patno, max(n) as highest_count from


(select patno, p_addr_id, count(p_addr_id) as n from physical where date1 >= :start_date  group by patno, p_addr_id) 

 group by patno


) w


left outer join
(select patno, p_addr_id as doc, count(p_addr_id) as n from physical where date1 >= :start_date  group by patno, p_addr_id) 
 w2 on w.patno = w2.patno and w.highest_count=w2.n

inner join register on register.patno = w.patno
left outer join staff1 s1 on s1.staffid = register.addr_id
left outer join staff1 s2 on s2.staffid = w2.doc
where register.patno >99 and status_pat = 'ACTIVE' and register.lname <> 'TESTPATIENT'