forked from MIT-LCP/mimic-omop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
etl.sql
64 lines (64 loc) · 1.53 KB
/
etl.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
with
"note_section" as
(
select
noteevents.mimic_id as note_id
, nextval('mimic_id_seq') as note_nlp_id
--, coalesce(concept.concept_id, 0) as section_concept_id
, 0 as section_concept_id
, section_begin as offset_begin
, section_end as offset_end
, section_text as lexical_variant
, 'UIMA Section Extractor v1.0'::text as nlp_system
, now()::date as nlp_date
, now() as nlp_datetime
, concept.concept_name as section_source_value
, concept.concept_id as section_source_concept_id
from :OMOP_SCHEMA.tmp_note_nlp
join noteevents using (row_id)
left join gcpt_note_section_to_concept ON section_code = section_id -- the local section
left join :OMOP_SCHEMA.concept
ON label_mapped = concept_name
AND concept_code = 'MIMIC Generated'
AND domain_id = 'Note Nlp'
WHERE iserror IS NULL
)
INSERT INTO :OMOP_SCHEMA.note_nlp
(
note_nlp_id
, note_id
, section_concept_id
, snippet
, lexical_variant
, note_nlp_concept_id
, note_nlp_source_concept_id
, nlp_system
, nlp_date
, nlp_datetime
, term_exists
, term_temporal
, term_modifiers
, offset_begin
, offset_end
, section_source_value
, section_source_concept_id
)
SELECT
note_nlp_id
, note_id
, section_concept_id
, null::text as snippet
, lexical_variant
, 4307844 as note_nlp_concept_id --document section
, 0 as note_nlp_source_concept_id -- 0
, nlp_system
, nlp_date
, nlp_datetime
, null::text as term_exists
, null::text as term_temporal
, null::text as term_modifiers
, offset_begin
, offset_end
, section_source_value
, section_source_concept_id
FROM note_section;