T - the type of the FHIR ConceptMap objects being usedC - the type of the subclass of this class being used.public abstract class AbstractConceptMaps<T extends org.hl7.fhir.instance.model.api.IBaseResource,C extends AbstractConceptMaps<T,C>> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static String |
CONCEPT_MAP_TABLE
Defalt table name where concept maps are stored.
|
protected SparkRowConverter |
conceptMapRowConverter |
protected org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> |
conceptMaps |
protected ca.uhn.fhir.context.FhirVersionEnum |
fhirVersion |
static String |
MAPPING_DATABASE
Default database name where mapping information is stored.
|
protected static org.apache.spark.sql.Encoder<Mapping> |
MAPPING_ENCODER
An encoder for serializing mappings.
|
static String |
MAPPING_TABLE
Default table name where expanded mapping information is stored.
|
protected org.apache.spark.sql.Dataset<Mapping> |
mappings |
protected org.apache.spark.sql.Dataset<UrlAndVersion> |
members |
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 |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractConceptMaps(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> conceptMaps,
org.apache.spark.sql.Dataset<Mapping> mappings,
SparkRowConverter conceptMapRowConverter) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
addToConceptMap(T map,
org.apache.spark.sql.Dataset<Mapping> mappings)
Adds the given mappings to the concept map.
|
abstract org.apache.spark.broadcast.Broadcast<BroadcastableMappings> |
broadcast(Map<String,String> conceptMapUriToVersion)
Broadcast mappings stored in the given conceptMaps instance that match the given
conceptMapUris.
|
org.apache.spark.broadcast.Broadcast<BroadcastableMappings> |
broadcast(Set<String> conceptMapUris,
boolean includeExperimental)
Broadcast mappings stored in the given conceptMaps instance that match the given
conceptMapUris.
|
T |
getConceptMap(String uri,
String version)
Returns the concept map with the given uri and version, or null if there is no such map.
|
org.apache.spark.sql.Dataset<Mapping> |
getLatestMappings(Set<String> uris,
boolean includeExperimental)
Returns a dataset with the latest mappings for each valueset here.
|
Map<String,String> |
getLatestVersions(boolean includeExperimental)
Returns the latest versions of all concept maps.
|
Map<String,String> |
getLatestVersions(Set<String> urls,
boolean includeExperimental)
Returns the latest versions of a given set of concept maps.
|
org.apache.spark.sql.Dataset<Mapping> |
getMappings()
Returns a dataset of all mappings in this collection.
|
org.apache.spark.sql.Dataset<Mapping> |
getMappings(Map<String,String> uriToVersion)
Returns a dataset with the mappings for each uri and version.
|
org.apache.spark.sql.Dataset<Mapping> |
getMappings(String uri,
String version)
Returns the mappings for the given URI and version.
|
org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> |
getMaps()
Returns a dataset of concept maps to inspect metadata.
|
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> conceptMaps)
Returns a simple dataset of URL and versions of concept maps.
|
protected boolean |
hasDuplicateUrlAndVersions(org.apache.spark.sql.Dataset<UrlAndVersion> membersToCheck)
Returns true if the UrlAndVersions of new value sets contains duplicates with the current
ValueSets.
|
protected abstract C |
newInstance(org.apache.spark.sql.SparkSession spark,
org.apache.spark.sql.Dataset<UrlAndVersion> members,
org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> conceptMaps,
org.apache.spark.sql.Dataset<Mapping> mappings)
Returns a new instance of this ConceptMaps type with the given parameters.
|
abstract C |
withConceptMaps(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> conceptMaps)
Returns a new ConceptMaps instance that includes the given maps.
|
protected C |
withConceptMaps(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> newMaps,
org.apache.spark.sql.Dataset<Mapping> newMappings) |
C |
withConceptMaps(List<T> conceptMaps)
Returns a new ConceptMaps instance that includes the given maps.
|
C |
withConceptMaps(T... conceptMap)
Returns a new ConceptMaps instance that includes the given map.
|
C |
withDisjointMapsFromDirectory(String path)
Returns all concept maps that are disjoint with concept maps stored in the default database and
adds them to our collection.
|
C |
withDisjointMapsFromDirectory(String path,
String database)
Returns all concept maps that are disjoint with concept maps stored in the default database and
adds them to our collection.
|
C |
withExpandedMap(T conceptMap,
org.apache.spark.sql.Dataset<Mapping> mappings)
Returns a new ConceptMaps instance that includes the given map and expanded mappings.
|
C |
withMapsFromDirectory(String path)
Reads all concept maps from a given directory and adds them to
our collection.
|
void |
writeToDatabase(String database)
Writes the updated concept maps to a database using the default "mappings" and "conceptmaps"
table names.
|
void |
writeToTables(String mappingsTable,
String conceptMapTable)
Writes mappings to the given tables.
|
protected static final org.apache.spark.sql.Encoder<Mapping> MAPPING_ENCODER
protected static final org.apache.spark.sql.Encoder<UrlAndVersion> URL_AND_VERSION_ENCODER
public static final String MAPPING_DATABASE
public static final String MAPPING_TABLE
protected static final String CONCEPT_MAP_TABLE
protected static final Pattern TABLE_NAME_PATTERN
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<org.apache.spark.sql.Row> conceptMaps
protected final org.apache.spark.sql.Dataset<Mapping> mappings
protected final SparkRowConverter conceptMapRowConverter
protected AbstractConceptMaps(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> conceptMaps,
org.apache.spark.sql.Dataset<Mapping> mappings,
SparkRowConverter conceptMapRowConverter)
public static org.apache.spark.sql.Encoder<UrlAndVersion> getUrlAndVersionEncoder()
protected org.apache.spark.sql.Dataset<UrlAndVersion> getUrlAndVersions(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> conceptMaps)
conceptMaps - a datafrae of concept maps to scan.public C withDisjointMapsFromDirectory(String path)
path - a path from which disjoint concept maps will be loadedpublic C withDisjointMapsFromDirectory(String path, String database)
path - a path from which disjoint concept maps will be loadeddatabase - the database to check concept maps againstpublic C withMapsFromDirectory(String path)
path - a path from which concept maps will be loadedpublic abstract C withConceptMaps(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> conceptMaps)
conceptMaps - concept maps to add to the returned collection.public C withConceptMaps(T... conceptMap)
conceptMap - concept maps to addpublic C withConceptMaps(List<T> conceptMaps)
conceptMaps - concept maps to addprotected C withConceptMaps(org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> newMaps, org.apache.spark.sql.Dataset<Mapping> newMappings)
protected abstract C newInstance(org.apache.spark.sql.SparkSession spark, org.apache.spark.sql.Dataset<UrlAndVersion> members, org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> conceptMaps, org.apache.spark.sql.Dataset<Mapping> mappings)
spark - the spark sessionmembers - Concept map URL and version detailsconceptMaps - the concept maps to includemappings - the mappings themselvespublic C withExpandedMap(T conceptMap, org.apache.spark.sql.Dataset<Mapping> mappings)
conceptMap - concept map to addmappings - dataset of mappings to add to addprotected abstract void addToConceptMap(T map, org.apache.spark.sql.Dataset<Mapping> mappings)
map - the concept mapmappings - the mappings to addpublic T getConceptMap(String uri, String version)
uri - the uri of the map to returnversion - the version of the map to returnpublic org.apache.spark.sql.Dataset<org.apache.spark.sql.Row> getMaps()
getMappings() method to query mappings
in depth.public org.apache.spark.sql.Dataset<Mapping> getMappings()
public org.apache.spark.sql.Dataset<Mapping> getMappings(String uri, String version)
uri - the uri of the concept map for which we get mappingsversion - the version of the concept map for which we get mappingspublic org.apache.spark.sql.Dataset<Mapping> getMappings(Map<String,String> uriToVersion)
uriToVersion - a map of concept map URI to the version to loadpublic org.apache.spark.sql.Dataset<Mapping> getLatestMappings(Set<String> uris, boolean includeExperimental)
uris - URIs for the value setsincludeExperimental - include valuesets labeled as experimentalpublic Map<String,String> getLatestVersions(boolean includeExperimental)
includeExperimental - flag to include concept maps marked as experimentalpublic Map<String,String> getLatestVersions(Set<String> urls, boolean includeExperimental)
urls - a set of URLs to retrieve the latest version for, or null to load them all.includeExperimental - flag to include concept maps marked as experimentalprotected boolean hasDuplicateUrlAndVersions(org.apache.spark.sql.Dataset<UrlAndVersion> membersToCheck)
membersToCheck - url and versions to check for duplciatespublic void writeToDatabase(String database)
database - the database name to which the concepts are saved.public void writeToTables(String mappingsTable, String conceptMapTable)
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.
mappingsTable - name of the table containing the mapping recordsconceptMapTable - name of the table containing the concept map metadatapublic org.apache.spark.broadcast.Broadcast<BroadcastableMappings> broadcast(Set<String> conceptMapUris, boolean includeExperimental)
conceptMapUris - the URIs to broadcast.includeExperimental - flag to include experimental map versions in the broadcast.public abstract org.apache.spark.broadcast.Broadcast<BroadcastableMappings> broadcast(Map<String,String> conceptMapUriToVersion)
conceptMapUriToVersion - map of the concept map URIs to broadcast to their versions.Copyright © 2020. All rights reserved.