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\nas 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-ordelta-in front of that name. A delta's CSVs carry achange_typecolumn, which a full extract's CSVs don't have. - An encrypted ZIP has
.gpgadded to its name. Over MESH, an unencrypted ZIP is sent base64-encoded with.b64added 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_typecolumn. - Subsequent extracts are delta extracts: Medicus compares against the
previous day's full extract and outputs only the changes, adding a
change_typecolumn with one ofadded,updated, orremoved. - If a query includes a
uidcolumn, 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
idcolumn. 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
| Column | Format | Description |
|---|---|---|
id | UUID | Unique identifier for the patient. |
nhs_number | String, no spaces | The patient's NHS number. |
date_of_birth | YYYY-MM-DD | The patient's date of birth. |
official_name_prefix | String | The patient's prefix, for example Mr. |
official_given_name | String | The patient's first name. |
official_family_name | String | The patient's surname. |
preferred_given_name | String | The patient's preferred first name. |
clinical_sex | male / female / unknown | Derived: sex at birth, otherwise gender identity. |
deceased | Boolean | Whether the patient is deceased. |
is_test_patient | Boolean | Whether this is a test patient record. |
named_gp_name | String | The name of the patient's named GP. |
named_gp_identifier_type | String (identifier type) | Identifier type for the named GP (most commonly a GMC number). |
named_gp_identifier_value | String | The named GP identifier. |
home_address_line_1 | String | The patient's home address. |
home_address_line_2 | String | |
home_address_line_3 | String | |
home_address_locality | String | |
home_address_administrative_area | String | |
home_address_postal_code | String | |
home_address_country | String | |
date_of_death | YYYY-MM-DD | Date of death, if deceased. |
communication_email_address | String | Email address for communicating with the patient. |
communication_home_phone_number | String | Home phone number. |
communication_mobile_phone_number | String | Mobile phone number. |
guernsey_social_insurance_number | String, no spaces | Commonly referred to as the "GY Number". |
Patient Registration
{odsCode}-patient-registration.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique identifier for the registration record. |
patient_id | UUID | Foreign key for the related patient. |
start_date | YYYY-MM-DD | Registration start date. |
end_date | YYYY-MM-DD | Registration end date, if the patient has deregistered. |
registration_type | String | For example permanent, temporary, immediate-necessary-treatment. Can be customised by the organisation. |
prescriptions_dispensed_by_practice | Boolean | Whether the patient has medication dispensed by the practice. |
care_home_resident | Boolean | Whether the patient is a care-home resident. May also be recorded as a coded entry. |
Coded Entry
{odsCode}-coded-entry.csv
| Column | Format | Description |
|---|---|---|
id | String | Unique 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_id | UUID | Identifier of the underlying care record entry. Shared by every row that entry produces. |
patient_id | UUID | Unique identifier for the patient. |
entity_type | String | The 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. |
code | String | The SNOMED CT concept ID. |
code_description | String | The SNOMED CT description. |
clinically_relevant_date | YYYY-MM-DD | The record entry date (for example the observation date). |
clinically_relevant_time | HH:MM:SS | |
care_record_sorting_date_time | YYYY-MM-DD HH:MM:SS | Timestamp used to order care record entries. |
created_in_original_system_date_time | YYYY-MM-DD HH:MM:SS | Created date-time in the system the record originated from, if migrated. |
created_date_time | YYYY-MM-DD HH:MM:SS | Created date-time in the original system. |
encounter_id | UUID | Useful for de-duplicating codes in the same encounter (for example for activity counts). |
value_1 | Number | Optional value for numeric entries, for example height. |
value_1_unit_code | String | SNOMED CT concept ID. |
value_1_unit_description | String | The SNOMED CT description. |
value_2 | Number | Only populated for blood pressures. |
value_2_unit_code | String | SNOMED CT concept ID. |
value_2_unit_description | String | The SNOMED CT description. |
body_site_code | String | Optional SNOMED CT body site (for example for an immunisation or procedure). |
body_site_description | String | The SNOMED CT description. |
route_code | String | Optional SNOMED CT route (for example 255560000 Intravenous). |
route_description | String | The SNOMED CT description. |
batch_number | String | Usually only populated for immunisations. |
expiry_date | YYYY-MM-DD | Usually only populated for immunisations. |
status | Active / Ended | Only populated for certain records, for example allergies. |
end_date | YYYY-MM-DD | Only populated for certain records, for example allergies. |
practitioner_name | String | The responsible practitioner. |
practitioner_identifier_type | String (identifier type) | Identifier type for the responsible practitioner. |
practitioner_identifier_value | String | The responsible practitioner's identifier. |
organisation_identifier_type | String (organisation identifier type) | Identifier type for the responsible organisation. |
organisation_identifier_value | String | The responsible organisation's identifier. |
performed_at_local_organisation | T / F / N | Where 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_name | String | The responsible organisation. |
encounter_type_code | String | The SNOMED CT encounter type. Commonly 1269515004 (Face to face), 439708006 (Home visit), 386472008 (Phone), 149971000000103 (Online), 37351000000107 (Administration). |
encounter_type_description | String | The 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_limit | Number | Lower limit of the reference range, for investigation results and observations. Empty when a result has more than one range. |
reference_range_upper_limit | Number | Upper limit of the reference range, for investigation results and observations. Empty when a result has more than one range. |
episode | first / subsequent | Only populated for problems. |
significance | major / minor / unknown | Only populated for problems. unknown when the problem has no significance recorded. |
parent_problem_id | UUID | The parent problem's care_record_id. Only populated for problems nested under another problem. |
clinical_case_id | UUID | Foreign key for the related clinical case, if linked to one. |
Prescription
{odsCode}-prescription.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
patient_id | UUID | Unique identifier for the patient. |
type | String | One of acute, repeat-prescribing, repeat-dispensing, variable-repeat. |
status | String | One of authorised, reauthorised, discontinued, requires-reauthorisation. |
product_code | String | The SNOMED CT / dm+d concept ID for the drug product. |
product_description | String | The SNOMED CT description. |
dosage_instruction | String | Free-text dosage instructions. |
start_date | YYYY-MM-DD | Date the prescription is authorised to start from. |
expected_end_date | YYYY-MM-DD | Derived estimate of when the supply ends. |
authorised_date | YYYY-MM-DD | Date the prescription was authorised. |
authorised_by_practitioner_name | String | The authorising practitioner. |
authorised_by_practitioner_identifier_type | String (identifier type) | Identifier type for the authorising practitioner. |
authorised_by_practitioner_identifier_value | String | The authorising practitioner's identifier. |
last_issue_date | YYYY-MM-DD | Date the prescription was last issued. |
discontinued_date | YYYY-MM-DD | Date the prescription was discontinued, if applicable. |
review_date | YYYY-MM-DD | Date the prescription is due for review, if set. |
created_date_time | YYYY-MM-DD HH:MM:SS | Date-time the prescription was created in Medicus. |
created_in_original_system_date_time | YYYY-MM-DD HH:MM:SS | Created date-time in the system the record originated from, if migrated. |
encounter_id | UUID | Foreign key for the encounter the prescription was recorded in, if any. |
clinical_case_id | UUID | Foreign key for the related clinical case, if linked to one. |
Prescription Issue
{odsCode}-prescription-issue.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
patient_id | UUID | Unique identifier for the patient. |
prescription_id | UUID | Unique identifier for the parent prescription. |
product_code | String | The SNOMED CT / dm+d concept ID for the drug product. |
product_description | String | The SNOMED CT description. |
expected_days_supply | Integer | Days the supply is expected to last. |
supply_end_date | YYYY-MM-DD | Date the supply is expected to end. |
quantity_value | Number | The quantity issued to the patient. |
quantity_unit_code | String | SNOMED CT concept ID for the quantity unit. |
quantity_unit_description | String | The SNOMED CT description (for example tablet). |
issue_date | YYYY-MM-DD | Date the issue was issued to the patient. |
issue_method | String | One 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_type | String (identifier type) | Identifier type for the issuing practitioner. |
issued_by_practitioner_identifier_value | String | The issuing practitioner's identifier. |
issued_by_practitioner_name | String | The issuing practitioner. |
issued_by_organisation | String | The issuing organisation. |
issue_number | Integer | The issue number in the authorised sequence (for example 3 of 12). |
issue_status | String | not-issued or issued. |
pharmacy_ods_code | String | ODS code of the pharmacy the issue's EPS order was sent to, if issued via EPS. |
created_date_time | YYYY-MM-DD HH:MM:SS | Date-time the issue was created in Medicus. |
Outbound Referral
{odsCode}-outbound-referral.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the outbound referral. Matches care_record_id on its coded entry. |
patient_id | UUID | Foreign key for the related patient. |
type | manual / nhs-e-referral / bars | How the referral was sent. |
status | active / cancelled / sent | The referral status. |
priority | routine / urgent / two-week-wait | The referral priority, if recorded. |
referral_date | YYYY-MM-DD | Date of the referral, if recorded. |
clinical_specialty_code | SNOMED CT concept ID | The clinical specialty referred to, if recorded. |
clinical_specialty_description | String | Description of the clinical specialty. |
referred_to_organisation_name | String | Organisation referred to. Only populated for manual and BaRS referrals. |
referred_to_organisation_identifier_type | String (organisation identifier type) | Identifier type for the organisation referred to, for example nhs-england-ods-code. |
referred_to_organisation_identifier_value | String | The organisation's identifier, for example its ODS code. |
referred_to_service_name | String | Service referred to. Only populated for manual and BaRS referrals. |
referred_to_service_identifier_type | String | Identifier type for the service referred to. |
referred_to_service_identifier_value | String | The service's identifier. |
referred_to_practitioner_name | String | Practitioner referred to. Only populated for manual referrals. |
referred_to_practitioner_identifier_type | String (practitioner identifier type) | Identifier type for the practitioner referred to. |
referred_to_practitioner_identifier_value | String | The practitioner's identifier. |
unique_booking_reference_number | String, 12 digits | The NHS e-Referral Service UBRN. Only populated for referrals sent through e-RS. |
encounter_id | UUID | Foreign key for the encounter the referral was recorded in, if any. |
created_date_time | YYYY-MM-DD HH:MM:SS | Date-time the referral was created in Medicus. |
created_in_original_system_date_time | YYYY-MM-DD HH:MM:SS | Created date-time in the system the record originated from, if migrated. |
Appointment
{odsCode}-appointment.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
patient_id | UUID | Unique identifier for the patient. |
status | String | One of pending, started, seen, rescheduled, cancelled, did-not-attend. |
appointment_type_id | UUID | A practice-defined appointment type. |
nhs_national_slot_type_category | String | GPAD category (for example "General Consultation Acute"). |
intended_start_date_time | YYYY-MM-DD HH:MM:SS | Planned start. |
intended_end_date_time | YYYY-MM-DD HH:MM:SS | Planned end. |
intended_duration_seconds | Number | Planned duration in seconds. |
appointment_container_id | UUID | The session/clinic the appointment belongs to. |
delivery_mode | String | One of face-to-face, home-visit, video, phone. |
linked_encounter_id | UUID | The encounter created when the appointment was completed, if any. |
arrived_date_time | YYYY-MM-DD HH:MM:SS | When the patient was marked as arrived. |
booked_date_time | YYYY-MM-DD HH:MM:SS | When the appointment was booked. |
cancelled_date_time | YYYY-MM-DD HH:MM:SS | When the appointment was cancelled. |
rescheduled_date_time | YYYY-MM-DD HH:MM:SS | When the appointment was rescheduled. |
Appointment Practitioner
{odsCode}-appointment-practitioner.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
practitioner_name | String | The practitioner's name. |
practitioner_identifier_type | String (identifier type) | Identifier type for the practitioner. |
practitioner_identifier_value | String | The practitioner's identifier. |
appointment_container_id | UUID | The session/clinic this practitioner is associated with. |
Appointment Service
{odsCode}-appointment-service.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
name | String | The name of the service. |
Appointment Type
{odsCode}-appointment-type.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
name | String | The name of the appointment type. |
appointment_service_id | UUID | Foreign key for the related appointment service. |
Site
{odsCode}-site.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
name | String | The name of the site. |
Room
{odsCode}-room.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
name | String | The name of the room. |
site_id | UUID | Foreign key for the related site. |
Clinical Case
{odsCode}-clinical-case.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
patient_id | UUID | Foreign key for the related patient. |
commissioned_service_id | UUID | Foreign key for the related commissioned service, if any. |
clinical_case_type_id | UUID | Foreign key for the related clinical case type. |
case_status | open / closed | Whether the case is currently open or closed. |
created_date_time | YYYY-MM-DD HH:MM:SS | When the case was created. |
closed_date_time | YYYY-MM-DD HH:MM:SS | When the case was closed, if closed. |
Clinical Case Type
{odsCode}-clinical-case-type.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
case_type_name | String | The name of the clinical case type. |
Encounter
{odsCode}-encounter.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the encounter. Matches encounter_id on the coded entry file and linked_encounter_id on the appointment file. |
patient_id | UUID | Foreign key for the related patient. |
start_date | YYYY-MM-DD | The date the encounter started. |
start_time | HH:MM:SS | The time the encounter started, if recorded. |
end_date_time | YYYY-MM-DD HH:MM:SS | When the encounter ended, if recorded. |
actual_duration_seconds | Number | Seconds from start to end. Only populated when both the start time and end are recorded. |
encounter_type_code | String | The 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_description | String | The SNOMED CT description. |
responsible_practitioner_name | String | The responsible practitioner, as recorded on the encounter. |
responsible_practitioner_identifier_type | String (identifier type) | Identifier type for the responsible practitioner. medicus-staff-id for staff in this organisation. |
responsible_practitioner_identifier_value | String | The responsible practitioner's identifier. |
location_name | String | Where the encounter took place, as recorded on the encounter. |
location_identifier_type | String (identifier type) | Identifier type for the location. medicus-site-id for sites in this organisation. |
location_identifier_value | String | The location's identifier. Matches id on the site file where the type is medicus-site-id. |
Staff
{odsCode}-staff.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the staff member. Matches practitioner_identifier_value where practitioner_identifier_type is medicus-staff-id. |
name | String | The staff member's prefix, first name and surname. |
gender | male / female / indeterminate | The staff member's gender identity, if recorded. |
status | active / archived | Whether the staff member is active or archived. |
Staff Professional Identifier
{odsCode}-staff-professional-identifier.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. The ID of the registration it came from. |
staff_id | UUID | Foreign key for the related staff member. |
type | gb-gmc-number / gb-nmc-pin / gb-gphc-number / gb-hcpc-number / gb-nhs-doctor-index-number / gb-nhs-spurious-gp-prescriber-code | Which registration this is. A staff member can have several of the same type. |
value | String | The registration number, PIN or code. |
Job Role
{odsCode}-job-role.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
name | String | The name of the job role. |
status | active / archived | Whether the job role is active or archived. |
locum_staff | Boolean | Whether the job role is for locum staff. |
gpad_healthcare_professional_type | String | The GP Appointments Data (GPAD) healthcare professional type, if set. |
gp_connect_role | String | The NHS RBAC role code used for GP Connect, if set. |
Job Role Assignment
{odsCode}-job-role-assignment.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
staff_id | UUID | Foreign key for the related staff member. |
job_role_id | UUID | Foreign key for the related job role. |
Team
{odsCode}-team.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
name | String | The name of the team. |
status | active / archived | Whether the team is active or archived. |
Team Membership
{odsCode}-team-membership.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
team_id | UUID | Foreign key for the related team. |
staff_id | UUID | Foreign key for the related staff member. |
Commissioned Service
{odsCode}-commissioned-service.csv
| Column | Format | Description |
|---|---|---|
id | UUID | Unique ID for the record. |
name | String | The name of the commissioned service. |
service_identifier | String | The service identifier code. |
commissioning_organisation_identifier | String | Identifier for the commissioning organisation. |
commissioning_organisation_identifier_type | String (organisation identifier type) | Identifier type for the commissioning organisation. |
commissioning_organisation_name | String | The name of the commissioning organisation. |
Scheduled Activity
{odsCode}-scheduled-activity.csv
| Column | Format | Description |
|---|---|---|
id | String | For 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_id | UUID | The session/clinic the row belongs to. Empty for meetings and absences. |
type | appointment-slot / break / rota-activity / meeting / absence | What 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_id | UUID | The appointment type a slot is offered as. Empty for everything else. |
staff_id | UUID | The 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_category | String | The 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_id | UUID | Foreign 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_id | UUID | Foreign 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_time | YYYY-MM-DD HH:MM:SS | When it starts. 00:00:00 on an absence with no start time. |
end_date_time | YYYY-MM-DD HH:MM:SS | When 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_seconds | Number | Seconds from start to end. |