Skip to content

Commit aca171e

Browse files
committed
Concept Set Source Code Evaluation
1 parent c3c007c commit aca171e

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

src/main/java/org/ohdsi/webapi/service/ConceptSetService.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ public ConceptSetExpression getConceptSetExpression(@PathParam("id") final int i
8484
expression.items = new ConceptSetExpression.ConceptSetItem[map.size()];
8585

8686
// lookup the concepts we need information for
87-
String[] identifiers = new String[map.size()];
87+
long[] identifiers = new long[map.size()];
8888
int identifierIndex = 0;
8989
for (Long identifier : map.keySet()) {
90-
identifiers[identifierIndex] = identifier.toString();
90+
identifiers[identifierIndex] = identifier;
9191
identifierIndex++;
9292
}
9393

src/main/java/org/ohdsi/webapi/service/VocabularyService.java

+5-25
Original file line numberDiff line numberDiff line change
@@ -78,28 +78,17 @@ public Concept mapRow(final ResultSet resultSet, final int arg1) throws SQLExcep
7878
@POST
7979
@Produces(MediaType.APPLICATION_JSON)
8080
@Consumes(MediaType.APPLICATION_JSON)
81-
public Collection<Concept> executeIdentifierLookup(@PathParam("sourceKey") String sourceKey, String[] identifiers) {
81+
public Collection<Concept> executeIdentifierLookup(@PathParam("sourceKey") String sourceKey, long[] identifiers) {
8282
if (identifiers.length == 0) {
8383
return new ArrayList<>();
8484
}
8585

86-
int[] intIdentifiers =new int[identifiers.length];
87-
int i=0;
88-
for(String identifier:identifiers){
89-
try {
90-
intIdentifiers[i]=Integer.parseInt(identifier);
91-
i++;
92-
} catch (NumberFormatException e) {
93-
throw new IllegalArgumentException("Not a number: " + identifier + " at index " + i, e);
94-
}
95-
}
96-
9786
Source source = getSourceRepository().findBySourceKey(sourceKey);
9887
String tableQualifier = source.getTableQualifier(SourceDaimon.DaimonType.Vocabulary);
9988

10089
String sql_statement = ResourceHelper.GetResourceAsString("/resources/vocabulary/sql/lookupIdentifiers.sql");
10190
sql_statement = SqlRender.renderSql(sql_statement, new String[]{"identifiers", "CDM_schema"}, new String[]{
102-
JoinArray(intIdentifiers), tableQualifier});
91+
JoinArray(identifiers), tableQualifier});
10392
sql_statement = SqlTranslate.translateSql(sql_statement, "sql server", source.getSourceDialect());
10493

10594
return getSourceJdbcTemplate(source).query(sql_statement, this.rowMapper);
@@ -146,7 +135,7 @@ public Collection<Concept> executeSourcecodeLookup(@PathParam("sourceKey") Strin
146135
@POST
147136
@Produces(MediaType.APPLICATION_JSON)
148137
@Consumes(MediaType.APPLICATION_JSON)
149-
public Collection<Concept> executeMappedLookup(@PathParam("sourceKey") String sourceKey, String[] identifiers) {
138+
public Collection<Concept> executeMappedLookup(@PathParam("sourceKey") String sourceKey, long[] identifiers) {
150139
if (identifiers.length == 0) {
151140
return new ArrayList<>();
152141
}
@@ -511,16 +500,7 @@ public Collection<Concept> getRelatedConcepts(@PathParam("sourceKey") String sou
511500

512501
ArrayList<String> filterList = new ArrayList<String>();
513502

514-
int[] conceptIds =new int[search.conceptId.length];
515-
int i=0;
516-
for (String conceptId : search.conceptId) {
517-
try {
518-
conceptIds[i] = Integer.parseInt(conceptId);
519-
i++;
520-
} catch (NumberFormatException e) {
521-
throw new IllegalArgumentException("Not a number: " + conceptId + " at index " + i, e);
522-
}
523-
}
503+
long[] conceptIds = search.conceptId;
524504

525505
if (search.vocabularyId != null && search.vocabularyId.length > 0) {
526506
filterList.add("VOCABULARY_ID IN (" + JoinArray(search.vocabularyId) + ")");
@@ -565,7 +545,7 @@ public Void mapRow(ResultSet resultSet, int arg1) throws SQLException {
565545
return concepts.values();
566546
}
567547

568-
private String JoinArray(final int[] array) {
548+
private String JoinArray(final long[] array) {
569549
String result = "";
570550

571551
for (int i = 0; i < array.length; i++) {

src/main/java/org/ohdsi/webapi/vocabulary/RelatedConceptSearch.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ public RelatedConceptSearch() {
2323
public String[] conceptClassId;
2424

2525
@JsonProperty("CONCEPT_ID")
26-
public String[] conceptId;
26+
public long[] conceptId;
2727
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,28 @@
1+
-- get all of the concepts that were part of the list of concepts provided
2+
3+
Select concept_id, concept_name, ISNULL(standard_concept, 'N') standard_concept, ISNULL(invalid_reason, 'V') INVALID_REASON,
4+
CONCEPT_CODE, CONCEPT_CLASS_ID, DOMAIN_ID, VOCABULARY_ID
5+
from concept
6+
where concept_id in (@identifiers)
7+
8+
UNION
9+
10+
--get all source codes that map to the list of concepts provided
11+
112
select CONCEPT_ID, CONCEPT_NAME, ISNULL(STANDARD_CONCEPT,'N') STANDARD_CONCEPT, ISNULL(c.INVALID_REASON,'V') INVALID_REASON, CONCEPT_CODE, CONCEPT_CLASS_ID, DOMAIN_ID, VOCABULARY_ID
213
from @CDM_schema.concept_relationship cr
314
join @CDM_schema.concept c on c.concept_id = cr.concept_id_1
415
where cr.concept_id_2 in (@identifiers)
516
and cr.INVALID_REASON is null
617
and relationship_id in ('Maps to')
7-
and standard_concept IS NULL
18+
19+
UNION
20+
21+
--get anything that may be stashed in the source-to-concept-map table
22+
23+
select 0 as CONCEPT_ID, SOURCE_CODE_DESCRIPTION as CONCEPT_NAME, 'N' as STANDARD_CONCEPT, ISNULL(INVALID_REASON,'V') INVALID_REASON,
24+
SOURCE_CODE as CONCEPT_CODE, NULL as CONCEPT_CLASS_ID, NULL as DOMAIN_ID, SOURCE_VOCABULARY_ID as VOCABULARY_ID
25+
from @CDM_schema.SOURCE_TO_CONCEPT_MAP
26+
where TARGET_CONCEPT_ID in (@identifiers)
27+
and INVALID_REASON is null
828
order by domain_id, vocabulary_id

0 commit comments

Comments
 (0)