T - the type of the FHIR ValueSet objects being usedC - the type of the subclass of this class being used.public abstract class AbstractValueSets<T extends org.hl7.fhir.instance.model.api.IBaseResource,C extends AbstractValueSets<T,C>> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected ca.uhn.fhir.context.FhirVersionEnum |
fhirVersion |
protected org.apache.spark.sql.Dataset<UrlAndVersion> |
members
URI and Version metadata used to preserve uniqueness among value sets.
|
protected org.apache.spark.sql.SparkSession |
spark |
protected static Pattern |
TABLE_NAME_PATTERN |
protected static org.apache.spark.sql.Encoder<UrlAndVersion> |
URL_AND_VERSION_ENCODER |
protected static org.apache.spark.sql.Encoder<Value> |
VALUE_ENCODER
An encoder for serializing values.
|
static String |
VALUE_SETS_DATABASE
Default database name where the value sets information is stored.
|
static String |
VALUE_SETS_TABLE
Default table name where value sets metadata is stored.
|
protected org.apache.spark.sql.Dataset<Value> |
values |
static String |
VALUES_TABLE
Default table name where the expanded values information is stored.
|
protected SparkRowConverter |
valueSetRowConverter |
protected org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> |
valueSets |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractValueSets(org.apache.spark.sql.SparkSession spark,
ca.uhn.fhir.context.FhirVersionEnum fhirVersion,
org.apache.spark.sql.Dataset<UrlAndVersion> members,
org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> valueSets,
org.apache.spark.sql.Dataset<Value> values,
SparkRowConverter valueSetRowConverter) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addToValueSet(T valueSet,
org.apache.spark.sql.Dataset<Value> values)
Adds the given values to the given value set instance.
|
org.apache.spark.sql.Dataset<Value> |
getLatestValues(Set<String> uris,
boolean includeExperimental)
Returns a dataset with the latest values for each valueset of the given uris.
|
Map<String,String> |
getLatestVersions(boolean includeExperimental)
Returns the latest version of all value sets.
|
Map<String,String> |
getLatestVersions(Set<String> uris,
boolean includeExperimental)
Returns the latest versions of a given set of value sets.
|
static org.apache.spark.sql.Encoder<UrlAndVersion> |
getUrlAndVersionEncoder()
Returns the encoder for UrlAndVersion tuples.
|
protected org.apache.spark.sql.Dataset<UrlAndVersion> |
getUrlAndVersions(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> valueSets)
Returns a dataset of distinct URL and version tuples.
|
static org.apache.spark.sql.Encoder<Value> |
getValueEncoder()
Returns the encoder for values.
|
org.apache.spark.sql.Dataset<Value> |
getValues()
Returns a dataset of all values in this collection.
|
org.apache.spark.sql.Dataset<Value> |
getValues(Map<String,String> uriToVersion)
Returns a dataset with the values for each element in the map of uri to version.
|
org.apache.spark.sql.Dataset<Value> |
getValues(String uri,
String version)
Returns the values for the given URI and version.
|
T |
getValueSet(String uri,
String version)
Returns the value set with the given uri and version, or null if there is no such value set.
|
org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> |
getValueSets()
Returns a dataset of value sets to inspect metadata.
|
protected boolean |
hasDuplicateUrlAndVersions(org.apache.spark.sql.Dataset<UrlAndVersion> membersToCheck)
Returns true if the UrlAndVersions if the membersToCheck has any duplicates with the members
of this value sets instance.
|
protected org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> |
valueSetDatasetFromDirectory(String path)
Returns a dataset of ValueSet from the content stored at the given directory.
|
C |
withDisjointValueSetsFromDirectory(String path)
Returns all value sets that are disjoint with value sets stored in the default database and
adds them to our collection.
|
C |
withDisjointValueSetsFromDirectory(String path,
String database)
Returns all value sets that are disjoint with value sets stored in the given database and
adds them to our collection.
|
abstract C |
withValueSets(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> valueSets)
Returns a new ValueSets instance that includes the given value sets.
|
C |
withValueSets(List<T> valueSets)
Returns a new ValueSets instance that includes the given value sets.
|
C |
withValueSets(T... valueSets)
Returns a new ValueSets instance that includes the given value sets.
|
C |
withValueSetsFromDirectory(String path)
Reads all value sets from a given directory and adds them to our collection.
|
void |
writeToDatabase()
Writes the the value sets to the default database "ontologies" using default table names:
"values", and "valuesets".
|
void |
writeToDatabase(String database)
Writes the value sets to the given database using default table names: "values", "valuesets",
and "ancestors".
|
void |
writeToTables(String valuesTable,
String valueSetTable)
Writes value sets to the given tables.
|
protected static final org.apache.spark.sql.Encoder<Value> VALUE_ENCODER
protected static final org.apache.spark.sql.Encoder<UrlAndVersion> URL_AND_VERSION_ENCODER
protected static final Pattern TABLE_NAME_PATTERN
public static final String VALUE_SETS_DATABASE
public static final String VALUES_TABLE
public static final String VALUE_SETS_TABLE
protected final org.apache.spark.sql.SparkSession spark
protected final ca.uhn.fhir.context.FhirVersionEnum fhirVersion
protected final org.apache.spark.sql.Dataset<UrlAndVersion> members
protected final org.apache.spark.sql.Dataset<Value> values
protected final org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> valueSets
protected final SparkRowConverter valueSetRowConverter
protected AbstractValueSets(org.apache.spark.sql.SparkSession spark,
ca.uhn.fhir.context.FhirVersionEnum fhirVersion,
org.apache.spark.sql.Dataset<UrlAndVersion> members,
org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> valueSets,
org.apache.spark.sql.Dataset<Value> values,
SparkRowConverter valueSetRowConverter)
public static org.apache.spark.sql.Encoder<UrlAndVersion> getUrlAndVersionEncoder()
public static org.apache.spark.sql.Encoder<Value> getValueEncoder()
public Map<String,String> getLatestVersions(boolean includeExperimental)
includeExperimental - whether to include value sets marked as experimentalpublic Map<String,String> getLatestVersions(Set<String> uris, boolean includeExperimental)
uris - a set of URIs for which to retrieve the latest versions, or null to load them allincludeExperimental - whether to include value sets marked as experimentalpublic org.apache.spark.sql.Dataset<Value> getLatestValues(Set<String> uris, boolean includeExperimental)
uris - URIs for the value setsincludeExperimental - whether to include value sets marked as experimentalpublic org.apache.spark.sql.Dataset<Value> getValues()
public org.apache.spark.sql.Dataset<Value> getValues(String uri, String version)
uri - the uri of the value set for which we get valuesversion - the version of the value set for which we get valuespublic org.apache.spark.sql.Dataset<Value> getValues(Map<String,String> uriToVersion)
uriToVersion - a map of value set URI to the version to loadpublic org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> getValueSets()
getValues() method to query values in depth.public T getValueSet(String uri, String version)
uri - the uri of the value set to returnversion - the version of the value set to returnprotected abstract void addToValueSet(T valueSet, org.apache.spark.sql.Dataset<Value> values)
valueSet - the value set to add.values - the values to add.protected org.apache.spark.sql.Dataset<UrlAndVersion> getUrlAndVersions(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> valueSets)
valueSets - valueSets to scan for the URL and version.protected boolean hasDuplicateUrlAndVersions(org.apache.spark.sql.Dataset<UrlAndVersion> membersToCheck)
membersToCheck - the members to check for duplicatespublic abstract C withValueSets(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> valueSets)
valueSets - the value sets to add to the returned collection.public C withValueSets(T... valueSets)
valueSets - the value sets to add to the returned collection.public C withValueSets(List<T> valueSets)
valueSets - the value sets to add to the returned collection.public C withValueSetsFromDirectory(String path)
path - a path from which value sets will be loadedpublic C withDisjointValueSetsFromDirectory(String path)
path - a path from which disjoint value sets will be loadedpublic C withDisjointValueSetsFromDirectory(String path, String database)
path - a path from which disjoint value sets will be loadeddatabase - the database to check value sets againstprotected org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> valueSetDatasetFromDirectory(String path)
path - the path containting the value setspublic void writeToDatabase()
public void writeToDatabase(String database)
database - the name of the database to which the value sets are savedpublic void writeToTables(String valuesTable, String valueSetTable)
Warning: these updates are likely not atomic due to the lack of transactional semantics in the underlying data store. Concurrent users may see previous items removed before new ones are added, or items appear separately than others. This is intended for use in a user-specific sandbox or staging environment.
valuesTable - name of the table to which the value records are savedvalueSetTable - name of the table to which the value set metadata is savedCopyright © 2020. All rights reserved.