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 StringADMIN_GROUPstatic StringFHIRDATA_GROUPstatic StringSCHEMA_GROUP_TAG
-
Constructor Summary
Constructors Constructor Description FhirSchemaGenerator(String adminSchemaName, String schemaName)Generate the IBM FHIR Server Schema for all resourceTypesFhirSchemaGenerator(String adminSchemaName, String schemaName, 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 voidaddCodeSystems(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);protected voidaddFhirRefSequence(PhysicalDataModel pdm)protected voidaddFhirSequence(PhysicalDataModel pdm)CREATE SEQUENCE fhir_sequence AS BIGINT START WITH 1 CACHE 20000 NO CYCLE;voidaddLogicalResources(PhysicalDataModel pdm)Add the system-wide logical_resources table.protected voidaddParameterNames(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);TableaddResourceDateValues(PhysicalDataModel model)Add the table for data search parameters at the (system-wide) resource levelTableaddResourceStrValues(PhysicalDataModel pdm)Add system-wide RESOURCE_STR_VALUES table to support _profile properties (which are of type REFERENCE).protected voidaddResourceTables(PhysicalDataModel model, IDatabaseObject... dependency)Add the collection of tables for each of the listed FHIR resource typesTableaddResourceTokenValues(PhysicalDataModel pdm)Add the system-wide TOKEN_VALUES table which is used for _tag and _security search properties in R4protected voidaddResourceTypes(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 voidaddTenantKeysTable(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 voidaddTenantSequence(PhysicalDataModel pdm)CREATE SEQUENCE fhir_sequence AS BIGINT START WITH 1 CACHE 1000 NO CYCLE;protected voidaddTenantTable(PhysicalDataModel model)Create a table to manage the list of tenants.voidaddVariable(PhysicalDataModel model)Add the session variable we need.voidbuildAdminSchema(PhysicalDataModel model)Build the admin part of the schema.voidbuildDatabaseSpecificArtifactsDb2(PhysicalDataModel model)voidbuildDatabaseSpecificArtifactsPostgres(PhysicalDataModel model)voidbuildSchema(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
-
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-
-
addFhirRefSequence
protected void addFhirRefSequence(PhysicalDataModel pdm)
-
-