# Using type IDs with the snomedct model

**URL:** <https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165>\
**Category:** MedCAT\
**Tags:** medical-ontologies\
**Created:** [February 23, 2023, 2:40pm UTC](https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165 "2023-02-23T14:40:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaya](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@Jaya](https://discourse.cogstack.org/u/Jaya)\
**Post date:** [February 23, 2023, 2:40pm UTC](https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165/1 "2023-02-23T14:40:51Z")

</div>

Hello,

I am trying to run a set of sentences through a medcat model to get a list of SCTIDs from the snomed-ct medcat model, based on type IDs.

I am following the example at link - [GitHub & BitBucket HTML Preview](https://htmlpreview.github.io/?https://github.com/CogStack/MedCATtutorials/blob/main/notebooks/introductory/Part_4_3_Annotating_documents_with_the_full_MedCAT_pipeline_with_MetaAnnotations.html) - Annotating documents with the full medCAT pipeline

Instead of the model in the example (“medmen\_wstatus\_2021\_oct.zip”), I am using “mc\_modelpack\_snomed\_int\_16\_mar\_2022…zip”.

In order to filter by type ID, I am using a TUI (from [SNOMED-CT\_Analysis/Exploring a SNOMED-CT Release.ipynb at master · tomolopolis/SNOMED-CT\_Analysis · GitHub](https://github.com/tomolopolis/SNOMED-CT_Analysis/blob/master/Exploring%20a%20SNOMED-CT%20Release.ipynb)) for clinical finding ( **T-02000** **Clinical finding (finding)**) instead of the ones used in the example (such as T047, T048). But , this doesn’t work, and I get a KeyError for the TUI used. I suspect the TUI is not recognised as a type\_id similar to the umls ones used in the example, but unsure how to go ahead at this point so I can get SCTIDs based on a type ID. Any suggestions, or has anyone done something similar with the snomed-ct model?

versions:  
medcat 1.5.0  
python 3.10.5

Thanks!

Jaya

---

<div class="post-metadata">

**Author:** ![mart.ratas](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mart.ratas](https://discourse.cogstack.org/u/mart.ratas)\
**Post date:** [February 23, 2023, 3:37pm UTC](https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165/2 "2023-02-23T15:37:09Z")

</div>

Hi,

I’m not fully familiar with what the **T-02000** refers to or whether/where it is stored.

But the `type_id` field of the the SNOMED-CT CDB is written here:

> <https://github.com/CogStack/MedCAT/blob/master/medcat/utils/preprocess_snomed.py#L146>

The description is simply gathered from the parenthesis of the name:

> <https://github.com/CogStack/MedCAT/blob/master/medcat/utils/preprocess_snomed.py#L139>

I am not sure whether/where there would be a list of what the type IDs correspond to. But if you find a concept with the correct type-name in the parentheses then you should be able to use that one.  
You may have to look into `addl_info['cui2original_names']` to find the original names with the brackets.

PS:  
A **subset** of SNOMED TUIs and their _possible_ names (I looked through the `addl_info['cui2original_names']` for them, but didn’t check too thoroughly) I’ve got saved from something I ran locally:

> <https://gist.github.com/mart-r/02af4f79f10b56492d21ecda746c7597>

---

<div class="post-metadata">

**Author:** ![Jaya](https://avatars.discourse-cdn.com/v4/letter/j/22d042/32.png) [@Jaya](https://discourse.cogstack.org/u/Jaya)\
**Post date:** [February 24, 2023, 10:39am UTC](https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165/3 "2023-02-24T10:39:05Z")

</div>

Thanks so much for this! The subset of type\_ids that you’ve shared in the end is exactly what I needed, but didn’t know where to find them. So its good to know for the future. Really appreciate your help!

---

<div class="post-metadata">

**Author:** ![Hideaki](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hideaki](https://discourse.cogstack.org/u/Hideaki)\
**Post date:** [April 5, 2023, 10:29am UTC](https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165/4 "2023-04-05T10:29:44Z")

</div>

Hi there,

This is so useful! I’m still getting to grips with coding and things. May I ask how you generated this list? Did you reverse the hash function of the Semantic Tags?

-Hideaki

---

<div class="post-metadata">

**Author:** ![mart.ratas](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mart.ratas](https://discourse.cogstack.org/u/mart.ratas)\
**Post date:** [April 5, 2023, 10:43am UTC](https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165/5 "2023-04-05T10:43:36Z")

</div>

Unfortunately I didn’t do anything that exhaustive.

I just had a bunch of annotated data and ran through the CUIs that were annotated. And I simply extracted the type from the brackets in the names. Though there were sometimes multiple names with bracketed parts so it wasn’t too straight forward.

---

<div class="post-metadata">

**Author:** ![Hideaki](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hideaki](https://discourse.cogstack.org/u/Hideaki)\
**Post date:** [April 7, 2023, 1:10pm UTC](https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165/7 "2023-04-07T13:10:32Z")

</div>

Dear @zeljko, can you help with this?

---

<div class="post-metadata">

**Author:** ![zeljko](https://avatars.discourse-cdn.com/v4/letter/z/7ab992/32.png) [@zeljko](https://discourse.cogstack.org/u/zeljko)\
**Post date:** [April 7, 2023, 1:59pm UTC](https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165/8 "2023-04-07T13:59:08Z")

</div>

Hi @Hideaki,

I’m not sure which CDB are you using, most versions have the following field: `cat.cdb.addl_info['type_id2name']` this is a map from TUI (or type\_id) to the name. Unfortunately not all CDBs have this as we did not have it standardised. If your CDB does not have this field please post the CDB name here and I can try to find the mapping.

---

<div class="post-metadata">

**Author:** ![Hideaki](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@Hideaki](https://discourse.cogstack.org/u/Hideaki)\
**Post date:** [April 10, 2023, 10:34am UTC](https://discourse.cogstack.org/t/using-type-ids-with-the-snomedct-model/165/9 "2023-04-10T10:34:26Z")

</div>

Thank you, @zeljko. I used the cat.cdb.add1\_info[‘type\_id2name’] for my SNOMED-CT cdb. This method generated a dictionary which I used as a lookup operation to populate my dataframe of CUIs and percentage of documents where the CUI is mentioned. Hope i used it correctly
