如何从 Snomed Postgres Sql 数据库查找关系

2023-12-24

问题陈述:

从 Snomed CT 数据库中提取所有父母、祖父母、子女和孙子女

描述:

我正在尝试在本地机器上设置 snomed 数据库来提取特定概念的关系(所有父母和孩子)(使用 Concept_id)。

我已经从以下位置下载了 snomed 数据https://download.nlm.nih.gov/umls/kss/IHTSDO20190131/SnomedCT_InternationalRF2_PRODUCTION_20190131T120000Z.zip https://download.nlm.nih.gov/umls/kss/IHTSDO20190131/SnomedCT_InternationalRF2_PRODUCTION_20190131T120000Z.zip

然后我将数据导入到PostgreSQL 数据库使用我在这里找到的脚本https://github.com/IHTSDO/snomed-database-loader/tree/master/PostgreSQL https://github.com/IHTSDO/snomed-database-loader/tree/master/PostgreSQL

但我没有找到这些表之间的任何关系,以便我可以获取特定概念 id 的父母、祖父母、孩子和孙子(我尝试过肺癌 93880001)

Following image contains table structure: enter image description here

我真的很感谢任何帮助或建议。


根据,这可能无法从任何地方访问,93880001 有三个父项:

  • 肺部恶性肿瘤(疾病)
  • 胸内器官原发性恶性肿瘤(病症)
  • 原发性呼吸道恶性肿瘤(疾病)

和31个孩子:

  • 肺实质癌(疾病)
  • 肺上皮样血管内皮瘤(疾病)
  • 肺非霍奇金淋巴瘤(疾病)
  • 非小细胞肺癌(疾病)
  • 等等...

查找层次结构的较高和较低级别的方法是使用relationship_f.sourceid and relationship_f.destinationid。然而,原始表格对用户不友好,所以我建议做一些视图。我从 Oracle .sql 文件中获取了代码this https://github.com/bcarlsenca/SNOMED-DB-Load-Scripts/blob/master/src/main/resources/rf2/oracle_views.sqlGitHub 存储库。

首先,我们创建一个包含概念 ID 和首选名称的视图:

create view conceptpreferredname as
SELECT distinct c.id conceptId, d.term preferredName, d.id descriptionId
FROM postgres.snomedct.concept_f c
inner JOIN postgres.snomedct.description_f d
  ON c.id = d.conceptId
  AND d.active = '1'
  AND d.typeId = '900000000000013009'
inner JOIN postgres.snomedct.langrefset_f l
  ON d.id = l.referencedComponentId
  AND l.active = '1'
  AND l.refSetId = '900000000000508004'  -- GB English
  AND l.acceptabilityId = '900000000000548007';

然后我们来看看关系:

CREATE VIEW relationshipwithnames AS
SELECT id, effectiveTime, active,
    moduleId, cpn1.preferredName moduleIdName,
    sourceId, cpn2.preferredName sourceIdName,
    destinationId, cpn3.preferredName destinationIdName,
    relationshipGroup,
    typeId, cpn4.preferredName typeIdName,
    characteristicTypeId, cpn5.preferredName characteristicTypeIdName,
    modifierId, cpn6.preferredName modifierIdName
from postgres.snomedct.relationship_f relationship,
    conceptpreferredname cpn1,
    conceptpreferredname cpn2,
    conceptpreferredname cpn3,
    conceptpreferredname cpn4,
    conceptpreferredname cpn5,
    conceptpreferredname cpn6
WHERE moduleId = cpn1.conceptId
AND sourceId = cpn2.conceptId
AND destinationId = cpn3.conceptId
AND typeId = cpn4.conceptId
AND characteristicTypeId = cpn5.conceptId
AND modifierId = cpn6.conceptId;

因此,打印三个父概念的名称和 ID 的查询将是:

select *
from relationshipwithnames r
where r.sourceId = '93880001'
and r.active = '1'
and r.typeIdName = 'Is a';

请注意,这实际上返回了三个额外的概念,在线 SNOMED 浏览器认为这些概念已经过时。我不知道为什么。

要打印子概念的名称和 ID,请替换destinationId with sourceId:

select *
from relationshipwithnames r
where r.destinationId = '93880001'
and r.active = '1'
and r.typeIdName = 'Is a';

请注意,这实际上返回了 16 个额外的概念,在线 SNOMED 浏览器认为这些概念已经过时。同样,我找不到可靠的方法来从结果中仅排除这十六个。

从这里开始,查询祖父母和孙子女就很简单了。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何从 Snomed Postgres Sql 数据库查找关系 的相关文章

随机推荐