Skip to content

Read the characterization explore concept hierarchy from the vocabulary daimon - #2601

Open
DG47 wants to merge 1 commit into
OHDSI:masterfrom
DG47:fix/cc-explore-vocabulary-schema
Open

DG47 wants to merge 1 commit into
OHDSI:masterfrom
DG47:fix/cc-explore-vocabulary-schema

Conversation

@DG47

@DG47 DG47 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #2600

What was wrong

The Explore panel of a characterization report (GET /cohort-characterization/generation/{id}/explore/prevalence/{analysisId}/{cohortId}/{covariateId}) lists the ancestors and descendants of a covariate's concept. Its query, cohortcharacterizations/sql/queryCovariateStatsVocab.sql, joined concept and concept_ancestor through @cdm_database_schema, which CcServiceImpl.getPrevalenceStatsByGenerationId filled with the CDM daimon's qualifier. On a source whose Vocabulary daimon points at a different schema than the CDM daimon, the query failed with relation "<cdm>.concept_ancestor" does not exist, so Explore returned a server error for every covariate. The report itself was fine, because queryResults.sql already reads concept names from the vocabulary schema.

What changed

  • queryCovariateStatsVocab.sql reads concept and concept_ancestor through @vocabulary_database_schema. SourceAwareSqlRender already fills that parameter from the Vocabulary daimon, and Source.getTableQualifierOrNull falls back to the CDM daimon when a source has no Vocabulary daimon, so single-schema sources behave as before.
  • CcServiceImpl no longer passes the CDM qualifier to this query, since it no longer uses it.

This is the same change #2556 made for the person profile queries.

How it was tested

New CcPrevalenceStatsVocabularyTest runs getPrevalenceStatsByGenerationId on the embedded Postgres database with cc_results, concept and concept_ancestor rows for a small diabetes hierarchy:

  • separate CDM and vocabulary schemas: fails on master with relation "cc_explore_cdm.concept_ancestor" does not exist, passes with this change
  • a single schema and no Vocabulary daimon: passes before and after

Full unit suite (mvn -DskipUnitTests=false -DskipITtests=true test, JDK 21): Tests run: 176, Failures: 0, Errors: 0, Skipped: 5.

…ry daimon

The Explore panel of a characterization report (GET /cohort-characterization
/generation/{id}/explore/prevalence/{analysisId}/{cohortId}/{covariateId})
lists the ancestors and descendants of a covariate's concept. Its query,
queryCovariateStatsVocab.sql, joined concept and concept_ancestor through
@cdm_database_schema, which CcServiceImpl filled with the CDM daimon's
qualifier. On a source whose Vocabulary daimon points at a different schema
than the CDM daimon, the query failed with "relation <cdm>.concept_ancestor
does not exist", so Explore returned a server error for every covariate,
even though the report itself (queryResults.sql) already reads concept
names from the vocabulary schema.

Read both tables through @vocabulary_database_schema, which
SourceAwareSqlRender fills from the Vocabulary daimon and which falls back
to the CDM daimon when the source has none, and drop the CDM qualifier the
query no longer uses. This is the same change OHDSI#2556 made for the person
profile queries.

Adds a test that runs Explore on the embedded Postgres database for a
source with separate CDM and vocabulary schemas, and for a source with no
Vocabulary daimon.
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.

Characterization Explore fails with "concept_ancestor does not exist" when the Vocabulary daimon is a separate schema

1 participant