-
Notifications
You must be signed in to change notification settings - Fork 35
FI-930: Support FHIRPath for generating searches #490
Conversation
lib/app/sequence_base.rb
Outdated
@@ -743,6 +743,8 @@ def check_resource_against_profile(resource, resource_type, specified_profile = | |||
end | |||
|
|||
def resolve_path(elements, path) | |||
return Inferno::FHIRPATH_EVALUATOR.evaluate(elements, path) if Inferno::FHIRPATH_EVALUATOR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validator example avoids these if statements by having two versions of the validator. I think the remaining logic in this method should be moved to an internal fhirpath evaluator so that these methods can just call a method on whichever evaluator was instantiated at boot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know if resolve_element_from_path
is the same as calling resolve_path
and returning the first element that satisfies the block predicate (if it exists)? I think that resolve_element_from_path
does some short-circuiting to skip unnecessary computation, but other than that, should the result be the same?
I wanted to ask before I make a common interface between the internal and external FHIRPath evaluator because I want to know if there's anything wrong with defining resolve_element_from_path
in terms of resolve_path
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure. @czh-orz ?
lib/app/sequence_base.rb
Outdated
@@ -754,6 +756,11 @@ def resolve_path(elements, path) | |||
end | |||
|
|||
def resolve_element_from_path(element, path) | |||
if Inferno::FHIRPATH_EVALUATOR | |||
elements = Inferno::FHIRPATH_EVALUATOR.evaluate(element, path) | |||
return block_given? ? elements.find { |el| yield(el) } : elements.first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is behavior we need the evaluator to perform, I think it belongs there as a separate method rather than here.
end | ||
|
||
# @param fhirpath_url [String] the base url for the FHIRPath /evaluate endpoint | ||
def initialize(fhirpath_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking over this branch is exposing some issues that are also present in the validator implementation. This class (as well as both of the validator classes) has no non-global state, so it could just be a module instead. This isn't necessarily something that needs fixing, just something that jumped out at me.
3ef696e
to
6ff4b5b
Compare
bf1ccf4
to
02a34e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking pretty good. Still need to do some testing, which I won't be able to get to until tomorrow.
Yes, I came across that issue as well. It seems to be non-deterministic which outcome happens, and I was able to reproduce that skip result on development by re-running the test multiple times. |
a771fb3
to
a40c0fd
Compare
FI-930: SearchParameters that have complicated FHIRPath expressions (e.g. use descendants() or |) cannot be generically processed by Inferno. Inferno uses the FHIRPath in order to determine the value of the searchParameter to be used in the search and validate that the results returned conform to the value.
This PR creates a
FHIRPathEvaluator
class that posts elements to the FHIRPath endpoint. It also adds two new config options,fhirpath_evaluator
andexternal_fhirpath_evaluator_url
, which are analogous to theresource_validator
andexternal_resource_validator_url
config options. Whenfhirpath_evaluator
is set toexternal
, POST requests will be made to the FHIRPath endpoint in order to resolve FHIRPath expressions against a given complex datatype.The goal was to substitute out the logic that was previously
resolve_path
andresolve_element_from_path
with a more complete FHIRPath solution. This allows us to remove some of the FHIRPath patching (e.g. removing.as()
and truncating the path) that was done in the sequences. However, one patch that has not been removed is.where(resolve() ...)
because the external FHIRPath evaluator does not know how to resolve references of the form[Resource]/[id]
.NOTE: This PR requires running wrapper/FI-931-add-fhirpath-endpoint locally to work.UPDATE: this is no longer true; you will just have to re-pull themaster
branch off-v-w
and rebuild.Submitter:
Reviewer 1:
Name:
where appropriate, and accomplishes the task's purpose
Reviewer 2:
Name:
where appropriate, and accomplishes the task's purpose