RSS Git Download  Clone
Raw Blame History
[previous_cml_monitoring]
select date(r.created_at) as 'registered', rrs.results_summary as 'result'
from requests r
	join ( patient_case pc join patients p on pc.patient_id = p.id )
		on r.patient_case_id = pc.id
	join ( request_initial_screen ris join screens s on ris.screen_id = s.id )
		on ris.request_id = r.id
	join ( request_result_summaries rrs join lab_sections ls on rrs.lab_section_id = ls.id )
		on rrs.request_id = r.id
where s.description = 'Follow-up CML (PB)'
	and ls.section_name = 'Molecular'
	and p.nhs_number = ?
order by r.created_at desc
limit 5

[referral_sources]
select rs.id, rs.display_name, rs.organisation_code
from referral_sources rs
    join referral_types rt on rs.referral_type_id = rt.id
where rt.description = 'hospital'
    and rs.is_active = 'yes'
	and rs.display_name regexp ? /* sqlite can't do rlike, use 'regexp' */