-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Non-Standard to Standard Concepts mapping API (#2407)
* Batch operation for fetching related standard concepts with reverse mappings * Optimized SQL for fetching related standard concepts, eliminated vendor-specific string aggregating function * Renaming the migration script * Update git actions to use cache@v4. --------- Co-authored-by: oleg-odysseus <[email protected]> Co-authored-by: Chris Knoll <[email protected]>
- Loading branch information
1 parent
df5175c
commit 17cbf89
Showing
7 changed files
with
173 additions
and
5 deletions.
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
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
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; |