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

Large diffs are not rendered by default.

881 changes: 821 additions & 60 deletions postman/validated_relationship_service.sandbox.postman_collection.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions sandbox/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
PATIENT_IDENTIFIERS = ["9000000017", "9000000033", "9000000042"]
RELATED_IDENTIFIERS = ["9000000009", "9000000025", "9000000042"]

CONSENT_PERFORMER = "Consent:performer"
CONSENT_GRANTEE = "Consent:grantee"
CONSENT_PATIENT = "Consent:patient"

# Example files
Expand All @@ -29,47 +29,47 @@
)
GET_CONSENT__MULTIPLE_RELATIONSHIPS = f"{GET_CONSENT__DIRECTORY}multiple-relationships.yaml"
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-include-performer-patient.yaml"
f"{GET_CONSENT__DIRECTORY}multiple-relationships-include-grantee-patient.yaml"
)
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PATIENT = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-include-patient.yaml"
)
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PERFORMER = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-include-performer.yaml"
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_GRANTEE = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-include-grantee.yaml"
)
GET_CONSENT__NO_RELATIONSHIPS = f"{GET_CONSENT__DIRECTORY}no-relationships.yaml"
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP = f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship.yaml"
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH = (
f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer-patient.yaml"
f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-grantee-patient.yaml"
)
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_PATIENT = (
f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-patient.yaml"
)
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_PERFORMER = (
f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer.yaml"
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_GRANTEE = (
f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-grantee.yaml"
)
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP = f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship.yaml"
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH = (
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-performer-patient.yaml"
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-grantee-patient.yaml"
)
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PATIENT = (
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-patient.yaml"
)
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PERFORMER = (
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-performer.yaml"
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_GRANTEE = (
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-grantee.yaml"
)
GET_CONSENT__STATUS_PARAM_INVALID = f"{GET_CONSENT__DIRECTORY}errors/invalid-status-parameter.yaml"
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient.yaml"
)
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer.yaml"
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_GRANTEE = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-grantee.yaml"
)
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-patient.yaml"
)
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer-patient.yaml"
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-grantee-patient.yaml"
)
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_UNKNOWN_LEGAL_BASIS = (
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-unknown-legal-basis.yaml"
Expand Down
8 changes: 4 additions & 4 deletions sandbox/api/get_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_GRANTEE,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH,
GET_CONSENT__MULTIPLE_RELATIONSHIPS,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PATIENT,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PERFORMER,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_GRANTEE,
GET_CONSENT__NO_RELATIONSHIPS,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH,
Expand Down Expand Up @@ -79,7 +79,7 @@ def get_consent_response() -> Union[dict, tuple]:
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_GRANTEE,
)
# Filtering
elif performer_identifier == "9000000017":
Expand All @@ -97,7 +97,7 @@ def get_consent_response() -> Union[dict, tuple]:
GET_CONSENT__MULTIPLE_RELATIONSHIPS,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PATIENT,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PERFORMER,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_GRANTEE,
)
# No relationships
elif performer_identifier == "9000000025":
Expand Down
8 changes: 4 additions & 4 deletions sandbox/api/get_consent_by_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_PATIENT,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_PERFORMER,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_GRANTEE,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PATIENT,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PERFORMER,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_GRANTEE,
GET_CONSENT_BY_ID__INVALID_ID_ERROR,
BAD_REQUEST_INCLUDE_PARAM_INVALID,
INVALIDATED_RESOURCE,
Expand Down Expand Up @@ -41,15 +41,15 @@ def get_consent_by_id_response(identifier: str) -> Union[dict, tuple]:
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_PATIENT,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_PERFORMER,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_GRANTEE,
)
elif identifier == "39df03a2-1b14-4d19-b1dc-d5d8cbf96948":
return check_for_consent_include_params(
_include,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PATIENT,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PERFORMER,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_GRANTEE,
)
elif identifier == "a0922245-1072-40c3-8f4e-a7490c10d365":
return generate_response_from_example(INVALIDATED_RESOURCE, 404)
Expand Down
44 changes: 22 additions & 22 deletions sandbox/api/tests/test_get_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
("request_args", "response_file_name", "status_code"),
[
(
"performer:identifier=9000000017&status=active&_include=Consent:performer&_include=Consent:patient",
"performer:identifier=9000000017&status=active&_include=Consent:grantee&_include=Consent:patient",
"./api/examples/GET_Consent/filtered-relationships-status-active-include-details.yaml",
200,
),
Expand Down Expand Up @@ -79,13 +79,13 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
200,
),
(
"performer:identifier=9000000022&_include=Consent:performer",
"./api/examples/GET_Consent/multiple-relationships-include-performer.yaml",
"performer:identifier=9000000022&_include=Consent:grantee",
"./api/examples/GET_Consent/multiple-relationships-include-grantee.yaml",
200,
),
(
"performer:identifier=9000000022&_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/multiple-relationships-include-performer-patient.yaml",
"performer:identifier=9000000022&_include=Consent:grantee&_include=Consent:patient",
"./api/examples/GET_Consent/multiple-relationships-include-grantee-patient.yaml",
200,
),
(
Expand All @@ -104,18 +104,18 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
200,
),
(
"performer:identifier=9000000010&_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
"performer:identifier=9000000010&_include=Consent:grantee&_include=Consent:patient",
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-grantee-patient.yaml",
200,
),
(
"patient:identifier=9000000005&_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
"patient:identifier=9000000005&_include=Consent:grantee&_include=Consent:patient",
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-grantee-patient.yaml",
200,
),
(
"performer:identifier=9000000010&patient:identifier=9000000005&_include=Consent:performer&_include=Consent:patient", # noqa: E501
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
"performer:identifier=9000000010&patient:identifier=9000000005&_include=Consent:grantee&_include=Consent:patient", # noqa: E501
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-grantee-patient.yaml",
200,
),
(
Expand All @@ -134,18 +134,18 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
200,
),
(
"performer:identifier=9000000019&_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
"performer:identifier=9000000019&_include=Consent:grantee&_include=Consent:patient",
"./api/examples/GET_Consent/single-mother-child-relationship-include-grantee-patient.yaml",
200,
),
(
"patient:identifier=9000000009&_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
"patient:identifier=9000000009&_include=Consent:grantee&_include=Consent:patient",
"./api/examples/GET_Consent/single-mother-child-relationship-include-grantee-patient.yaml",
200,
),
(
"performer:identifier=9000000019&patient:identifier=9000000009&_include=Consent:performer&_include=Consent:patient", # noqa: E501
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
"performer:identifier=9000000019&patient:identifier=9000000009&_include=Consent:grantee&_include=Consent:patient", # noqa: E501
"./api/examples/GET_Consent/single-mother-child-relationship-include-grantee-patient.yaml",
200,
),
(
Expand All @@ -154,8 +154,8 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
200,
),
(
"patient:identifier=9000000100&_include=Consent:performer",
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-performer.yaml",
"patient:identifier=9000000100&_include=Consent:grantee",
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-grantee.yaml",
200,
),
(
Expand All @@ -164,8 +164,8 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
200,
),
(
"patient:identifier=9000000100&_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml",
"patient:identifier=9000000100&_include=Consent:grantee&_include=Consent:patient",
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-grantee-patient.yaml",
200,
),
(
Expand Down Expand Up @@ -232,6 +232,6 @@ def test_get_consent__500_internal_server_error(
"""Test Consent endpoint."""
mock_remove_system.side_effect = Exception("Test exception")
# Act
client.get(f"{CONSENT_API_ENDPOINT}?performer:identifier=9000000015&status=active&_include=Consent:performer")
client.get(f"{CONSENT_API_ENDPOINT}?performer:identifier=9000000015&status=active&_include=Consent:grantee")
# Assert
mock_generate_response_from_example.assert_called_once_with("./api/examples/errors/internal-server-error.yaml", 500)
16 changes: 8 additions & 8 deletions sandbox/api/tests/test_get_consent_by_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def test_get_consent_by_id_returns_expected_responses__mocked_get_consent_by_id(
),
(
"74eed847-ca25-4e76-8cf2-f2c2d7842a7a", # Single consenting adult relationship with include performer
"_include=Consent:performer",
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer.yaml",
"_include=Consent:grantee",
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-grantee.yaml",
200,
),
(
Expand All @@ -84,8 +84,8 @@ def test_get_consent_by_id_returns_expected_responses__mocked_get_consent_by_id(
),
(
"74eed847-ca25-4e76-8cf2-f2c2d7842a7a", # Single consenting adult relationship with include both
"_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
"_include=Consent:grantee&_include=Consent:patient",
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-grantee-patient.yaml",
200,
),
(
Expand All @@ -96,8 +96,8 @@ def test_get_consent_by_id_returns_expected_responses__mocked_get_consent_by_id(
),
(
"39df03a2-1b14-4d19-b1dc-d5d8cbf96948", # Single adult-child relationship with include performer
"_include=Consent:performer",
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer.yaml",
"_include=Consent:grantee",
"./api/examples/GET_Consent/single-mother-child-relationship-include-grantee.yaml",
200,
),
(
Expand All @@ -108,8 +108,8 @@ def test_get_consent_by_id_returns_expected_responses__mocked_get_consent_by_id(
),
(
"39df03a2-1b14-4d19-b1dc-d5d8cbf96948", # Single adult-child relationship with include both
"_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
"_include=Consent:grantee&_include=Consent:patient",
"./api/examples/GET_Consent/single-mother-child-relationship-include-grantee-patient.yaml",
200,
),
],
Expand Down
20 changes: 10 additions & 10 deletions sandbox/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .constants import (
BAD_REQUEST_INCLUDE_PARAM_INVALID,
CONSENT_PATIENT,
CONSENT_PERFORMER,
CONSENT_GRANTEE,
GET_CONSENT__STATUS_PARAM_INVALID,
INCLUDE_FLAG,
INTERNAL_SERVER_ERROR_EXAMPLE,
Expand Down Expand Up @@ -231,36 +231,36 @@ def check_for_consent_include_params(
include_none_response_yaml: str,
include_both_response_yaml: str = None,
include_patient_response_yaml: str = None,
include_performer_response_yaml: str = None,
include_grantee_response_yaml: str = None,
) -> Response:
"""Checks the GET consent request include params and provides the related response

Args:
_include (List[str]): The include parameters supplied to the request
include_none_response_yaml (str): Bundle to return when include params are empty
include_both_response_yaml (str): (optional) Bundle to return when include param
is Consent:performer,Consent:patient
is Consent:grantee,Consent:patient
include_patient_response_yaml (str): (optional) Bundle to return when include param is Consent:patient
include_performer_response_yaml (str): (optional) Bundle to return when include param is Consent:performer
include_grantee_response_yaml (str): (optional) Bundle to return when include param is Consent:grantee

Returns:
response: Resultant Response object based on input.
"""
if _include == [] or _include is None:
return generate_response_from_example(include_none_response_yaml, 200)
elif _include == [CONSENT_PERFORMER]:
if include_performer_response_yaml:
return generate_response_from_example(include_performer_response_yaml, 200)
elif _include == [CONSENT_GRANTEE]:
if include_grantee_response_yaml:
return generate_response_from_example(include_grantee_response_yaml, 200)
else:
logger.error("No consent performer example provided")
logger.error("No consent grantee example provided")
return generate_response_from_example(INTERNAL_SERVER_ERROR_EXAMPLE, 500)
elif _include == [CONSENT_PATIENT]:
if include_patient_response_yaml:
return generate_response_from_example(include_patient_response_yaml, 200)
else:
logger.error("No consent:patient example provided")
return generate_response_from_example(INTERNAL_SERVER_ERROR_EXAMPLE, 500)
elif len(_include) == 2 and CONSENT_PATIENT in _include and CONSENT_PERFORMER in _include:
elif len(_include) == 2 and CONSENT_PATIENT in _include and CONSENT_GRANTEE in _include:
return generate_response_from_example(include_both_response_yaml, 200)
else:
return generate_response_from_example(BAD_REQUEST_INCLUDE_PARAM_INVALID, 422)
Expand Down Expand Up @@ -288,7 +288,7 @@ def check_for_consent_filtering(
if status == [] or status is None:
return generate_response_from_example(INVALIDATED_RESOURCE, 404)
if status == ["active"]:
if len(_include) == 2 and CONSENT_PERFORMER in _include and CONSENT_PERFORMER in _include:
if len(_include) == 2 and CONSENT_GRANTEE in _include and CONSENT_GRANTEE in _include:
return generate_response_from_example(status_active_with_details_response_yaml, 200)
else:
return generate_response_from_example(INVALIDATED_RESOURCE, 404)
Expand Down
Loading