Package com.ibm.fhir.schema.control
Class FhirSchemaGenerator
- java.lang.Object
-
- com.ibm.fhir.schema.control.FhirSchemaGenerator
-
public class FhirSchemaGenerator extends Object
Encapsulates the generation of the FHIR schema artifacts
-
-
Field Summary
Fields Modifier and Type Field Description static String
ADMIN_GROUP
static String
FHIRDATA_GROUP
static String
SCHEMA_GROUP_TAG
-
Constructor Summary
Constructors Constructor Description FhirSchemaGenerator(String adminSchemaName, String schemaName, boolean multitenant)
Generate the IBM FHIR Server Schema for all resourceTypesFhirSchemaGenerator(String adminSchemaName, String schemaName, boolean multitenant, Set<String> resourceTypes)
Generate the IBM FHIR Server Schema with just the given resourceTypes
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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);void
addCommonTokenValues(PhysicalDataModel pdm)
Table used to store normalized values for tokens, shared by all the_TOKEN_VALUES tables. protected void
addFhirRefSequence(PhysicalDataModel pdm)
protected void
addFhirSequence(PhysicalDataModel pdm)
CREATE SEQUENCE fhir_sequence AS BIGINT START WITH 1 CACHE 20000 NO CYCLE;Table
addLogicalResourceCompartments(PhysicalDataModel pdm)
Adds the system level logical_resource_compartments table which identifies to which compartments a give resource belongs.void
addLogicalResources(PhysicalDataModel pdm)
Add the system-wide logical_resources table.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);protected void
addReferencesSequence(PhysicalDataModel pdm)
Add the sequence used by the new local/external references data modelTable
addResourceDateValues(PhysicalDataModel model)
Add the table for data search parameters at the (system-wide) resource levelTable
addResourceStrValues(PhysicalDataModel pdm)
Add system-wide RESOURCE_STR_VALUES table to support _profile properties (which are of type REFERENCE).protected void
addResourceTables(PhysicalDataModel model, IDatabaseObject... dependency)
Add the collection of tables for each of the listed FHIR resource typesTable
addResourceTokenRefs(PhysicalDataModel pdm)
Add the system-wide RESOURCE_TOKEN_REFS table which is used for _tag and _security search properties in R4 (new table for issue #1366 V0006 schema change).Table
addResourceTokenValues(PhysicalDataModel pdm)
Add the system-wide TOKEN_VALUES table which is used for _tag and _security search properties in R4protected 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);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.protected void
addTenantSequence(PhysicalDataModel pdm)
CREATE SEQUENCE fhir_sequence AS BIGINT START WITH 1 CACHE 1000 NO CYCLE;protected void
addTenantTable(PhysicalDataModel model)
Create a table to manage the list of tenants.void
addVariable(PhysicalDataModel model)
Add the session variable we need.void
buildAdminSchema(PhysicalDataModel model)
Build the admin part of the schema.void
buildDatabaseSpecificArtifactsDb2(PhysicalDataModel model)
void
buildDatabaseSpecificArtifactsPostgres(PhysicalDataModel model)
void
buildSchema(PhysicalDataModel model)
Create the schema using the given target
-
-
-
Field Detail
-
SCHEMA_GROUP_TAG
public static final String SCHEMA_GROUP_TAG
- See Also:
- Constant Field Values
-
FHIRDATA_GROUP
public static final String FHIRDATA_GROUP
- See Also:
- Constant Field Values
-
ADMIN_GROUP
public static final String ADMIN_GROUP
- See Also:
- Constant Field Values
-
-
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
-
addLogicalResourceCompartments
public Table addLogicalResourceCompartments(PhysicalDataModel pdm)
Adds the system level logical_resource_compartments table which identifies to which compartments a give resource belongs. A resource may belong to many compartments.- 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
-
-
addCommonTokenValues
public void addCommonTokenValues(PhysicalDataModel pdm)
Table used to store normalized values for tokens, shared by all the_TOKEN_VALUES tables. Although this requires an additional join, it cuts down on space by avoiding repeating long strings (e.g. urls). This also helps to reduce the total sizes of the indexes, helping to improve cache hit rates for a given buffer cache size. Token values may or may not have an associated code system, in which case, it assigned a default system. This is why CODE_SYSTEM_ID is not nullable and has a FK constraint. We never need to find all token values for a given code-system, so there's no need for a second index (CODE_SYSTEM_ID, TOKEN_VALUE). Do not add it. Because different parameter names may reference the same token value (e.g. 'Observation.subject' and 'Claim.patient' are both patient references), the common token value is not distinguished by a parameter_name_id. Where common token values are used to represent local relationships between two resources, the code_system encodes the resource type of the referenced resource and the token_value represents its logical_id. This approach simplifies query writing when following references. - Parameters:
pdm
-
-
addResourceTokenRefs
public Table addResourceTokenRefs(PhysicalDataModel pdm)
Add the system-wide RESOURCE_TOKEN_REFS table which is used for _tag and _security search properties in R4 (new table for issue #1366 V0006 schema change). Replaces the previous TOKEN_VALUES table. All token values are now normalized in the COMMON_TOKEN_VALUES table- Parameters:
pdm
-- Returns:
- Table the table that was added to the PhysicalDataModel
-
addFhirSequence
protected void addFhirSequence(PhysicalDataModel pdm)
CREATE SEQUENCE fhir_sequence AS BIGINT START WITH 1 CACHE 20000 NO CYCLE;
- Parameters:
pdm
-
-
addFhirRefSequence
protected void addFhirRefSequence(PhysicalDataModel pdm)
-
addReferencesSequence
protected void addReferencesSequence(PhysicalDataModel pdm)
Add the sequence used by the new local/external references data model- Parameters:
pdm
-
-
-