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, registration history, medications, referrals, and reference data.


Model Description
Patient Demographics, registration status, and opt-in flags
Patient Registration History Historical registration type and status entries
Observation Clinical observations, test results, and coded entries
Consultation Patient consultations with practitioners
Consultation Section Sections within a consultation (e.g. History, Examination)
Problem Active and past clinical problems
Referral Inbound and outbound referrals
Diary Diary entries and recall events
Appointment Slot Appointment bookings and slot status
Model Description
Drug Record medication_drug_record: medication courses (repeat and acute prescriptions)
Issue Record medication_issue_record: individual prescription issues from a drug record
Model Description
Clinical Code SNOMED CT and Read code mappings
Codeable Concept Extended code metadata including fully specified names
Drug Code Drug code to dm+d product mappings
MKB Drug Pack Drug pack details (units, pricing, supplier)
MKB Mapping Attributes Language and sexual orientation code mappings
MKB Mapping DMD Preparation dm+d preparation code mappings
MKB Mapping Ethnicity Ethnicity SNOMED code mappings
Sensitive SNOMED Code Codes classified as sensitive
Model Description
Sharing Agreements Data sharing agreement status between organisations
Query Utilization user_query_utilization: your personal query execution history and performance
Model Data Quality Latest data quality status by model and environment
Model Run Latest 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.