-
Notifications
You must be signed in to change notification settings - Fork 5
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
FI-2750: Add FHIRPath Support #520
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #520 +/- ##
==========================================
+ Coverage 79.83% 79.86% +0.03%
==========================================
Files 252 253 +1
Lines 13305 13351 +46
Branches 1289 1290 +1
==========================================
+ Hits 10622 10663 +41
- Misses 1934 1939 +5
Partials 749 749
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Vanessa Fotso <[email protected]>
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 PR shouldn't be updating package-lock.json
since it doesn't include any front end changes.
# @param resource [FHIR::Model] the root FHIR resource to use when evaluating the fhirpath expression. | ||
# @param path [String] The FHIRPath expression to evaluate. | ||
# @param fhirpath_evaluator [Symbol] the name of the evaluator to use. | ||
# @return [Array] An array representing the result of evaluating the given expression against |
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.
An array of what?
# @param name [Symbol] the name of the fhirpath evaluator, only needed if you are | ||
# using multiple evaluators | ||
# @param url [String] the url of the fhirpath service | ||
def fhirpath_evaluator(name: :default, url: nil) |
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.
Is there a reason why test writers would need to have multiple fhirpath services? I was really hoping this would just work out of the box without having to define fhirpath services.
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.
updated
# | ||
# results will be an array representing the result of evaluating the given | ||
# expression against the given root element. Each "result" in the returned | ||
# array will be in the form `{ "type": "[FHIR datatype name]", "element": [JSON representation of element] }`. |
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.
Would it be possible/desireable to instantiate the element from FHIR::Models rather than than using the JSON representation of the element?
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 result types of a FHIRPath expression are unpredictable as they depend on the specific query or expression being evaluated. The element
value can be anything from a primitive type to a complex FHIR data type. element
is either a primitive value or a JSON representation of a FHIR element. Transforming element
into a FHIR::Model
only makes sense when the returned value is consistently a FHIR element, which is not always the case.
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.
But why doesn't representing that value as a FHIR model make sense, while representing it as JSON does make sense?
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 value of element is not always a json. I should update the description of the element
key because it is confusing. The description should be something like primitive value or JSON representation of FHIR element
or simply the result value of the FHIRPath expression
.
These are the examples of results depending on the expression we are evaluating:
path = Patient.gender='female'
result = [ {"type": "boolean", "element": true }]
path = Patient.name.given
result = [
{
"type": "string",
"element": "patient"
},
{
"type": "string",
"element": "sample"
}
]
path = Patient.name
result = [
{
"type": "HumanName",
"element": {
"use": "official",
"family": "Chalmers",
"given": [
"patient",
"sample"
]
}
}
]
I am not sure if you want to add condition handling to transform to FHIR model when the value is a fhir element.
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.
Right, it isn't always JSON. You always have to check the type.
We use fhir_models
widely throughout Inferno, so given these two options:
- Return a primitive or a Hash for complex types
- Return a primitive or a FHIR model instance for complex types
I'm wondering if there are technical reasons not to return a FHIR models instance here.
We generally expect (and encourage) test authors to use FHIR models to represent resources (e.g. in the first parameter of evaluate_fhirpath
), so why not use them here?
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.
updated
Signed-off-by: Vanessa Fotso <[email protected]>
Signed-off-by: Vanessa Fotso <[email protected]>
Signed-off-by: Vanessa Fotso <[email protected]>
Signed-off-by: Vanessa Fotso <[email protected]>
Signed-off-by: Vanessa Fotso <[email protected]>
Signed-off-by: Vanessa Fotso <[email protected]>
Signed-off-by: Vanessa Fotso <[email protected]>
Signed-off-by: Vanessa Fotso <[email protected]>
Signed-off-by: Vanessa Fotso <[email protected]>
Co-authored-by: Stephen MacVicar <[email protected]>
Summary
This PR introduces FHIRPath support, enabling evaluation of FHIRPath expressions on FHIR resources using an external FHIRPath service. The new functionality allows tests to evaluate expressions and receive results from a configurable FHIRPath evaluator.