Skip to content

Introduce MeasureReference sealed interface#979

Merged
JPercival merged 4 commits intomainfrom
measure-reference
Mar 26, 2026
Merged

Introduce MeasureReference sealed interface#979
JPercival merged 4 commits intomainfrom
measure-reference

Conversation

@JPercival
Copy link
Copy Markdown
Contributor

Replace Either3<CanonicalType, IdType, Measure> and the three-separate-lists pattern (List, List, List) with a single sealed type:

sealed interface MeasureReference {
record ById(IIdType id)
record ByIdentifier(String identifier)
record ByCanonicalUrl(String url)
}

HAPI providers convert at the boundary via fromOperationParams(). R4MeasureServiceUtils.getMeasures() dispatches on the sealed type. R4CareGapsParameters uses List instead of 3 fields. R4MultiMeasureService, R4CareGapsProcessor accept List. R4CareGapsService.liftMeasureParameters() deleted -- boundary conversion now happens once in the transport layer.
R4CollectDataService reads Measure directly via repository.read() instead of wrapping in Either3.

The type is self-documenting: a measure can be referenced by ID, identifier, or canonical URL. Compiler enforces exhaustive handling.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 25, 2026

Formatting check succeeded!

@JPercival JPercival force-pushed the measure-reference branch 2 times, most recently from 9e6dfc0 to 74d1ea6 Compare March 25, 2026 14:39
Copy link
Copy Markdown
Contributor

@lukedegruchy lukedegruchy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with the caveat that it will require a lot of code to change downstream just to compile.

Replace Either3<CanonicalType, IdType, Measure> and the three-separate-lists
pattern (List<IdType>, List<String>, List<String>) with a single sealed type:

  sealed interface MeasureReference {
      record ById(IIdType id)
      record ByIdentifier(String identifier)
      record ByCanonicalUrl(String url)
  }

HAPI providers convert at the boundary via fromOperationParams().
R4MeasureServiceUtils.getMeasures() dispatches on the sealed type.
R4CareGapsParameters uses List<MeasureReference> instead of 3 fields.
R4MultiMeasureService, R4CareGapsProcessor accept List<MeasureReference>.
R4CareGapsService.liftMeasureParameters() deleted -- boundary conversion
now happens once in the transport layer.
R4CollectDataService reads Measure directly via repository.read() instead
of wrapping in Either3.

The type is self-documenting: a measure can be referenced by ID,
identifier, or canonical URL. Compiler enforces exhaustive handling.
@JPercival JPercival enabled auto-merge (squash) March 26, 2026 20:55
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
61.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@JPercival JPercival merged commit df8ae73 into main Mar 26, 2026
7 of 9 checks passed
@JPercival JPercival deleted the measure-reference branch March 26, 2026 21:07
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.

2 participants