Class FhirSchemaGenerator


  • public class FhirSchemaGenerator
    extends Object
    Encapsulates the generation of the FHIR schema artifacts
    • Constructor Detail

      • FhirSchemaGenerator

        public FhirSchemaGenerator​(String adminSchemaName,
                                   String schemaName)
        Generate the IBM FHIR Server Schema for all resourceTypes
        Parameters:
        adminSchemaName -
        schemaName -
      • FhirSchemaGenerator

        public FhirSchemaGenerator​(String adminSchemaName,
                                   String schemaName,
                                   Set<String> resourceTypes)
        Generate the IBM FHIR Server Schema with just the given resourceTypes
        Parameters:
        adminSchemaName -
        schemaName -
    • Method Detail

      • buildAdminSchema

        public void buildAdminSchema​(PhysicalDataModel model)
        Build the admin part of the schema. One admin schema can support multiple FHIRDATA schemas. It is also possible to have multiple admin schemas (on a dev system, for example, although in production there would probably be just one admin schema in a given database
        Parameters:
        model -
      • addVariable

        public void addVariable​(PhysicalDataModel model)
        Add the session variable we need. This variable is used to support multi-tenancy via the row-based access control permission predicate.
        Parameters:
        model -
      • addTenantTable

        protected void addTenantTable​(PhysicalDataModel model)
        Create a table to manage the list of tenants. The tenant id is used as a partition value for all the other tables
        Parameters:
        model -
      • addTenantKeysTable

        protected void addTenantKeysTable​(PhysicalDataModel model)
        Each tenant can have multiple access keys which are used to authenticate and authorize clients for access to the data for a given tenant. We support multiple keys per tenant as a way to allow key rotation in the configuration without impacting service continuity
        Parameters:
        model -
      • addTenantSequence

        protected void addTenantSequence​(PhysicalDataModel pdm)
            CREATE SEQUENCE fhir_sequence
                     AS BIGINT
             START WITH 1
                  CACHE 1000
               NO CYCLE;
             
        Parameters:
        pdm -
      • buildSchema

        public void buildSchema​(PhysicalDataModel model)
        Create the schema using the given target
        Parameters:
        model -
      • buildDatabaseSpecificArtifactsDb2

        public void buildDatabaseSpecificArtifactsDb2​(PhysicalDataModel model)
      • buildDatabaseSpecificArtifactsPostgres

        public void buildDatabaseSpecificArtifactsPostgres​(PhysicalDataModel model)
      • addLogicalResources

        public void addLogicalResources​(PhysicalDataModel pdm)
        Add the system-wide logical_resources table. Note that LOGICAL_ID is denormalized, stored in both LOGICAL_RESOURCES and _LOGICAL_RESOURCES. This avoids an additional join, and simplifies the migration to this new schema model.
        Parameters:
        pdm -
      • addResourceTokenValues

        public Table addResourceTokenValues​(PhysicalDataModel pdm)
        Add the system-wide TOKEN_VALUES table which is used for _tag and _security search properties in R4
        Parameters:
        pdm -
        Returns:
        Table the table that was added to the PhysicalDataModel
      • addResourceStrValues

        public Table addResourceStrValues​(PhysicalDataModel pdm)
        Add system-wide RESOURCE_STR_VALUES table to support _profile properties (which are of type REFERENCE).
        Parameters:
        pdm -
        Returns:
        Table the table that was added to the PhysicalDataModel
      • addResourceDateValues

        public Table addResourceDateValues​(PhysicalDataModel model)
        Add the table for data search parameters at the (system-wide) resource level
        Parameters:
        model -
        Returns:
        Table the table that was added to the PhysicalDataModel
      • addResourceTypes

        protected void addResourceTypes​(PhysicalDataModel model)
                CREATE TABLE resource_types (
                    resource_type_id INT NOT NULL
                    CONSTRAINT pk_resource_type PRIMARY KEY,
                    resource_type   VARCHAR(64) NOT NULL
                );
        
                -- make sure resource_type values are unique
                CREATE UNIQUE INDEX unq_resource_types_rt ON resource_types(resource_type);
                
        Parameters:
        model -
      • addResourceTables

        protected void addResourceTables​(PhysicalDataModel model,
                                         IDatabaseObject... dependency)
        Add the collection of tables for each of the listed FHIR resource types
        Parameters:
        model -
      • addParameterNames

        protected void addParameterNames​(PhysicalDataModel model)
        CREATE TABLE parameter_names ( parameter_name_id INT NOT NULL CONSTRAINT pk_parameter_name PRIMARY KEY, parameter_name VARCHAR(255 OCTETS) NOT NULL ); CREATE UNIQUE INDEX unq_parameter_name_rtnm ON parameter_names(parameter_name) INCLUDE (parameter_name_id);
        Parameters:
        model -
      • addCodeSystems

        protected void addCodeSystems​(PhysicalDataModel model)
        Add the code_systems table to the database schema CREATE TABLE code_systems ( code_system_id INT NOT NULL CONSTRAINT pk_code_system PRIMARY KEY, code_system_name VARCHAR(255 OCTETS) NOT NULL ); CREATE UNIQUE INDEX unq_code_system_cinm ON code_systems(code_system_name);
        Parameters:
        model -
      • addFhirSequence

        protected void addFhirSequence​(PhysicalDataModel pdm)
            CREATE SEQUENCE fhir_sequence
                     AS BIGINT
             START WITH 1
                  CACHE 20000
               NO CYCLE;
         
        Parameters:
        pdm -