Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RxNorm Extension buider changes #421

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 5 additions & 41 deletions working/Build_RxE.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,44 +122,7 @@ JOIN concept c ON c.concept_id = r.concept_id_2
'RxNorm',
'RxNorm Extension',
'UCUM'
)

UNION ALL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it non-needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we made a mistake in one of the RxE releases there's no chance to fix it.
Anyway, when we populate relationship_to_concept we go through existing mappings and synomyms. So this step not only redundant but dangerous.


SELECT DISTINCT c1.concept_code AS concept_code_1,
c1.vocabulary_id AS vocabulary_id_1,
r.concept_id_2 AS concept_id_2,
1 AS precedence,
NULL::NUMERIC AS conversion_factor
FROM concept c1
JOIN concept_relationship r ON r.concept_id_1 = c1.concept_id
AND r.relationship_id IN (
'Maps to',
'Source - RxNorm eq'
)
AND r.invalid_reason IS NULL
JOIN concept c2 ON c2.concept_id = r.concept_id_2
AND c2.invalid_reason IS NULL
WHERE c1.vocabulary_id = (
SELECT dcs.vocabulary_id
FROM drug_concept_stage dcs LIMIT 1
)
AND c2.vocabulary_id IN (
'RxNorm',
'RxNorm Extension'
)
AND c2.concept_class_id IN (
'Ingredient',
'Dose Form',
'Brand Name',
'Supplier'
)
AND NOT EXISTS (
SELECT 1
FROM relationship_to_concept rtc
WHERE rtc.concept_code_1 = c1.concept_code
);

);
CREATE INDEX idx_rtc ON r_to_c (concept_code_1, concept_id_2);
ANALYZE r_to_c;

Expand Down Expand Up @@ -6408,10 +6371,11 @@ FROM maps_to m
JOIN ex e ON e.concept_id = m.to_id
JOIN r_to_c rtc ON rtc.concept_code_1 = m.from_code
JOIN concept dc ON dc.concept_id = rtc.concept_id_2
WHERE dc.vocabulary_id IN (
WHERE EXISTS (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ой. а разве так работает?
у тебя же внутри подзапроса должно быть условие, связывающее подзапрос с запросом

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, это работает. @ekorchmar посоветовал так сделать.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а он случайно не объяснил, зачем нам подзапрос, который всегда дает true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHERE dc.vocabulary_id = c_int.vocabulary_id

Добавила условие

SELECT c_int.vocabulary_id
FROM concept c_int
WHERE c_int.domain_id = 'Drug'
WHERE dc.vocabulary_id = c_int.vocabulary_id
AND c_int.domain_id = 'Drug'
AND c_int.standard_concept = 'C'
);

Expand Down Expand Up @@ -6710,4 +6674,4 @@ DROP TABLE pack_name;
DROP SEQUENCE omop_seq;
DROP TABLE rl;
DROP TABLE ex;
DROP TABLE xxx_replace;
DROP TABLE xxx_replace;