Skip to content
Open

Large diffs are not rendered by default.

643 changes: 636 additions & 7 deletions postman/validated_relationship_service.sandbox.postman_collection.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion sandbox/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
POST_CONSENT__INVALID_GRANTOR_VALUE = f"{POST_CONSENT__DIRECTORY}errors/invalid_grantor_identifier_value.yaml"
POST_CONSENT__INVALID_GRANTOR_SYSTEM = f"{POST_CONSENT__DIRECTORY}errors/invalid_grantor_identifier_system.yaml"
POST_CONSENT__MISSING_GRANTOR_REFERENCE = f"{POST_CONSENT__DIRECTORY}errors/missing_grantor_reference.yaml"
POST_CONSENT__MISSING_GRANTOR_IDENTIFIER = f"{POST_CONSENT__DIRECTORY}errors/missing_grantor_identifier.yaml"

# PATCH Consent
PATCH_CONSENT__DIRECTORY = "./api/examples/PATCH_Consent/"
Expand All @@ -98,7 +99,11 @@
PATCH_CONSENT__RESOURCE_NOT_FOUND = f"{PATCH_CONSENT__DIRECTORY}errors/resource_not_found.yaml"
PATCH_CONSENT__INVALID_STATE_TRANSITION = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_state_transition.yaml"
PATCH_CONSENT__MISSING_FREE_TEXT_FOR_OTHER = f"{PATCH_CONSENT__DIRECTORY}errors/missing_free_text_for_other.yaml"
PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE = f"{PATCH_CONSENT__DIRECTORY}errors/missing_grantor_for_active_status.yaml"
PATCH_CONSENT__MISSING_GRANTOR = f"{PATCH_CONSENT__DIRECTORY}errors/missing_grantor.yaml"
PATCH_CONSENT__INVALID_GRANTOR_VALUE = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_grantor_identifier_value.yaml"
PATCH_CONSENT__INVALID_GRANTOR_SYSTEM = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_grantor_identifier_system.yaml"
PATCH_CONSENT__MISSING_GRANTOR_REFERENCE = f"{PATCH_CONSENT__DIRECTORY}errors/missing_grantor_reference.yaml"
PATCH_CONSENT__MISSING_GRANTOR_IDENTIFIER = f"{PATCH_CONSENT__DIRECTORY}errors/missing_grantor_identifier.yaml"

# POST QuestionnaireResponse
POST_QUESTIONNAIRE_RESPONSE_DIRECTORY = "./api/examples/POST_QuestionnaireResponse/"
Expand Down
26 changes: 23 additions & 3 deletions sandbox/api/patch_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
PATCH_CONSENT__SUCCESS,
PATCH_CONSENT__INVALID_STATUS_REASON,
PATCH_CONSENT__MISSING_FREE_TEXT_FOR_OTHER,
PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE,
PATCH_CONSENT__MISSING_GRANTOR,
PATCH_CONSENT__INVALID_GRANTOR_VALUE,
PATCH_CONSENT__INVALID_GRANTOR_SYSTEM,
PATCH_CONSENT__MISSING_GRANTOR_REFERENCE,
PATCH_CONSENT__MISSING_GRANTOR_IDENTIFIER,
)
from .utils import generate_response_from_example

Expand Down Expand Up @@ -84,8 +88,24 @@ def patch_consent_response(id: str) -> Union[dict, tuple]:
return generate_response_from_example(PATCH_CONSENT__SUCCESS, 200)

elif id == "90957744-b971-496e-b7c3-ab971868ce14":
# PATCH to activate proxy role without providing grantor extension
return generate_response_from_example(PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE, 400)
# Missing grantor extension
return generate_response_from_example(PATCH_CONSENT__MISSING_GRANTOR, 400)

elif id == "b68cbfc8-ccc2-48ad-b97b-b7410d773dc1":
# Invalid grantor identifier value
return generate_response_from_example(PATCH_CONSENT__INVALID_GRANTOR_VALUE, 422)

elif id == "fd189522-68e5-42dc-b44c-989be0eaa2bf":
# Invalid grantor identifier system
return generate_response_from_example(PATCH_CONSENT__INVALID_GRANTOR_SYSTEM, 422)

elif id == "7e764160-38b6-41eb-9012-a3e476cbc517":
# Missing grantor reference
return generate_response_from_example(PATCH_CONSENT__MISSING_GRANTOR_REFERENCE, 400)

elif id == "faefd8c5-5e24-4415-8252-96e9241c7e78":
# Missing grantor identifier
return generate_response_from_example(PATCH_CONSENT__MISSING_GRANTOR_IDENTIFIER, 400)

