Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,23 @@ jobs:
- name: Run install goal
env:
R_KEEP_PKG_SOURCE: yes
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn --batch-mode install \
-pl '!site,!benchmark'
timeout-minutes: 60

- name: Run SonarCloud analysis
# Secrets are not available for pull requests from forks.
if: env.SONAR_TOKEN != ''
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
mvn --batch-mode \
org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.projectKey=aehrc_pathling -Dsonar.organization=aehrc \
-Dsonar.host.url=https://sonarcloud.io \
-pl '!site,!benchmark'
timeout-minutes: 60
timeout-minutes: 10

- name: Upload test artifacts
if: always()
Expand Down
8 changes: 4 additions & 4 deletions lib/R/R/view.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' @param ds The DataSource object containing the data to be queried.
#' @param resource A string representing the type of FHIR resource that the view is based upon, e.g. 'Patient' or 'Observation'.
#' @param select A list of columns and nested selects to include in the view. Each element should be a list with appropriate structure.
#' @param constants An optional list of constants that can be used in FHIRPath expressions.
#' @param constant An optional list of constants that can be used in FHIRPath expressions.
#' @param where An optional list of FHIRPath expressions that can be used to filter the view.
#' @param json An optional JSON string representing the view definition, as an alternative to providing the parameters as R objects.
#' @return A Spark DataFrame containing the results of the view.
Expand Down Expand Up @@ -66,7 +66,7 @@
#' )
#' )
#' }
ds_view <- function(ds, resource, select = NULL, constants = NULL, where = NULL, json = NULL) {
ds_view <- function(ds, resource, select = NULL, constant = NULL, where = NULL, json = NULL) {
jquery <- j_invoke(ds, "view", as.character(resource))

if (!is.null(json)) {
Expand All @@ -83,8 +83,8 @@ ds_view <- function(ds, resource, select = NULL, constants = NULL, where = NULL,
query$select <- select
}

if (!is.null(constants)) {
query$constants <- constants
if (!is.null(constant)) {
query$constant <- constant
}

if (!is.null(where)) {
Expand Down
32 changes: 32 additions & 0 deletions lib/R/tests/testthat/test-view.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,35 @@ test_that("test SOF view with components", {
expect_equal(colnames(sof_result), colnames(ResultRow))
expect_equal(sof_result %>% sdf_collect(), ResultRow)
})


# test SOF view with constants
test_that("test SOF view with constants", {
# expectations
ResultRow <- tibble::tibble(
id = c("8ee183e2-b3c0-4151-be94-b945d6aa8c6d"),
family_name = c("Krajcik437")
)

# actuals
sof_result <- ds_view(
test_data_source(),
resource = "Patient",
constant = list(
list(name = "filter_id", valueUuid = "8ee183e2-b3c0-4151-be94-b945d6aa8c6d")
),
select = list(
list(
column = list(
list(path = "id", name = "id"),
list(path = "name.first().family", name = "family_name")
)
)
),
where = list(
list(path = "id = %filter_id")
)
)
expect_equal(colnames(sof_result), colnames(ResultRow))
expect_equal(sof_result %>% sdf_collect(), ResultRow)
})
6 changes: 3 additions & 3 deletions lib/python/pathling/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def view(
self,
resource: Optional[str] = None,
select: Optional[Sequence[Dict]] = None,
constants: Optional[Sequence[Dict]] = None,
constant: Optional[Sequence[Dict]] = None,
where: Optional[Sequence[Dict]] = None,
json: Optional[str] = None,
) -> DataFrame:
Expand All @@ -82,7 +82,7 @@ def view(
:param resource: The FHIR resource that the view is based upon, e.g. 'Patient' or
'Observation'.
:param select: A list of columns and nested selects to include in the view.
:param constants: A list of constants that can be used in FHIRPath expressions.
:param constant: A list of constants that can be used in FHIRPath expressions.
:param where: A list of FHIRPath expressions that can be used to filter the view.
:param json: A JSON string representing the view definition, as an alternative to providing
the parameters as Python objects.
Expand All @@ -96,7 +96,7 @@ def view(
args = locals()
query = {
key: args[key]
for key in ["resource", "select", "constants", "where"]
for key in ["resource", "select", "constant", "where"]
if args[key] is not None
}
query_json = dumps(query)
Expand Down
24 changes: 24 additions & 0 deletions lib/python/tests/test_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,30 @@ def test_view_on_ndjson(ndjson_test_data_dir, pathling_ctx):
]


def test_view_with_constants(ndjson_test_data_dir, pathling_ctx):
"""Reproduces #2574: view with constants fails to resolve constant references in where clause."""

data_source = pathling_ctx.read.ndjson(ndjson_test_data_dir)
result = data_source.view(
resource="Patient",
constant=[
{"name": "filter_id", "valueUuid": "8ee183e2-b3c0-4151-be94-b945d6aa8c6d"}
],
select=[
{
"column": [
{"path": "id", "name": "id"},
{"path": "name.first().family", "name": "family_name"},
]
}
],
where=[{"path": "id = %filter_id"}],
)
assert result.collect() == [
ResultRow("8ee183e2-b3c0-4151-be94-b945d6aa8c6d", "Krajcik437"),
Comment on lines +63 to +70
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh no, how embarrassing.

Apologies, I installed uv but couldn't get the tests to run

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem at all!

If you let us know what you had trouble with, we will try to improve the documentation in CONTRIBUTING.md.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made sure to have java 21 installed, and python with UV

then i ran mvn clean install -pl lib/python -am but it kept ending in a killed process. when i cdd into the python library folder and ran pytest through uv it failed with missing libraries.

i'm not familiar with the java tooling so i don't know which knobs and dials to turn to make it less likely to crash on me. It could also be my machine, i've had wsl crash on me a fair bit while using pyspark and pathling.

]


ConditionCodingRow = Row("id", "code_text", "system", "code", "display")


Expand Down
Loading