Skip to content

Make it more obvious how to obtain primitive values from FHIRPathSystemValue #2153

@lmsurpre

Description

@lmsurpre

Is your feature request related to a problem? Please describe.
I wrote some code to extract all the resource ids from a bundle via fhirpath, but it took me longer than it should have to figure out how to get the primitive value out of the FHIRPathNode:

        Bundle bundle = load("patients.json");
        Collection<FHIRPathNode> nodes = FHIRPathEvaluator.evaluator().evaluate(bundle,
                "Bundle.entry.resource.id");

        List<Member> members = nodes.stream()
                .filter(node -> node.isSystemValue())
                .map(node -> string("Patient/" + node.howToGetTheValue...

Eventually I found the correct answer:
node.asSystemValue().asStringValue().string()

What tripped me up is that we have a FHIRPathNode.getValue() which I thought would work, but it turns out that actually returns the FHIRPathNode's value (child) when it holds one, not the primitive value of current FHIRPathNode when you already have a FHIRPathSystemValue.

Having this method on instances of FHIRPathSystemValue doesn't make much sense, because FHIRPathSystemValue itself is a terminal node and the getValue() just gets in the way of the actual accessors which don't use get at all.

Describe the solution you'd like

  1. override the getValue() javadoc for FHIRPathSystemValue to indicate that it will always return null.
  2. in the concrete subtypes for FHIRPathSystemValue, add a @see link to the actually getters for the given primitive type

Describe alternatives you've considered

Acceptance Criteria

Additional context

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions