Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
lmsurpre opened this issue Mar 26, 2021 · 0 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@lmsurpre
Copy link
Member

lmsurpre commented Mar 26, 2021

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

@prb112 prb112 added the enhancement New feature or request label Mar 26, 2021
JohnTimm added a commit that referenced this issue Mar 26, 2021
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
JohnTimm added a commit that referenced this issue Mar 26, 2021
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
JohnTimm added a commit that referenced this issue Mar 26, 2021
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
JohnTimm added a commit that referenced this issue Mar 26, 2021
Issue #2153 - introduce system value base class, update javadoc
@lmsurpre lmsurpre added this to the Sprint 2021-04 milestone Mar 26, 2021
lmsurpre added a commit that referenced this issue May 5, 2022
I also updated the javadoc (relates to #2153) because the user was
confused about the FHIRPathNode API and I thought it could use further
clarification.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants