Skip to content

Implement hasValue - #113

Open
FikriMilano wants to merge 5 commits into
ohs-foundation:mainfrom
FikriMilano:has-value
Open

Implement hasValue#113
FikriMilano wants to merge 5 commits into
ohs-foundation:mainfrom
FikriMilano:has-value

Conversation

@FikriMilano

@FikriMilano FikriMilano commented Aug 3, 2026

Copy link
Copy Markdown
Member

In FHIR, a primitive field can be present but empty: the element carries only an id or an extension and no actual value, e.g. a given name whose content comes only from _given. hasValue() answers whether a single primitive element actually contains its value. (https://hl7.org/fhir/R4/fhirpath.html#functions)

Everything else is false: an extension-only element, a complex type (the function only applies to primitives), and empty or multi-item input, following the spec wording "contains a single value which is a FHIR primitive".

  • Fixes testPeriodInvariantOld and testPrimitiveExtensions

  • Enable the conformance runner's input lookup to answer both xml and json, instead of just xml, testPrimitiveExtensions (and even other test cases) inputFile carries json instead of xml

  • Adds missing patient-name-extensions.json input file

  • Skips testStartsWithNonString1, testEndsWithNonString1 and testContainsNonString1 with reason: their input resource is also missing from the vendored copy, so they only passed because the missing-input crash satisfied their expected-error assertion. With the input present they need the engine to throw a singleton evaluation error for the non-string input (in their case, complex type), which it currently returns empty list.

@FikriMilano
FikriMilano requested a review from jingtang10 August 3, 2026 10:23
@FikriMilano FikriMilano self-assigned this Aug 3, 2026
@FikriMilano
FikriMilano requested a review from a team August 3, 2026 10:23
@FikriMilano FikriMilano moved this from Todo to In Progress in FHIR Foundations Aug 3, 2026
// primitive" - two items fail that, they do not error.
assertEquals(
listOf(false),
fhirPathEngine.evaluateExpression("(1 | 2).hasValue()", observation).toList(),

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.

Could it be that they evaluate to false since the 1 and 2 are treated as FhirPath literals? That would make this test vague, I think

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.

Could you also add a test for a primitive with id and extension but no value?

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