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 patient privacy.

Data is exposed through 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_drug_record: medication courses (repeat and acute prescriptions)
Issue Recordmedication_issue_record: individual 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 Utilizationuser_query_utilization: your personal query execution history and performance
Model Data QualityLatest data quality status by model and environment
Model RunLatest successful model run windows by environment

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.


For practical guidance on common modelling questions, see the OpenSafely FAQ.

Join clinical event models to patient using patient_id 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

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

Soft-deleted records are handled in the platform data layer before records are exposed to consumers. The is_deleted column remains available in models for documentation, lineage, and audit use cases.