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 by the extract definition, for example YGMYW-coded-entry.csv. {odsCode} is replaced with the organisation's ODS code.
  • 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.
  • String fields have no maximum length. Store them in an unbounded text type so nothing is truncated.
  • All CSV files for a run are added to one ZIP. The extract definition sets its name, for example {odsCode}-medicus-test-extract-{yyyy-mm-dd}.zip, where {yyyy-mm-dd} is the date the extract ran.
  • The ZIP is sent with full- or delta- in front of that name. A delta's CSVs carry a change_type column, which a full extract's CSVs don't have.
  • An encrypted ZIP has .gpg added to its name. Over MESH, an unencrypted ZIP is sent base64-encoded with .b64 added to its name.

For example, a full extract for organisation YGMYW run on 2026-01-15 is sent as 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-outbound-referral.csv
├── YGMYW-appointment.csv
├── YGMYW-appointment-practitioner.csv
├── YGMYW-appointment-service.csv
├── YGMYW-appointment-type.csv
├── YGMYW-site.csv
├── YGMYW-room.csv
├── YGMYW-clinical-case.csv
├── YGMYW-clinical-case-type.csv
├── YGMYW-encounter.csv
├── YGMYW-staff.csv
├── YGMYW-staff-professional-identifier.csv
├── YGMYW-job-role.csv
├── YGMYW-job-role-assignment.csv
├── YGMYW-team.csv
├── YGMYW-team-membership.csv
├── YGMYW-commissioned-service.csv
└── YGMYW-scheduled-activity.csv

A delta run of the same extract is sent as 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 its id column. If an extract definition changes, Medicus must restart with a fresh full initial extract.
  • The scheduled activity file only covers the six months before and after the run date. A row is included while any part of it falls in that range. A row that drops out because it ended more than six months ago is not sent as removed; keep your own history if you need it.

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
idStringUnique ID for the row, {care_record_id}-{name}, for example ac552fad-8100-4044-90b9-e39930ac7d85-immunisationProduct. One care record entry can produce more than one row: an immunisation has a code and a product row, an allergy a code and a substance row.
care_record_idUUIDIdentifier of the underlying care record entry. Shared by every row that entry produces.
patient_idUUIDUnique identifier for the patient.
entity_typeStringThe record type: allergy-intolerance, communication, consultation-topic, document, fit-note, immunisation, investigation-group, investigation-result, medication-statement, note, observation, outbound-referral, prescription, problem or procedure. A prescription row is one issue of a prescription, and its care_record_id is the issue ID. 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_organisationT / F / NWhere the activity was performed, used by some payment extracts. T is this organisation, F is another organisation, and N means no performing organisation is recorded. Always N for allergies, communications, documents, investigations and problems.
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.
value_1_comparator< / <= / > / >= / =The comparator recorded with value_1, for example a result of <5 has <. Only populated for investigation results and observations.
reference_range_lower_limitNumberLower limit of the reference range, for investigation results and observations. Empty when a result has more than one range.
reference_range_upper_limitNumberUpper limit of the reference range, for investigation results and observations. Empty when a result has more than one range.
episodefirst / subsequentOnly populated for problems.
significancemajor / minor / unknownOnly populated for problems. unknown when the problem has no significance recorded.
parent_problem_idUUIDThe parent problem's care_record_id. Only populated for problems nested under another problem.
clinical_case_idUUIDForeign key for the related clinical case, if linked to one.

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.
review_dateYYYY-MM-DDDate the prescription is due for review, if set.
created_date_timeYYYY-MM-DD HH:MM:SSDate-time the prescription was created in Medicus.
created_in_original_system_date_timeYYYY-MM-DD HH:MM:SSCreated date-time in the system the record originated from, if migrated.
encounter_idUUIDForeign key for the encounter the prescription was recorded in, if any.
clinical_case_idUUIDForeign key for the related clinical case, if linked to one.

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, fp10-private-controlled-drug, 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.
pharmacy_ods_codeStringODS code of the pharmacy the issue's EPS order was sent to, if issued via EPS.
created_date_timeYYYY-MM-DD HH:MM:SSDate-time the issue was created in Medicus.

