Class FhirResourceTableGroup
- java.lang.Object
-
- org.linuxforhealth.fhir.schema.control.FhirResourceTableGroup
-
public class FhirResourceTableGroup extends java.lang.Object
Utility to create all the tables associated with a particular resource type
-
-
Constructor Summary
Constructors Constructor Description FhirResourceTableGroup(PhysicalDataModel model, java.lang.String schemaName, java.util.Set<IDatabaseObject> procedureDependencies, Tablespace fhirTablespace, java.util.Collection<GroupPrivilege> privileges, java.util.List<With> withs)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDateValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
CREATE TABLE device_date_values ( row_id BIGINT NOT NULL, parameter_name_id INT NOT NULL, date_start TIMESTAMP, date_end TIMESTAMP, resource_id BIGINT NOT NULL ) ; CREATE INDEX idx_device_date_values_pser ON device_date_values(parameter_name_id, date_start, date_end, resource_id); CREATE INDEX idx_device_date_values_pesr ON device_date_values(parameter_name_id, date_end, date_start, resource_id); CREATE INDEX idx_device_date_values_rpse ON device_date_values(resource_id, parameter_name_id, date_start, date_end); ALTER TABLE device_date_values ADD CONSTRAINT fk_device_date_values_pn FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_date_values ADD CONSTRAINT fk_device_date_values_r FOREIGN KEY (resource_id) REFERENCES device_resources;void
addLatLngValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
CREATE TABLE device_latlng_values ( row_id BIGINT NOT NULL, parameter_name_id INT NOT NULL, latitude_value DOUBLE, longitude_value DOUBLE, resource_id BIGINT NOT NULL ) CREATE INDEX idx_device_latlng_values_pnnlv ON device_latlng_values(parameter_name_id, latitude_value, resource_id); CREATE INDEX idx_device_latlng_values_pnnhv ON device_latlng_values(parameter_name_id, longitude_value, resource_id); CREATE INDEX idx_device_latlng_values_rplat ON device_latlng_values(resource_id, parameter_name_id, latitude_value); CREATE INDEX idx_device_latlng_values_rplng ON device_latlng_values(resource_id, parameter_name_id, longitude_value); ALTER TABLE device_latlng_values ADD CONSTRAINT fk_device_latlng_values_pn FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_latlng_values ADD CONSTRAINT fk_device_latlng_values_r FOREIGN KEY (resource_id) REFERENCES device_resources;void
addListLogicalResourceItems(java.util.List<IDatabaseObject> group, java.lang.String prefix)
Special case for LIST resources where we attach a child table to its LIST_LOGICAL_RESOURCES to support usage of the list items in search queries.void
addLogicalResources(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the logical_resources table definition for the given resource prefixvoid
addNumberValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
CREATE TABLE device_number_values ( row_id BIGINT NOT NULL, parameter_name_id INT NOT NULL, number_value DOUBLE, resource_id BIGINT NOT NULL ) ; CREATE INDEX idx_device_number_values_pnnv ON device_number_values(parameter_name_id, number_value, resource_id); CREATE INDEX idx_device_number_values_rps ON device_number_values(resource_id, parameter_name_id, number_value); ALTER TABLE device_number_values ADD CONSTRAINT fk_device_number_values_pn FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_number_values ADD CONSTRAINT fk_device_number_values_r FOREIGN KEY (resource_id) REFERENCES device_resources;void
addPatientCurrentRefs(java.util.List<IDatabaseObject> group, java.lang.String prefix)
Add the extension table used to support references to the current resources lists defined by the spec: https://www.hl7.org/fhir/lifecycle.html#currentTable
addProfiles(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the resource-specific profiles table which maps to the normalized URI values stored in COMMON_CANONICAL_VALUESvoid
addQuantityValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
CREATE TABLE device_quantity_values ( row_id BIGINT NOT NULL, parameter_name_id INT NOT NULL, code VARCHAR(255 OCTETS) NOT NULL, quantity_value DOUBLE, quantity_value_low DOUBLE, quantity_value_high DOUBLE, code_system_id INT, resource_id BIGINT NOT NULL ) ; CREATE INDEX idx_device_quantity_values_pnnv ON device_quantity_values(parameter_name_id, code, quantity_value, resource_id, code_system_id); CREATE INDEX idx_device_quantity_values_rps ON device_quantity_values(resource_id, parameter_name_id, code, quantity_value, code_system_id); CREATE INDEX idx_device_quantity_values_pclhsr ON device_quantity_values(parameter_name_id, code, quantity_value_low, quantity_value_high, code_system_id, resource_id); CREATE INDEX idx_device_quantity_values_pchlsr ON device_quantity_values(parameter_name_id, code, quantity_value_high, quantity_value_low, code_system_id, resource_id); CREATE INDEX idx_device_quantity_values_rpclhs ON device_quantity_values(resource_id, parameter_name_id, code, quantity_value_low, quantity_value_high, code_system_id); CREATE INDEX idx_device_quantity_values_rpchls ON device_quantity_values(resource_id, parameter_name_id, code, quantity_value_high, quantity_value_low, code_system_id); ALTER TABLE device_quantity_values ADD CONSTRAINT fk_device_quantity_values_pn FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_quantity_values ADD CONSTRAINT fk_device_quantity_values_r FOREIGN KEY (resource_id) REFERENCES device_resources;Table
addRefValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Schema V0027 adds a dedicated table for supporting reference values instead of using token values.void
addRefValuesView(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
View to encapsulate the join between xx_ref_values and logical_resource_ident tables, which makes it easier for the search query builder to compose search queries using reference parameters.void
addResources(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the resources table definitionTable
addResourceTokenRefs(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
parameter_name_id INT NOT NULL, code_system_id INT NOT NULL, token_value VARCHAR(255 OCTETS), resource_id BIGINT NOT NULL composite_id SMALLINT ) ; /** New schema for issue #1366.ObjectGroup
addResourceType(java.lang.String resourceTypeName, boolean isRetired)
Add all the tables required for the given resource type.Table
addSecurity(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the common_token_values mapping table for security search parametersvoid
addStrValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the STR_VALUES table for the given resource name prefixTable
addTags(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Resource-specific tags.void
addTokenValuesView(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
View created over common_token_values and resource_token_refs to hide the schema change (V0006 issue 1366) as much as possible from the search query generation.
-
-
-
Constructor Detail
-
FhirResourceTableGroup
public FhirResourceTableGroup(PhysicalDataModel model, java.lang.String schemaName, java.util.Set<IDatabaseObject> procedureDependencies, Tablespace fhirTablespace, java.util.Collection<GroupPrivilege> privileges, java.util.List<With> withs)
Public constructor
-
-
Method Detail
-
addResourceType
public ObjectGroup addResourceType(java.lang.String resourceTypeName, boolean isRetired)
Add all the tables required for the given resource type. For example, if the resourceTypeName is Patient, the following tables will be added:- patient_logical_resources
- patient_resources
- patient_str_values
- patient_date_values
- patient_token_values
- patient_number_values
- patient_latlng_values
- patient_quantity_values
- Parameters:
resourceTypeName
-boolean
- isRetired
-
addLogicalResources
public void addLogicalResources(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the logical_resources table definition for the given resource prefix- Parameters:
group
-prefix
-isRetired
-
-
addResources
public void addResources(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the resources table definitionresource_id BIGINT NOT NULL, logical_resource_id BIGINT NOT NULL, version_id INT NOT NULL, last_updated TIMESTAMP NOT NULL, is_deleted CHAR(1) NOT NULL, data BLOB(2147483647) INLINE LENGTH 10240; CREATE UNIQUE INDEX device_resource_prf_in1 ON device_resources (resource_id) INCLUDE (logical_resource_id, version_id, is_deleted);
- Parameters:
group
-prefix
-isRetired
-
-
addStrValues
public void addStrValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the STR_VALUES table for the given resource name prefixparameter_name_id INT NOT NULL, str_value VARCHAR(511 OCTETS), str_value_lcase VARCHAR(511 OCTETS), resource_id BIGINT NOT NULL, composite_id SMALLINT CREATE INDEX idx_device_str_values_psr ON device_str_values(parameter_name_id, str_value, resource_id); CREATE INDEX idx_device_str_values_plr ON device_str_values(parameter_name_id, str_value_lcase, resource_id); CREATE INDEX idx_device_str_values_rps ON device_str_values(resource_id, parameter_name_id, str_value); CREATE INDEX idx_device_str_values_rpl ON device_str_values(resource_id, parameter_name_id, str_value_lcase); ALTER TABLE device_str_values ADD CONSTRAINT fk_device_str_values_pnid FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_str_values ADD CONSTRAINT fk_device_str_values_pnid FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_str_values ADD CONSTRAINT fk_device_str_values_rid FOREIGN KEY (resource_id) REFERENCES device_resources;
- Parameters:
group
-prefix
-isRetired
-
-
addResourceTokenRefs
public Table addResourceTokenRefs(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
parameter_name_id INT NOT NULL, code_system_id INT NOT NULL, token_value VARCHAR(255 OCTETS), resource_id BIGINT NOT NULL composite_id SMALLINT ) ; /** New schema for issue #1366. Uses a map table to reduce cost of indexing repeated token values
- Parameters:
isRetired
-pdm
-- Returns:
-
addRefValues
public Table addRefValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Schema V0027 adds a dedicated table for supporting reference values instead of using token values.- Parameters:
isRetired
-pdm
-- Returns:
-
addProfiles
public Table addProfiles(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the resource-specific profiles table which maps to the normalized URI values stored in COMMON_CANONICAL_VALUES- Parameters:
group
-prefix
-isRetired
-- Returns:
-
addTags
public Table addTags(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Resource-specific tags. Tags are treated as tokens, but are separated out into their own table to avoid issues with cardinality estimation (because they are not very selective).- Parameters:
group
-prefix
-isRetired
-- Returns:
-
addSecurity
public Table addSecurity(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
Add the common_token_values mapping table for security search parameters- Parameters:
group
-prefix
-isRetired
-- Returns:
-
addTokenValuesView
public void addTokenValuesView(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
View created over common_token_values and resource_token_refs to hide the schema change (V0006 issue 1366) as much as possible from the search query generation. Search queries simply need to join against this view instead of the old {resourceType}_token_values table- Parameters:
isRetired
-pdm
-
-
addRefValuesView
public void addRefValuesView(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
View to encapsulate the join between xx_ref_values and logical_resource_ident tables, which makes it easier for the search query builder to compose search queries using reference parameters.- Parameters:
group
-prefix
-isRetired
-
-
addDateValues
public void addDateValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
CREATE TABLE device_date_values ( row_id BIGINT NOT NULL, parameter_name_id INT NOT NULL, date_start TIMESTAMP, date_end TIMESTAMP, resource_id BIGINT NOT NULL ) ; CREATE INDEX idx_device_date_values_pser ON device_date_values(parameter_name_id, date_start, date_end, resource_id); CREATE INDEX idx_device_date_values_pesr ON device_date_values(parameter_name_id, date_end, date_start, resource_id); CREATE INDEX idx_device_date_values_rpse ON device_date_values(resource_id, parameter_name_id, date_start, date_end); ALTER TABLE device_date_values ADD CONSTRAINT fk_device_date_values_pn FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_date_values ADD CONSTRAINT fk_device_date_values_r FOREIGN KEY (resource_id) REFERENCES device_resources;
- Parameters:
group
-prefix
-isRetired
-
-
addNumberValues
public void addNumberValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
CREATE TABLE device_number_values ( row_id BIGINT NOT NULL, parameter_name_id INT NOT NULL, number_value DOUBLE, resource_id BIGINT NOT NULL ) ; CREATE INDEX idx_device_number_values_pnnv ON device_number_values(parameter_name_id, number_value, resource_id); CREATE INDEX idx_device_number_values_rps ON device_number_values(resource_id, parameter_name_id, number_value); ALTER TABLE device_number_values ADD CONSTRAINT fk_device_number_values_pn FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_number_values ADD CONSTRAINT fk_device_number_values_r FOREIGN KEY (resource_id) REFERENCES device_resources;
- Parameters:
group
-prefix
-isRetired
-
-
addLatLngValues
public void addLatLngValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
CREATE TABLE device_latlng_values ( row_id BIGINT NOT NULL, parameter_name_id INT NOT NULL, latitude_value DOUBLE, longitude_value DOUBLE, resource_id BIGINT NOT NULL ) CREATE INDEX idx_device_latlng_values_pnnlv ON device_latlng_values(parameter_name_id, latitude_value, resource_id); CREATE INDEX idx_device_latlng_values_pnnhv ON device_latlng_values(parameter_name_id, longitude_value, resource_id); CREATE INDEX idx_device_latlng_values_rplat ON device_latlng_values(resource_id, parameter_name_id, latitude_value); CREATE INDEX idx_device_latlng_values_rplng ON device_latlng_values(resource_id, parameter_name_id, longitude_value); ALTER TABLE device_latlng_values ADD CONSTRAINT fk_device_latlng_values_pn FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_latlng_values ADD CONSTRAINT fk_device_latlng_values_r FOREIGN KEY (resource_id) REFERENCES device_resources;
- Parameters:
group
-prefix
-isRetired
-
-
addQuantityValues
public void addQuantityValues(java.util.List<IDatabaseObject> group, java.lang.String prefix, boolean isRetired)
CREATE TABLE device_quantity_values ( row_id BIGINT NOT NULL, parameter_name_id INT NOT NULL, code VARCHAR(255 OCTETS) NOT NULL, quantity_value DOUBLE, quantity_value_low DOUBLE, quantity_value_high DOUBLE, code_system_id INT, resource_id BIGINT NOT NULL ) ; CREATE INDEX idx_device_quantity_values_pnnv ON device_quantity_values(parameter_name_id, code, quantity_value, resource_id, code_system_id); CREATE INDEX idx_device_quantity_values_rps ON device_quantity_values(resource_id, parameter_name_id, code, quantity_value, code_system_id); CREATE INDEX idx_device_quantity_values_pclhsr ON device_quantity_values(parameter_name_id, code, quantity_value_low, quantity_value_high, code_system_id, resource_id); CREATE INDEX idx_device_quantity_values_pchlsr ON device_quantity_values(parameter_name_id, code, quantity_value_high, quantity_value_low, code_system_id, resource_id); CREATE INDEX idx_device_quantity_values_rpclhs ON device_quantity_values(resource_id, parameter_name_id, code, quantity_value_low, quantity_value_high, code_system_id); CREATE INDEX idx_device_quantity_values_rpchls ON device_quantity_values(resource_id, parameter_name_id, code, quantity_value_high, quantity_value_low, code_system_id); ALTER TABLE device_quantity_values ADD CONSTRAINT fk_device_quantity_values_pn FOREIGN KEY (parameter_name_id) REFERENCES parameter_names; ALTER TABLE device_quantity_values ADD CONSTRAINT fk_device_quantity_values_r FOREIGN KEY (resource_id) REFERENCES device_resources;
- Parameters:
group
-prefix
-isRetired
-
-
addListLogicalResourceItems
public void addListLogicalResourceItems(java.util.List<IDatabaseObject> group, java.lang.String prefix)
Special case for LIST resources where we attach a child table to its LIST_LOGICAL_RESOURCES to support usage of the list items in search queries. The FK to LIST_LOGICAL_RESOURCES is its parent. We then point to the resource being referenced via a resourceType/logicalId tuple. This means that the list item record can be created before the referenced resource is created.- Parameters:
group
-prefix
-
-
addPatientCurrentRefs
public void addPatientCurrentRefs(java.util.List<IDatabaseObject> group, java.lang.String prefix)
Add the extension table used to support references to the current resources lists defined by the spec: https://www.hl7.org/fhir/lifecycle.html#current- Parameters:
group
- - the group of tables for this resource (Patient in this case)prefix
- - the resource name - PATIENT
-
-