health.fhir.r4.terminology
Module health.fhir.r4.terminology
API
Declarations
ballerinax/health.fhir.r4.terminology Ballerina library
FHIR Terminology Package
A package containing utilities to perform search, read interactions on FHIR terminologies, including code systems and value sets.
Package Overview
FHIR Terminology Package is a collection of standardized terminologies, including code systems, value sets, concept maps and other related artifacts. These packages provide a comprehensive set of codes and concepts that allow for accurate representation and exchange of healthcare data within the FHIR ecosystem.
This package provides the following functionalities required for FHIR terminology related requirements.
- Get by Id
- Search CodeSystems and ValueSets
- CodeSystem-lookup - Given a code/system, or a Coding, get additional details about the concept, including definition, status, designations, and properties. One of the products of this operation is a complete decomposition of a code from a structured terminology
- ValueSet-expand - Get the definition of a value set.
- ValueSet-validate-code - Validate that a coded value is in the set of codes allowed by a value set.
- CodeSystem-subsumes - Test the subsumption(The meaning of the hierarchy of concepts as represented in this resource) relationship between code/Coding A and code/Coding B given the semantics of subsumption in the underlying code system.
- ConceptMap-translate - Translate a code from one value set to another, based on the existing value set and concept maps resources.
Functions
addCodeSystem
function addCodeSystem(CodeSystem codeSystem, Terminology? terminology) returns FHIRError?Add a new CodeSystem.
Parameters
- codeSystem CodeSystem - ValueSet to be added, data in the Ballerina record format
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- FHIRError? - Return FHIRError
addCodeSystems
function addCodeSystems(CodeSystem[] codeSystems, Terminology? terminology) returns FHIRError[]?Add a list of new CodeSystems.
Parameters
- codeSystems CodeSystem[] - List CodeSystems
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- FHIRError[]? - Return List of FHIRErrors if any
addCodeSystemsAsJson
function addCodeSystemsAsJson(json[] codeSystemJsonArray, Terminology? terminology) returns FHIRError[]?Add a list of new CodeSystems as a json or json array.
Parameters
- codeSystemJsonArray json[] - CodeSystem data in the JSON format
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- FHIRError[]? - Return List of FHIRErrors if any
addConceptMap
function addConceptMap(ConceptMap conceptMap, Terminology? terminology) returns FHIRError?addValueSet
function addValueSet(ValueSet valueSet, Terminology? terminology) returns FHIRError?Add a new ValueSet.
Parameters
- valueSet ValueSet - ValueSet to be added, data in the Ballerina record format
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- FHIRError? - Return FHIRError
addValueSets
function addValueSets(ValueSet[] valueSets, Terminology? terminology) returns FHIRError[]?Add a list of new ValueSets.
Parameters
- valueSets ValueSet[] - List ValueSets in the Ballerina record format
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- FHIRError[]? - Return List of FHIRErrors if any
addValueSetsAsJson
function addValueSetsAsJson(json[] valueSetJsonArray, Terminology? terminology) returns FHIRError[]?Add a list of new ValueSet as a json or json array.
Parameters
- valueSetJsonArray json[] - Json ValueSet data in the JSON format
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- FHIRError[]? - Return List of FHIRErrors if any
codeSystemLookUp
function codeSystemLookUp(code|Coding codeValue, CodeSystem? cs, uri? system, string? 'version, Terminology? terminology) returns CodeSystemConcept[]|CodeSystemConcept|FHIRErrorExtract the respective concepts from a given CodeSystem based on the give code or Coding or CodeableConcept data. This method was implemented based on : http://hl7.org/fhir/R4/terminology-service.html#lookup.
Parameters
- cs CodeSystem? (default ()) - CodeSystem record to be processed. If system parameter is not supplied, this value shoud be mandatory,
else this is an optional field
- system uri? (default ()) - System URL of the CodeSystem to be processed, if system CodeSystem(cs) is not supplied,
this value shoud be mandatory
- 'version string? (default ()) -
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- CodeSystemConcept[]|CodeSystemConcept|FHIRError - Return list of Concepts if processing is successful, return FHIRError if fails
createCodeableConcept
function createCodeableConcept(uri system, code code, string? version, Terminology? terminology) returns CodeableConcept|FHIRErrorCreate CodeableConcept data type for given code in a given system.
Parameters
- system uri - system uri of the code system or value set
- code code - code interested
- version string? (default () ) - Version of the CodeSystem and it should be provided with system parameter, if this version parameter is not supplied then the latest version of CodeSystem will picked up.
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- CodeableConcept|FHIRError - Created CodeableConcept record or FHIRError if not found
createCoding
function createCoding(uri system, code code, string? version, Terminology? terminology) returns Coding|FHIRErrorCreate Coding data type for given code in a given system.
Parameters
- system uri - System uri of the CodeSystem or valueSet
- code code - code interested
- version string? (default () ) - Version of the CodeSystem and it should be provided with system parameter, if this version parameter is not supplied then the latest version of CodeSystem will picked up.
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
findConceptsInValueSetFromCodeValue
function findConceptsInValueSetFromCodeValue(code|Coding|CodeableConcept codeValue, uri system, string? version, Terminology? terminology) returns CodeSystemConcept[]|CodeSystemConcept|FHIRErrorParameters
- codeValue code|Coding|CodeableConcept -
- system uri -
- version string? -
- terminology Terminology? (default inMemoryTerminology) -
readCodeSystemById
function readCodeSystemById(string id, string? version, Terminology? terminology) returns CodeSystem|FHIRErrorFind a Code System based on the provided Id and version.
Parameters
- id string - Id of the CodeSystem to be retrieved
- version string? (default ()) - Version of the CodeSystem to be retrieved and it should be provided with system parameter, if this version parameter is not supplied then the latest version of CodeSystem will picked up.
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- CodeSystem|FHIRError - Return CodeSystem data if the request is successful, return FHIR error if no data found for the provided Id
readCodeSystemByUrl
function readCodeSystemByUrl(uri url, string? version, Terminology? terminology) returns CodeSystem|FHIRErrorFind a CodeSystem based on the provided URL and version.
Parameters
- url uri - URL of the CodeSystem to be retrieved
- version string? (default ()) - Version of the CodeSystem to be retrieved and it should be provided with system parameter, if this version parameter is not supplied then the latest version of CodeSystem will picked up.
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- CodeSystem|FHIRError - Return CodeSystem data if the request is successful, return FHIR error if no data found for the provided URL
readConceptMap
function readConceptMap(uri conceptMapUrl, string? version, Terminology? terminology) returns ConceptMap|FHIRErrorParameters
- conceptMapUrl uri -
- version string? (default ()) -
- terminology Terminology? (default inMemoryTerminology) -
readValueSetById
function readValueSetById(string id, string? version, Terminology? terminology) returns ValueSet|FHIRErrorFind a ValueSet for a provided Id and version.
Parameters
- id string - Id of the Value Set to be retrieved
- version string? (default ()) - Version of the ValueSet to be retrieved and it should be provided with system parameter, if this version parameter is not supplied then the latest version of CodeSystem will picked up.
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
readValueSetByUrl
function readValueSetByUrl(uri url, string? version, Terminology? terminology) returns ValueSet|FHIRErrorFind a ValueSet for a provided URL and version.
Parameters
- url uri - URL of the Value Set to be retrieved
- version string? (default ()) - Version of the ValueSet to be retrieved and it should be provided with system parameter, if this version parameter is not supplied then the latest version of CodeSystem will picked up.
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
searchCodeSystems
function searchCodeSystems(map<RequestSearchParameter[]> params, Terminology? terminology) returns CodeSystem[]|FHIRErrorSearch for Code systems based on the provided search parameters. Allowed search parameters are name, title, url, version, status and so on.
Parameters
- params map<RequestSearchParameter[]> - List of search parameters, should be passed as map of string arrays
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- CodeSystem[]|FHIRError - Return array of CodeSystem data if success, return FHIR error if the request contains unsupported search parameters and for any other processing errors
searchConceptMaps
function searchConceptMaps(map<RequestSearchParameter[]> params, Terminology? terminology) returns FHIRError|ConceptMap[]Parameters
- params map<RequestSearchParameter[]> -
- terminology Terminology? (default inMemoryTerminology) -
searchValueSets
function searchValueSets(map<RequestSearchParameter[]> params, Terminology? terminology) returns FHIRError|ValueSet[]Search for Value Sets for the provided search parameters. Allowed search parameters: are name, title, url, version, status and son on.
Parameters
- params map<RequestSearchParameter[]> - List of search parameters, should be passed as map of string arrays
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
subsumes
function subsumes(code|Coding conceptA, code|Coding conceptB, CodeSystem? cs, uri? system, string? version, Terminology? terminology) returns Parameters|FHIRErrorThis method with compare concepts. This method was implemented based on: http://hl7.org/fhir/R4/terminology-service.html#subsumes.
Parameters
- cs CodeSystem? (default ()) - CodeSystem value
- system uri? (default ()) - System uri of the codeSystem
- version string? (default ()) - Version of the CodeSystem and it should be provided with system parameter, if this version parameter is not supplied then the latest version of CodeSystem will picked up.
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- Parameters|FHIRError - Return Values either equivalent or not-subsumed if processing is successful, FHIRError processing fails
translate
function translate(uri sourceValueSetUri, uri? targetValueSetUri, CodeableConcept codesToTranslate, Terminology? terminology) returns Parameters|OperationOutcomeThis function translates codes from a source value set to a target value set using the concept maps in the terminology service.
When both source value set URI and target value set URI are provided, the function looks for concept maps that match both value sets. Then matches the provided codes with the found concept maps and returns the response. The response will contain the target codes from all the matching concept maps.
When only the source value set URI is provided, the function looks for all concept maps that match the source value set. Then matches the provided codes with the found concept maps and returns the response. The response will contain the target codes from all the matching concept maps.
The codeable concept can contain multiple codings. The system and code of each coding will be used to find matches in the concept maps. When the system is not provided, the code will be used to match the concept maps ignoring the code system. When the system is present, both the system and code will be used to find matches.
This function is implemented based on: https://hl7.org/fhir/R4/terminology-service.html#translate
Parameters
- sourceValueSetUri uri - the URL of the source value set
- targetValueSetUri uri? - the URL of the target value set (optional)
- codesToTranslate CodeableConcept - the codes to translate
- terminology Terminology? (default inMemoryTerminology) - the terminology service to use
Return Type
- Parameters|OperationOutcome - an r4:Parameters resource containing the translation results, or an r4:OperationOutcome resource if an error occurs
valueSetExpansion
function valueSetExpansion(map<RequestSearchParameter[]>? searchParams, ValueSet? vs, uri? system, Terminology? terminology) returns ValueSet|FHIRErrorExtract all the concepts from a given valueSet based on the given filter parameters. This method was implemented based on : http://hl7.org/fhir/R4/terminology-service.html#expand.
Parameters
- searchParams map<RequestSearchParameter[]>? - List of search parameters to filter concepts, should be passed as map of string arrays
- vs ValueSet? (default ()) - ValueSet record to be processed. If system parameter is not supplied, this value shoud be mandatory, else this is an optional field
- system uri? (default ()) - System URL of the ValueSet to be processed, if system ValueSet(vs) is not supplied then
this value shoud be mandatory
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
valueSetLookUp
function valueSetLookUp(code|Coding|CodeableConcept codeValue, ValueSet? vs, uri? system, string? version, Terminology? terminology) returns CodeSystemConcept[]|CodeSystemConcept|FHIRErrorExtract the respective concepts from a given ValueSet based on the give code or Coding or CodeableConcept data. This method was implemented based on : http://hl7.org/fhir/R4/terminology-service.html#validation.
Parameters
- codeValue code|Coding|CodeableConcept - Code or Coding or CodeableConcept data type value to process with the ValueSet
- vs ValueSet? (default ()) - vs - ValueSet record to be processed. If system parameter is not supplied, this value shoud be mandatory,
else this is an optional field
- system uri? (default ()) - System URL of the ValueSet to be processed, if system ValueSet(vs) is not supplied then
this value shoud be mandatory
- version string? (default ()) - Version of the ValueSet and it should be provided with system parameter, if this version parameter is not supplied then the latest version of CodeSystem will picked up.
- terminology Terminology? (default inMemoryTerminology) - Terminology - optional parameter allowing you to pass a custom implementation of the Terminology and by default we use InMemoryTerminology.
Return Type
- CodeSystemConcept[]|CodeSystemConcept|FHIRError - Return list of Concepts if processing is successful, return FHIRError if fails
Constants
health.fhir.r4.terminology: CODESYSTEMS_SEARCH_PARAMS
This is a map of implemented search params for CodeSystems. These are defined as a map because to make the search process ease.
health.fhir.r4.terminology: CONCEPT_MAPS_SEARCH_PARAMS
This is a map of implemented search params for CodeSystems. These are defined as a map because to make the search process ease.
health.fhir.r4.terminology: DEFAULT_FHIR_CODE_SYSTEMS
health.fhir.r4.terminology: DEFAULT_FHIR_CONCEPT_MAPS
health.fhir.r4.terminology: DEFAULT_FHIR_VALUE_SETS
health.fhir.r4.terminology: DEFAULT_VERSION
health.fhir.r4.terminology: DEFINITION
health.fhir.r4.terminology: DISPLAY
health.fhir.r4.terminology: EXTERNAL_FHIR_CODE_SYSTEMS
health.fhir.r4.terminology: EXTERNAL_FHIR_VALUE_SETS
health.fhir.r4.terminology: FILTER
health.fhir.r4.terminology: OUTCOME
health.fhir.r4.terminology: SEARCH_COUNT_ATTRIBUTE
health.fhir.r4.terminology: SEARCH_OFFSET_ATTRIBUTE
health.fhir.r4.terminology: TERMINOLOGY_SEARCH_DEFAULT_COUNT
health.fhir.r4.terminology: TERMINOLOGY_SEARCH_MAXIMUM_COUNT
health.fhir.r4.terminology: VALUESETS_EXPANSION_PARAMS
This is a map of implemented search params for ValueSets. These define as a map because to make the search process ease
health.fhir.r4.terminology: VALUESETS_SEARCH_PARAMS
This is a map of implemented search params for ValueSets. These define as a map because to make the search process ease
Enums
health.fhir.r4.terminology: CodeSystemSubsumption
Members
Records
health.fhir.r4.terminology: CodeConceptDetails
Fields
- url uri -
Object types
health.fhir.r4.terminology: Terminology
Defines the interface for a Terminology implementation.
This should be implemented and provided to the Terminology API. Default implementation is
an in-memory terminology implementation.
isCodeSystemExist
To check whether the CodeSystem exists.
Return Type
- boolean - Return true if the CodeSystem exists, else false.
addCodeSystem
function addCodeSystem(CodeSystem codeSystem) returns FHIRError?Add a new code system. Terminology API makes sure that the CodeSystem is valid.
Parameters
- codeSystem CodeSystem - CodeSystem to be added.
Return Type
- FHIRError? - FHIRError if any.
findCodeSystem
function findCodeSystem(uri? system, string? id, string? version) returns CodeSystem|FHIRErrorThe function definition for Concept finder implementations.
Parameters
- system uri? (default ()) - CodeSystem URL to be searched.
- id string? (default ()) - Id of the CodeSystem to be searched.
- version string? (default ()) - Version of the CodeSystem to be searched.
Return Type
- CodeSystem|FHIRError - CodeSystem if found or else FHIRError.
searchCodeSystem
function searchCodeSystem(map<RequestSearchParameter[]> params, int? offset, int? count) returns CodeSystem[]|FHIRErrorThe function definition for Concept finder implementations.
Parameters
- params map<RequestSearchParameter[]> - Search parameters.
- offset int? (default ()) - Offset value for the search.
- count int? (default ()) - Count value for the search.
Return Type
- CodeSystem[]|FHIRError - CodeSystem array if found or else FHIRError.
findConcept
function findConcept(uri system, code code, string? version) returns CodeConceptDetails|FHIRErrorThe function definition for Concept finder implementations.
Parameters
- system uri - System URL of the CodeSystem to be searched.
- code code - Code of the Concept to be searched.
- version string? (default ()) - version of the CodeSystem to be searched.
Return Type
- CodeConceptDetails|FHIRError - CodeConceptDetails if found or else FHIRError.
isValueSetExist
To check whether the ValueSet exists.
Return Type
- boolean - Return true if the ValueSet exists, else false.
addValueSet
Add a new value set. Terminology API makes sure that the ValueSet is valid.
Parameters
- valueSet ValueSet - ValueSet to be added.
Return Type
- FHIRError? - FHIRError if any.
findValueSet
The function definition for ValueSet finder implementations.
Parameters
- system uri? (default ()) - System URL of the ValueSet to be searched.
- id string? (default ()) - Id of the ValueSet to be searched.
- version string? (default ()) - version of the ValueSet to be searched.
searchValueSet
function searchValueSet(map<RequestSearchParameter[]> params, int? offset, int? count) returns ValueSet[]|FHIRErrorSearch ValueSets.
Parameters
- params map<RequestSearchParameter[]> - Search parameters.
- offset int? (default ()) - Offset value for the search.
- count int? (default ()) - Count value for the search.
expandValueSet
function expandValueSet(map<RequestSearchParameter[]> searchParams, ValueSet valueSet, int offset, int count) returns ValueSet|FHIRErrorExpands a ValueSet with the given search parameters, offset, and count.
This function applies filtering and pagination to the concepts in the provided ValueSet, returning a ValueSetExpansion or an FHIRError if the operation fails.
Parameters
- searchParams map<RequestSearchParameter[]> - Map of search parameters to filter concepts (e.g., filter by display or definition).
- valueSet ValueSet - The ValueSet record to be expanded.
- offset int - The starting index for pagination (optional).
- count int - The maximum number of concepts to return (optional).
Return Type
isConceptMapExist
To check whether the ConceptMap exists.
Return Type
- boolean - Return true if the ConceptMap exists, else false.
addConceptMap
function addConceptMap(ConceptMap conceptMap) returns FHIRError?Add a new concept map. Terminology API makes sure that the ConceptMap is valid.
Parameters
- conceptMap ConceptMap - ConceptMap to be added.
Return Type
- FHIRError? - FHIRError if any.
findConceptMaps
function findConceptMaps(uri sourceValueSetUri, uri? targetValueSetUri) returns ConceptMap[]|FHIRErrorFind a ConceptMap by its source and target ValueSets.
Parameters
- sourceValueSetUri uri - URI of the source ValueSet.
- targetValueSetUri uri? (default ()) - URI of the target ValueSet.
Return Type
- ConceptMap[]|FHIRError - ConceptMap if found or else FHIRError.
searchConceptMap
function searchConceptMap(map<RequestSearchParameter[]> params, int? offset, int? count) returns ConceptMap[]|FHIRErrorThe function definition for Concept Map finder implementations.
Parameters
- params map<RequestSearchParameter[]> - Search parameters.
- offset int? (default ()) - Offset value for the search.
- count int? (default ()) - Count value for the search.
Return Type
- ConceptMap[]|FHIRError - Concept Map array if found or else FHIRError.
getConceptMap
function getConceptMap(uri conceptMapUrl, string? version) returns ConceptMap|FHIRErrorThe function definition for Concept Map finder implementations.
Parameters
- conceptMapUrl uri - URI of the ConceptMap to be found.
- version string? (default ()) - Version of the ConceptMap to be found (optional).
Return Type
- ConceptMap|FHIRError - ConceptMap if found or else FHIRError.
Import
import ballerinax/health.fhir.r4.terminology;Metadata
Released date: 20 days ago
Version: 7.0.0
Compatibility
Platform: any
Ballerina version: 2201.12.8
GraalVM compatible: Yes
Pull count
Total: 758
Current verison: 2
Weekly downloads
Keywords
Healthcare
FHIR
R4
Terminology
Contributors