Relational Schema Migration Guide
Migration from the preview relational schema
The latest relational schema includes all resource types that were available in the preview schema, with 14 additional resource types. The new types are listed below in the section "Tables for new resource types".
Changes to existing tables
Upon reviewing the preview schema for usability gaps, our changes have primary centered around the following:
- We revamped the way codeable concept relationships work. Instead of using a single
CODEABLE_CONCEPT
table across all resource types, selected codeable concepts have a dedicated dimension table. - We have "top-leveled" additional columns to make them more quickly accessible.
- We discovered many columns and child tables that are either very sparsely populated or populated exclusively with data that doesn't provide information. These have been removed from the schema.
- We renamed many columns to follow consistent conventions and avoid keyword collisions.
condition
condition
Column changes
code_codeable_concept_id
has been renamed tocondition_code_id
, which references thecondition_code
table.clinical_status_codeable_concept_id
is removed. Use theclinical_status
field to get the value directly.verification_status_codeable_concept_id
is removed. Use theverification_status
field to get the value directly.condition_severity_codeable_concept_id
is removed.onset_date_time
andonset_string
are removed. Use theonset
field.abatement_date_time
andabatement_string
are removed. Use theabatement
field.asserter_patient_id
andrecorder_patient_id
are removed as the asserter and recorder are always Practitioners in the current dataset.
Changes to related tables
condition_body_site
has been removed due to lack of datacondition_category
has been redefined to represent unique values of thecategory
field (a CodeableConcept structure) in FHIR condition resourcescondition_category_coding
is a new table containing all unique codings that referencecondition_category
condition_code
is a new table that represents all unique values ofcode
in FHIR condition resourcescodntiion_code_coding
is a new table containing codings that referencecondition_code
condition_note
:author_string
has been removed due to lack of data.text
has been renamedtext_markdown
to avoid colliding with the name of a SQL data type
condition_summary_snomed
condition_summary_snomed
This table has been renamed to lens_snomed_condition
. This follows a convention of using lens
as a prefix for all tables that contain Lens derived data.
Column changes to this table:
clinical_status_codeable_concept_id
has been removed. Use theclinical_status
field to get the value directly.code_codeable_concept_id
has been renamedlens_snomed_condition_code_id
onset_date_time
has been renamedonset
Changes to related tables
lens_snomed_condition_code
is a new table that represents all unique values ofcode
on the FHIR condition resourcelens_snomed_condition_code_coding
contains all unique codings that referencelens_snomed_condition_code
condition_summary_snomed_aggregated_from
has been removed due to lack of use casescondition_summary_snomed_identitifier
has been removed due to lack fo data
encounter
encounter
Column changes
class_coding_id
has been removed. Useclass_code
to retrieve an enriched version of the encounter class.service_type_codeable_concept_id
has been removedhospitalization_admit_source_codeable_concept_id
has been removed due to lack of datapart_of_encounter_id
has been removed due to lack of datatype_display
has been added as a humna-readable field of the encounter typelocation_id
has been added to reference the associated Locationhospitalization_discharge_disposition_codeable_concept_id
has been renamed toencounter_hospitalization_discharge_disposition_id
Changes to related tables
encounter_diagnosis
now includes ause_code
column containing a scalar value instead ofuse_codeable_concept_id
, as most CodeableConcept values contained only acode
element.encounter_reason_code
now includes columns for the SNOMED, ICD-10-CM, and ICD-9-CM values, and a human-readable display field. Thecodeable_concept_id
columns has been removed.encounter_participant
TODOencounter_hospitalization_discharge_disposition
is a new table that represents all unique values of encounter hospitalization discharge dispositions.encounter_hospitalization_discharge_disposition_coding
contains the codings that referenceencounter_hospitalization_discharge_disposition
encounter_location
has been removed. Use thelocation_id
column on theencounter
table instead.encounter_type
is a new table that represents all unque values of the encounter type.encounter_type_coding
contains all unique codings that referenceencounter_type
.
episode_of_care
episode_of_care
This table has been renamed to lens_transition_of_care
.
Column changes
encounter_class_coding_id
has been removed. Use theencounter_class_code
column instead to get the extracted coding of the encounter class, andencounter_class_display
for a human-readable display name for the encounter class.discharge_disposition_codeable_concept_id
has been renamedtransition_of_care_discharge_disposition_id
Changes to related tables
episode_of_care_diagnosis
has been renamedlens_transition_of_care_diagnosis
. The columnrole_codeable_concept_id
has been removed in favor of top-leveled columnsrole_code
androle_display
.episode_of_care_aggregated_from
has been renamedlens_transition_of_care_aggregated_from
episode_of_care_identifier
has been renamedlens_transition_of_care_identifier
episode_of_care_discharge_disposition
has been renamedlens_transition_of_care_disposition
episode_of_care_discharge_disposition_coding
has been renamedlens_transition_of_care_disposition_coding
episode_of_care_narrative
has been renamedlens_transition_of_care_narrative
medication_dispense
medication_dispense
Column changes
days_supply_value
has been renameddays_supply
Changes to related tables
medication_dispense_performer
has been removed because the medication dispenses in our data currently have at most one performer. Use theperformer_actor_organization_id
column onmedication_dispense
instead.medication_dispense_authorizing_prescription
has been removed because the medication dispenses in our data currently have at most one authorizing prescription. Use theauthorizing_prescription_medication_request_id
column onmedication_dispense
instead.medication_dispense_dosage_instruction
has been removed because the medication dispenses in our data currently have at most one dosage instruction. Use thedosage_instruction
onmedication_dispense
instead to get the text of the instruction.
medication_statement
medication_statement
Column changes
medication_codeable_concept_id
has been renamed tomedication_concept_id
, and references themedication_concept
table.context_display
has been removedeffective_period_start
has been renamedeffective_start
effective_period_end
has been renamedeffective_end
information_source_patient_id
has been removed due to lack of datatext_div
andtext_status
have been removedmedication_refills
,medication_last_fill_date
, andmedication_prescribed_date
have been removed as these columns are only populated on Lens resources
Changes to related tables
medication_statement_derived_from
has been removed as this data is only populated for Lens resourcesmedication_statement_dosage
has been removed as medication statements in our data currently have at most one dosage. Use thedosage_id
column on themedication_statement
table instead.medication_statement_reason_code
has been removed. Use themedication_statement_reason_code_bridge
table to join tomedication_statement_reason_code_coding
medication_statement_summary_rxnorm
medication_statement_summary_rxnorm
This table has been renamed to lens_rxnorm_medicationstatement
. This follows a convention of using lens
as a prefix for all tables that contain Lens derived data.
Column changes
text_div
andtext_status
have been removed.medication_codeable_concept_id
has been renamed tomedication_concept_id
, and references themedication_concept
table.effective_period_start
andeffective_period_end
have been removed due to lack of data.medication_refills
has been renamedrefills
medication_last_fill_date
has been renamedlast_fill_date
medication_prescribed_date
has been renamedprescribed_date
medication_days_supply
has been renameddays_supply
medication_quantity
has been renamedquantity
medication_last_prescriber_practitioner_id
has been renamedlast_prescriber_practitioner_id
medication_last_prescriber_medication_request_id
has been renamedlast_prescriber_medication_request_id
Changes to related tables
medication_statement_summary_rxnorm_aggregated_from
has been removed due to lack fo use cases.medication_statement_summary_rxnorm_derived_from
has been removed due to lack of use cases.medication_statement_summary_rxnorm_dosage
has been removed. Use thedosage_id
field on thelens_rxnorm_medicationstatement
instead.
observation
observation
Column changes
text_div
andtext_status
have been removed.code_codeable_concept_id
has been renamedobservation_code_id
and references theobservation_code
table.value_codeable_concept_id
has been renamedobservation_value_concept_id
and references theobservation_value_concept
table.data_absent_reason_codeable_concept_id
has been removed.data_absent_reason
contains the coding for the reason for data absence.body_site_codeable_concept_id
has been renamedbody_site_id
and references thebody_site
table.method_codeable_concept_id
has been renamedobservation_method_id
and references theobservation_method
table.
Changes to related tables
observation_component
has been removed.observation_interpreation
no longer hascodeable_concept_id
, instead it encodes all unique values of theinterpretation
field on FHIR Observations, and can be joined toobservation
andobservation_interpretation_coding
.observation_note
:text
has been renamedtext_markdown
observation_reference_range
has been removed. The high, low, unit, and value fields have been top-leveled on theobservation
table.
organization
organization
Column changes: no columns have been altered to removed. Columns have been added for the organization type and address.
Changes to related tables
organization_address
has been removed. Use theaddress_line_1
,address_line_2
,address_city
,address_state
, andaddress_postal_code
fields onorganization
.organization_contact
has been removed due to lakc of data.organization_contact_telecom
has been removed due to lack of data.
patient
patient
Column changes:
marital_status_codeable_concept_id
has been removed. Usemarital_status
to get the coding value.deceased_boolean
has been renamed todeceased
. This column is automatically set totrue
ifdeceased_datetime
is populated.
Changes to related tables
patient_communication
language_preference_type_coding_id
has been removed. Usepreferred_type
to get the coding directly.patient_proficiency_coding_id
has been removed. Uselanguage_ability
andlanguage_ability_display
to get the coding and display name of the langauge proficiency.language_codeable_concept_id
has been renamed topatient_communication_language_id
and references thepatient_communication_language
table.
patient_contact
:name_human_name_id
has been removed. Use thename_family
,name_given_
, andname_given_2
fields directly on thepatient_contact
table.address_id
has been removed. Use theaddress_line_1
,address_line_2
,address_city
,address_state
, andaddress_postal_code
fields on thepatient_contact
table.
patient_contact_relationship
has been removed. Use therelationship
field on thepatient_contact
table to get the code representing the contact's relationship to the patient.patient_address
:address_id
has been removed. The patient's address info can be directly found on this table, instead of joining to a separateaddress
table.
practitioner
practitioner
Column changes
active
has been removed due to lack of data.
Changes to related tables
practitioner_name
has been removed. Use thename_family
,name_given_1
, andname_given_2
fields on thepractitioner
table.practitioner_address
has been removed. Use theaddress_line_1
,address_line_2
,address_city
,address_state
, andaddress_postal_code
fields on thepractitioner
table.practitioner_qualification
:code_codeable_concept_id
has been removed. Instead, this table now represents all unique values of thequalification
field on FHIR Practitioners and can be joined topractitioner
andpractitioner_qualification_coding
.
procedure
procedure
Column changes
text_div
andtext_status
have been removed.code_codeable_concept_id
has been renamedprocedure_code_id
, and references theprocedure_code
table.performed_start
is now a timestamp.performed_end
is now a timestamp.code_text
has been renamedcode_display
.
Changes to related tables
procedure_body_site
has been dropped. Usebody_site_concept_id
to join to thebody_site
table instead.
related_person
related_person
Column changes: no changed or removed columns. Columns have been added for the related person's name and adddress.
Changes to related tables
related_person_relationship
:codeable_concept_id
has been removed. Instead, this table represents all unique values of therelationship
field on RelatedPerson resources, and can be joined torelated_person
andrelated_person_relationship_coding
.related_person_name
has been removed. Use thename_family
,name_given_1
, andname_given_2
fields on therelated_person
table.related_person_address
has been removed. Use theaddress_line_1
,address_line_2
,address_city
,address_state
, andaddress_postal_code
fields on therelated_person
table.
Tables for new resource types
allergy_intolerance
appointment
care_plan
care_team
consent
coverage
device
device_use_statement
diagnostic_report
document_reference
immunization
medication
medication_administration
medication_request
Migration from rectangularized schema
Compared to the rectangularized schema, the relational schema follows a number of rules for predictability:
- Words in identifiers are separated by underscores
- All resource tables include a
resource_json
column. This column contains the raw FHIR resource, and serves as an "escape hatch" for fields that haven't been extracted to their own columns. - Other than the
resource_json
column, all columns are scalar values. - Tables can be joined to each other using foreign key relationships. Primary key columns are always named
id
, and foreign key columns are named after the table that they reference. For example, a column that references thepatient
table may be calledpatient_id
, orsubject_patient_id
to specify that the referenced patient is the subject of the referencing resource. - An exception to the
_id
column name rule is the columnbuilder_id
, which does not reference a table. - The relational schema separates summarized Condition, MedicationStatement, and Encounter resources from the source data. The summarized resources are in tables that begin with the
lens_
prefix.
Added and removed resource types
The relational schema includes the following resource types, which were not included in the rectangularized schema:
- Transition of Care (Based on FHIR EpisodeOfCare)
- Medication
- RelatedPerson
The tables for QuestionnaireResponse and Provenance have been removed due to lack of analytic use cases.
Updated about 2 months ago