Outbound Referral​

{odsCode}-outbound-referral.csv

ColumnFormatDescription
idUUIDUnique ID for the outbound referral. Matches care_record_id on its coded entry.
patient_idUUIDForeign key for the related patient.
typemanual / nhs-e-referral / barsHow the referral was sent.
statusactive / cancelled / sentThe referral status.
priorityroutine / urgent / two-week-waitThe referral priority, if recorded.
referral_dateYYYY-MM-DDDate of the referral, if recorded.
clinical_specialty_codeSNOMED CT concept IDThe clinical specialty referred to, if recorded.
clinical_specialty_descriptionStringDescription of the clinical specialty.
referred_to_organisation_nameStringOrganisation referred to. Only populated for manual and BaRS referrals.
referred_to_organisation_identifier_typeString (organisation identifier type)Identifier type for the organisation referred to, for example nhs-england-ods-code.
referred_to_organisation_identifier_valueStringThe organisation's identifier, for example its ODS code.
referred_to_service_nameStringService referred to. Only populated for manual and BaRS referrals.
referred_to_service_identifier_typeStringIdentifier type for the service referred to.
referred_to_service_identifier_valueStringThe service's identifier.
referred_to_practitioner_nameStringPractitioner referred to. Only populated for manual referrals.
referred_to_practitioner_identifier_typeString (practitioner identifier type)Identifier type for the practitioner referred to.
referred_to_practitioner_identifier_valueStringThe practitioner's identifier.
unique_booking_reference_numberString, 12 digitsThe NHS e-Referral Service UBRN. Only populated for referrals sent through e-RS.
encounter_idUUIDForeign key for the encounter the referral was recorded in, if any.
created_date_timeYYYY-MM-DD HH:MM:SSDate-time the referral was created in Medicus.
created_in_original_system_date_timeYYYY-MM-DD HH:MM:SSCreated date-time in the system the record originated from, if migrated.

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.

Clinical Case​

{odsCode}-clinical-case.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
patient_idUUIDForeign key for the related patient.
commissioned_service_idUUIDForeign key for the related commissioned service, if any.
clinical_case_type_idUUIDForeign key for the related clinical case type.
case_statusopen / closedWhether the case is currently open or closed.
created_date_timeYYYY-MM-DD HH:MM:SSWhen the case was created.
closed_date_timeYYYY-MM-DD HH:MM:SSWhen the case was closed, if closed.

Clinical Case Type​

{odsCode}-clinical-case-type.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
case_type_nameStringThe name of the clinical case type.

Encounter​

{odsCode}-encounter.csv

ColumnFormatDescription
idUUIDUnique ID for the encounter. Matches encounter_id on the coded entry file and linked_encounter_id on the appointment file.
patient_idUUIDForeign key for the related patient.
start_dateYYYY-MM-DDThe date the encounter started.
start_timeHH:MM:SSThe time the encounter started, if recorded.
end_date_timeYYYY-MM-DD HH:MM:SSWhen the encounter ended, if recorded.
actual_duration_secondsNumberSeconds from start to end. Only populated when both the start time and end are recorded.
encounter_type_codeStringThe SNOMED CT encounter type. Encounters recorded in Medicus use one of 1269515004 (Face to face), 386472008 (Phone), 719410009 (Video), 149971000000103 (Online), 439708006 (Home visit), 37351000000107 (Administration). Encounters received through GP2GP or a data migration can carry other codes.
encounter_type_descriptionStringThe SNOMED CT description.
responsible_practitioner_nameStringThe responsible practitioner, as recorded on the encounter.
responsible_practitioner_identifier_typeString (identifier type)Identifier type for the responsible practitioner. medicus-staff-id for staff in this organisation.
responsible_practitioner_identifier_valueStringThe responsible practitioner's identifier.
location_nameStringWhere the encounter took place, as recorded on the encounter.
location_identifier_typeString (identifier type)Identifier type for the location. medicus-site-id for sites in this organisation.
location_identifier_valueStringThe location's identifier. Matches id on the site file where the type is medicus-site-id.

