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

feature: Group by and having statement in FHIR Path #4

Closed
mertgencturk opened this issue Jul 13, 2020 · 1 comment
Closed

feature: Group by and having statement in FHIR Path #4

mertgencturk opened this issue Jul 13, 2020 · 1 comment

Comments

@mertgencturk
Copy link

Feature Request

Describe the Feature Request
I would like to have a list of patients having more than two chronic conditions. I am able to retrieve conditions from repository through FHIR query. What I need more is to group conditions by their subject and keep the ones having at least two condition resources.

Is your feature request related to a problem? Please describe
No.

@tnamli
Copy link
Contributor

tnamli commented Sep 22, 2020

We have implemented a FHIR path function with the following signature;

groupBy(groupingExpr: expression, aggregationExpr: expression)

The 'groupingExpr' is an expression that returns a key value for each item in the collection. Then items in the input collection are grouped based on the equality of these keys.

The 'aggregationExpr' is an expression that returns an aggregation value from the grouped items. The result is a JSON array that contains a JSON object for each group with the following elements;

  • "bucket": Where the value is the key value extracted by groupingExpr for corresponding group
  • "agg": Where the value is the aggregated value calculated by the aggregationExpr for the corresponding group

We have also implemented the following aggregation functions for ease of use;

sum(valueExtractorExpr: expression)
Extract the numeric value (Fhir Path Number) by appliying the valueExtractorExpr on each item in the input collection and sum the results.
e.g. Return the sum of observation values within a bundle for each patient
Bundle.entry.resource.filter($this is Observation).groupBy($this.subject.reference, sum(valueQuantity.value))

avg(valueExtractorExpr: expression)
Extract the numeric value by appliying the valueExtractorExpr on each item in the input collection and take the average of results.

min(valueExtractorExpr: expression)
Extract the numeric value by appliying the valueExtractorExpr on each item in the input collection and take the minimum.

max(valueExtractorExpr: expression)
Extract the numeric value by appliying the valueExtractorExpr on each item in the input collection and take the maximum.

@tnamli tnamli closed this as completed Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants