Skip to content

Implement comparable - #110

Open
FikriMilano wants to merge 1 commit into
ohs-foundation:mainfrom
FikriMilano:comparable
Open

Implement comparable#110
FikriMilano wants to merge 1 commit into
ohs-foundation:mainfrom
FikriMilano:comparable

Conversation

@FikriMilano

Copy link
Copy Markdown
Member

Implements the comparable(quantity) function.

comparable() does not compare amounts. It checks whether these two quantities can be compared at all.

  • Two masses can (80 'kg' and 1 'g' are both masses, so true, regardless of the numbers)
  • A mass and a time cannot (1 'cm' vs 1 's' is false).

The function predicts the = and > operators, not the ~ equivalence operator (https://build.fhir.org/ig/HL7/FHIRPath/#fn-comparable).

This matters for calendar units: a calendar year is equivalent to the UCUM year 1 'a', but not comparable to it, because 1 year = 1 'a' is empty per the spec (https://hl7.org/fhirpath/N1/#time-valued-quantities).

@FikriMilano
FikriMilano requested a review from jingtang10 August 1, 2026 07:53
@FikriMilano FikriMilano self-assigned this Aug 1, 2026
@FikriMilano
FikriMilano requested a review from a team August 1, 2026 07:53
@FikriMilano FikriMilano moved this from Todo to In Progress in FHIR Foundations Aug 1, 2026
params.singleOrNull()?.toFhirPathType(fhirPathTypeResolver) as? FhirPathQuantity
?: return emptyList()

val leftUnit = left.toEqualCanonicalized().unit ?: return emptyList()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should it return emptyList() or listOf(false)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants