Remote Subscriber Database (RSD) Schema (Compass 2): Difference between revisions

From Discovery Data Service
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 3: Line 3:
== DRAFT ==
== DRAFT ==


== Table: organisation ==
== Table: organization ==
PRIMARY KEY (pk_organization_id PRIMARY KEY (id))
PRIMARY KEY (pk_organization_id PRIMARY KEY (id))
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
Line 12: Line 12:
|'''References'''
|'''References'''
|-
|-
|Id
|id
|bigint
|bigint
|NOT NULL
|NOT NULL
Line 19: Line 19:
|-
|-
|ods_code
|ods_code
|varchar(50),
|varchar(50)
|
|DEFAULT NULL
|
|
|
|
Line 26: Line 26:
|Name
|Name
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 32: Line 32:
|type_code
|type_code
|varchar(50)
|varchar(50)
|
|DEFAULT NULL
|
|
|
|
Line 38: Line 38:
|type_desc
|type_desc
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 44: Line 44:
|Postcode
|Postcode
|varchar(10)
|varchar(10)
|
|DEFAULT NULL
|
|
|
|
Line 50: Line 50:
|parent_organization_id
|parent_organization_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |PRIMARY KEY pk_organization_id PRIMARY KEY (id)
| colspan="5" |PRIMARY KEY pk_organization_id PRIMARY KEY (id)
|}
|}


Line 66: Line 66:
|'''References'''
|'''References'''
|-
|-
|Id
|id
|bigint
|bigint
|NOT NULL
|NOT NULL
Line 73: Line 73:
|-
|-
|name
|name
|varchar(255),
|varchar(255)
|
|DEFAULT NULL
|
|The name of a location set by the publisher. E.g. ward, clinic, domiciliary
|
|
|-
|-
|type_code,
|type_code,
|varchar(50)
|varchar(50)
|
|DEFAULT NULL
|
|
|
|
Line 86: Line 86:
|type_desc
|type_desc
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
|-
|-
|postcode
|postcode
|varchar10),
|varchar10)
|
|DEFAULT NULL
|
|
|
|
Line 98: Line 98:
|managing_organization_id
|managing_organization_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_location_id PRIMARY KEY (id)
| colspan="5" |CONSTRAINT pk_location_id PRIMARY KEY (id)
|-
|-
| colspan="5" |CONSTRAINT fk_location_organisation_id FOREIGN KEY (managing_organization_id)
| colspan="5" |CONSTRAINT fk_location_organisation_id FOREIGN KEY (managing_organization_id)
|-
|-
| colspan="5" |REFERENCES organization (id)  
| colspan="5" |REFERENCES organization (id)
|-
|-
| colspan="5" |MATCH SIMPLE
| colspan="5" |MATCH SIMPLE
Line 122: Line 122:
|'''References'''
|'''References'''
|-
|-
|Id
|id
|bigint
|bigint
|NOT NULL
|NOT NULL
Line 131: Line 131:
|bigint
|bigint
|NOT NULL
|NOT NULL
|
|Owning organisation (i.e. publisher)
|
|organisation.id
|-
|-
|Name
|name
|varchar(1024)
|varchar(1024)
|
|DEFAULT NULL
|
|
|
|
Line 142: Line 142:
|role_code
|role_code
|varchar(50)
|varchar(50)
|
|DEFAULT NULL
|
|
|
|
Line 148: Line 148:
|role_desc
|role_desc
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 154: Line 154:
|gmc_code
|gmc_code
|varchar(50)
|varchar(50)
|
|DEFAULT NULL
|
|
|
|
Line 160: Line 160:
| colspan="5" |CONSTRAINT pk_practitioner_id PRIMARY KEY (id),
| colspan="5" |CONSTRAINT pk_practitioner_id PRIMARY KEY (id),
|-
|-
| colspan="5" |CONSTRAINT fk_practitioner_organisation_id FOREIGN KEY (organization_id)
| colspan="5" |CONSTRAINT fk_practitioner_organisation_id FOREIGN KEY (organization_id)
|-
|-
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
Line 176: Line 176:
|'''References'''
|'''References'''
|-
|-
|Id
|id
|bigint
|bigint
|NOT NULL
|NOT NULL
Line 185: Line 185:
|bigint
|bigint
|NOT NULL
|NOT NULL
|
|Owning organisation (i.e. publisher)
|
|organization.id
|-
|-
|practitioner_id
|practitioner_id
|bigint
|bigint
|DEFAULT NULL
|
|
|
|practitioner.id
|
|-
|-
|start_date
|start_date
|date
|date
|
|DEFAULT NULL
|
|
|
|
Line 202: Line 202:
|type
|type
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 208: Line 208:
|Location
|Location
|varchar(255)
|varchar(255)
|DEFAULT NULL
|
|
|
|location.id
|
|-
|-
|Name
|Name
|varchar(150)
|varchar(150)
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_schedule_id PRIMARY KEY (organization_id, id),
| colspan="5" |CONSTRAINT pk_schedule_id PRIMARY KEY (organization_id, id),
|-
|-
| colspan="5" |CONSTRAINT fk_schedule_organization_id FOREIGN KEY (organization_id)
| colspan="5" |CONSTRAINT fk_schedule_organization_id FOREIGN KEY (organization_id)
|-
|-
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 236: Line 236:
|'''References'''
|'''References'''
|-
|-
|Id
|id
|bigint
|bigint
|NOT NULL
|NOT NULL
Line 249: Line 249:
|-
|-
|title
|title
|varchar(50),
|varchar(50)
|
|DEFAULT NULL
|
|
|
|
|-
|-
|first_names
|first_names
|varchar(255),
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
|-
|-
|last_name
|last_name
|varchar(255),
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 268: Line 268:
|gender_concept_id
|gender_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
|-
|-
|nhs_number
|nhs_number
|varchar(255),
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
|-
|-
|date_of_birth date,
|date_of_birth date,
|date
|date
|
|DEFAULT NULL
|
|
|
|
|-
|-
|date_of_death date,
|date_of_death date,
|date
|date
|
|DEFAULT NULL
|
|
|
|
Line 298: Line 298:
|ethnic_code_concept_id
|ethnic_code_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 304: Line 304:
|registered_practice_organization_id
|registered_practice_organization_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_person_id PRIMARY KEY (id)
| colspan="5" |CONSTRAINT pk_person_id PRIMARY KEY (id)
|}
|}


Line 320: Line 320:
|'''References'''
|'''References'''
|-
|-
|Id
|id
|bigint
|bigint
|NOT NULL
|NOT NULL
Line 329: Line 329:
|bigint
|bigint
|NOT NULL
|NOT NULL
|
|Owning organisation (i.e. publisher)
|
|organization.id
|-
|-
|person_id
|person_id
|bigint
|bigint
|NOT NULL
|NOT NULL
|
|Unique individual across all organisations
|
|person.id
|-
|-
|title
|title
|varchar(50),
|varchar(50)
|
|
|
|
Line 345: Line 345:
|-
|-
|first_names
|first_names
|varchar(255),
|varchar(255)
|
|
|
|
Line 351: Line 351:
|-
|-
|last_name
|last_name
|varchar(255),
|varchar(255)
|
|
|
|
Line 363: Line 363:
|-
|-
|nhs_number
|nhs_number
|varchar(255),
|varchar(255)
|
|
|
|
Line 398: Line 398:
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_patient_id_organization_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_patient_id_organization_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |CONSTRAINT fk_patient_organization_id FOREIGN KEY (organization_id)
| colspan="5" |CONSTRAINT fk_patient_organization_id FOREIGN KEY (organization_id)
|-
|-
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
|}
|}


