IHTSDO / snowstorm

Scalable SNOMED CT Terminology Server using Elasticsearch
Other
208 stars 83 forks source link

Extract children and parent for searched terms #165

Closed MahboobehJannesari closed 4 years ago

MahboobehJannesari commented 4 years ago

Hi, I would like to know how can I extract all children and parents for a searched term in snowstorm api?

e.g I search for "Escherichia Coli", I would like to get highest-level parent as an output, how can i find the relation between outputs?

kaicode commented 4 years ago

The GET /{branch}/concepts API endpoint can be used to load the children or parents of a concept using the ecl parameter.

Using the concept 131148009 | Bleeding (finding) | as an example the following ECL could be used:

The ECL parameter must be URI encoded. Example API call using the public server to fetch the first 1,000 results from the July 2020 International Release: https://browser.ihtsdotools.org/snowstorm/snomed-ct/MAIN/2020-07-31/concepts?ecl=%3C!131148009&limit=1000 The returnIdOnly parameter can be set to true to get faster responses.

If working with results of a term search will need to repeat the relevant calls above for each of the search results.

kaicode commented 4 years ago

You also asked for the highest level parent.

Search for a term, e.g. "Escherichia Coli" Using GET /{branch}/concepts?activeFilter=true&termActive=true&term=Escherichia%20Coli

Take the returned conceptId and use ECL to search for the ancestor of this concept which is a direct child of the root concept 138875005 | SNOMED CT Concept (SNOMED RT+CTV3) |.

Using 112283007 | Escherichia coli (organism) | as an example the ECL would be >112283007 AND <!138875005

Use GET /{branch}/concepts?ecl=%3E112283007%20AND%20%3C!138875005 (The ECL must be URL encoded.)

A single concept will be returned which is the top level concept for the hierarchy of the search result.

MahboobehJannesari commented 4 years ago

why I should use 138875005 | SNOMED CT Concept (SNOMED RT+CTV3) | ?

">112283007 AND <!138875005" return "Organism" for "Escherichia Coli" while I need to detect "Escherichia coli (organism)" as highest level parent and remove items that are its children such as "Escherichia coli F41"

I need to identify hierarchy aspect of outputs?

kaicode commented 4 years ago

I don't think I fully understand your question.

Here is some background information about the search which may help:

When searching for "Escherichia Coli" the results would include:

The concept with the shortest active description matching the search term will appear at the top. The intention of this sorting is that the simplest concept which matches should be at the top. It could be that just picking the top concept meets your requirements.

The results contain a concept from the substance hierarchy. The search can be filtered by the organism hierarchy by adding an ecl parameter with < 410607006 | Organism (organism) |.


How would you define the idea of the highest level parent? This idea may be subjective.

Considering the concept "Escherichia coli F41", some of its ancestors are listed here:

Screenshot 2020-10-06 at 12 17 38

Which parent would you consider as the top level parent? I have only expanded 3 levels of parents but there are more. "Escherichia coli (organism)" and "Genus Escherichia (organism)" share common terms with your search term but "Family Enterobacteriaceae (organism)" is also a parent.

kaicode commented 4 years ago

If you would like to test for an ancestor descendant relationship between the concepts in the search results you can use ECL.

For example to test if 112283007 | Escherichia coli (organism) | is a parent of 407257001 | Escherichia coli serogroup O9 (organism) | use <112283007 AND 407257001. This will return the concept 407257001 if it's a descendant of 112283007.

GET /{branch}/concepts?ecl=<112283007 AND 407257001

MahboobehJannesari commented 4 years ago

I could extract highest level parents, for example for Escherichia coli (list of (concept, fsn , conceptId))

[{'Escherichia coli', 'Escherichia coli (organism)', '112283007'}, {'Escherichia coli antigen', '25671000087101', 'Antigen of Escherichia coli (substance)'}, {'Escherichia coli DNA', '708263001', 'Deoxyribonucleic acid of Escherichia coli (substance)'}, {'Immunoglobulin G antibody to E scherichia coli (substance)', 'Escherichia coli IgG', '710437000'}, {'Escherichia coli IgM', 'Immunoglobulin M antibody to Escherichia coli (substance)', '710644002'}]

By adding which filters I can have unique output for Microbiology terms or there is a criteria that I order outputs by tags? for example I order all terms related to substance? LOINC code is useful?

kaicode commented 4 years ago

You can filter the search by the organism hierarchy using an ECL logical filter in combination with the term filter.

Here is an example search for "Escherichia coli" with an ECL filter matching only the 410607006 | Organism (organism) | hierarchy: GET/{branch}/concepts?limit=10&ecl=<<410607006&activeFilter=true&termActive=true&term=Escherichia%20Coli

I've included an optional 10 item results limit in this example. You only seem interested in the first few results.

MahboobehJannesari commented 4 years ago

Is there a search method that I get list of tags for a term?

kaicode commented 4 years ago

I don't understand your question. One of these may be helpful:

Concepts have multiple descriptions: GET /{branch}/descriptions?conceptId={conceptId}

Each concept has one "semantic tag", shown within parenthesis of the FSN term, e.g. 404684003 | Clinical finding (finding) | has finding.

Snowstorm description search allows filtering using semantic tags. For example search for active descriptions of active concepts using the term asthma filtered by concept having the semantic tag disorder or procedure - GET /browser/{branch}/descriptions?active=true&conceptActive=true&semanticTags=disorder&semanticTags=procedure&term=asthma

This example also returns a list of semantic tags of the search matches together with the number of concept found for each. This is what drives the search function in the SNOMED CT Public Browser.

kaicode commented 4 years ago

Closing due to inactivity.