Skip to content

Commit 2fb9c32

Browse files
committed
NPA-4689 Add GET /QuestionnaireResponse endpoint to Sandbox
1 parent 5d228e9 commit 2fb9c32

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

sandbox/api/app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from flask import Flask
55

66
from .get_consent import get_consent_response
7+
from .get_questionnaire_response import get_questionnaire_response_response
78
from .get_related_person import get_related_person_response
89
from .patch_consent import patch_consent_response
910
from .post_consent import post_consent_response
@@ -37,6 +38,16 @@ def get_related_persons() -> Union[dict, tuple]:
3738
return get_related_person_response()
3839

3940

41+
@app.route(f"/{COMMON_PATH}/QuestionnaireResponse", methods=["GET"])
42+
def get_questionnaire_response() -> Union[dict, tuple]:
43+
"""Sandbox API for GET /QuestionnaireResponse
44+
45+
Returns:
46+
Union[dict, tuple]: Response for GET /QuestionnaireResponse
47+
"""
48+
return get_questionnaire_response_response()
49+
50+
4051
@app.route(f"/{COMMON_PATH}/QuestionnaireResponse", methods=["POST"])
4152
def post_questionnaire_response() -> Union[dict, tuple]:
4253
"""Sandbox API for POST /QuestionnaireResponse

sandbox/api/constants.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,15 @@
6262
PATCH_CONSENT__RESOURCE_NOT_FOUND = f"{PATCH_CONSENT__DIRECTORY}errors/resource_not_found.yaml"
6363
PATCH_CONSENT__INVALID_STATE_TRANSITION = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_state_transition.yaml"
6464

65-
QR_DIRECTORY = "./api/examples/POST_QuestionnaireResponse/"
66-
QUESTIONNAIRE_RESPONSE__SUCCESS = f"{QR_DIRECTORY}success.yaml"
65+
# POST QuestionnaireResponse
66+
POST_QUESTIONNAIRE_RESPONSE_DIRECTORY = "./api/examples/POST_QuestionnaireResponse/"
67+
POST_QUESTIONNAIRE_RESPONSE__SUCCESS = f"{POST_QUESTIONNAIRE_RESPONSE_DIRECTORY}success.yaml"
6768

69+
# GET QuestionnaireResponse
70+
GET_QUESTIONNAIRE_RESPONSE_DIRECTORY = "./api/examples/GET_QuestionnaireResponse/"
71+
GET_QUESTIONNAIRE_RESPONSE__SUCCESS = f"{GET_QUESTIONNAIRE_RESPONSE_DIRECTORY}success.yaml"
72+
73+
# GET RelatedPerson
6874
RELATED_DIRECTORY = "./api/examples/GET_RelatedPerson/"
6975
RELATED__ERROR_IDENTIFIER_MISSING = f"{RELATED_DIRECTORY}errors/invalid-identifier-missing.yaml"
7076
RELATED__ERROR_IDENTIFIER_SYSTEM = f"{RELATED_DIRECTORY}errors/invalid-identifier-system.yaml"

sandbox/api/get_consent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
INVALIDATED_RESOURCE,
2121
)
2222
from .utils import (
23-
check_for_get_consent_errors,
2423
check_for_consent_filtering,
2524
check_for_consent_include_params,
25+
check_for_get_consent_errors,
2626
generate_response_from_example,
2727
remove_system,
2828
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from logging import INFO, basicConfig, getLogger
2+
from typing import Union
3+
4+
from .constants import INTERNAL_SERVER_ERROR_EXAMPLE, GET_QUESTIONNAIRE_RESPONSE__SUCCESS
5+
from .utils import generate_response_from_example
6+
7+
basicConfig(level=INFO, format="%(asctime)s - %(message)s")
8+
logger = getLogger(__name__)
9+
10+
11+
def get_questionnaire_response_response() -> Union[dict, tuple]:
12+
"""Sandbox API for GET /QuestionnaireResponse
13+
14+
Returns:
15+
Union[dict, tuple]: Response for GET /QuestionnaireResponse
16+
"""
17+
try:
18+
return generate_response_from_example(GET_QUESTIONNAIRE_RESPONSE__SUCCESS, 200)
19+
except Exception:
20+
logger.exception("GET questionnaire response failed")
21+
return generate_response_from_example(INTERNAL_SERVER_ERROR_EXAMPLE, 500)

sandbox/api/tests/test_get_questionnaire_response.py

Whitespace-only changes.

0 commit comments

Comments
 (0)