pathling package
Submodules
pathling.coding module
- class pathling.coding.Coding(system: str, code: str, version: Optional[str] = None, display: Optional[str] = None, user_selected: Optional[bool] = None)[source]
Bases:
object
A Coding represents a code in a code system. See: https://hl7.org/fhir/R4/datatypes.html#Coding
- classmethod of_snomed(code: str, version: Optional[str] = None, display: Optional[str] = None, user_selected: Optional[bool] = None) Coding [source]
Creates a SNOMED Coding.
- Parameters
code – the code
version – a URI that identifies the version of the code system
display – the display text for the Coding
user_selected – an indicator of whether the Coding was chosen directly by the user
- Returns
a SNOMED coding with given arguments.
pathling.context module
- class pathling.context.PathlingContext(spark: SparkSession, jpc: JavaObject)[source]
Bases:
object
Main entry point for Pathling API functionality. Should be instantiated with the
PathlingContext.create()
class method.Example use:
pc = PathlingContext.create(spark) patient_df = pc.encode(spark.read.text('ndjson_resources'), 'Patient') patient_df.show()
- classmethod create(spark: Optional[SparkSession] = None, max_nesting_level: Optional[int] = 3, enable_extensions: Optional[bool] = False, enabled_open_types: Optional[Sequence[str]] = ('boolean', 'code', 'date', 'dateTime', 'decimal', 'integer', 'string', 'Coding', 'CodeableConcept', 'Address', 'Identifier', 'Reference'), enable_terminology: Optional[bool] = True, terminology_server_url: Optional[str] = 'https://tx.ontoserver.csiro.au/fhir', terminology_verbose_request_logging: Optional[bool] = False, terminology_socket_timeout: Optional[int] = 60000, max_connections_total: Optional[int] = 32, max_connections_per_route: Optional[int] = 16, terminology_retry_enabled: Optional[bool] = True, terminology_retry_count: Optional[int] = 2, enable_cache: Optional[bool] = True, cache_max_entries: Optional[int] = 200000, cache_storage_type: Optional[str] = 'memory', cache_storage_path: Optional[str] = None, cache_default_expiry: Optional[int] = 600, cache_override_expiry: Optional[int] = None, token_endpoint: Optional[str] = None, enable_auth: Optional[bool] = False, client_id: Optional[str] = None, client_secret: Optional[str] = None, scope: Optional[str] = None, token_expiry_tolerance: Optional[int] = 120) PathlingContext [source]
Creates a
PathlingContext
with the given configuration options. This should only be done once within a SparkSession - subsequent calls with different configuration may produce an error.If no SparkSession is provided, and there is not one already present in this process - a new SparkSession will be created.
If a SparkSession is not provided, and one is already running within the current process, it will be reused - and it is assumed that the Pathling library API JAR is already on the classpath. If you are running your own cluster, make sure it is on the list of packages.
If a SparkSession is provided, it needs to include the Pathling library API JAR on its classpath. You can get the path for the JAR (which is bundled with the Python package) using the pathling.etc.find_jar method.
- Parameters
spark – a pre-configured
SparkSession
instance, use this if you need to control the way that the session is set upmax_nesting_level – controls the maximum depth of nested element data that is encoded upon import. This affects certain elements within FHIR resources that contain recursive references, e.g. QuestionnaireResponse.item.
enable_extensions – enables support for FHIR extensions
enabled_open_types – the list of types that are encoded within open types, such as extensions. This default list was taken from the data types that are common to extensions found in widely-used IGs, such as the US and AU base profiles. In general, you will get the best query performance by encoding your data with the shortest possible list.
enable_terminology – enables the use of terminology functions
terminology_server_url – the endpoint of a FHIR terminology service (R4) that the server can use to resolve terminology queries. The default server is suitable for testing purposes only.
terminology_verbose_request_logging – setting this option to True will enable additional logging of the details of requests to the terminology service. Note that logging is subject to the Spark logging level, which you can set using SparkContext.setLogLevel. Verbose request logging is sent to the DEBUG logging level.
terminology_socket_timeout – the maximum period (in milliseconds) that the server should wait for incoming data from the HTTP service
max_connections_total – the maximum total number of connections for the client
max_connections_per_route – the maximum number of connections per route for the client
terminology_retry_enabled – controls whether terminology requests that fail for possibly transient reasons (network connections, DNS problems) should be retried
terminology_retry_count – the number of times to retry failed terminology requests
enable_cache – set this to false to disable caching of terminology requests (not recommended)
cache_max_entries – sets the maximum number of entries that will be held in memory
cache_storage_type – the type of storage to use for the terminology cache. See StorageType.
cache_storage_path – the path on disk to use for the cache, required when cache_storage_type is disk
cache_default_expiry – the default expiry time for cache entries (in seconds), used when the server does not provide an expiry value
cache_override_expiry – if provided, this value overrides the expiry time provided by the terminology server
enable_auth – enables authentication of requests to the terminology server
token_endpoint – an OAuth2 token endpoint for use with the client credentials grant
client_id – a client ID for use with the client credentials grant
client_secret – a client secret for use with the client credentials grant
scope – a scope value for use with the client credentials grant
token_expiry_tolerance – the minimum number of seconds that a token should have before expiry when deciding whether to send it with a terminology request
- Returns
a
PathlingContext
instance initialized with the specified configuration
- encode(df: DataFrame, resource_name: str, input_type: Optional[str] = None, column: Optional[str] = None) DataFrame [source]
Takes a dataframe with a string representations of FHIR resources in the given column and encodes the resources of the given types as Spark dataframe.
- Parameters
df – a
DataFrame
containing the resources to encode.resource_name – the name of the FHIR resource to extract (Condition, Observation, etc.)
input_type – the mime type of input string encoding. Defaults to application/fhir+json.
column – the column in which the resources to encode are stored. If ‘None’ then the input dataframe is assumed to have one column of type string.
- Returns
a
DataFrame
containing the given type of resources encoded into Spark columns
- encode_bundle(df: DataFrame, resource_name: str, input_type: Optional[str] = None, column: Optional[str] = None) DataFrame [source]
Takes a dataframe with a string representations of FHIR bundles in the given column and encodes the resources of the given types as Spark dataframe.
- Parameters
df – a
DataFrame
containing the bundles with the resources to encode.resource_name – the name of the FHIR resource to extract (Condition, Observation, etc.)
input_type – the MIME type of the input string encoding. Defaults to application/fhir+json.
column – the column in which the resources to encode are stored. If ‘None’ then the input dataframe is assumed to have one column of type string.
- Returns
a
DataFrame
containing the given type of resources encoded into Spark columns
- member_of(df: DataFrame, coding_column: Column, value_set_uri: str, output_column_name: str)[source]
Takes a dataframe with a Coding column as input. A new column is created which contains a Boolean value, indicating whether the input Coding is a member of the specified FHIR ValueSet.
- Parameters
df – a DataFrame containing the input data
coding_column – a Column containing a struct representation of a Coding
value_set_uri – an identifier for a FHIR ValueSet
output_column_name – the name of the result column
- Returns
A new dataframe with an additional column containing the result of the operation
- property spark: SparkSession
Returns the SparkSession associated with this context.
- subsumes(df: DataFrame, output_column_name: str, left_coding_column: Optional[Column] = None, right_coding_column: Optional[Column] = None, left_coding: Optional[Coding] = None, right_coding: Optional[Coding] = None)[source]
Takes a dataframe with two Coding columns. A new column is created which contains a Boolean value, indicating whether the left Coding subsumes the right Coding.
- Parameters
df – a DataFrame containing the input data
left_coding_column – a Column containing a struct representation of a Coding, for the left-hand side of the subsumption test
right_coding_column – a Column containing a struct representation of a Coding, for the right-hand side of the subsumption test
left_coding – a Coding object for the left-hand side of the subsumption test
right_coding – a Coding object for the right-hand side of the subsumption test
output_column_name – the name of the result column
- Returns
A new dataframe with an additional column containing the result of the operation.
- translate(df: DataFrame, coding_column: Column, concept_map_uri: str, reverse: Optional[bool] = False, equivalence: Optional[str] = 'equivalent', target: Optional[str] = None, output_column_name: Optional[str] = 'result')[source]
Takes a dataframe with a Coding column as input. A new column is created which contains the array of Codings value with translation targets from the specified FHIR ConceptMap. There may be more than one target concept for each input concept.
- Parameters
df – a DataFrame containing the input data
coding_column – a Column containing a struct representation of a Coding
concept_map_uri – an identifier for a FHIR ConceptMap
reverse – the direction to traverse the map - false results in “source to target” mappings, while true results in “target to source”
equivalence – a comma-delimited set of values from the ConceptMapEquivalence ValueSet
target – identifies the value set in which a translation is sought. If there is no target specified, the server should return all known translations.
output_column_name – the name of the result column
- Returns
A new dataframe with an additional column containing the result of the operation.
pathling.etc module
pathling.fhir module
pathling.functions module
- pathling.functions.to_coding(coding_column: Column, system: str, version: Optional[str] = None) Column [source]
Converts a Column containing codes into a Column that contains a Coding struct. The Coding struct Column can be used as an input to terminology functions such as member_of and translate.
- Parameters
coding_column – the Column containing the codes
system – the URI of the system the codes belong to
version – the version of the code system
- Returns
a Column containing a Coding struct
- pathling.functions.to_ecl_value_set(ecl: str) str [source]
Converts a SNOMED CT ECL expression into a FHIR ValueSet URI. Can be used with the member_of function.
- Parameters
ecl – the ECL expression
- Returns
the ValueSet URI
- pathling.functions.to_snomed_coding(coding_column: Column, version: Optional[str] = None) Column [source]
Converts a Column containing codes into a Column that contains a SNOMED Coding struct. The Coding struct Column can be used as an input to terminology functions such as member_of and translate.
- Parameters
coding_column – the Column containing the codes
version – the version of the code system
- Returns
a Column containing a Coding struct
pathling.udfs module
- class pathling.udfs.Equivalence[source]
Bases:
object
Concept map equivalences, see https://www.hl7.org/fhir/R4/valueset-concept-map-equivalence.html.
- DISJOINT = 'disjoint'
- EQUAL = 'equal'
- EQUIVALENT = 'equivalent'
- INEXACT = 'inexact'
- NARROWER = 'narrower'
- RELATEDTO = 'relatedto'
- SPECIALIZES = 'specializes'
- SUBSUMES = 'subsumes'
- UNMATCHED = 'unmatched'
- WIDER = 'wider'
- class pathling.udfs.PropertyType[source]
Bases:
object
Allowed property types.
- BOOLEAN = 'boolean'
- CODE = 'code'
- CODING = 'Coding'
- DATETIME = 'dateTime'
- DECIMAL = 'decimal'
- INTEGER = 'integer'
- STRING = 'string'
- pathling.udfs.designation(coding: Union[Column, str, Coding], use: Optional[Union[Column, str, Coding]] = None, language: Optional[str] = None) Column [source]
Takes a Coding column as its input. Returns the Column, which contains the values of designations (strings) for this coding for the specified use and language. If the language is not provided (is null) then all designations with the specified type are returned regardless of their language.
- Parameters
coding – a Column containing a struct representation of a Coding
use – the code with the use of the designations
language – the language of the designations
- Returns
the Column containing the result of the operation (array of strings with designation values)
- pathling.udfs.display(coding: Union[Column, str, Coding]) Column [source]
Takes a Coding column as its input. Returns the Column, which contains the canonical display name associated with the given code.
- Parameters
coding – a Column containing a struct representation of a Coding.
- Returns
a Column containing the result of the operation (String).
- pathling.udfs.member_of(coding: Union[Column, str, Coding], value_set_uri: str) Column [source]
Takes a Coding or array of Codings column as its input. Returns the column which contains a Boolean value, indicating whether any of the input Codings is the member of the specified FHIR ValueSet.
- Parameters
coding – a Column containing a struct representation of a Coding or an array of such structs.
value_set_uri – an identifier for a FHIR ValueSet
- Returns
a Column containing the result of the operation.
- pathling.udfs.property_of(coding: Union[Column, str, Coding], property_code: str, property_type: str = 'string') Column [source]
Takes a Coding column as its input. Returns the Column, which contains the values of properties for this coding with specified names and types. The type of the result column depends on the types of the properties. Primitive FHIR types are mapped to their corresponding SQL primitives. Complex types are mapped to their corresponding structs. The allowed property types are: code | Coding | string | integer | boolean | dateTime | decimal. See also
PropertyType
.- Parameters
coding – a Column containing a struct representation of a Coding
property_code – the code of the property to retrieve.
property_type – the type of the property to retrieve.
- Returns
the Column containing the result of the operation (array of property values)
- pathling.udfs.subsumed_by(left_coding: Union[Column, str, Coding], right_coding: Union[Column, str, Coding]) Column [source]
Takes two Coding columns as input. Returns the Column, which contains a Boolean value, indicating whether the left Coding is subsumed by the right Coding.
- Parameters
left_coding – a Column containing a struct representation of a Coding or an array of Codings.
right_coding – a Column containing a struct representation of a Coding or an array of Codings.
- Returns
a Column containing the result of the operation (boolean).
- pathling.udfs.subsumes(left_coding: Union[Column, str, Coding], right_coding: Union[Column, str, Coding]) Column [source]
- Takes two Coding columns as input. Returns the Column, which contains a
Boolean value, indicating whether the left Coding subsumes the right Coding.
- Parameters
left_coding – a Column containing a struct representation of a Coding or an array of Codings.
right_coding – a Column containing a struct representation of a Coding or an array of Codings.
- Returns
a Column containing the result of the operation (boolean).
- pathling.udfs.translate(coding: Union[Column, str, Coding], concept_map_uri: str, reverse: bool = False, equivalences: Optional[Union[str, Collection[str]]] = None, target: Optional[str] = None) Column [source]
Takes a Coding column as input. Returns the Column which contains an array of Coding value with translation targets from the specified FHIR ConceptMap. There may be more than one target concept for each input concept. Only the translation with the specified equivalences are returned. See also
Equivalence
. :param coding: a Column containing a struct representation of a Coding :param concept_map_uri: an identifier for a FHIR ConceptMap :param reverse: the direction to traverse the map - false results in “source to target”mappings, while true results in “target to source”
- Parameters
equivalences – a value of a collection of values from the ConceptMapEquivalence ValueSet
target – identifies the value set in which a translation is sought. If there’s no target specified, the server should return all known translations.
- Returns
a Column containing the result of the operation (an array of Coding structs).
Module contents
- class pathling.Coding(system: str, code: str, version: Optional[str] = None, display: Optional[str] = None, user_selected: Optional[bool] = None)[source]
Bases:
object
A Coding represents a code in a code system. See: https://hl7.org/fhir/R4/datatypes.html#Coding
- classmethod of_snomed(code: str, version: Optional[str] = None, display: Optional[str] = None, user_selected: Optional[bool] = None) Coding [source]
Creates a SNOMED Coding.
- Parameters
code – the code
version – a URI that identifies the version of the code system
display – the display text for the Coding
user_selected – an indicator of whether the Coding was chosen directly by the user
- Returns
a SNOMED coding with given arguments.
- class pathling.Equivalence[source]
Bases:
object
Concept map equivalences, see https://www.hl7.org/fhir/R4/valueset-concept-map-equivalence.html.
- DISJOINT = 'disjoint'
- EQUAL = 'equal'
- EQUIVALENT = 'equivalent'
- INEXACT = 'inexact'
- NARROWER = 'narrower'
- RELATEDTO = 'relatedto'
- SPECIALIZES = 'specializes'
- SUBSUMES = 'subsumes'
- UNMATCHED = 'unmatched'
- WIDER = 'wider'
- class pathling.MimeType[source]
Bases:
object
Constants for FHIR encoding mime types.
- FHIR_JSON: str = 'application/fhir+json'
- FHIR_XML: str = 'application/fhir+xml'
- class pathling.PathlingContext(spark: SparkSession, jpc: JavaObject)[source]
Bases:
object
Main entry point for Pathling API functionality. Should be instantiated with the
PathlingContext.create()
class method.Example use:
pc = PathlingContext.create(spark) patient_df = pc.encode(spark.read.text('ndjson_resources'), 'Patient') patient_df.show()
- classmethod create(spark: Optional[SparkSession] = None, max_nesting_level: Optional[int] = 3, enable_extensions: Optional[bool] = False, enabled_open_types: Optional[Sequence[str]] = ('boolean', 'code', 'date', 'dateTime', 'decimal', 'integer', 'string', 'Coding', 'CodeableConcept', 'Address', 'Identifier', 'Reference'), enable_terminology: Optional[bool] = True, terminology_server_url: Optional[str] = 'https://tx.ontoserver.csiro.au/fhir', terminology_verbose_request_logging: Optional[bool] = False, terminology_socket_timeout: Optional[int] = 60000, max_connections_total: Optional[int] = 32, max_connections_per_route: Optional[int] = 16, terminology_retry_enabled: Optional[bool] = True, terminology_retry_count: Optional[int] = 2, enable_cache: Optional[bool] = True, cache_max_entries: Optional[int] = 200000, cache_storage_type: Optional[str] = 'memory', cache_storage_path: Optional[str] = None, cache_default_expiry: Optional[int] = 600, cache_override_expiry: Optional[int] = None, token_endpoint: Optional[str] = None, enable_auth: Optional[bool] = False, client_id: Optional[str] = None, client_secret: Optional[str] = None, scope: Optional[str] = None, token_expiry_tolerance: Optional[int] = 120) PathlingContext [source]
Creates a
PathlingContext
with the given configuration options. This should only be done once within a SparkSession - subsequent calls with different configuration may produce an error.If no SparkSession is provided, and there is not one already present in this process - a new SparkSession will be created.
If a SparkSession is not provided, and one is already running within the current process, it will be reused - and it is assumed that the Pathling library API JAR is already on the classpath. If you are running your own cluster, make sure it is on the list of packages.
If a SparkSession is provided, it needs to include the Pathling library API JAR on its classpath. You can get the path for the JAR (which is bundled with the Python package) using the pathling.etc.find_jar method.
- Parameters
spark – a pre-configured
SparkSession
instance, use this if you need to control the way that the session is set upmax_nesting_level –
controls the maximum depth of nested element data that is encoded upon import. This affects certain elements within FHIR resources that contain recursive references, e.g. QuestionnaireResponse.item.
enable_extensions – enables support for FHIR extensions
enabled_open_types – the list of types that are encoded within open types, such as extensions. This default list was taken from the data types that are common to extensions found in widely-used IGs, such as the US and AU base profiles. In general, you will get the best query performance by encoding your data with the shortest possible list.
enable_terminology – enables the use of terminology functions
terminology_server_url – the endpoint of a FHIR terminology service (R4) that the server can use to resolve terminology queries. The default server is suitable for testing purposes only.
terminology_verbose_request_logging – setting this option to True will enable additional logging of the details of requests to the terminology service. Note that logging is subject to the Spark logging level, which you can set using SparkContext.setLogLevel. Verbose request logging is sent to the DEBUG logging level.
terminology_socket_timeout – the maximum period (in milliseconds) that the server should wait for incoming data from the HTTP service
max_connections_total – the maximum total number of connections for the client
max_connections_per_route – the maximum number of connections per route for the client
terminology_retry_enabled – controls whether terminology requests that fail for possibly transient reasons (network connections, DNS problems) should be retried
terminology_retry_count – the number of times to retry failed terminology requests
enable_cache – set this to false to disable caching of terminology requests (not recommended)
cache_max_entries – sets the maximum number of entries that will be held in memory
cache_storage_type – the type of storage to use for the terminology cache. See StorageType.
cache_storage_path – the path on disk to use for the cache, required when cache_storage_type is disk
cache_default_expiry – the default expiry time for cache entries (in seconds), used when the server does not provide an expiry value
cache_override_expiry – if provided, this value overrides the expiry time provided by the terminology server
enable_auth – enables authentication of requests to the terminology server
token_endpoint – an OAuth2 token endpoint for use with the client credentials grant
client_id – a client ID for use with the client credentials grant
client_secret – a client secret for use with the client credentials grant
scope – a scope value for use with the client credentials grant
token_expiry_tolerance – the minimum number of seconds that a token should have before expiry when deciding whether to send it with a terminology request
- Returns
a
PathlingContext
instance initialized with the specified configuration
- encode(df: DataFrame, resource_name: str, input_type: Optional[str] = None, column: Optional[str] = None) DataFrame [source]
Takes a dataframe with a string representations of FHIR resources in the given column and encodes the resources of the given types as Spark dataframe.
- Parameters
df – a
DataFrame
containing the resources to encode.resource_name – the name of the FHIR resource to extract (Condition, Observation, etc.)
input_type – the mime type of input string encoding. Defaults to application/fhir+json.
column – the column in which the resources to encode are stored. If ‘None’ then the input dataframe is assumed to have one column of type string.
- Returns
a
DataFrame
containing the given type of resources encoded into Spark columns
- encode_bundle(df: DataFrame, resource_name: str, input_type: Optional[str] = None, column: Optional[str] = None) DataFrame [source]
Takes a dataframe with a string representations of FHIR bundles in the given column and encodes the resources of the given types as Spark dataframe.
- Parameters
df – a
DataFrame
containing the bundles with the resources to encode.resource_name – the name of the FHIR resource to extract (Condition, Observation, etc.)
input_type – the MIME type of the input string encoding. Defaults to application/fhir+json.
column – the column in which the resources to encode are stored. If ‘None’ then the input dataframe is assumed to have one column of type string.
- Returns
a
DataFrame
containing the given type of resources encoded into Spark columns
- member_of(df: DataFrame, coding_column: Column, value_set_uri: str, output_column_name: str)[source]
Takes a dataframe with a Coding column as input. A new column is created which contains a Boolean value, indicating whether the input Coding is a member of the specified FHIR ValueSet.
- Parameters
df – a DataFrame containing the input data
coding_column – a Column containing a struct representation of a Coding
value_set_uri – an identifier for a FHIR ValueSet
output_column_name – the name of the result column
- Returns
A new dataframe with an additional column containing the result of the operation
- property spark: SparkSession
Returns the SparkSession associated with this context.
- subsumes(df: DataFrame, output_column_name: str, left_coding_column: Optional[Column] = None, right_coding_column: Optional[Column] = None, left_coding: Optional[Coding] = None, right_coding: Optional[Coding] = None)[source]
Takes a dataframe with two Coding columns. A new column is created which contains a Boolean value, indicating whether the left Coding subsumes the right Coding.
- Parameters
df – a DataFrame containing the input data
left_coding_column – a Column containing a struct representation of a Coding, for the left-hand side of the subsumption test
right_coding_column – a Column containing a struct representation of a Coding, for the right-hand side of the subsumption test
left_coding – a Coding object for the left-hand side of the subsumption test
right_coding – a Coding object for the right-hand side of the subsumption test
output_column_name – the name of the result column
- Returns
A new dataframe with an additional column containing the result of the operation.
- translate(df: DataFrame, coding_column: Column, concept_map_uri: str, reverse: Optional[bool] = False, equivalence: Optional[str] = 'equivalent', target: Optional[str] = None, output_column_name: Optional[str] = 'result')[source]
Takes a dataframe with a Coding column as input. A new column is created which contains the array of Codings value with translation targets from the specified FHIR ConceptMap. There may be more than one target concept for each input concept.
- Parameters
df – a DataFrame containing the input data
coding_column – a Column containing a struct representation of a Coding
concept_map_uri – an identifier for a FHIR ConceptMap
reverse – the direction to traverse the map - false results in “source to target” mappings, while true results in “target to source”
equivalence – a comma-delimited set of values from the ConceptMapEquivalence ValueSet
target – identifies the value set in which a translation is sought. If there is no target specified, the server should return all known translations.
output_column_name – the name of the result column
- Returns
A new dataframe with an additional column containing the result of the operation.
- class pathling.PropertyType[source]
Bases:
object
Allowed property types.
- BOOLEAN = 'boolean'
- CODE = 'code'
- CODING = 'Coding'
- DATETIME = 'dateTime'
- DECIMAL = 'decimal'
- INTEGER = 'integer'
- STRING = 'string'
- pathling.designation(coding: Union[Column, str, Coding], use: Optional[Union[Column, str, Coding]] = None, language: Optional[str] = None) Column [source]
Takes a Coding column as its input. Returns the Column, which contains the values of designations (strings) for this coding for the specified use and language. If the language is not provided (is null) then all designations with the specified type are returned regardless of their language.
- Parameters
coding – a Column containing a struct representation of a Coding
use – the code with the use of the designations
language – the language of the designations
- Returns
the Column containing the result of the operation (array of strings with designation values)
- pathling.display(coding: Union[Column, str, Coding]) Column [source]
Takes a Coding column as its input. Returns the Column, which contains the canonical display name associated with the given code.
- Parameters
coding – a Column containing a struct representation of a Coding.
- Returns
a Column containing the result of the operation (String).
- pathling.find_jar(verbose: bool = False) str [source]
Gets the path to the Pathling library JAR, bundled with the python distribution.
- pathling.member_of(coding: Union[Column, str, Coding], value_set_uri: str) Column [source]
Takes a Coding or array of Codings column as its input. Returns the column which contains a Boolean value, indicating whether any of the input Codings is the member of the specified FHIR ValueSet.
- Parameters
coding – a Column containing a struct representation of a Coding or an array of such structs.
value_set_uri – an identifier for a FHIR ValueSet
- Returns
a Column containing the result of the operation.
- pathling.property_of(coding: Union[Column, str, Coding], property_code: str, property_type: str = 'string') Column [source]
Takes a Coding column as its input. Returns the Column, which contains the values of properties for this coding with specified names and types. The type of the result column depends on the types of the properties. Primitive FHIR types are mapped to their corresponding SQL primitives. Complex types are mapped to their corresponding structs. The allowed property types are: code | Coding | string | integer | boolean | dateTime | decimal. See also
PropertyType
.- Parameters
coding – a Column containing a struct representation of a Coding
property_code – the code of the property to retrieve.
property_type – the type of the property to retrieve.
- Returns
the Column containing the result of the operation (array of property values)
- pathling.subsumed_by(left_coding: Union[Column, str, Coding], right_coding: Union[Column, str, Coding]) Column [source]
Takes two Coding columns as input. Returns the Column, which contains a Boolean value, indicating whether the left Coding is subsumed by the right Coding.
- Parameters
left_coding – a Column containing a struct representation of a Coding or an array of Codings.
right_coding – a Column containing a struct representation of a Coding or an array of Codings.
- Returns
a Column containing the result of the operation (boolean).
- pathling.subsumes(left_coding: Union[Column, str, Coding], right_coding: Union[Column, str, Coding]) Column [source]
- Takes two Coding columns as input. Returns the Column, which contains a
Boolean value, indicating whether the left Coding subsumes the right Coding.
- Parameters
left_coding – a Column containing a struct representation of a Coding or an array of Codings.
right_coding – a Column containing a struct representation of a Coding or an array of Codings.
- Returns
a Column containing the result of the operation (boolean).
- pathling.to_coding(coding_column: Column, system: str, version: Optional[str] = None) Column [source]
Converts a Column containing codes into a Column that contains a Coding struct. The Coding struct Column can be used as an input to terminology functions such as member_of and translate.
- Parameters
coding_column – the Column containing the codes
system – the URI of the system the codes belong to
version – the version of the code system
- Returns
a Column containing a Coding struct
- pathling.to_ecl_value_set(ecl: str) str [source]
Converts a SNOMED CT ECL expression into a FHIR ValueSet URI. Can be used with the member_of function.
- Parameters
ecl – the ECL expression
- Returns
the ValueSet URI
- pathling.to_snomed_coding(coding_column: Column, version: Optional[str] = None) Column [source]
Converts a Column containing codes into a Column that contains a SNOMED Coding struct. The Coding struct Column can be used as an input to terminology functions such as member_of and translate.
- Parameters
coding_column – the Column containing the codes
version – the version of the code system
- Returns
a Column containing a Coding struct
- pathling.translate(coding: Union[Column, str, Coding], concept_map_uri: str, reverse: bool = False, equivalences: Optional[Union[str, Collection[str]]] = None, target: Optional[str] = None) Column [source]
Takes a Coding column as input. Returns the Column which contains an array of Coding value with translation targets from the specified FHIR ConceptMap. There may be more than one target concept for each input concept. Only the translation with the specified equivalences are returned. See also
Equivalence
. :param coding: a Column containing a struct representation of a Coding :param concept_map_uri: an identifier for a FHIR ConceptMap :param reverse: the direction to traverse the map - false results in “source to target”mappings, while true results in “target to source”
- Parameters
equivalences – a value of a collection of values from the ConceptMapEquivalence ValueSet
target – identifies the value set in which a translation is sought. If there’s no target specified, the server should return all known translations.
- Returns
a Column containing the result of the operation (an array of Coding structs).