问题陈述:
从 Snomed CT 数据库中提取所有的 parent 、祖 parent 、 child 和孙
描述:
我正在尝试在我的本地机器上设置 snomed 数据库,以提取特定概念(使用 concept_id)的关系(所有 parent 和 child )。
我已经从 https://download.nlm.nih.gov/umls/kss/IHTSDO20190131/SnomedCT_InternationalRF2_PRODUCTION_20190131T120000Z.zip 下载了 snomed 数据
然后我使用在这里找到的脚本将数据导入Postgres SQL DB https://github.com/IHTSDO/snomed-database-loader/tree/master/PostgreSQL
但我没有找到这些表之间的任何关系,因此我可以获取特定概念 ID 的 parent 、祖 parent 、子女和孙子女(我尝试使用肺癌 93880001强>)
非常感谢任何帮助或建议。
最佳答案
根据NHS CT Browser ,可能无法从任何地方访问,93880001 有三个 parent :
- 肺部恶性肿瘤(疾病)
- 胸腔内器官原发性恶性肿瘤(疾病)
- 呼吸道原发性恶性肿瘤(疾病)
和 31 个 child :
- 肺实质癌(疾病)
- 肺上皮样血管内皮瘤(疾病)
- 肺非霍奇金淋巴瘤(疾病)
- 非小细胞肺癌(疾病)
- 等等...
查找更高和更低层级的方法是使用relationship_f.sourceid
和relationship_f.destinationid
。但是,原始表格对用户不友好,因此我建议提出一些看法。我从 this 中的 Oracle .sql 文件中获取了代码GitHub repo 。
首先,我们创建一个包含概念 ID 和首选名称的 View :
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';
然后我们做一个关系 View :
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
替换为 sourceId
:
select *
from relationshipwithnames r
where r.destinationId = '93880001'
and r.active = '1'
and r.typeIdName = 'Is a';
请注意,这实际上返回了 16 个额外的概念,在线 SNOMED 浏览器认为这些概念已过时。同样,我找不到可靠的方法来从结果中仅排除这 16 个。
从这里开始,获取祖 parent 和孙子女的查询就很简单了。
关于postgresql - 如何从 Snomed Postgres Sql 数据库中查找关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56951658/