Line 414: Line 414:
|'''References'''
|'''References'''
|-
|-
|  id
|id
|bigint
|bigint
|NOT NULL
|NOT NULL
Line 420: Line 420:
|
|
|-
|-
|  organization_id
|organization_id
|bigint
|bigint
|NOT NULL
|NOT NULL
|Owning organisation (i.e. publisher)
|Owning organisation (i.e. publisher)
|organization.id
|organization.id
|-
|-
|  patient_id
|patient_id
|bigint
|bigint
|NOT NULL
|NOT NULL
Line 432: Line 432:
|patient.id
|patient.id
|-
|-
|  person_id
|person_id
|bigint
|bigint
|NOT NULL
|NOT NULL
|Unique individual across all organisations
|Unique individual across all organisations
|person.id
|person.id
|-
|-
|registration_type_concept_id
|registration_type_concept_id
|int
|int
|DEFAULT NULL
|DEFAULT NULL
|
|
|registration.type.id
|registration.type.id
Line 446: Line 446:
|registration_status_concept_id
|registration_status_concept_id
|int
|int
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
|-
|-
|date_registered date
|date_registered date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
|-
|-
|date_registered_end date
|date_registered_end date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 464: Line 464:
|usual_gp_practitioner_id
|usual_gp_practitioner_id
|bigint
|bigint
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|Practitioner.id
|-
|-
| colspan="5" |CONSTRAINT pk_episode_of_care_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_episode_of_care_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |CONSTRAINT fk_episode_of_care_patient_id_organisation_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_episode_of_care_patient_id_organisation_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_episode_of_care_practitioner_id FOREIGN KEY (usual_gp_practitioner_id)
| colspan="5" |CONSTRAINT fk_episode_of_care_practitioner_id FOREIGN KEY (usual_gp_practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


== Table: appointment ==
== Table: appointment ==
PRIMARY KEY  (organization_id,person_id,id)
PRIMARY KEY (organization_id,person_id,id)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
Line 501: Line 501:
|varchar(36)
|varchar(36)
|NOT NULL
|NOT NULL
|
|Owning organisation (i.e. publisher)
|
|organization.id
|-
|-
|patient_id
|patient_id
|varchar(36)
|varchar(36)
|NOT NULL
|NOT NULL
|
|The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times
|
|patient.id
|-
|-
|person_id
|person_id
|bigint
|bigint
|NOT NULL
|NOT NULL
|
|Unique individual across all organisations
|
|person.id
|-
|-
|practitioner_id
|practitioner_id
|bigint
|bigint
|
|DEFAULT NULL
|
|The clinician the activity is recorded against
|
|practitioner.id
|-
|-
|schedule_id
|schedule_id
|bigint
|bigint
|
|DEFAULT NULL
|
|The schedule the patient was put on to book multiple appointments. ID unique to the applied schedule
|
|schedule.id
|-
|-
|start_date
|start_date
|date
|date
|
|DEFAULT NULL
|
|
|
|
|-
|-
|planned_duration
|planned_duration
|integer
|int
|
|DEFAULT NULL
|
|The time allocated for the appointment, not necessarily the actual duration always in minutes
|
|
|-
|-
|actual_duration
|actual_duration
|integer
|int
|
|DEFAULT NULL
|
|Time between sent in and left always in minutes
|
|
|-
|-
|appointment_status_concept_id
|appointment_status_concept_id
|int
|int
|
|DEFAULT NULL
|
|The status of the appointment e.g. arrived/sent in/left/DNA
|
|
|-
|-
|patient_wait
|patient_wait
|integer
|int
|
|DEFAULT NULL
|
|How long the patient waited from being marked as arrived to being sent in
|
|
|-
|-
|patient_delay
|patient_delay
|integer
|int
|
|DEFAULT NULL
|
|
|
|
Line 566: Line 566:
|date_time_sent_in
|date_time_sent_in
|datetime
|datetime
|
|DEFAULT NULL
|
|Date and time the patient was sent into the practitioner
|
|
|-
|-
|date_time_left
|date_time_left
|datetime
|datetime
|
|DEFAULT NULL
|
|Date and time the patient left the practitioner
|
|
|-
|-
|source_id
|source_id
|varchar(36)
|varchar(36)
|
|DEFAULT NULL
|
|
|
|
|-
|-
|cancelled_date
|cancelled_date
|Datetime
|datetime
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_appointment_id PRIMARY KEY (organization_id,person_id,id),
| colspan="5" |CONSTRAINT pk_appointment_id PRIMARY KEY (organization_id,person_id,id),
|-
|-
| colspan="5" |CONSTRAINT fk_appointment_organization_id FOREIGN KEY (organization_id)
| colspan="5" |CONSTRAINT fk_appointment_organization_id FOREIGN KEY (organization_id)
|-
|-
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_appointment_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |CONSTRAINT fk_appointment_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 613: Line 613:
|-
|-
|id
|id
|Bigint
|bigint
|NOT NULL
|NOT NULL
|
|
Line 638: Line 638:
|practitioner_id
|practitioner_id
|bigint
|bigint
|
|DEFAULT NULL
|The clinician the activity is recorded against
|The clinician the activity is recorded against
|
|
Line 644: Line 644:
|appointment_id
|appointment_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 650: Line 650:
|clinical_effective_date
|clinical_effective_date
|date
|date
|
|DEFAULT NULL
|The date the clinical code is recorded for
|The date the clinical code is recorded for
|
|
Line 659: Line 659:
date_precision_concept_id
date_precision_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 665: Line 665:
|episode_of_care_id
|episode_of_care_id
|bigint
|bigint
|
|DEFAULT NULL
|Is this instance of the code a review of a previous encounter
|Is this instance of the code a review of a previous encounter
|
|
|-
|-
|  service_provider_organization_id
|service_provider_organization_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 677: Line 677:
|core_concept_id
|core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 683: Line 683:
|non_core_concept_id
|non_core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 689: Line 689:
|age_at_event
|age_at_event
|decimal(5,2)
|decimal(5,2)
|
|DEFAULT NULL
|
|
|
|
Line 695: Line 695:
|Type
|Type
|text
|text
|
|DEFAULT NULL
|
|
|
|
Line 701: Line 701:
|sub_type
|sub_type
|text
|text
|
|DEFAULT NULL
|
|
|
|
Line 707: Line 707:
|admission_method
|admission_method
|varchar(40)
|varchar(40)
|
|DEFAULT NULL
|
|
|
|
Line 713: Line 713:
|end_date
|end_date
|date
|date
|
|DEFAULT NULL
|
|
|
|
Line 719: Line 719:
|institution_location_id
|institution_location_id
|text
|text
|
|DEFAULT NULL
|
|
|
|
Line 725: Line 725:
|date_recorded
|date_recorded
|datetime
|datetime
|
|DEFAULT NULL
|
|
|
|
|-
|-
|  service_provider_organization_id
|service_provider_organization_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 738: Line 738:




CONSTRAINT pk_encounter_id PRIMARY KEY (organization_id,person_id,id),
CONSTRAINT pk_encounter_id PRIMARY KEY (organization_id,person_id,id),
|-
|-
| colspan="5" |/*known examples of Emis  consultations referring to unknown appointments, so removed this
| colspan="5" |CONSTRAINT fk_encounter_appointment_id FOREIGN KEY (appointment_id)
|-
|-
| colspan="5" |CONSTRAINT  fk_encounter_appointment_id FOREIGN KEY (appointment_id)
| colspan="5" |REFERENCES appointment (id) MATCH SIMPLE
|-
|-
| colspan="5" |  REFERENCES appointment (id) MATCH SIMPLE
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,*/
|-
|-
| colspan="5" |  ON UPDATE NO ACTION ON DELETE NO ACTION,*/
| colspan="5" |CONSTRAINT fk_encounter_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |CONSTRAINT  fk_encounter_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON  DELETE NO ACTION,
| colspan="5" |CONSTRAINT fk_encounter_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |CONSTRAINT  fk_encounter_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |REFERENCES practitioner  (id) MATCH SIMPLE
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON  DELETE NO ACTION,
| colspan="5" |CONSTRAINT fk_encounter_episode_of_care_id FOREIGN KEY (episode_of_care_id)
|-
|-
| colspan="5" |CONSTRAINT  fk_encounter_episode_of_care_id FOREIGN KEY (episode_of_care_id)
| colspan="5" |REFERENCES episode_of_care (id) MATCH SIMPLE
|-
|-
| colspan="5" |REFERENCES episode_of_care  (id) MATCH SIMPLE
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON  DELETE NO ACTION,
| colspan="5" |CONSTRAINT fk_encounter_service_provider_organization_id FOREIGN KEY (service_provider_organization_id)
|-
|-
| colspan="5" |CONSTRAINT  fk_encounter_service_provider_organization_id FOREIGN KEY  (service_provider_organization_id)
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
|-
|-
| colspan="5" |REFERENCES organization  (id) MATCH SIMPLE
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 814: Line 812:
|practitioner_id
|practitioner_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 820: Line 818:
|appointment_id
|appointment_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 826: Line 824:
|clinical_effective_date
|clinical_effective_date
|datetime
|datetime
|
|DEFAULT NULL
|
|
|
|
Line 832: Line 830:
|date_precision_concept_id
|date_precision_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 838: Line 836:
|episode_of_care_id
|episode_of_care_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 844: Line 842:
|service_provider_organization_id
|service_provider_organization_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 850: Line 848:
|core_concept_id
|core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 856: Line 854:
|non_core_concept_id
|non_core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 862: Line 860:
|age_at_event
|age_at_event
|decimal(5,2)
|decimal(5,2)
|
|DEFAULT NULL
|
|
|
|
Line 868: Line 866:
|type
|type
|text
|text
|
|DEFAULT NULL
|
|
|
|
Line 874: Line 872:
|sub_type
|sub_type
|text
|text
|
|DEFAULT NULL
|
|
|
|
Line 880: Line 878:
|admission_method
|admission_method
|varchar(40)
|varchar(40)
|
|DEFAULT NULL
|
|
|
|
Line 886: Line 884:
|end_date
|end_date
|date
|date
|
|DEFAULT NULL
|
|
|
|
Line 892: Line 890:
|institution_location_id
|institution_location_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 898: Line 896:
|date_recorded
|date_recorded
|datetime
|datetime
|
|DEFAULT NULL
|
|
|
|
|-
|-
|Finished
|finished
|boolean
|boolean
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_encounter_event_id PRIMARY KEY (organization_id, person_id, id),
| colspan="5" |CONSTRAINT pk_encounter_event_id PRIMARY KEY (organization_id, person_id, id),
|-
|-
| colspan="5" |CONSTRAINT fk_encounter_event_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_encounter_event_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_encounter_event_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |CONSTRAINT fk_encounter_event_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_encounter_event_episode_of_care_id FOREIGN KEY (episode_of_care_id)
| colspan="5" |CONSTRAINT fk_encounter_event_episode_of_care_id FOREIGN KEY (episode_of_care_id)
|-
|-
| colspan="5" |REFERENCES episode_of_care (id) MATCH SIMPLE
| colspan="5" |REFERENCES episode_of_care (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_encounter_event_service_provider_organization_id FOREIGN KEY (service_provider_organization_id)
| colspan="5" |CONSTRAINT fk_encounter_event_service_provider_organization_id FOREIGN KEY (service_provider_organization_id)
|-
|-
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 944: Line 942:
|'''References'''
|'''References'''
|-
|-
|Id
|id
|bigint
|bigint
|NOT NULL
|NOT NULL
|same as the id column on the encounter table
|same as the id column on the encounter table
|
|
|-
|-
Line 953: Line 951:
|bigint
|bigint
|NOT NULL
|NOT NULL
|IM reference (i.e. Admission method)
|IM reference (i.e. Admission method)
|
|
|-
|-
Line 959: Line 957:
|bigint
|bigint
|NOT NULL
|NOT NULL
|IM reference (i.e. Emergency admission)
|IM reference (i.e. Emergency admission)
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_encounter_additional_id PRIMARY KEY (id, property_id, value_id)
| colspan="5" |CONSTRAINT pk_encounter_additional_id PRIMARY KEY (id, property_id, value_id)
|}
|}


Line 975: Line 973:
|-
|-
|id
|id
|Bigint
|bigint
|NOT NULL
|NOT NULL
|
|
Line 981: Line 979:
|-
|-
|organization_id
|organization_id
|Bigint
|bigint
|NOT NULL
|NOT NULL
|Owning organisation (i.e. publisher)
|Owning organisation (i.e. publisher)
|organization.id
|organization.id
|-
|-
|patient_id
|patient_id
|Bigint
|bigint
|NOT NULL
|NOT NULL
|The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times
|The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times
Line 993: Line 991:
|-
|-
|person_id
|person_id
|Bigint
|bigint
|NOT NULL
|NOT NULL
|Unique individual across all organisations
|Unique individual across all organisations
|person.id
|person.id
|-
|-
|encounter_id
|encounter_id
|bigint
|bigint
|DEFAULT NULL
|DEFAULT NULL
|
|
|encounter.id
|encounter.id
Line 1,006: Line 1,004:
|practitioner_id
|practitioner_id
|bigint
|bigint
|DEFAULT NULL
|DEFAULT NULL
|The clinician the activity is recorded against
|The clinician the activity is recorded against
|practitioner.id
|practitioner.id
|-
|-
|clinical_effective_date
|clinical_effective_date
|Date
|Date
|DEFAULT NULL
|DEFAULT NULL
|
|The date the clinical code is recorded for
|
|
|-
|-
|date_precision_concept_id
|date_precision_concept_id
|Int
|Int
|DEFAULT NULL
|DEFAULT NULL
|
|Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
|
|
|-
|-
Line 1,025: Line 1,023:
|boolean
|boolean
|NOT NULL
|NOT NULL
|Is this instance of the code a review of a previous encounter
|Is this instance of the code a review of a previous encounter
|
|
|-
|-
|core_concept_id
|core_concept_id
|Int
|Int
|
|DEFAULT NULL
|
|
|
|
Line 1,036: Line 1,034:
|non_core_concept_id
|non_core_concept_id
|Int
|Int
|
|DEFAULT NULL
|
|
|
|
Line 1,042: Line 1,040:
|age_at_event
|age_at_event
|decimal(5,2)
|decimal(5,2)
|
|DEFAULT NULL
|
|
|
|
Line 1,049: Line 1,047:
|datetime
|datetime
|NOT NULL
|NOT NULL
|Is this instance of the code a review of a previous encounter
|Is this instance of the code a review of a previous encounter
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_allergy_intolerance_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_allergy_intolerance_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |CONSTRAINT fk_allergy_intolerance_encounter_id FOREIGN KEY (encounter_id)
| colspan="5" |CONSTRAINT fk_allergy_intolerance_encounter_id FOREIGN KEY (encounter_id)
|-
|-
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_allergy_intolerance_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_allergy_intolerance_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_allergy_intolerance_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |CONSTRAINT fk_allergy_intolerance_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 1,091: Line 1,089:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Owning organisation (i.e. publisher)
|Owning organisation (i.e. publisher)
|organization.id
|organization.id
|-
|-
Line 1,103: Line 1,101:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Unique individual across all organisations
|Unique individual across all organisations
|person.id
|person.id
|-
|-
|encounter_id
|encounter_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|
|
|encounter.id
|encounter.id
Line 1,114: Line 1,112:
|practitioner_id
|practitioner_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|The clinician the activity is recorded against
|The clinician the activity is recorded against
|practitioner.id
|practitioner.id
|-
|-
|clinical_effective_date
|clinical_effective_date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
|-
|-
|date_precision_concept_id
|date_precision_concept_id
|smallint(6)
|DEFAULT NULL
|Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
|
|
|
|-
|
|
|-
|is_active
|is_active
|tinyint(4)
|tinyint(4)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,138: Line 1,136:
|cancellation_date
|cancellation_date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,144: Line 1,142:
|dose
|dose
|varchar(1000)
|varchar(1000)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,150: Line 1,148:
|quantity_value
|quantity_value
|double
|double
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,156: Line 1,154:
|quantity_unit
|quantity_unit
|varchar(255)
|varchar(255)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,162: Line 1,160:
|authorisation_type_concept_id
|authorisation_type_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,168: Line 1,166:
|core_concept_id
|core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,174: Line 1,172:
|non_core_concept_id
|non_core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,180: Line 1,178:
|bnf_reference
|bnf_reference
|varchar(6)
|varchar(6)
|
|DEFAULT NULL
|
|
|
|
Line 1,186: Line 1,184:
|age_at_event
|age_at_event
|decimal(5,2)
|decimal(5,2)
|
|DEFAULT NULL
|
|
|
|
Line 1,192: Line 1,190:
|Issue_method
|Issue_method
|text
|text
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_medication_statement_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_medication_statement_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |CONSTRAINT fk_medication_statement_encounter_id FOREIGN KEY (encounter_id)
| colspan="5" |CONSTRAINT fk_medication_statement_encounter_id FOREIGN KEY (encounter_id)
|-
|-
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_medication_statement_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_medication_statement_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_medication_statement_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |CONSTRAINT fk_medication_statement_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 1,247: Line 1,245:
|bigint
|bigint
|NOT NULL
|NOT NULL
|Unique individual across all organisations
|Unique individual across all organisations
|person.id
|person.id
|-
|-
|encounter_id
|encounter_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|encounter.id
|encounter.id
Line 1,258: Line 1,256:
|practitioner_id
|practitioner_id
|bigint
|bigint
|
|DEFAULT NULL
|The clinician the activity is recorded against
|The clinician the activity is recorded against
|practitioner.id
|practitioner.id
|-
|-
|clinical_effective_date
|clinical_effective_date
|date
|date
|
|DEFAULT NULL
|
|
|
|
Line 1,270: Line 1,268:
|date_precision_concept_id
|date_precision_concept_id
|int
|int
|
|DEFAULT NULL
|
|Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
|
|
|-
|-
|dose
|dose
|varchar(1000)
|varchar(1000)
|
|DEFAULT NULL
|
|
|
|
Line 1,282: Line 1,280:
|quantity_value
|quantity_value
|real
|real
|
|DEFAULT NULL
|
|
|
|
Line 1,288: Line 1,286:
|quantity_unit
|quantity_unit
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
|-
|-
|duration_days
|duration_days
|integer
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,300: Line 1,298:
|estimated_cost
|estimated_cost
|real
|real
|
|DEFAULT NULL
|
|
|
|
Line 1,306: Line 1,304:
|medication_statement_id
|medication_statement_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 1,312: Line 1,310:
|core_concept_id
|core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,318: Line 1,316:
|non_core_concept_id
|non_core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,324: Line 1,322:
|bnf_reference
|bnf_reference
|varchar(6)
|varchar(6)
|
|DEFAULT NULL
|
|
|
|
Line 1,330: Line 1,328:
|age_at_event
|age_at_event
|decimal(5,2)
|decimal(5,2)
|
|DEFAULT NULL
|
|
|
|
Line 1,336: Line 1,334:
|issue_method
|issue_method
|text
|text
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_medication_order_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_medication_order_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |CONSTRAINT fk_medication_order_encounter_id FOREIGN KEY (encounter_id)
| colspan="5" |CONSTRAINT fk_medication_order_encounter_id FOREIGN KEY (encounter_id)
|-
|-
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_medication_order_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_medication_order_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_medication_order_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |CONSTRAINT fk_medication_order_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 1,379: Line 1,377:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Owning organisation (i.e. publisher)
|Owning organisation (i.e. publisher)
|
|
|-
|-
Line 1,391: Line 1,389:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Unique individual across all organisations
|Unique individual across all organisations
|person.id
|person.id
|-
|-
|effective_date
|effective_date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,402: Line 1,400:
|date_precision_concept_id
|date_precision_concept_id
|smallint(6)
|smallint(6)
|DEFAULT NULL
|DEFAULT NULL
|
|Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
|
|
|-
|-
Line 1,415: Line 1,413:
|text
|text
|
|
|This is a warning set by the publisher regarding he patient
|This is a warning set by the publisher regarding he patient
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_flag_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_flag_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |CONSTRAINT fk_flag_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_flag_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 1,445: Line 1,443:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Owning organisation (i.e. publisher)
|Owning organisation (i.e. publisher)
|organization.id
|organization.id
|-
|-
Line 1,457: Line 1,455:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Unique individual across all organisations
|Unique individual across all organisations
|person.id
|person.id
|-
|-
|encounter_id
|encounter_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|
|
|encounter.id
|encounter.id
Line 1,468: Line 1,466:
|practitioner_id
|practitioner_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|The clinician the activity is recorded against
|The clinician the activity is recorded against
|practitioner.id
|practitioner.id
|-
|-
|clinical_effective_date
|clinical_effective_date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,480: Line 1,478:
|date_precision_concept_id
|date_precision_concept_id
|smallint(6)
|smallint(6)
|DEFAULT NULL
|DEFAULT NULL
|
|Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
|
|
|-
|-
|result_value
|result_value
|double
|double
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,492: Line 1,490:
|result_value_units
|result_value_units
|varchar(50)
|varchar(50)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,498: Line 1,496:
|result_date
|result_date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,510: Line 1,508:
|result_concept_id
|result_concept_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,528: Line 1,526:
|problem_end_date
|problem_end_date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,534: Line 1,532:
|parent_observation_id
|parent_observation_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,540: Line 1,538:
|core_concept_id
|core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,546: Line 1,544:
|non_core_concept_id
|non_core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
|-
|-
|age_at_event
|age_at_event
|decimal (5,2)
|decimal (5,2)
|
|DEFAULT NULL
|
|
|
|
Line 1,558: Line 1,556:
|episodicity_concept_id
|episodicity_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,564: Line 1,562:
|is_primary
|is_primary
|boolean
|boolean
|
|DEFAULT NULL
|
|
|
|
Line 1,570: Line 1,568:
|date_recorded
|date_recorded
|datetime
|datetime
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_observation_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_observation_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |CONSTRAINT fk_observation_encounter_id FOREIGN KEY (encounter_id)
| colspan="5" |CONSTRAINT fk_observation_encounter_id FOREIGN KEY (encounter_id)
|-
|-
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_observation_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_observation_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_observation_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |CONSTRAINT fk_observation_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 1,630: Line 1,628:
|encounter_id
|encounter_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 1,636: Line 1,634:
|practitioner_id
|practitioner_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 1,642: Line 1,640:
|clinical_effective_date
|clinical_effective_date
|date
|date
|
|DEFAULT NULL
|
|
|
|
Line 1,648: Line 1,646:
|date_precision_concept_id
|date_precision_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,654: Line 1,652:
|result_value
|result_value
|real
|real
|
|DEFAULT NULL
|
|
|
|
Line 1,660: Line 1,658:
|result_value_units
|result_value_units
|varchar(50)
|varchar(50)
|
|DEFAULT NULL
|
|
|
|
Line 1,666: Line 1,664:
|result_date
|result_date
|date
|date
|
|DEFAULT NULL
|
|
|
|
Line 1,672: Line 1,670:
|result_text
|result_text
|text
|text
|
|DEFAULT NULL
|
|
|
|
Line 1,678: Line 1,676:
|result_concept_id
|result_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,696: Line 1,694:
|problem_end_date
|problem_end_date
|date
|date
|
|DEFAULT NULL
|
|
|
|
Line 1,702: Line 1,700:
|parent_observation_id
|parent_observation_id
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 1,708: Line 1,706:
|core_concept_id
|core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,714: Line 1,712:
|non_core_concept_id
|non_core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
|-
|-
|age_at_event
|age_at_event
|decimal (5,2)
|decimal (5,2)
|
|DEFAULT NULL
|
|
|
|
Line 1,726: Line 1,724:
|episodicity_concept_id
|episodicity_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,732: Line 1,730:
|is_primary
|is_primary
|boolean
|boolean
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_diagnostic_order_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_diagnostic_order_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |CONSTRAINT fk_diagnostic_order_encounter_id FOREIGN KEY (encounter_id)
| colspan="5" |CONSTRAINT fk_diagnostic_order_encounter_id FOREIGN KEY (encounter_id)
|-
|-
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_diagnostic_order_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_diagnostic_order_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_diagnostic_order_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |CONSTRAINT fk_diagnostic_order_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 1,787: Line 1,785:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Unique individual across all organisations
|Unique individual across all organisations
|person.id
|person.id
|-
|-
|encounter_id
|encounter_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|
|
|encounter.id
|encounter.id
Line 1,798: Line 1,796:
|practitioner_id
|practitioner_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|The clinician the activity is recorded against
|The clinician the activity is recorded against
|practitioner.id
|practitioner.id
|-
|-
|clinical_effective_date
|clinical_effective_date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,810: Line 1,808:
|date_precision_concept_id
|date_precision_concept_id
|int
|int
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,816: Line 1,814:
|status_concept_id
|status_concept_id
|int
|int
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,822: Line 1,820:
|core_concept_id
|core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,828: Line 1,826:
|non_core_concept_id
|non_core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,834: Line 1,832:
|age_at_event
|age_at_event
|decimal(5,2)
|decimal(5,2)
|
|DEFAULT NULL
|
|
|
|
Line 1,840: Line 1,838:
|date_recorded
|date_recorded
|datetime
|datetime
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_procedure_request_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_procedure_request_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |/*got an Emis procedure request referring to a confidential encounter, so can't enforce this
| colspan="5" |/*got an Emis procedure request referring to a confidential encounter, so can't enforce this
|-
|-
| colspan="5" |CONSTRAINT fk_procedure_request_encounter_id FOREIGN KEY (encounter_id)
| colspan="5" |CONSTRAINT fk_procedure_request_encounter_id FOREIGN KEY (encounter_id)
|-
|-
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,*/
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,*/
|-
|-
| colspan="5" |CONSTRAINT fk_procedure_request_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_procedure_request_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_procedure_request_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |CONSTRAINT fk_procedure_request_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 1,897: Line 1,895:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Unique individual across all organisations
|Unique individual across all organisations
|person.id
|person.id
|-
|-
|encounter_id
|encounter_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|
|
|encounter.id
|encounter.id
Line 1,908: Line 1,906:
|practitioner_id
|practitioner_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|The clinician the activity is recorded against
|The clinician the activity is recorded against
|practitioner.id
|practitioner.id
|-
|-
|clinical_effective_date
|clinical_effective_date
|date
|date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,920: Line 1,918:
|date_precision_concept_id
|date_precision_concept_id
|smallint(6)
|smallint(6)
|DEFAULT NULL
|DEFAULT NULL
|
|Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
|
|
|-
|-
|requester_organization_id
|requester_organization_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 1,932: Line 1,930:
|recipient_organization_id
|recipient_organization_id
|bigint(20)
|bigint(20)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
|-
|-
|referral_request_priority_concept_id
|referral_request_priority_concept_id
|smallint(6)
|DEFAULT NULL
|
|
|
|referral.request.priority
|
|
|-
|-
|referral_request_type_concept_id
|referral_request_type_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|referral.request.type
|referral.request.type
Line 1,950: Line 1,948:
|Mode
|Mode
|varchar(50)
|varchar(50)
|
|DEFAULT NULL
|
|
|
|
Line 1,956: Line 1,954:
|outgoing_referral
|outgoing_referral
|boolean
|boolean
|
|DEFAULT NULL
|
|
|
|
Line 1,962: Line 1,960:
|is_review
|is_review
|boolean
|boolean
|
|DEFAULT NULL
|
|
|
|
Line 1,968: Line 1,966:
|core_concept_id
|core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,974: Line 1,972:
|non_core_concept_id
|non_core_concept_id
|int
|int
|
|DEFAULT NULL
|
|
|
|
Line 1,980: Line 1,978:
|age_at_event
|age_at_event
|decimal(5,2)
|decimal(5,2)
|
|DEFAULT NULL
|
|
|
|
Line 1,986: Line 1,984:
|date_recorded
|date_recorded
|datetime
|datetime
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_referral_request_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
| colspan="5" |CONSTRAINT pk_referral_request_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
|-
|-
| colspan="5" |/*got an Emis referral request referring to a confidential encounter, so can't enforce this
| colspan="5" |/*got an Emis referral request referring to a confidential encounter, so can't enforce this
|-
|-
| colspan="5" |CONSTRAINT fk_referral_request_encounter_id FOREIGN KEY (encounter_id)
| colspan="5" |CONSTRAINT fk_referral_request_encounter_id FOREIGN KEY (encounter_id)
|-
|-
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
| colspan="5" |REFERENCES encounter (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,*/
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,*/
|-
|-
| colspan="5" |CONSTRAINT fk_referral_request_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_referral_request_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_referral_request_practitioner_id FOREIGN KEY (practitioner_id)
| colspan="5" |CONSTRAINT fk_referral_request_practitioner_id FOREIGN KEY (practitioner_id)
|-
|-
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
| colspan="5" |REFERENCES practitioner (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_referral_request_recipient_organization_id FOREIGN KEY (recipient_organization_id)
| colspan="5" |CONSTRAINT fk_referral_request_recipient_organization_id FOREIGN KEY (recipient_organization_id)
|-
|-
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION,
|-
|-
| colspan="5" |CONSTRAINT fk_referral_request_requester_organization_id FOREIGN KEY (requester_organization_id)
| colspan="5" |CONSTRAINT fk_referral_request_requester_organization_id FOREIGN KEY (requester_organization_id)
|-
|-
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
| colspan="5" |REFERENCES organization (id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 2,054: Line 2,052:
|pseudo_id
|pseudo_id
|varchar(255)
|varchar(255)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_pseudo_id PRIMARY KEY (patient_id, salt_key_name)
| colspan="5" |CONSTRAINT pk_pseudo_id PRIMARY KEY (patient_id, salt_key_name)
|}
|}


Line 2,079: Line 2,077:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Owning organisation (i.e. publisher)
|Owning organisation (i.e. publisher)
|organisation.id
|organisation.id
|-
|-
Line 2,085: Line 2,083:
|bigint(20)
|bigint(20)
|NOT NULL
|NOT NULL
|Unique individual across all organisations
|Unique individual across all organisations
|person.id
|person.id
|-
|-
|Uprn
|Uprn
|bigint
|bigint
|
|DEFAULT NULL
|
|
|
|
Line 2,096: Line 2,094:
|qualifier
|qualifier
|varchar(50)
|varchar(50)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,102: Line 2,100:
|algorithm
|algorithm
|varchar(255)
|varchar(255)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,108: Line 2,106:
|match
|match
|varchar(255)
|varchar(255)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,114: Line 2,112:
|no_address
|no_address
|tinyint(1)
|tinyint(1)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,120: Line 2,118:
|invalid_address
|invalid_address
|tinyint(1)
|tinyint(1)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
|-
|-
|  missing_postcode
|missing_postcode
|tinyint(1)
|tinyint(1)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,132: Line 2,130:
|invalid_postcode
|invalid_postcode
|tinyint(1)
|tinyint(1)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_patient_id_organization_id PRIMARY KEY (`organization_id`,`person_id`,`patient_id`),
| colspan="5" |CONSTRAINT pk_patient_id_organization_id PRIMARY KEY (`organization_id`,`person_id`,`patient_id`),
|-
|-
| colspan="5" |CONSTRAINT fk_patient_uprn_patient_id_organisation_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_patient_uprn_patient_id_organisation_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
| colspan="5" |REFERENCES patient (id, organization_id) MATCH SIMPLE
|-
|-
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
| colspan="5" |ON UPDATE NO ACTION ON DELETE NO ACTION
|}
|}


