Cohort sample with age "not between" includes people from other cohorts and ignores the gender filter
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
調査の方向性
CohortSamplingService.sampleElements と generateSample.sql を読みます。issue では notBetween フィルターと、生成される WHERE 句が示されています。コホートサンプリングの既存テストを確認し、コホートへの所属と、年齢モードが "not between" の場合の性別フィルターをカバーするテストを追加します。サンプルに選択したコホートの対象だけが含まれ、選択した性別が反映されれば完了です。issue ではテストファイルは指定されていません。
索引モデルが issue の本文から書いたものです。
説明
Expected behavior
Creating a cohort sample (POST /cohortsample/{cohortDefinitionId}/{sourceKey}, the "Samples" tab of a cohort definition in ATLAS) with the age mode "not between" and a minimum and maximum age should only draw people from that cohort whose age at cohort start is below the minimum or above the maximum, and should still apply the selected gender filter.
Actual behavior
CohortSamplingService.sampleElements builds the filter for notBetween as
expressionBuilder.append(" AND age > @age_max OR age < @age_min");
and appends it after WHERE cohort_definition_id = @cohort_definition_id in generateSample.sql. Because AND binds tighter than OR, the condition becomes
WHERE (cohort_definition_id = @cohort_definition_id AND age > @age_max)
OR (age < @age_min AND gender_concept_id IN (...))
so the sample:
- draws people younger than the minimum age from every cohort in the results schema's
cohorttable, not only the selected cohort, and - draws people older than the maximum age regardless of the gender filter.
The other age modes (lessThan, between, ...) are not affected.
Steps to reproduce behavior
With a results schema cohort table and a CDM person table on PostgreSQL (all cohort entries start on 2020-06-01, so age = 2020 - year_of_birth):
| person_id | gender_concept_id | year_of_birth | age | cohort_definition_id |
|---|---|---|---|---|
| 1 | 8507 | 2010 | 10 | 1 |
| 2 | 8532 | 1970 | 50 | 1 |
| 3 | 8532 | 1940 | 80 | 1 |
| 4 | 8507 | 1935 | 85 | 1 |
| 5 | 8532 | 2015 | 5 | 2 |
| 6 | 8532 | 1930 | 90 | 2 |
- Create a sample of cohort 1 with age "not between" 20 and 60 and no gender filter. Expected people 1, 3, 4; actual 1, 3, 4, 5 (person 5 is only in cohort 2).
- Create a sample of cohort 1 with age "not between" 20 and 60 and gender female. Expected person 3; actual 3, 4 (male), 5 (cohort 2).
The WHERE clause of generateSample.sql for step 2, before translation:
WHERE cohort_definition_id = @cohort_definition_id
AND age > @age_max OR age < @age_min AND gender_concept_id IN (8532)
Environment
WebAPI master (3.0.1-SNAPSHOT, 89de588d); the same code is in v2.15.1. ATLAS offers "not between" in the sample age options (cohort-definition-manager.js). Reproduced on PostgreSQL; the precedence is the same on every supported dialect.
- 主要言語
- Java
- スター
- 153
- フォーク
- 186
- 平均マージ
- 2日 19時間
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OHDSI/WebAPI のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
CDM cache warming issues one record-count query per concept on Snowflake, Spark and BigQuery (getConceptsForBatch.sql relies on integer division)対応中かも @DG47 が今日担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
GET /conceptset/{id}/expression returns items in nondeterministic order (query has no ORDER BY)オープン
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
OHDSI/WebAPI#2543 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
OHDSI/WebAPI#2513 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
jakartaee/expression-language#501 ·
メンテナーはふだん 7 日以内に返信
-
enhancement triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
ShaftHQ/SHAFT_ENGINE#7902 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
Filter.toString() throws IllegalFormatConversionException for withinGeoRange filters対応中かも @dudanogueira が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
weaviate/java-client#638 ·