Skip to content

Only match a numeric vocabulary search against concept_id when it fits in an INT - #2602

Open
chenyangsu wants to merge 1 commit into
OHDSI:masterfrom
chenyangsu:fix/vocab-search-large-numeric-query
Open

chenyangsu wants to merge 1 commit into
OHDSI:masterfrom
chenyangsu:fix/vocab-search-large-numeric-query

Conversation

@chenyangsu

Copy link
Copy Markdown

When the vocabulary search term is all digits, prepareExecuteSearch adds or CONCEPT_ID = CAST(@query as int). A term longer than an INT, such as the 11-digit NDC code 50090347201, makes that cast fail on PostgreSQL:

POST /WebAPI/vocabulary/{sourceKey}/search   {"QUERY":"50090347201","DOMAIN_ID":["Drug"]}
409 {"message":"ERROR: value \"50090347201\" is out of range for type integer"}

The GET form (/search?query=50090347201), which ATLAS uses for a search without filters, runs the same SQL through DatabaseSearchProvider, and its handler logs the exception and returns []. Either way the concept with that concept_code is not found.

This change adds the concept_id clause only when the term parses as an int, so a longer number is still matched against concept_name and concept_code. If you would rather cast to BIGINT in the SQL, I can switch; that version still fails for terms of 20 or more digits.

Testing: the new VocabularySearchNumericQueryTest runs the search SQL on the embedded PostgreSQL; 2 of its 3 tests fail on master with the error above. ./mvnw test: 179 unit tests, 0 failures, 5 skipped; 35 integration tests, 0 failures, 3 skipped.

…s in an INT

A numeric search term is also compared with CAST(@query as int). A term
longer than an INT, such as an 11-digit NDC code, made the cast fail, so
the search returned an error (POST) or no rows (GET) instead of matching
the code by name and concept_code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant