Skip to content
Partner Developer Portal

OpenSafely

The OpenSafely dataset provides pseudonymised primary care data from EMIS Web GP practices in England. It is designed for secure health research and analytics, enabling population-level studies while protecting individual patient privacy.

The data is made available through a set of structured models covering clinical events, patient demographics, medications, referrals, and reference data.


ModelDescription
PatientDemographics, registration status, and opt-in flags
ObservationClinical observations, test results, and coded entries
ConsultationPatient consultations with practitioners
Consultation SectionSections within a consultation (e.g. History, Examination)
ProblemActive and past clinical problems
ReferralInbound and outbound referrals
DiaryDiary entries and recall events
Appointment SlotAppointment bookings and slot status
ModelDescription
Drug RecordMedication courses (repeat and acute prescriptions)
Issue RecordIndividual prescription issues from a drug record
ModelDescription
Clinical CodeSNOMED CT and Read code mappings
Codeable ConceptExtended code metadata including fully specified names
Drug CodeDrug code to dm+d product mappings
MKB Drug PackDrug pack details (units, pricing, supplier)
MKB Mapping AttributesLanguage and sexual orientation code mappings
MKB Mapping DMD Preparationdm+d preparation code mappings
MKB Mapping EthnicityEthnicity SNOMED code mappings
Sensitive SNOMED CodeCodes classified as sensitive
ModelDescription
Sharing AgreementsData sharing agreement status between organisations
Query UtilizationYour personal query execution history and performance

The pipeline processes source data weekly, but consumer-facing models update monthly (last Sunday of each month). This provides a stable analytical baseline throughout the month. See Data Freshness & Quality for full details.

Each patient appears as a single row globally, deduplicated by NHS number across all qualifying practices. When a patient transfers between practices, their record updates to reflect the new practice without creating duplicates. See Practice Transfers for details.

All patient identifiers (patient_id, nhs_number) are pseudonymised. Pseudonymisation is deterministic within your user context and stable across practice transfers, enabling longitudinal analysis.

Only data from England GP practices with an active sharing agreement is included. Records flagged as sensitive or confidential at the source are excluded from clinical event models.


All clinical event models include a patient_id and organisation column. Join to the patient model on both columns to access demographic information:

SELECT
o.observation_id,
o.effective_datetime,
o.snomed_concept_id,
p.sex,
p.age,
p.date_of_birth
FROM explorer_open_safely.observation AS o
INNER JOIN explorer_open_safely.patient AS p
ON o.patient_id = p.patient_id
AND o.organisation = p.organisation
WHERE o.is_deleted = FALSE
AND p.is_deleted = FALSE

Use the clinical_code or codeable_concept models to look up human-readable terms for code_id values:

SELECT
o.observation_id,
o.effective_datetime,
c.term,
c.snomed_concept_id
FROM explorer_open_safely.observation AS o
INNER JOIN explorer_open_safely.clinical_code AS c
ON o.code_id = c.code_id
WHERE o.is_deleted = FALSE
AND c.is_deleted = FALSE

All models include an is_deleted column. When is_deleted = TRUE, the record has been soft-deleted at the source and all non-primary-key columns will be NULL. Always filter these out unless you have a specific reason to include them:

WHERE is_deleted = FALSE