SQL: Contacts and Associated Patient Charts

About

This SQL locates all Contacts in your system and the patient chart(s) they're associated with.  This can be useful for evaluating whether you might have duplicate Contacts that need to be merged using the Merge Contacts feature.

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

Caveats

  • The Contacts may have any relationship to the patient chart.
  • The patient charts may be any status (ACTIVE, INACTIVE, DISCHARGED, etc).

Code

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

select first_name as contact_first, last_name as contact_last,  register.patno, fname as patient_first, lname as patient_last from  register
inner join register_contact on register.patno = register_contact.patno
inner join contact on contact.id = register_contact.contact_id
where register.patno is not null and register.patno >= 99
order by patno