else:
# Resource not found
Expand Down
11 changes: 8 additions & 3 deletions sandbox/api/post_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
POST_CONSENT__INVALID_GRANTOR_VALUE,
POST_CONSENT__INVALID_GRANTOR_SYSTEM,
POST_CONSENT__MISSING_GRANTOR_REFERENCE,
POST_CONSENT__MISSING_GRANTOR_IDENTIFIER,
)
from .utils import generate_response_from_example

Expand Down Expand Up @@ -68,17 +69,21 @@ def post_consent_response() -> Union[dict, tuple]:
response = generate_response_from_example(POST_CONSENT__MISSING_GRANTOR, 400)

elif patient_identifier == "9000000055":
# Invalid/empty ODS code
# Invalid ODS code
response = generate_response_from_example(POST_CONSENT__INVALID_GRANTOR_VALUE, 422)

elif patient_identifier == "9000000056":
# Wrong system
# Invalid identifier system
response = generate_response_from_example(POST_CONSENT__INVALID_GRANTOR_SYSTEM, 422)

elif patient_identifier == "9000000057":
# Missing valueReference/identifier
# Missing valueReference
response = generate_response_from_example(POST_CONSENT__MISSING_GRANTOR_REFERENCE, 400)

elif patient_identifier == "9000000058":
# Missing valueIdentifier
response = generate_response_from_example(POST_CONSENT__MISSING_GRANTOR_IDENTIFIER, 400)

else:
# Out of scope errors
raise ValueError("Invalid Request")
Expand Down
28 changes: 26 additions & 2 deletions sandbox/api/tests/test_patch_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
PATCH_CONSENT__SUCCESS,
PATCH_CONSENT__INVALID_STATUS_REASON,
PATCH_CONSENT__MISSING_FREE_TEXT_FOR_OTHER,
PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE,
PATCH_CONSENT__MISSING_GRANTOR,
PATCH_CONSENT__INVALID_GRANTOR_VALUE,
PATCH_CONSENT__INVALID_GRANTOR_SYSTEM,
PATCH_CONSENT__MISSING_GRANTOR_REFERENCE,
PATCH_CONSENT__MISSING_GRANTOR_IDENTIFIER,
)

CONSENT_API_ENDPOINT = "/FHIR/R4/Consent"
Expand Down Expand Up @@ -53,7 +57,27 @@
),
(
"90957744-b971-496e-b7c3-ab971868ce14",
PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE,
PATCH_CONSENT__MISSING_GRANTOR,
400,
),
(
"b68cbfc8-ccc2-48ad-b97b-b7410d773dc1",
PATCH_CONSENT__INVALID_GRANTOR_VALUE,
422,
),
(
"fd189522-68e5-42dc-b44c-989be0eaa2bf",
PATCH_CONSENT__INVALID_GRANTOR_SYSTEM,
422,
),
(
"7e764160-38b6-41eb-9012-a3e476cbc517",
PATCH_CONSENT__MISSING_GRANTOR_REFERENCE,
400,
),
(
"faefd8c5-5e24-4415-8252-96e9241c7e78",
PATCH_CONSENT__MISSING_GRANTOR_IDENTIFIER,
400,
),
(
Expand Down
7 changes: 7 additions & 0 deletions sandbox/api/tests/test_post_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
POST_CONSENT__INVALID_GRANTOR_VALUE,
POST_CONSENT__INVALID_GRANTOR_SYSTEM,
POST_CONSENT__MISSING_GRANTOR_REFERENCE,
POST_CONSENT__MISSING_GRANTOR_IDENTIFIER,
)

