Skip to content

Commit

Permalink
Add more responses for _include parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
JackPlowman committed Apr 4, 2024
1 parent e63cbe5 commit e05dffc
Show file tree
Hide file tree
Showing 10 changed files with 403 additions and 40 deletions.
21 changes: 20 additions & 1 deletion sandbox/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,31 @@ def get_related_persons() -> Union[dict, tuple]:
# Check Headers
if errors := check_for_errors(request):
return errors

# Successful request, select response
if request.args.get("identifier") and request.args.get("patient"):
if (
request.args.get("identifier")
and request.args.get("patient")
and request.args.get("_include") == "patient"
):
# Request with identifier, patient and _include=patient
return get_response(
"./api/responses/GET_RelatedPerson/identifier_and_patient_include.json"
)
elif request.args.get("identifier") and request.args.get("patient"):
# Request with identifier and patient
return get_response(
"./api/responses/GET_RelatedPerson/identifier_and_patient.json"
)
elif (
request.args.get("identifier") and request.args.get("_include") == "patient"
):
# Request with identifier and _include=patient
return get_response(
"./api/responses/GET_RelatedPerson/identifier_include.json"
)
elif request.args.get("identifier"):
# Request with identifier
return get_response("./api/responses/GET_RelatedPerson/identifier.json")
else:
raise ValueError("Invalid request")
Expand Down
9 changes: 7 additions & 2 deletions sandbox/api/responses/GET_RelatedPerson/identifier.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"entry": [
{
"fullUrl": "/validated-relationships/FHIR/R4/RelatedPerson/ABCD1234",
"fullUrl": "https://internal-dev.api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/ABCD1234",
"resource": {
"id": "ABCD1234",
"identifier": [
Expand Down Expand Up @@ -38,7 +38,12 @@
"search": { "mode": "match" }
}
],
"link": [{ "relation": "self", "url": "sandbox" }],
"link": [
{
"relation": "self",
"url": "sandbox"
}
],
"timestamp": "2024-00-00T00:00:00+00:00",
"total": 1,
"type": "searchset",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"entry": [
{
"fullUrl": "/validated-relationships/FHIR/R4/RelatedPerson/ABCD1234",
"fullUrl": "https://internal-dev.api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/BE974742",
"resource": {
"id": "ABCD1234",
"id": "BE974742",
"identifier": [
{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "1234567890"
"value": "4567891012"
}
],
"patient": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "0987654321"
"value": "3456789101"
},
"type": "Patient"
},
Expand All @@ -38,19 +38,19 @@
"search": { "mode": "match" }
},
{
"fullUrl": "/validated-relationships/FHIR/R4/RelatedPerson/1234ABCD",
"fullUrl": "https://internal-dev.api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/A3CC67E2",
"resource": {
"id": "1234ABCD",
"id": "A3CC67E2",
"identifier": [
{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "1234567890"
"value": "4567891012"
}
],
"patient": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "2234567890"
"value": "5678910123"
},
"type": "Patient"
},
Expand All @@ -75,7 +75,12 @@
"search": { "mode": "match" }
}
],
"link": [{ "relation": "self", "url": "" }],
"link": [
{
"relation": "self",
"url": "sandbox"
}
],
"timestamp": "2024-00-00T00:00:00+00:00",
"total": 2,
"type": "searchset",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
{
"entry": [
{
"fullUrl": "https://internal-dev.api.service.nhs.uk/validated-relationships/FHIR/R4/Patient/3456789101",
"resource": {
"id": "3456789101",
"birthDate": "2017-09-23",
"identifier": [
{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "3456789101"
}
],
"name": [
{
"id": "BLnbA",
"family": "MOGAJI",
"given": ["GADIL"],
"period": { "start": "2021-07-08" },
"prefix": ["MR"],
"use": "usual"
}
],
"resourceType": "Patient"
},
"search": { "mode": "include" }
},
{
"fullUrl": "https://internal-dev.api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/BE974742",
"resource": {
"id": "BE974742",
"identifier": [
{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "4567891012"
}
],
"patient": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "3456789101"
},
"type": "Patient"
},
"relationship": [
{
"coding": [
{
"code": "MTH",
"display": "mother",
"system": "http://hl7.org/fhir/ValueSet/relatedperson-relationshiptype"
},
{
"code": "Personal",
"display": "Personal relationship with the patient",
"system": "https://fhir.nhs.uk/R4/CodeSystem/UKCore-AdditionalRelatedPersonRole"
}
]
}
],
"resourceType": "RelatedPerson"
},
"search": { "mode": "match" }
},
{
"fullUrl": "https://internal-dev.api.service.nhs.uk/validated-relationships/FHIR/R4/Patient/5678910123",
"resource": {
"id": "5678910123",
"birthDate": "2018-04-27",
"identifier": [
{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "5678910123"
}
],
"name": [
{
"id": "vitjN",
"family": "FEARON",
"given": ["Daren"],
"period": { "start": "2018-09-21" },
"prefix": ["MR"],
"use": "usual"
}
],
"resourceType": "Patient"
},
"search": { "mode": "include" }
},
{
"fullUrl": "https://internal-dev.api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/A3CC67E2",
"resource": {
"id": "A3CC67E2",
"identifier": [
{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "4567891012"
}
],
"patient": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "5678910123"
},
"type": "Patient"
},
"relationship": [
{
"coding": [
{
"code": "MTH",
"display": "mother",
"system": "http://hl7.org/fhir/ValueSet/relatedperson-relationshiptype"
},
{
"code": "Personal",
"display": "Personal relationship with the patient",
"system": "https://fhir.nhs.uk/R4/CodeSystem/UKCore-AdditionalRelatedPersonRole"
}
]
}
],
"resourceType": "RelatedPerson"
},
"search": { "mode": "match" }
}
],
"link": [
{
"relation": "self",
"url": "sandbox"
}
],
"timestamp": "2024-00-00T00:00:00+00:00",
"total": 4,
"type": "searchset",
"resourceType": "Bundle"
}
76 changes: 76 additions & 0 deletions sandbox/api/responses/GET_RelatedPerson/identifier_include.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"entry": [
{
"fullUrl": "https://internal-dev.api.service.nhs.uk/validated-relationships/FHIR/R4/Patient/0987654321",
"resource": {
"id": "0987654321",
"birthDate": "2014-09-21",
"identifier": [
{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "0987654321"
}
],
"name": [
{
"id": "ggvay",
"family": "WOMACK",
"given": ["David", "Gus"],
"period": { "start": "2018-06-24" },
"prefix": ["MR"],
"use": "usual"
}
],
"resourceType": "Patient"
},
"search": { "mode": "include" }
},
{
"fullUrl": "https://internal-dev.api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/ABCD1234",
"resource": {
"id": "ABCD1234",
"identifier": [
{
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "1234567890"
}
],
"patient": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "0987654321"
},
"type": "Patient"
},
"relationship": [
{
"coding": [
{
"code": "MTH",
"display": "mother",
"system": "http://hl7.org/fhir/ValueSet/relatedperson-relationshiptype"
},
{
"code": "Personal",
"display": "Personal relationship with the patient",
"system": "https://fhir.nhs.uk/R4/CodeSystem/UKCore-AdditionalRelatedPersonRole"
}
]
}
],
"resourceType": "RelatedPerson"
},
"search": { "mode": "match" }
}
],
"link": [
{
"relation": "self",
"url": "sandbox"
}
],
"timestamp": "2024-00-00T00:00:00+00:00",
"total": 2,
"type": "searchset",
"resourceType": "Bundle"
}
2 changes: 1 addition & 1 deletion sandbox/api/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from ..app import app

RELATED_PERSON_API_ENDPOINT = "/FHIR/R4/RelatedPerson"

@pytest.fixture()
def client() -> object:
Expand Down
Loading

0 comments on commit e05dffc

Please sign in to comment.