Line 2,163: Line 2,161:
|bigint
|bigint
|NOT NULL
|NOT NULL
|
|Owning organisation (i.e. publisher)
|
|
|-
|-
Line 2,169: Line 2,167:
|bigint
|bigint
|NOT NULL
|NOT NULL
|
|The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times
|
|patient.id
|-
|-
|person_id bigint
|person_id
|bigint
|bigint
|
|DEFAULT NULL
|
|Unique individual across all organisations
|
|person.id
|-
|-
|use_concept_id
|use_concept_id
|int
|int
|
|DEFAULT NULL
|use of contact (e.g. mobile, home,work
|use of contact (e.g. mobile, home,work
|
|
|-
|-
|type_concept_id
|type_concept_id
|int
|int
|
|DEFAULT NULL
|type of contact (e.g. phone, email)
|type of contact (e.g. phone, email)
|
|
|-
|-
|start_date date
|start_date date
|date
|date
|
|DEFAULT NULL
|
|
|
|
|-
|-
|end_date date
|end_date date
|date
|date
|
|DEFAULT NULL
|
|
|
|
Line 2,204: Line 2,202:
|value
|value
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT pk_organization_id_id_patient_id_person_id PRIMARY KEY (`organization_id`,`id`,`patient_id`,`person_id`),
| colspan="5" |CONSTRAINT pk_organization_id_id_patient_id_person_id PRIMARY KEY (`organization_id`,`id`,`patient_id`,`person_id`),
|-
|-
| colspan="5" |CONSTRAINT fk_patient_contact_patient_id_organisation_id FOREIGN KEY (patient_id, organization_id)
| colspan="5" |CONSTRAINT fk_patient_contact_patient_id_organisation_id FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id)
| colspan="5" |REFERENCES patient (id, organization_id)
|-
|-
| colspan="5" |COMMENT 'stores contact details (e.g. phone) for patients'
| colspan="5" |COMMENT 'stores contact details (e.g. phone) for patients'
|}
|}


Line 2,235: Line 2,233:
|bigint
|bigint
|NOT NULL
|NOT NULL
|
|Owning organisation (i.e. publisher)
|
|organisation.id
|-
|-
|patient_id
|patient_id
|bigint
|bigint
|NOT NULL
|NOT NULL
|
|The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times
|
|patient.id
|-
|-
|person_id
|person_id
|bigint
|bigint
|
|DEFAULT NULL
|
|Unique individual across all organisations
|
|person.id
|-
|-
|address_line_1
|address_line_1
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 2,258: Line 2,256:
|address_line_2
|address_line_2
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 2,264: Line 2,262:
|address_line_3
|address_line_3
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 2,270: Line 2,268:
|address_line_4
|address_line_4
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 2,276: Line 2,274:
|city
|city
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 2,282: Line 2,280:
|postcode
|postcode
|varchar(255)
|varchar(255)
|
|DEFAULT NULL
|
|
|
|
Line 2,289: Line 2,287:
|int
|int
|NOT NULL
|NOT NULL
|use of address (e.g. home, temporary)
|use of address (e.g. home, temporary)
|
|
|-
|-
Line 2,300: Line 2,298:
|end_date
|end_date
|Date
|Date
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,306: Line 2,304:
|lsoa_2001_code
|lsoa_2001_code
|varchar(9)
|varchar(9)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,312: Line 2,310:
|lsoa_2011_code
|lsoa_2011_code
|varchar(9)
|varchar(9)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,318: Line 2,316:
|msoa_2001_code
|msoa_2001_code
|varchar(9)
|varchar(9)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,324: Line 2,322:
|msoa_2011_code
|msoa_2011_code
|varchar(9)
|varchar(9)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,330: Line 2,328:
|ward_code
|ward_code
|varchar(9)
|varchar(9)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,336: Line 2,334:
|local_authority_code
|local_authority_code
|varchar(9)
|varchar(9)
|DEFAULT NULL
|DEFAULT NULL
|
|
|
|
Line 2,344: Line 2,342:
| colspan="5" |PRIMARY KEY (`organization_id`,`id`,`patient_id`,`person_id`)
| colspan="5" |PRIMARY KEY (`organization_id`,`id`,`patient_id`,`person_id`)
|-
|-
| colspan="5" |CONSTRAINT fk_patient_address_patient_id_organization_id  
| colspan="5" |CONSTRAINT fk_patient_address_patient_id_organization_id
|-
|-
| colspan="5" |FOREIGN KEY (patient_id, organization_id)
| colspan="5" |FOREIGN KEY (patient_id, organization_id)
|-
|-
| colspan="5" |REFERENCES patient (id, organization_id)
| colspan="5" |REFERENCES patient (id, organization_id)
|-
|-
| colspan="5" |COMMENT 'stores address details for patients'
| colspan="5" |COMMENT 'stores address details for patients'
|}
|}


Line 2,364: Line 2,362:
|datetime(3)
|datetime(3)
|NOT NULL
|NOT NULL
|date time the change was made to this DB
|date time the change was made to this DB
|
|
|-
|-
Line 2,370: Line 2,368:
|tinyint
|tinyint
|NOT NULL
|NOT NULL
|type of transaction 0=insert, 1=update, 2=delete
|type of transaction 0=insert, 1=update, 2=delete
|
|
|-
|-
Line 2,376: Line 2,374:
|tinyint
|tinyint
|NOT NULL
|NOT NULL
|identifier of the table changed
|identifier of the table changed
|
|
|-
|-
Line 2,407: Line 2,405:
|
|
|-
|-
| colspan="5" |CONSTRAINT   PRIMARY KEY (id)
| colspan="5" |CONSTRAINT  PRIMARY KEY (id)
|}
|}


Line 2,474: Line 2,472:
|-
|-
|updated datetime
|updated datetime
|Datetime
|datetime
|NOT NULL
|NOT NULL
|
|
|
|
|-
|-
| colspan="5" |CONSTRAINT  PRIMARY KEY (dbid),
| colspan="5" |CONSTRAINT PRIMARY KEY (dbid),
|}
|}


Line 2,509: Line 2,507:
|
|
|-
|-
| colspan="5" |CONSTRAINT  PRIMARY KEY (legacy)
| colspan="5" |CONSTRAINT PRIMARY KEY (legacy)
|}
|}


Line 2,638: Line 2,636:
PRIMARY KEY(id)
PRIMARY KEY(id)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
|'''Data type'''
|'''Data type'''
|'''Constraint'''
|'''Constraint'''
Line 2,656: Line 2,654:
|
|
|-
|-
| colspan="5" |CONSTRAINT  PRIMARY KEY (id)
| colspan="5" |CONSTRAINT PRIMARY KEY (id)
|}
|}


Line 2,662: Line 2,660:
PRIMARY KEY(ethnic_code)
PRIMARY KEY(ethnic_code)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
|'''Data type'''
|'''Data type'''
|'''Constraint'''
|'''Constraint'''
Line 2,680: Line 2,678:
|
|
|-
|-
| colspan="5" |CONSTRAINT  PRIMARY KEY (ethnic_code)
| colspan="5" |CONSTRAINT PRIMARY KEY (ethnic_code)
|}
|}


Line 2,686: Line 2,684:
PRIMARY KEY(id, uprn)
PRIMARY KEY(id, uprn)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
|'''Data type'''
|'''Data type'''
|'''Constraint'''
|'''Constraint'''
Line 2,836: Line 2,834:
|
|
|-
|-
| colspan="5" |CONSTRAINT  PRIMARY KEY (id,uprn)
| colspan="5" |CONSTRAINT PRIMARY KEY (id,uprn)
|}
|}


Line 2,866: Line 2,864:
PRIMARY KEY(organization_id)
PRIMARY KEY(organization_id)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
|'''Data type'''
|'''Data type'''
|'''Constraint'''
|'''Constraint'''
Line 2,920: Line 2,918:
|
|
|-
|-
| colspan="5" |CONSTRAINT  PRIMARY KEY (organization_id)
| colspan="5" |CONSTRAINT PRIMARY KEY (organization_id)
|}
|}


Line 2,926: Line 2,924:
PRIMARY KEY(id)
PRIMARY KEY(id)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
|'''Data type'''
|'''Data type'''
|'''Constraint'''
|'''Constraint'''
Line 2,950: Line 2,948:
PRIMARY KEY(id)
PRIMARY KEY(id)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
|'''Data type'''
|'''Data type'''
|'''Constraint'''
|'''Constraint'''
Line 2,968: Line 2,966:
|
|
|-
|-
| colspan="5" |CONSTRAINT  PRIMARY KEY (id)
| colspan="5" |CONSTRAINT PRIMARY KEY (id)
|}
|}


