Skip to content

OpenSAFELY Contracts reference🔗

Danger

This page discusses the new OpenSAFELY Data Builder for accessing OpenSAFELY data sources.

Use OpenSAFELY cohort-extractor, unless you are specifically involved in the development or testing of Data Builder.

OpenSAFELY Data Builder and its documentation are still undergoing extensive development. We will announce when Data Builder is ready for general use on the Platform News page.

This page will be a reference for OpenSAFELY Contracts.

It is likely that much or all of this content will be automatically generated from the Data Builder contracts code via a MkDocs plugin.

Contracts/PatientDemographics🔗

Provides demographic information about patients.

Column name Description Type Constraints
patient_id Patient's pseudonymous identifier, for linkage. You should not normally output or operate on this column PseudoPatientId Must have a value, must be unique.
date_of_birth Patient's year and month of birth, provided in format YYYY-MM-01. Date Must have a value, must be the first day of a month.
sex Patient's sex. Choice Must have a value.
date_of_death Patient's year and month of death, provided in format YYYY-MM-01. Date Must be the first day of a month.

Contracts/WIP_ClinicalEvents🔗

TODO.

Column name Description Type Constraints
patient_id PseudoPatientId .
code Code .
system String .
date Date .
numeric_value Float .

Contracts/WIP_CovidTestResults🔗

TODO.

Column name Description Type Constraints
patient_id PseudoPatientId .
date Date .
positive_result Boolean .

Contracts/WIP_HospitalAdmissions🔗

TODO.

Column name Description Type Constraints
patient_id PseudoPatientId .
admission_date Date .
primary_diagnosis Code .
admission_method Integer .
episode_is_finished Boolean .
spell_id Integer .

Contracts/WIP_Hospitalizations🔗

TODO.

Column name Description Type Constraints
patient_id PseudoPatientId .
date Date .
code Code .
system String .

Contracts/WIP_HospitalizationsWithoutSystem🔗

TODO.

Column name Description Type Constraints
patient_id PseudoPatientId .
code Code .

Contracts/WIP_PatientAddress🔗

TODO.

Column name Description Type Constraints
patient_id PseudoPatientId .
patientaddress_id Integer .
date_start Date .
date_end Date .
index_of_multiple_deprivation_rounded Integer .
has_postcode Boolean .

Contracts/WIP_PracticeRegistrations🔗

TODO.

Column name Description Type Constraints
patient_id PseudoPatientId .
pseudo_id Integer .
nuts1_region_name String .
date_start Date .
date_end Date .

Contracts/WIP_Prescriptions🔗

TODO.

Column name Description Type Constraints
patient_id PseudoPatientId .
prescribed_dmd_code Code .
processing_date Date .

Contracts/WIP_SimplePatientDemographics🔗

TODO.

Column name Description Type Constraints
patient_id PseudoPatientId Must be unique.
date_of_birth Date .

Universal/Patients🔗

Column name Description Type Constraints
patient_id Patient's pseudonymous identifier, for linkage.This will not normally be output, or operated on by researchers. PseudoPatientId Must have a value, must be unique.
date_of_birth Patient's year and month of birth, provided in format YYYY-MM-01. The day will always be the first of the month. Date Must be the first day of a month, must have a value.
sex Patient's sex as defined by the options: male, female, intersex, unknown. Choice Must have a value.
date_of_death Patient's year and month of death, provided in format YYYY-MM-01.The day will always be the first of the month. Date Must have a value.