Skip to main content
Bulk Data Extracts

Extract Schema

Each query in an extract is written to its own CSV file, and all CSV files for a run are bundled into a single ZIP.

File structure

  • Each query is saved as a CSV file, named after the entity (for example coded_entry.csv). Table files are prefixed with the organisation's ODS code, for example YGMYW-patient.csv.
  • CSVs are comma-separated, use " for enclosure and \ for escaping, and use \n as the end-of-line character.
  • The first row is a header row of the field names selected in the query.
  • All CSV files for a run are added to one ZIP. Any reasonable ZIP naming convention is supported (for example {odsCode}-medicus-test-extract-{yyyy-mm-dd}.zip).
  • The ZIP filename is prefixed with full- or delta- for convenience.

For example, a full extract for organisation YGMYW run on 2026-01-15 produces a ZIP named full-YGMYW-medicus-test-extract-2026-01-15.zip, containing:

full-YGMYW-medicus-test-extract-2026-01-15.zip
├── YGMYW-patient.csv
├── YGMYW-patient-registration.csv
├── YGMYW-coded-entry.csv
├── YGMYW-prescription.csv
├── YGMYW-prescription-issue.csv
├── YGMYW-appointment.csv
├── YGMYW-appointment-practitioner.csv
├── YGMYW-appointment-service.csv
├── YGMYW-appointment-type.csv
├── YGMYW-site.csv
└── YGMYW-room.csv

A delta run of the same extract instead produces delta-YGMYW-medicus-test-extract-2026-01-15.zip, with the same CSV files inside.

Delta extracts

Delta extracts minimise transfer and processing by sending only what changed since the previous run.

  • The initial extract is always a full extract, with no change_type column.
  • Subsequent extracts are delta extracts: Medicus compares against the previous day's full extract and outputs only the changes, adding a change_type column with one of added, updated, or removed.
  • If a query includes a uid column, it is used as the unique identifier to decide added/updated/removed. Otherwise Medicus compares all column values.
  • If there are no changes for a query, the CSV is still produced with headers and no data rows.
  • The primary key of each row is a record UUID. If an extract definition changes, Medicus must restart with a fresh full initial extract.

Common formats used below: UUIDs (for example ac552fad-8100-4044-90b9-e39930ac7d85), dates as YYYY-MM-DD, and date-times as YYYY-MM-DD HH:MM:SS.

Identifier types (used by practitioner, GP, and organisation columns): practitioner/GP *_identifier_type is one of medicus-staff-id, medicus-referral-provider-practitioner-id, gb-nhs-gp-connect-practitioner-id, gb-gmc-number, gb-gphc-number, gb-hcpc-number, gb-nmc-pin, sds-user-id. Organisation organisation_identifier_type is one of medicus-tenant-id, nhs-england-ods-code, third-party-system-organisation-id, unknown-identifier-type.

Patient

{odsCode}-patient.csv

ColumnFormatDescription
idUUIDUnique identifier for the patient.
nhs_numberString, no spacesThe patient's NHS number.
date_of_birthYYYY-MM-DDThe patient's date of birth.
official_name_prefixStringThe patient's prefix, for example Mr.
official_given_nameStringThe patient's first name.
official_family_nameStringThe patient's surname.
preferred_given_nameStringThe patient's preferred first name.
clinical_sexmale / female / unknownDerived: sex at birth, otherwise gender identity.
deceasedBooleanWhether the patient is deceased.
is_test_patientBooleanWhether this is a test patient record.
named_gp_nameStringThe name of the patient's named GP.
named_gp_identifier_typeString (identifier type)Identifier type for the named GP (most commonly a GMC number).
named_gp_identifier_valueStringThe named GP identifier.
home_address_line_1StringThe patient's home address.
home_address_line_2String
home_address_line_3String
home_address_localityString
home_address_administrative_areaString
home_address_postal_codeString
home_address_countryString
date_of_deathYYYY-MM-DDDate of death, if deceased.
communication_email_addressStringEmail address for communicating with the patient.
communication_home_phone_numberStringHome phone number.
communication_mobile_phone_numberStringMobile phone number.
guernsey_social_insurance_numberString, no spacesCommonly referred to as the "GY Number".

