-
Notifications
You must be signed in to change notification settings - Fork 168
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
Non-Standard to Standard Concepts mapping API #2407
Open
alex-odysseus
wants to merge
3
commits into
master
Choose a base branch
from
concepts-mapping
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/org/ohdsi/webapi/vocabulary/MappedRelatedConcept.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.ohdsi.webapi.vocabulary; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Set; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class MappedRelatedConcept extends RelatedConcept { | ||
@JsonProperty("mapped_from") | ||
public Set<Long> mappedFromIds; | ||
} |
18 changes: 18 additions & 0 deletions
18
...gresql/V2.15.0.20241009000001__add_related_standard_concepts_permission_if_not_exists.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
INSERT INTO ${ohdsiSchema}.sec_permission (id, value, description) | ||
SELECT nextval('${ohdsiSchema}.sec_permission_id_seq'), 'vocabulary:*:related-standard:post', 'Access related mapped standard concepts resource' | ||
WHERE NOT EXISTS ( | ||
SELECT NULL FROM ${ohdsiSchema}.sec_permission | ||
WHERE value = 'vocabulary:*:related-standard:post' | ||
); | ||
|
||
INSERT INTO ${ohdsiSchema}.sec_role_permission(id, role_id, permission_id) | ||
SELECT nextval('${ohdsiSchema}.sec_role_permission_sequence'), sr.id, sp.id | ||
FROM ${ohdsiSchema}.sec_permission SP, ${ohdsiSchema}.sec_role sr | ||
WHERE sp.value IN ( | ||
'vocabulary:*:related-standard:post' | ||
) AND sr.name IN ('Atlas users') | ||
AND NOT EXISTS ( | ||
SELECT NULL FROM ${ohdsiSchema}.sec_role_permission | ||
WHERE permission_id = sp.id and role_id = sr.id); | ||
|
||
|
44 changes: 44 additions & 0 deletions
44
src/main/resources/resources/vocabulary/sql/getRelatedStandardMappedConcepts.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
SELECT | ||
c.CONCEPT_ID, | ||
c.CONCEPT_NAME, | ||
COALESCE(c.STANDARD_CONCEPT, 'N') as STANDARD_CONCEPT, | ||
COALESCE(c.INVALID_REASON, 'V') as INVALID_REASON, | ||
c.CONCEPT_CODE, | ||
c.CONCEPT_CLASS_ID, | ||
c.DOMAIN_ID, | ||
c.VOCABULARY_ID, | ||
c.VALID_START_DATE, | ||
c.VALID_END_DATE, | ||
c.RELATIONSHIP_NAME, | ||
c.RELATIONSHIP_DISTANCE | ||
FROM ( | ||
SELECT | ||
c.CONCEPT_ID, CONCEPT_NAME, COALESCE(c.STANDARD_CONCEPT, 'N') as STANDARD_CONCEPT, COALESCE(c.INVALID_REASON, 'V') as INVALID_REASON, | ||
c.CONCEPT_CODE, c.CONCEPT_CLASS_ID, c.DOMAIN_ID, c.VOCABULARY_ID, c.VALID_START_DATE, c.VALID_END_DATE, | ||
r.RELATIONSHIP_NAME, 1 as RELATIONSHIP_DISTANCE | ||
FROM | ||
@CDM_schema.concept_relationship cr | ||
JOIN | ||
@CDM_schema.concept c ON cr.CONCEPT_ID_2 = c.CONCEPT_ID | ||
JOIN | ||
@CDM_schema.relationship r ON cr.RELATIONSHIP_ID = r.RELATIONSHIP_ID | ||
WHERE | ||
cr.CONCEPT_ID_1 IN (@conceptIdList) | ||
AND COALESCE(c.STANDARD_CONCEPT, 'N') IN ('S', 'C') | ||
AND cr.INVALID_REASON IS NULL | ||
) c | ||
GROUP BY | ||
c.CONCEPT_ID, | ||
c.CONCEPT_NAME, | ||
c.STANDARD_CONCEPT, | ||
c.INVALID_REASON, | ||
c.CONCEPT_CODE, | ||
c.CONCEPT_CLASS_ID, | ||
c.DOMAIN_ID, | ||
c.VOCABULARY_ID, | ||
c.VALID_START_DATE, | ||
c.VALID_END_DATE, | ||
c.RELATIONSHIP_NAME, | ||
c.RELATIONSHIP_DISTANCE | ||
ORDER BY | ||
c.RELATIONSHIP_DISTANCE ASC; |
20 changes: 20 additions & 0 deletions
20
.../resources/resources/vocabulary/sql/getRelatedStandardMappedConcepts_getMappedFromIds.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
SELECT | ||
c.CONCEPT_ID, | ||
c.MAPPED_FROM_ID | ||
FROM ( | ||
SELECT DISTINCT | ||
c.CONCEPT_ID, | ||
CAST(cr.CONCEPT_ID_1 AS VARCHAR) as MAPPED_FROM_ID | ||
FROM | ||
@CDM_schema.concept_relationship cr | ||
JOIN | ||
@CDM_schema.concept c ON cr.CONCEPT_ID_2 = c.CONCEPT_ID | ||
JOIN | ||
@CDM_schema.relationship r ON cr.RELATIONSHIP_ID = r.RELATIONSHIP_ID | ||
WHERE | ||
cr.CONCEPT_ID_1 IN (@conceptIdList) | ||
AND COALESCE(c.STANDARD_CONCEPT, 'N') IN ('S', 'C') | ||
AND cr.INVALID_REASON IS NULL | ||
) c | ||
ORDER BY | ||
c.CONCEPT_ID; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query seems a bit off - why does it require a GROUP BY when there is no aggregation done in the outermost query? Should the
1 as RELATIONSHIP_DISTANCE
be summed?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could work the same as a select distinct...