CONSENT_API_ENDPOINT = "/FHIR/R4/Consent"
Expand Down Expand Up @@ -63,6 +64,12 @@
400,
None,
),
(
"9000000058",
POST_CONSENT__MISSING_GRANTOR_IDENTIFIER,
400,
None,
),
(
"9000000051",
POST_CONSENT__SUCCESS,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PatchConsentInvalidGrantorIdentifierSystemError:
summary: Invalid Grantor Identifier System
description: Returned when the grantor identifier system is incorrect
value:
issue:
- code: invalid
details:
coding:
- code: INVALID_GRANTOR_SYSTEM
display: Invalid grantor identifier system
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Valid grantor extension identifier system is required when creating/updating a consent with status 'active'
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor').valueReference.identifier.system"
severity: error
resourceType: OperationOutcome
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PatchConsentInvalidGrantorIdentifierValueError:
summary: Invalid Grantor ODS Code
description: Returned when the grantor ODS code value is invalid
value:
issue:
- code: invalid
details:
coding:
- code: INVALID_GRANTOR_VALUE
display: Invalid grantor identifier value
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Valid grantor extension identifier value is required when creating/updating a consent with status 'active'
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor').valueReference.identifier.value"
severity: error
resourceType: OperationOutcome
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PatchConsentMissingGrantorForActiveStatusError:
summary: Missing Grantor on Status Activation
PatchConsentMissingGrantorError:
summary: Missing Grantor Extension for Active Consent
description: Returned when a PATCH request attempts to set status to 'active' without including a grantor extension in the same request
value:
issue:
Expand All @@ -10,7 +10,7 @@ PatchConsentMissingGrantorForActiveStatusError:
display: Grantor required for active status
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Grantor extension must be included in the same PATCH request when changing status to active
diagnostics: Grantor extension is required when creating/updating an active proxy role
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor')"
severity: error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PatchConsentMissingGrantorIdentifierError:
summary: Missing Grantor Identifier Structure
description: Returned when the grantor extension is missing identifier
value:
issue:
- code: invalid
details:
coding:
- code: MISSING_GRANTOR_IDENTIFIER
display: Missing grantor identifier
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Grantor extension must contain a valueIdentifier
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor').valueReference.identifier"
severity: error
resourceType: OperationOutcome
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PatchConsentMissingGrantorReferenceError:
summary: Missing Grantor Reference Structure
description: Returned when the grantor extension is missing reference
value:
issue:
- code: invalid
details:
coding:
- code: MISSING_GRANTOR_REFERENCE
display: Missing grantor reference
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Grantor extension must contain a valueReference
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor').valueReference"
severity: error
resourceType: OperationOutcome
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PostConsentInvalidGrantorIdentifierSystemError:
summary: Invalid Grantor Identifier System
description: Returned when the grantor identifier system is incorrect or missing
description: Returned when the grantor identifier system is incorrect
value:
issue:
- code: invalid
Expand All @@ -10,7 +10,7 @@ PostConsentInvalidGrantorIdentifierSystemError:
display: Invalid grantor identifier system
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Grantor extension is required when creating a consent with status 'active'
diagnostics: Valid grantor extension identifier system is required when creating/updating a consent with status 'active'
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor').valueReference.identifier.system"
severity: error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PostConsentInvalidGrantorIdentifierValueError:
summary: Invalid Grantor ODS Code
description: Returned when the grantor ODS code value is missing, empty, or invalid
description: Returned when the grantor ODS code value is invalid
value:
issue:
- code: invalid
Expand All @@ -10,7 +10,7 @@ PostConsentInvalidGrantorIdentifierValueError:
display: Invalid grantor identifier value
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Grantor extension is required when creating a consent with status 'active'
diagnostics: Valid grantor extension identifier value is required when creating/updating a consent with status 'active'
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor').valueReference.identifier.value"
severity: error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PostConsentMissingGrantorError:
summary: Missing Grantor Extension for Active Consent
description: Returned when creating a consent with status 'active' but no grantor extension is included
description: Returned when creating a POST consent request with status 'active' but no grantor extension is included
value:
issue:
- code: invalid
Expand All @@ -10,7 +10,7 @@ PostConsentMissingGrantorError:
display: Grantor required for active status
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Grantor extension is required when creating a consent with status 'active'
diagnostics: Grantor extension is required when creating/updating an active proxy role
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor')"
severity: error
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
PostConsentMissingGrantorIdentifierError:
summary: Missing Grantor Identifier Structure
description: Returned when the grantor extension is missing reference
value:
issue:
- code: invalid
details:
coding:
- code: MISSING_GRANTOR_IDENTIFIER
display: Missing grantor identifier
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Grantor extension must contain a valueIdentifier
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor').valueReference.identifier"
severity: error
resourceType: OperationOutcome
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PostConsentMissingGrantorReferenceError:
summary: Missing Grantor Reference Structure
description: Returned when the grantor extension is malformed (missing valueReference or identifier)
description: Returned when the grantor extension is missing reference
value:
issue:
- code: invalid
Expand All @@ -10,7 +10,7 @@ PostConsentMissingGrantorReferenceError:
display: Missing grantor reference
system: https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode
version: "1"
diagnostics: Grantor extension must contain a valueReference with identifier
diagnostics: Grantor extension must contain a valueReference
expression:
- "extension.where(url = 'http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor').valueReference"
severity: error
Expand Down
Loading