opensafely / opensafely/pharmacy-first-data-development
Blog: Using consultation id to reconstruct episode-level care in primary care EHR data
@viv3ckj is already working on this.
Since Jan 23, 2026.
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 4
Description
Summary
We should write a short methods-focused blog explaining how consultation identifiers (consultation_id) can be used to link records from the same clinical encounter in primary care EHR data.
This blog is intended to be generalisable guidance for researchers. Pharmacy First will be used only as an example to show how consultation id-based linkage is used in practice.
The aim is to document:
- how consultation IDs can be used for episode-level linkage,
- what we observed when applying this in real data,
- and the practical limitations researchers should be aware of.
Purpose of the blog
The blog should help future users who want to:
- link diagnoses and medications within the same consultation,
- reconstruct episode-level care across multiple tables,
- avoid relying solely on date-based linkage.
It should focus on methodology and data behaviour, not service evaluation or policy analysis.
What the blog should cover
1. Why episode-level linkage matters
- Brief explanation of the problem with record-level EHR data.
- Limitations of same-day or time-window-based linkage.
2. Consultation identifiers in EHR data
- What
consultation_idis, as observed in the data. - How it can be used to group records across tables.
3. How we used consultation IDs
- Linking records across:
clinical_eventsmedications
- Consultation ID–based linkage as the primary approach.
- Same-day linkage as a comparison.
4. What we observed in practice (illustrative example)
- Using Pharmacy First consultations as an example:
- Same-day linkage identifies more records.
- Medication status fields (e.g. PGD) are not reliably populated.
- Emphasis that this reflects recording practices, not clinical care.
5. Limitations and caveats
- Incomplete population of consultation IDs.
- Variation in recording practices.
- Importance of checking behaviour in each use case.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.