Staff​

{odsCode}-staff.csv

ColumnFormatDescription
idUUIDUnique ID for the staff member. Matches practitioner_identifier_value where practitioner_identifier_type is medicus-staff-id.
nameStringThe staff member's prefix, first name and surname.
gendermale / female / indeterminateThe staff member's gender identity, if recorded.
statusactive / archivedWhether the staff member is active or archived.

Staff Professional Identifier​

{odsCode}-staff-professional-identifier.csv

ColumnFormatDescription
idUUIDUnique ID for the record. The ID of the registration it came from.
staff_idUUIDForeign key for the related staff member.
typegb-gmc-number / gb-nmc-pin / gb-gphc-number / gb-hcpc-number / gb-nhs-doctor-index-number / gb-nhs-spurious-gp-prescriber-codeWhich registration this is. A staff member can have several of the same type.
valueStringThe registration number, PIN or code.

Job Role​

{odsCode}-job-role.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
nameStringThe name of the job role.
statusactive / archivedWhether the job role is active or archived.
locum_staffBooleanWhether the job role is for locum staff.
gpad_healthcare_professional_typeStringThe GP Appointments Data (GPAD) healthcare professional type, if set.
gp_connect_roleStringThe NHS RBAC role code used for GP Connect, if set.

Job Role Assignment​

{odsCode}-job-role-assignment.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
staff_idUUIDForeign key for the related staff member.
job_role_idUUIDForeign key for the related job role.

Team​

{odsCode}-team.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
nameStringThe name of the team.
statusactive / archivedWhether the team is active or archived.

Team Membership​

{odsCode}-team-membership.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
team_idUUIDForeign key for the related team.
staff_idUUIDForeign key for the related staff member.

Commissioned Service​

{odsCode}-commissioned-service.csv

ColumnFormatDescription
idUUIDUnique ID for the record.
nameStringThe name of the commissioned service.
service_identifierStringThe service identifier code.
commissioning_organisation_identifierStringIdentifier for the commissioning organisation.
commissioning_organisation_identifier_typeString (organisation identifier type)Identifier type for the commissioning organisation.
commissioning_organisation_nameStringThe name of the commissioning organisation.

Scheduled Activity​

{odsCode}-scheduled-activity.csv

ColumnFormatDescription
idStringFor a slot, the session ID and slot start (YYYYMMDDHHMMSS), stable across runs while the slot keeps its start. For anything else, its UUID.
appointment_container_idUUIDThe session/clinic the row belongs to. Empty for meetings and absences.
typeappointment-slot / break / rota-activity / meeting / absenceWhat the time is: a slot a session offers, time in a session set aside for a break or rota activity, a meeting, or a staff member's absence.
appointment_type_idUUIDThe appointment type a slot is offered as. Empty for everything else.
staff_idUUIDThe staff member a break or rota activity is assigned to, or who is absent. Empty for slots and meetings, and when nobody is assigned.
nhs_national_slot_type_categoryStringThe NHS national slot type category: for a slot, its appointment type's default; for a rota activity or meeting, its own. Empty for breaks and absences, and for slots whose type has none.
room_idUUIDForeign key for the room: the session's for slots, breaks and rota activities, the meeting's for meetings. Empty for absences and when none is set.
site_idUUIDForeign key for the site: the session's for slots, breaks and rota activities, the meeting's for meetings. Empty for absences and when none is set.
start_date_timeYYYY-MM-DD HH:MM:SSWhen it starts. 00:00:00 on an absence with no start time.
end_date_timeYYYY-MM-DD HH:MM:SSWhen it ends. Midnight at the end of the last day on an absence with no end time. A slot can be shorter than its type's usual duration when the session does not divide evenly.
duration_secondsNumberSeconds from start to end.