Skip to content

Commit

Permalink
Revert "Fix populate for reference"
Browse files Browse the repository at this point in the history
This reverts commit 75208a5.
  • Loading branch information
ir4y committed Sep 18, 2024
1 parent 75208a5 commit fb29798
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 53 deletions.
17 changes: 4 additions & 13 deletions app/sdc/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ def init_item():
)
if data and len(data):
type = get_type(item, data)
if type == "Reference":
answers.extend([{"value": {"Reference": {"reference": d}}} for d in data])
else:
answers.extend([{"value": {type: d}} for d in data])
answers.extend([{"value": {type: d}} for d in data])
if answers:
root_item["answer"] = answers
elif "initialExpression" in item:
Expand All @@ -74,16 +71,10 @@ def init_item():
raise OperationOutcome(f'Error: "{item["initialExpression"]["expression"]}" - {str(e)}')
if data and len(data):
type = get_type(item, data)
if type == "Reference":
if item.get("repeats") is True:
answers = [{"value": {"Reference": {"reference": d}}} for d in data]
else:
answers = [{"value": {"Reference": {"reference": data[0]}}}]
if item.get("repeats") is True:
answers = [{"value": {type: d}} for d in data]
else:
if item.get("repeats") is True:
answers = [{"value": {type: d}} for d in data]
else:
answers = [{"value": {type: data[0]}}]
answers = [{"value": {type: data[0]}}]
if answers:
root_item["answer"] = answers
elif "initial" in item:
Expand Down
40 changes: 0 additions & 40 deletions tests/sdc/test_populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest

from app.test.utils import create_parameters
from app.converter.aidbox import from_first_class_extension


@pytest.mark.asyncio
Expand Down Expand Up @@ -803,42 +802,3 @@ async def test_source_query_populate_fhir_from_api(aidbox_client, safe_db):
"questionnaire": questionnaire.id,
"resourceType": "QuestionnaireResponse",
}


@pytest.mark.asyncio
async def test_reference_populate(aidbox_client, safe_db):
q = aidbox_client.resource(
"Questionnaire",
**{
"status": "active",
"launchContext": [{"name": {"code": "LaunchPatient"}, "type": ["Patient"]}],
"item": [
{
"type": "reference",
"linkId": "patientId",
"initialExpression": {
"language": "text/fhirpath",
"expression": "'Patient/' + %LaunchPatient.id",
},
},
],
},
)
await q.save()

assert q.id is not None

launch_patient = {"resourceType": "Patient", "id": "patienit-id"}

p = await from_first_class_extension(await q.execute("$populate", data=create_parameters(LaunchPatient=launch_patient)), aidbox_client)

assert p == {
"resourceType": "QuestionnaireResponse",
"questionnaire": q.id,
"item": [
{
"linkId": "patientId",
"answer": [{"valueReference": {"reference": f"Patient/{launch_patient['id']}"}}],
}
],
}

0 comments on commit fb29798

Please sign in to comment.