Line 2,974: Line 2,972:
PRIMARY KEY(id)
PRIMARY KEY(id)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
|'''Data type'''
|'''Data type'''
|'''Constraint'''
|'''Constraint'''
Line 2,992: Line 2,990:
|
|
|-
|-
| colspan="5" |CONSTRAINT  PRIMARY KEY (id)
| colspan="5" |CONSTRAINT PRIMARY KEY (id)
|}
|}


Line 2,998: Line 2,996:
PRIMARY KEY(id)
PRIMARY KEY(id)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
|'''Data type'''
|'''Data type'''
|'''Constraint'''
|'''Constraint'''
Line 3,034: Line 3,032:
PRIMARY KEY(organization_id,id,patient_id,person_id)
PRIMARY KEY(organization_id,id,patient_id,person_id)
{| class="wikitable sortable mw-collapsible mw-collapsed"
{| class="wikitable sortable mw-collapsible mw-collapsed"
|'''Column name'''
|'''Column name'''
|'''Data type'''
|'''Data type'''
|'''Constraint'''
|'''Constraint'''

Revision as of 15:08, 29 July 2020


DRAFT

Table: organization

PRIMARY KEY (pk_organization_id PRIMARY KEY (id))

Column name Data type Constraint Comments References
id bigint NOT NULL
ods_code varchar(50) DEFAULT NULL
Name varchar(255) DEFAULT NULL
type_code varchar(50) DEFAULT NULL
type_desc varchar(255) DEFAULT NULL
Postcode varchar(10) DEFAULT NULL
parent_organization_id bigint DEFAULT NULL
PRIMARY KEY pk_organization_id PRIMARY KEY (id)

Table: location

PRIMARY KEY (pk_location_id PRIMARY KEY id)

Column name Data type Constraint Comments References
id bigint NOT NULL
name varchar(255) DEFAULT NULL The name of a location set by the publisher. E.g. ward, clinic, domiciliary
type_code, varchar(50) DEFAULT NULL
type_desc varchar(255) DEFAULT NULL
postcode varchar10) DEFAULT NULL
managing_organization_id bigint DEFAULT NULL
CONSTRAINT pk_location_id PRIMARY KEY (id)
CONSTRAINT fk_location_organisation_id FOREIGN KEY (managing_organization_id)
REFERENCES organization (id)
MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: practitioner

PRIMARY KEY (id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL Owning organisation (i.e. publisher) organisation.id
name varchar(1024) DEFAULT NULL
role_code varchar(50) DEFAULT NULL
role_desc varchar(255) DEFAULT NULL
gmc_code varchar(50) DEFAULT NULL
CONSTRAINT pk_practitioner_id PRIMARY KEY (id),
CONSTRAINT fk_practitioner_organisation_id FOREIGN KEY (organization_id)
REFERENCES organization (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: schedule

PRIMARY KEY (organization_id, id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL Owning organisation (i.e. publisher) organization.id
practitioner_id bigint DEFAULT NULL practitioner.id
start_date date DEFAULT NULL
type varchar(255) DEFAULT NULL
Location varchar(255) DEFAULT NULL location.id
Name varchar(150) DEFAULT NULL
CONSTRAINT pk_schedule_id PRIMARY KEY (organization_id, id),
CONSTRAINT fk_schedule_organization_id FOREIGN KEY (organization_id)
REFERENCES organization (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: person

PRIMARY KEY (id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL
title varchar(50) DEFAULT NULL
first_names varchar(255) DEFAULT NULL
last_name varchar(255) DEFAULT NULL
gender_concept_id int DEFAULT NULL
nhs_number varchar(255) DEFAULT NULL
date_of_birth date, date DEFAULT NULL
date_of_death date, date DEFAULT NULL
current_address_id, bigint NOT NULL
ethnic_code_concept_id int DEFAULT NULL
registered_practice_organization_id bigint DEFAULT NULL
CONSTRAINT pk_person_id PRIMARY KEY (id)

Table: patient

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL Owning organisation (i.e. publisher) organization.id
person_id bigint NOT NULL Unique individual across all organisations person.id
title varchar(50)
first_names varchar(255)
last_name varchar(255)
gender_concept_id int
nhs_number varchar(255)
date_of_birth date
date_of_death date
current_address_id bigint
ethnic_code_concept_id int
registered_practice_organization_id bigint
CONSTRAINT pk_patient_id_organization_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
CONSTRAINT fk_patient_organization_id FOREIGN KEY (organization_id)
REFERENCES organization (id) MATCH SIMPLE

Table: episode_of_care

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL Owning organisation (i.e. publisher) organization.id
patient_id bigint NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint NOT NULL Unique individual across all organisations person.id
registration_type_concept_id int DEFAULT NULL registration.type.id
registration_status_concept_id int DEFAULT NULL
date_registered date date DEFAULT NULL
date_registered_end date date DEFAULT NULL
usual_gp_practitioner_id bigint DEFAULT NULL Practitioner.id
CONSTRAINT pk_episode_of_care_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
CONSTRAINT fk_episode_of_care_patient_id_organisation_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_episode_of_care_practitioner_id FOREIGN KEY (usual_gp_practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: appointment

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id varchar(36) NOT NULL Owning organisation (i.e. publisher) organization.id
patient_id varchar(36) NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint NOT NULL Unique individual across all organisations person.id
practitioner_id bigint DEFAULT NULL The clinician the activity is recorded against practitioner.id
schedule_id bigint DEFAULT NULL The schedule the patient was put on to book multiple appointments. ID unique to the applied schedule schedule.id
start_date date DEFAULT NULL
planned_duration int DEFAULT NULL The time allocated for the appointment, not necessarily the actual duration always in minutes
actual_duration int DEFAULT NULL Time between sent in and left always in minutes
appointment_status_concept_id int DEFAULT NULL The status of the appointment e.g. arrived/sent in/left/DNA
patient_wait int DEFAULT NULL How long the patient waited from being marked as arrived to being sent in
patient_delay int DEFAULT NULL
date_time_sent_in datetime DEFAULT NULL Date and time the patient was sent into the practitioner
date_time_left datetime DEFAULT NULL Date and time the patient left the practitioner
source_id varchar(36) DEFAULT NULL
cancelled_date datetime DEFAULT NULL
CONSTRAINT pk_appointment_id PRIMARY KEY (organization_id,person_id,id),
CONSTRAINT fk_appointment_organization_id FOREIGN KEY (organization_id)
REFERENCES organization (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_appointment_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: encounter

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL Owning organisation (i.e. publisher)
patient_id bigint NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times
person_id bigint NOT NULL Unique individual across all organisations
practitioner_id bigint DEFAULT NULL The clinician the activity is recorded against
appointment_id bigint DEFAULT NULL
clinical_effective_date date DEFAULT NULL The date the clinical code is recorded for


date_precision_concept_id

int DEFAULT NULL
episode_of_care_id bigint DEFAULT NULL Is this instance of the code a review of a previous encounter
service_provider_organization_id bigint DEFAULT NULL
core_concept_id int DEFAULT NULL
non_core_concept_id int DEFAULT NULL
age_at_event decimal(5,2) DEFAULT NULL
Type text DEFAULT NULL
sub_type text DEFAULT NULL
admission_method varchar(40) DEFAULT NULL
end_date date DEFAULT NULL
institution_location_id text DEFAULT NULL
date_recorded datetime DEFAULT NULL
service_provider_organization_id bigint(20) DEFAULT NULL


CONSTRAINT pk_encounter_id PRIMARY KEY (organization_id,person_id,id),

CONSTRAINT fk_encounter_appointment_id FOREIGN KEY (appointment_id)
REFERENCES appointment (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,*/
CONSTRAINT fk_encounter_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_encounter_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_encounter_episode_of_care_id FOREIGN KEY (episode_of_care_id)
REFERENCES episode_of_care (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_encounter_service_provider_organization_id FOREIGN KEY (service_provider_organization_id)
REFERENCES organization (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: encounter_event

PRIMARY KEY (organization_id, person_id, id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL
patient_id bigint NOT NULL
person_id bigint NOT NULL
encounter_id bigint NOT NULL parent encounter record
practitioner_id bigint DEFAULT NULL
appointment_id bigint DEFAULT NULL
clinical_effective_date datetime DEFAULT NULL
date_precision_concept_id int DEFAULT NULL
episode_of_care_id bigint DEFAULT NULL
service_provider_organization_id bigint DEFAULT NULL
core_concept_id int DEFAULT NULL
non_core_concept_id int DEFAULT NULL
age_at_event decimal(5,2) DEFAULT NULL
type text DEFAULT NULL
sub_type text DEFAULT NULL
admission_method varchar(40) DEFAULT NULL
end_date date DEFAULT NULL
institution_location_id bigint DEFAULT NULL
date_recorded datetime DEFAULT NULL
finished boolean DEFAULT NULL
CONSTRAINT pk_encounter_event_id PRIMARY KEY (organization_id, person_id, id),
CONSTRAINT fk_encounter_event_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_encounter_event_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_encounter_event_episode_of_care_id FOREIGN KEY (episode_of_care_id)
REFERENCES episode_of_care (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_encounter_event_service_provider_organization_id FOREIGN KEY (service_provider_organization_id)
REFERENCES organization (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: encounter_additional

PRIMARY KEY (id, property_id, value_id)

Column name Data type Constraint Comments References
id bigint NOT NULL same as the id column on the encounter table
property_id bigint NOT NULL IM reference (i.e. Admission method)
value_id bigint NOT NULL IM reference (i.e. Emergency admission)
CONSTRAINT pk_encounter_additional_id PRIMARY KEY (id, property_id, value_id)

Table: allergy_intolerance

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL Owning organisation (i.e. publisher) organization.id
patient_id bigint NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint NOT NULL Unique individual across all organisations person.id
encounter_id bigint DEFAULT NULL encounter.id
practitioner_id bigint DEFAULT NULL The clinician the activity is recorded against practitioner.id
clinical_effective_date Date DEFAULT NULL The date the clinical code is recorded for
date_precision_concept_id Int DEFAULT NULL Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
is_review boolean NOT NULL Is this instance of the code a review of a previous encounter
core_concept_id Int DEFAULT NULL
non_core_concept_id Int DEFAULT NULL
age_at_event decimal(5,2) DEFAULT NULL
date_recorded datetime NOT NULL Is this instance of the code a review of a previous encounter
CONSTRAINT pk_allergy_intolerance_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
CONSTRAINT fk_allergy_intolerance_encounter_id FOREIGN KEY (encounter_id)
REFERENCES encounter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_allergy_intolerance_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_allergy_intolerance_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: medication_statement

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint(20) NOT NULL
organization_id bigint(20) NOT NULL Owning organisation (i.e. publisher) organization.id
patient_id bigint(20) NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint(20) NOT NULL Unique individual across all organisations person.id
encounter_id bigint(20) DEFAULT NULL encounter.id
practitioner_id bigint(20) DEFAULT NULL The clinician the activity is recorded against practitioner.id
clinical_effective_date date DEFAULT NULL
date_precision_concept_id smallint(6) DEFAULT NULL Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
is_active tinyint(4) DEFAULT NULL
cancellation_date date DEFAULT NULL
dose varchar(1000) DEFAULT NULL
quantity_value double DEFAULT NULL
quantity_unit varchar(255) DEFAULT NULL
authorisation_type_concept_id int DEFAULT NULL
core_concept_id int DEFAULT NULL
non_core_concept_id int DEFAULT NULL
bnf_reference varchar(6) DEFAULT NULL
age_at_event decimal(5,2) DEFAULT NULL
Issue_method text DEFAULT NULL
CONSTRAINT pk_medication_statement_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
CONSTRAINT fk_medication_statement_encounter_id FOREIGN KEY (encounter_id)
REFERENCES encounter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_medication_statement_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_medication_statement_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: medication_order

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL Owning organisation (i.e. publisher) organization.id
patient_id bigint NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint NOT NULL Unique individual across all organisations person.id
encounter_id bigint DEFAULT NULL encounter.id
practitioner_id bigint DEFAULT NULL The clinician the activity is recorded against practitioner.id
clinical_effective_date date DEFAULT NULL
date_precision_concept_id int DEFAULT NULL Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
dose varchar(1000) DEFAULT NULL
quantity_value real DEFAULT NULL
quantity_unit varchar(255) DEFAULT NULL
duration_days int DEFAULT NULL
estimated_cost real DEFAULT NULL
medication_statement_id bigint DEFAULT NULL
core_concept_id int DEFAULT NULL
non_core_concept_id int DEFAULT NULL
bnf_reference varchar(6) DEFAULT NULL
age_at_event decimal(5,2) DEFAULT NULL
issue_method text DEFAULT NULL
CONSTRAINT pk_medication_order_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
CONSTRAINT fk_medication_order_encounter_id FOREIGN KEY (encounter_id)
REFERENCES encounter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_medication_order_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_medication_order_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: flag

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint(20) NOT NULL
organization_id bigint(20) NOT NULL Owning organisation (i.e. publisher)
patient_id bigint(20) NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint(20) NOT NULL Unique individual across all organisations person.id
effective_date date DEFAULT NULL
date_precision_concept_id smallint(6) DEFAULT NULL Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
is_active tinyint(1) NOT NULL
flag_text text This is a warning set by the publisher regarding he patient
CONSTRAINT pk_flag_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
CONSTRAINT fk_flag_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: observation

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint(20) NOT NULL
organization_id bigint(20) NOT NULL Owning organisation (i.e. publisher) organization.id
patient_id bigint(20) NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint(20) NOT NULL Unique individual across all organisations person.id
encounter_id bigint(20) DEFAULT NULL encounter.id
practitioner_id bigint(20) DEFAULT NULL The clinician the activity is recorded against practitioner.id
clinical_effective_date date DEFAULT NULL
date_precision_concept_id smallint(6) DEFAULT NULL Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
result_value double DEFAULT NULL
result_value_units varchar(50) DEFAULT NULL
result_date date DEFAULT NULL
result_text text
result_concept_id bigint(20) DEFAULT NULL
is_problem tinyint(1) NOT NULL
is_review tinyint(1) NOT NULL
problem_end_date date DEFAULT NULL
parent_observation_id bigint(20) DEFAULT NULL
core_concept_id int DEFAULT NULL
non_core_concept_id int DEFAULT NULL
age_at_event decimal (5,2) DEFAULT NULL
episodicity_concept_id int DEFAULT NULL
is_primary boolean DEFAULT NULL
date_recorded datetime DEFAULT NULL
CONSTRAINT pk_observation_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
CONSTRAINT fk_observation_encounter_id FOREIGN KEY (encounter_id)
REFERENCES encounter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_observation_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_observation_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: diagnostic_order

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL
patient_id bigint NOT NULL
person_id bigint NOT NULL
encounter_id bigint DEFAULT NULL
practitioner_id bigint DEFAULT NULL
clinical_effective_date date DEFAULT NULL
date_precision_concept_id int DEFAULT NULL
result_value real DEFAULT NULL
result_value_units varchar(50) DEFAULT NULL
result_date date DEFAULT NULL
result_text text DEFAULT NULL
result_concept_id int DEFAULT NULL
is_problem boolean NOT NULL
is_review boolean NOT NULL
problem_end_date date DEFAULT NULL
parent_observation_id bigint DEFAULT NULL
core_concept_id int DEFAULT NULL
non_core_concept_id int DEFAULT NULL
age_at_event decimal (5,2) DEFAULT NULL
episodicity_concept_id int DEFAULT NULL
is_primary boolean DEFAULT NULL
CONSTRAINT pk_diagnostic_order_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
CONSTRAINT fk_diagnostic_order_encounter_id FOREIGN KEY (encounter_id)
REFERENCES encounter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_diagnostic_order_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_diagnostic_order_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: procedure_request

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint(20) NOT NULL
organization_id bigint(20) NOT NULL Owning organisation (i.e. publisher) organization.id
patient_id bigint(20) NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint(20) NOT NULL Unique individual across all organisations person.id
encounter_id bigint(20) DEFAULT NULL encounter.id
practitioner_id bigint(20) DEFAULT NULL The clinician the activity is recorded against practitioner.id
clinical_effective_date date DEFAULT NULL
date_precision_concept_id int DEFAULT NULL
status_concept_id int DEFAULT NULL
core_concept_id int DEFAULT NULL
non_core_concept_id int DEFAULT NULL
age_at_event decimal(5,2) DEFAULT NULL
date_recorded datetime DEFAULT NULL
CONSTRAINT pk_procedure_request_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
/*got an Emis procedure request referring to a confidential encounter, so can't enforce this
CONSTRAINT fk_procedure_request_encounter_id FOREIGN KEY (encounter_id)
REFERENCES encounter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,*/
CONSTRAINT fk_procedure_request_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_procedure_request_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: referral_request

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
id bigint(20) NOT NULL
organization_id bigint(20) NOT NULL Owning organisation (i.e. publisher) organization.id
patient_id bigint(20) NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint(20) NOT NULL Unique individual across all organisations person.id
encounter_id bigint(20) DEFAULT NULL encounter.id
practitioner_id bigint(20) DEFAULT NULL The clinician the activity is recorded against practitioner.id
clinical_effective_date date DEFAULT NULL
date_precision_concept_id smallint(6) DEFAULT NULL Identifies the precision of the clinical effectiveness date to either year (1) month (2) day (5) minute (12) second (13) millisecond (14)
requester_organization_id bigint(20) DEFAULT NULL
recipient_organization_id bigint(20) DEFAULT NULL
referral_request_priority_concept_id smallint(6) DEFAULT NULL referral.request.priority
referral_request_type_concept_id int DEFAULT NULL referral.request.type
Mode varchar(50) DEFAULT NULL
outgoing_referral boolean DEFAULT NULL
is_review boolean DEFAULT NULL
core_concept_id int DEFAULT NULL
non_core_concept_id int DEFAULT NULL
age_at_event decimal(5,2) DEFAULT NULL
date_recorded datetime DEFAULT NULL
CONSTRAINT pk_referral_request_id PRIMARY KEY (`organization_id`,`person_id`,`id`),
/*got an Emis referral request referring to a confidential encounter, so can't enforce this
CONSTRAINT fk_referral_request_encounter_id FOREIGN KEY (encounter_id)
REFERENCES encounter (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,*/
CONSTRAINT fk_referral_request_patient_id_organization_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_referral_request_practitioner_id FOREIGN KEY (practitioner_id)
REFERENCES practitioner (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_referral_request_recipient_organization_id FOREIGN KEY (recipient_organization_id)
REFERENCES organization (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_referral_request_requester_organization_id FOREIGN KEY (requester_organization_id)
REFERENCES organization (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: pseudo_id

PRIMARY KEY (patient_id, salt_key_name)

Column name Data type Constraint Comments References
Id bigint NOT NULL
patient_id bigint NOT NULL
salt_key_name varchar(50) NOT NULL
pseudo_id varchar(255) DEFAULT NULL
CONSTRAINT pk_pseudo_id PRIMARY KEY (patient_id, salt_key_name)

Table: patient_uprn

PRIMARY KEY (organization_id,person_id,id)

Column name Data type Constraint Comments References
patient_id bigint(20) NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
organization_id bigint(20) NOT NULL Owning organisation (i.e. publisher) organisation.id
person_id bigint(20) NOT NULL Unique individual across all organisations person.id
Uprn bigint DEFAULT NULL
qualifier varchar(50) DEFAULT NULL
algorithm varchar(255) DEFAULT NULL
match varchar(255) DEFAULT NULL
no_address tinyint(1) DEFAULT NULL
invalid_address tinyint(1) DEFAULT NULL
missing_postcode tinyint(1) DEFAULT NULL
invalid_postcode tinyint(1) DEFAULT NULL
CONSTRAINT pk_patient_id_organization_id PRIMARY KEY (`organization_id`,`person_id`,`patient_id`),
CONSTRAINT fk_patient_uprn_patient_id_organisation_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION

Table: patient_contact

PRIMARY KEY (organization_id,id,patient_id,person_id)

Column name Data type Constraint Comments References
id bigint NOT NULL
organization_id bigint NOT NULL Owning organisation (i.e. publisher)
patient_id bigint NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint DEFAULT NULL Unique individual across all organisations person.id
use_concept_id int DEFAULT NULL use of contact (e.g. mobile, home,work
type_concept_id int DEFAULT NULL type of contact (e.g. phone, email)
start_date date date DEFAULT NULL
end_date date date DEFAULT NULL
value varchar(255) DEFAULT NULL
CONSTRAINT pk_organization_id_id_patient_id_person_id PRIMARY KEY (`organization_id`,`id`,`patient_id`,`person_id`),
CONSTRAINT fk_patient_contact_patient_id_organisation_id FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id)
COMMENT 'stores contact details (e.g. phone) for patients'

Table: patient_address

PRIMARY KEY (organization_id,id,patient_id,person_id)

Column name Data type Constraint Comments References
Id bigint NOT NULL
organization_id bigint NOT NULL Owning organisation (i.e. publisher) organisation.id
patient_id bigint NOT NULL The organisations record for this person’s registration. Patients may have multiple records across clinical systems and may have registered at an organisation multiple times patient.id
person_id bigint DEFAULT NULL Unique individual across all organisations person.id
address_line_1 varchar(255) DEFAULT NULL
address_line_2 varchar(255) DEFAULT NULL
address_line_3 varchar(255) DEFAULT NULL
address_line_4 varchar(255) DEFAULT NULL
city varchar(255) DEFAULT NULL
postcode varchar(255) DEFAULT NULL
use_concept_id int NOT NULL use of address (e.g. home, temporary)
start_date Date NOT NULL
end_date Date DEFAULT NULL
lsoa_2001_code varchar(9) DEFAULT NULL
lsoa_2011_code varchar(9) DEFAULT NULL
msoa_2001_code varchar(9) DEFAULT NULL
msoa_2011_code varchar(9) DEFAULT NULL
ward_code varchar(9) DEFAULT NULL
local_authority_code varchar(9) DEFAULT NULL
CONSTRAINT pk_organization_id_id_patient_id_person_id
PRIMARY KEY (`organization_id`,`id`,`patient_id`,`person_id`)
CONSTRAINT fk_patient_address_patient_id_organization_id
FOREIGN KEY (patient_id, organization_id)
REFERENCES patient (id, organization_id)
COMMENT 'stores address details for patients'

Table: event_log

Column name Data type Constraint Comments References
dt_change datetime(3) NOT NULL date time the change was made to this DB
change_type tinyint NOT NULL type of transaction 0=insert, 1=update, 2=delete
table_id tinyint NOT NULL identifier of the table changed
record_id bigint NOT NULL id of the record changed

Table: appointment_status

PRIMARY KEY (id)

Column name Data type Constraint Comments References
id smallint(6) NOT NULL
Value varchar(50) NOT NULL
CONSTRAINT PRIMARY KEY (id)

Table: concept

PRIMARY KEY (dbid)

Column name Data type Constraint Comments References
Dbid int(11) NOT NULL
Document int(11) NOT NULL
Id varchar(150) NOT NULL
Draft tinyint(1) NOT NULL
Name varchar(255) DEFAULT NULL
Description varchar(400) DEFAULT NULL
Scheme bigint(20) DEFAULT NULL
Code varchar(40) DEFAULT NULL
use_count bigint(20) NOT NULL DEFAULT 0
updated datetime datetime NOT NULL
CONSTRAINT PRIMARY KEY (dbid),

Table: concept_map

PRIMARY KEY (legacy)

Column name Data type Constraint Comments References
Legacy int(11) NOT NULL
Core int(11) NOT NULL
Updated datetime NOT NULL
CONSTRAINT PRIMARY KEY (legacy)

Table: concept_property_object

Column name Data type Constraint Comments References
dbid int(11) NOT NULL
group int(11) NOT NULL
property int(11) NOT NULL
value int(11) NOT NULL
updated datetime NOT NULL

Table: concept_tct

Column name Data type Constraint Comments References
Source int(11) DEFAULT NULL
Property int(11) DEFAULT NULL
Level int(11) DEFAULT NULL
Target int(11) DEFAULT NULL
Status int(11) DEFAULT NULL
created_date datetime DEFAULT NULL

Table: consent_code

Column name Data type Constraint Comments References
STATUS varchar(10) DEFAULT NULL
DESCRIPTION varchar(100) DEFAULT NULL
CODE varchar(20) DEFAULT NULL
TERM_CODE varchar(20) DEFAULT NULL
TERM varchar(100) DEFAULT NULL

Table: date_precision

PRIMARY KEY(id)

Column name Data type Constraint Comments References
Id smallint(6) NOT NULL
Value varchar(11) NOT NULL
CONSTRAINT PRIMARY KEY (id)

Table: ethnicity_lookup

PRIMARY KEY(ethnic_code)

Column name Data type Constraint Comments References
ethnic_code char(1) NOT NULL
ethnic_name varchar(100) DEFAULT NULL
CONSTRAINT PRIMARY KEY (ethnic_code)

Table: patient_address_match

PRIMARY KEY(id, uprn)

Column name Data type Constraint Comments References
Id bigint(20) NOT NULL
Uprn varchar(255) NOT NULL
Status smallint(6) DEFAULT NULL
Classification varchar(45) DEFAULT NULL
Latitude double DEFAULT NULL
Longitude double DEFAULT NULL
Xcoordinate double DEFAULT NULL
Ycoordinate double DEFAULT NULL
Qualifier varchar(50) DEFAULT NULL
Algorithm varchar(255) DEFAULT NULL
match_date datetime DEFAULT NULL
abp_address_number varchar(255) DEFAULT NULL
abp_address_street varchar(255) DEFAULT NULL
abp_address_locality varchar(255) DEFAULT NULL
abp_address_town varchar(10) DEFAULT NULL
abp_address_postcode varchar(10) DEFAULT NULL
abp_address_organization varchar(255) DEFAULT NULL
match_pattern_postcode varchar(255) DEFAULT NULL
match_pattern_street varchar(255) DEFAULT NULL
match_pattern_number varchar(255) DEFAULT NULL
match_pattern_building varchar(255) DEFAULT NULL
match_pattern_flat varchar(255) DEFAULT NULL
algorithm_version varchar(255) DEFAULT NULL
Epoc varchar(255) DEFAULT NULL
CONSTRAINT PRIMARY KEY (id,uprn)

Table: patient_gender

PRIMARY KEY(id)

Column name Data type Constraint Comments References
Id smallint(6) NOT NULL
Value varchar(10) NOT NULL
CONSTRAINT PRIMARY KEY (id)

Table: patient_pseudo_id

PRIMARY KEY(organization_id)

Column name Data type Constraint Comments References
Id bigint(20) NOT NULL
organization_id bigint(20) NOT NULL
patient_id bigint(20) NOT NULL
person_id bigint(20) NOT NULL
salt_name varchar(50) NOT NULL
Skid varchar(255) NOT NULL
is_nhs_number_valid tinyint(1) NOT NULL
is_nhs_number_verified_by_publisher tinyint(1) NOT NULL
CONSTRAINT PRIMARY KEY (organization_id)

Table: procedure_request_status

PRIMARY KEY(id)

Column name Data type Constraint Comments References
Id smallint(6) NOT NULL
Value varchar(50) NOT NULL
CONSTRAINT PRIMARY KEY (id)

Table: referral_request_priority

PRIMARY KEY(id)

Column name Data type Constraint Comments References
Id smallint(6) NOT NULL
Value varchar(50) NOT NULL
CONSTRAINT PRIMARY KEY (id)

Table: referral_request_type

PRIMARY KEY(id)

Column name Data type Constraint Comments References
Id smallint(6) NOT NULL
Value varchar(50) NOT NULL
CONSTRAINT PRIMARY KEY (id)

Table: registration_status

PRIMARY KEY(id)

Column name Data type Constraint Comments References
Id smallint(6) NOT NULL
Code varchar(10) NOT NULL
Description varchar(50) NOT NULL
is_active tinyint(1) NOT NULL
CONSTRAINT PRIMARY KEY (id)

Table: registration_status_history

PRIMARY KEY(organization_id,id,patient_id,person_id)

Column name Data type Constraint Comments References
Id bigint(20) NOT NULL
organization_id bigint(20) NOT NULL
patient_id bigint(20) NOT NULL
person_id bigint(20) NOT NULL
episode_of_care_id bigint(20) DEFAULT NULL
registration_status_concept_id int(11) DEFAULT NULL
start_date datetime DEFAULT NULL
end_date datetime DEFAULT NULL
CONSTRAINT PRIMARY KEY (organization_id,id,patient_id,person_id)