Skip to content

Read the Data Sources visit length of stay from Achilles analysis 213 - #2583

Open
DG47 wants to merge 1 commit into
OHDSI:masterfrom
DG47:fix/visit-length-of-stay-analysis-213
Open

DG47 wants to merge 1 commit into
OHDSI:masterfrom
DG47:fix/visit-length-of-stay-analysis-213

Conversation

@DG47

@DG47 DG47 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #2582

Achilles 1.7 (August 2022) renumbered "Distribution of length of stay by visit_concept_id" from analysis 211 to analysis 213 and reused 211 for "Number of visit records with end date < start date", a plain count that is written to achilles_results, not achilles_results_dist:

Achilles 211 213
1.6.x Distribution of length of stay by visit_concept_id (achilles_results_dist) -
1.7.0+ Number of visit records with end date < start date (achilles_results) Distribution of length of stay by visit_concept_id (achilles_results_dist)

cdmresults/sql/report/visit/drilldown/visitDurationByType.sql and cdmresults/sql/report/visit/drilldownsummary/visitDurationByType.sql still read analysis 211 from achilles_results_dist, so for any source characterized with Achilles 1.7 or later GET /cdmresults/{sourceKey}/visit/{conceptId} and GET /cdmresults/{sourceKey}/visit return an empty visitDurationByType array, and the Achilles cache warm-up (AchillesCacheTasklet lists visitDurationByType for the visit domain) caches that empty result.

Changes:

  • Accept analysis 213 in both queries. Analysis 211 is kept so results produced by Achilles 1.6.x and earlier keep working; in a 1.7+ results schema 211 never appears in achilles_results_dist, so the two cannot both match.
  • Add CDMResultsVisitDurationTest, which runs the visit drilldown and drilldown summary queries through CDMResultsAnalysisRunner.getDrilldown against the embedded Postgres database with a 213 row and a legacy 211 row. Two of the three tests fail on master.

The change is a plain IN (211, 213) list, so SqlRender translation is unaffected for the other dialects.

Testing:

  • mvn -DskipUnitTests=false -Dtest='CDMResultsVisitDurationTest,CDMResultsTreemapTest,CDMResultsAnalysisRunnerTest' -Dmaven.gitcommitid.skip=true -Pwebapi-postgresql test (JDK 21): 5 tests, 0 failures.

Achilles 1.7 renumbered "Distribution of length of stay by
visit_concept_id" from analysis 211 to 213 and reused 211 for the count
of visit records with an end date before the start date, which is
written to achilles_results rather than achilles_results_dist. The visit
drilldown and drilldown summary queries still read analysis 211 from
achilles_results_dist, so the visit duration box plot in the Data
Sources visit report has been empty for every source characterized with
Achilles 1.7 or later.

Accept analysis 213 in both queries and keep 211 so results produced by
older Achilles versions keep working.

Adds a test that runs the visit drilldown and drilldown summary queries
against the embedded Postgres database with a 213 row and a legacy 211
row.
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.

Data Sources visit drilldown returns an empty visitDurationByType for Achilles 1.7+ results (query still reads analysis 211)

1 participant