Patient Registration

{odsCode}-patient-registration.csv

ColumnFormatDescription
idUUIDUnique identifier for the registration record.
patient_idUUIDForeign key for the related patient.
start_dateYYYY-MM-DDRegistration start date.
end_dateYYYY-MM-DDRegistration end date, if the patient has deregistered.
registration_typeStringFor example permanent, temporary, immediate-necessary-treatment. Can be customised by the organisation.
prescriptions_dispensed_by_practiceBooleanWhether the patient has medication dispensed by the practice.
care_home_residentBooleanWhether the patient is a care-home resident. May also be recorded as a coded entry.

Coded Entry

{odsCode}-coded-entry.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
care_record_idUUIDIdentifier of the underlying care record entry.
patient_idUUIDUnique identifier for the patient.
entity_typeStringThe record type. Useful for filtering, but avoid assuming coded data always falls into neat buckets.
codeStringThe SNOMED CT concept ID.
code_descriptionStringThe SNOMED CT description.
clinically_relevant_dateYYYY-MM-DDThe record entry date (for example the observation date).
clinically_relevant_timeHH:MM:SS
care_record_sorting_date_timeYYYY-MM-DD HH:MM:SSTimestamp used to order care record entries.
created_in_original_system_date_timeYYYY-MM-DD HH:MM:SSCreated date-time in the system the record originated from, if migrated.
created_date_timeYYYY-MM-DD HH:MM:SSCreated date-time in the original system.
encounter_idUUIDUseful for de-duplicating codes in the same encounter (for example for activity counts).
value_1NumberOptional value for numeric entries, for example height.
value_1_unit_codeStringSNOMED CT concept ID.
value_1_unit_descriptionStringThe SNOMED CT description.
value_2NumberOnly populated for blood pressures.
value_2_unit_codeStringSNOMED CT concept ID.
value_2_unit_descriptionStringThe SNOMED CT description.
body_site_codeStringOptional SNOMED CT body site (for example for an immunisation or procedure).
body_site_descriptionStringThe SNOMED CT description.
route_codeStringOptional SNOMED CT route (for example 255560000 Intravenous).
route_descriptionStringThe SNOMED CT description.
batch_numberStringUsually only populated for immunisations.
expiry_dateYYYY-MM-DDUsually only populated for immunisations.
statusActive / EndedOnly populated for certain records, for example allergies.
end_dateYYYY-MM-DDOnly populated for certain records, for example allergies.
practitioner_nameStringThe responsible practitioner.
practitioner_identifier_typeString (identifier type)Identifier type for the responsible practitioner.
practitioner_identifier_valueStringThe responsible practitioner's identifier.
organisation_identifier_typeString (organisation identifier type)Identifier type for the responsible organisation.
organisation_identifier_valueStringThe responsible organisation's identifier.
performed_at_local_organisationBooleanWhether the activity was performed at the local organisation (used by some payment extracts).
organisation_nameStringThe responsible organisation.
encounter_type_codeStringThe SNOMED CT encounter type. Commonly 1269515004 (Face to face), 439708006 (Home visit), 386472008 (Phone), 149971000000103 (Online), 37351000000107 (Administration).
encounter_type_descriptionStringThe SNOMED CT description.

Prescription

{odsCode}-prescription.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
patient_idUUIDUnique identifier for the patient.
typeStringOne of acute, repeat-prescribing, repeat-dispensing, variable-repeat.
statusStringOne of authorised, reauthorised, discontinued, requires-reauthorisation.
product_codeStringThe SNOMED CT / dm+d concept ID for the drug product.
product_descriptionStringThe SNOMED CT description.
dosage_instructionStringFree-text dosage instructions.
start_dateYYYY-MM-DDDate the prescription is authorised to start from.
expected_end_dateYYYY-MM-DDDerived estimate of when the supply ends.
authorised_dateYYYY-MM-DDDate the prescription was authorised.
authorised_by_practitioner_nameStringThe authorising practitioner.
authorised_by_practitioner_identifier_typeString (identifier type)Identifier type for the authorising practitioner.
authorised_by_practitioner_identifier_valueStringThe authorising practitioner's identifier.
last_issue_dateYYYY-MM-DDDate the prescription was last issued.
discontinued_dateYYYY-MM-DDDate the prescription was discontinued, if applicable.

Prescription Issue

{odsCode}-prescription-issue.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
patient_idUUIDUnique identifier for the patient.
prescription_idUUIDUnique identifier for the parent prescription.
product_codeStringThe SNOMED CT / dm+d concept ID for the drug product.
product_descriptionStringThe SNOMED CT description.
expected_days_supplyIntegerDays the supply is expected to last.
supply_end_dateYYYY-MM-DDDate the supply is expected to end.
quantity_valueNumberThe quantity issued to the patient.
quantity_unit_codeStringSNOMED CT concept ID for the quantity unit.
quantity_unit_descriptionStringThe SNOMED CT description (for example tablet).
issue_dateYYYY-MM-DDDate the issue was issued to the patient.
issue_methodStringOne of electronic-prescription-service, fp10ss-printed-script, handwritten-script, private-handwritten-script, private-printed-script, fp10-personally-administered, gg-ps2016-printed-script, gg-private-printed-script, unknown.
issued_by_practitioner_identifier_typeString (identifier type)Identifier type for the issuing practitioner.
issued_by_practitioner_identifier_valueStringThe issuing practitioner's identifier.
issued_by_practitioner_nameStringThe issuing practitioner.
issued_by_organisationStringThe issuing organisation.
issue_numberIntegerThe issue number in the authorised sequence (for example 3 of 12).
issue_statusStringnot-issued or issued.

Appointment

{odsCode}-appointment.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
patient_idUUIDUnique identifier for the patient.
statusStringOne of pending, started, seen, rescheduled, cancelled, did-not-attend.
appointment_type_idUUIDA practice-defined appointment type.
nhs_national_slot_type_categoryStringGPAD category (for example "General Consultation Acute").
intended_start_date_timeYYYY-MM-DD HH:MM:SSPlanned start.
intended_end_date_timeYYYY-MM-DD HH:MM:SSPlanned end.
intended_duration_secondsNumberPlanned duration in seconds.
appointment_container_idUUIDThe session/clinic the appointment belongs to.
delivery_modeStringOne of face-to-face, home-visit, video, phone.
linked_encounter_idUUIDThe encounter created when the appointment was completed, if any.
arrived_date_timeYYYY-MM-DD HH:MM:SSWhen the patient was marked as arrived.
booked_date_timeYYYY-MM-DD HH:MM:SSWhen the appointment was booked.
cancelled_date_timeYYYY-MM-DD HH:MM:SSWhen the appointment was cancelled.
rescheduled_date_timeYYYY-MM-DD HH:MM:SSWhen the appointment was rescheduled.

Appointment Practitioner

{odsCode}-appointment-practitioner.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
practitioner_nameStringThe practitioner's name.
practitioner_identifier_typeString (identifier type)Identifier type for the practitioner.
practitioner_identifier_valueStringThe practitioner's identifier.
appointment_container_idUUIDThe session/clinic this practitioner is associated with.

Appointment Service

{odsCode}-appointment-service.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
nameStringThe name of the service.

Appointment Type

{odsCode}-appointment-type.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
nameStringThe name of the appointment type.
appointment_service_idUUIDForeign key for the related appointment service.

Site

{odsCode}-site.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
nameStringThe name of the site.

Room

{odsCode}-room.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
nameStringThe name of the room.
site_idUUIDForeign key for the related site.