使用SQL从电子病历中提取研究信息

时间:2012-09-17 11:29:40

标签: sql

我正在尝试从sql获取来自我们电子病历系统comments列的Progress Note table列中的数千条患者记录中的信息。

由于请求的敏感性以及患者可识别信息的问题,我只想从此“comments”列中提取必要的数据,而不会提取可能违反的其他非必要信息患者数据。

在“comments”列(这是一个自由文本列)中包含了一些文本,这些文本是在每位患者看到他们的顾问时写的,例如diagnosis,{{1} }和medication

对于我的研究,我只需要提取那些“评论”栏中包含以下词语的患者:

  

米氮平,精神分裂症和双极

这三个词必须出现在每位患者的每个评论栏中,才能被视为有效用于研究目的。因此,如果其中一个患者评论包括三个关键词中的两个,我将不会使用它(我不希望看到它,因为它将被视为不必要的提取) - 我只想看到任何具有所有这三个关键词的“general notes”。

任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

您可以使用以下内容:

select *
from yourtable t1
where exists (select *
              from yourtable t2
              where comments like '%Mirtazapine%'
                and t1.id = t2.id)
  and exists (select *
              from yourtable t2
              where comments like '%Shcizophrenia%'
                and t1.id = t2.id)
  and exists (select *
              from yourtable t2
              where comments like '%bi-polar%'
                and t1.id = t2.id)

或者:

select *
from yourtable t1
where comments like '%Mirtazapine%'
  and exists (select *
              from yourtable t2
              where comments like '%Shcizophrenia%'
                and t1.id = t2.id)
  and exists (select *
              from yourtable t2
              where comments like '%bi-polar%'
                and t1.id = t2.id)

请参阅SQL Fiddle with Demo