-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from lifeomic/fhir-sql
feat: adds new feature Fhir.es_sql()
- Loading branch information
Showing
5 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "phc" | ||
version = "0.33.4" | ||
version = "0.34.0" | ||
description = "Python SDK for the LifeOmic platform" | ||
authors = ["LifeOmic <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from phc import Session | ||
import os | ||
from phc.services import Fhir | ||
from unittest.mock import patch | ||
from test_session import jwt, sample | ||
|
||
|
||
@patch("phc.base_client.BaseClient._api_call") | ||
def test_es_sql(mock_api_call): | ||
session = Session(token=jwt.encode(sample, "secret"), account="bar") | ||
fhir = Fhir(session) | ||
project_id = "bar" | ||
query = "SELECT id, subject FROM diagnostic_report WHERE identifier.system = ? LIMIT 10" | ||
params = [ | ||
{ | ||
"type": "string", | ||
"value": "lrn:lo:dev:fountainlife:ehr:fountainlife:d22c690b-fb45-4ff2-8cb3-eed9f665cb30/DiagnosticReport", | ||
} | ||
] | ||
|
||
res = fhir.es_sql( | ||
project_id=project_id, | ||
statement=query, | ||
params=params, | ||
) | ||
|
||
mock_api_call.assert_called_once() | ||
args, kwargs = mock_api_call.call_args | ||
|
||
assert kwargs["api_path"] == f"fhir-search/sql/projects/{project_id}" | ||
assert kwargs["json"]["query"] == query | ||
assert kwargs["json"]["parameters"] == params |