SELECT DISTINCT CONCAT( "", d.demographic_no, "" ) as 'Chart No.',
CONCAT(d.last_name,', ', d.first_name) as 'Patient Name',
CONCAT(date_of_birth, '-', month_of_birth, '-',year_of_birth, ' ')
as 'Date of Birth',
d.hin as 'H.I.N.',
CONCAT(' Home: ', d.phone, ' Work: ' , d.phone2) as 'Phone Numbers'
FROM demographic d, eChart e
WHERE e.{source} LIKE '%{searchtext}%'
AND patient_status = 'AC'
AND d.demographic_no = e.demographicNo
ORDER BY last_name, first_name ;
( select 'SocialHistory','SocialHistory' ) UNION
( select 'FamilyHistory','FamilyHistory' ) UNION
( select 'MedicalHistory','MedicalHistory' ) UNION
( select 'OngoingConcerns','OngoingConcerns' ) UNION
( select 'Reminders','Reminders' ) UNION
( select 'Encounter','Encounter' ) ;