From b88a4018a9b19523eac45e7be61213073d9f5cff Mon Sep 17 00:00:00 2001 From: Jack Plowman <62281988+JackPlowman@users.noreply.github.com> Date: Thu, 16 May 2024 14:45:26 +0100 Subject: [PATCH] NPA-2676 Add QuestionnaireResponse Sandbox response --- sandbox/api/app.py | 19 +++++++++++++++++-- .../questionnaire_response_success.json | 17 +++++++++++++++++ sandbox/api/utils.py | 2 ++ 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 sandbox/api/responses/POST_QuestionnaireResponse/questionnaire_response_success.json diff --git a/sandbox/api/app.py b/sandbox/api/app.py index 6c8eea7..893d675 100644 --- a/sandbox/api/app.py +++ b/sandbox/api/app.py @@ -8,7 +8,7 @@ app = Flask(__name__) basicConfig(level=INFO, format="%(asctime)s - %(message)s") logger = getLogger(__name__) - +COMMON_PATH = "FHIR/R4" @app.route("/_status", methods=["GET"]) @app.route("/_ping", methods=["GET"]) @@ -21,7 +21,7 @@ def health() -> dict: } -@app.route("/FHIR/R4/RelatedPerson", methods=["GET"]) +@app.route(f"/{COMMON_PATH}/RelatedPerson", methods=["GET"]) def get_related_persons() -> Union[dict, tuple]: """Sandbox API for GET /RelatedPerson @@ -76,3 +76,18 @@ def get_related_persons() -> Union[dict, tuple]: except Exception as e: logger.error(e) return utils.generate_response(utils.load_json_file(utils.ERROR_RESPONSE), 500) + +@app.route(f"/{COMMON_PATH}/QuestionnaireResponse", methods=["POST"]) +def post_questionnaire_response() -> Union[dict, tuple]: + """Sandbox API for POST /QuestionnaireResponse + + Returns: + Union[dict, tuple]: Response for POST /QuestionnaireResponse + """ + + try: + utils.generate_response(utils.load_json_file(utils.QUESTIONNAIRE_RESPONSE_SUCCESS), 200) + + except Exception as e: + logger.error(e) + return utils.generate_response(utils.load_json_file(utils.ERROR_RESPONSE), 500) diff --git a/sandbox/api/responses/POST_QuestionnaireResponse/questionnaire_response_success.json b/sandbox/api/responses/POST_QuestionnaireResponse/questionnaire_response_success.json new file mode 100644 index 0000000..7d70513 --- /dev/null +++ b/sandbox/api/responses/POST_QuestionnaireResponse/questionnaire_response_success.json @@ -0,0 +1,17 @@ +{ + "resourceType": "OperationOutcome", + "issue": [ + { + "severity": "information", + "code": "informational", + "details": { + "coding": [ + { + "code": "HDJ2123F", + "display": "HDJ2123F" + } + ] + } + } + ] +} diff --git a/sandbox/api/utils.py b/sandbox/api/utils.py index 36e223c..085ac11 100644 --- a/sandbox/api/utils.py +++ b/sandbox/api/utils.py @@ -26,6 +26,8 @@ ERROR_RESPONSE = "./api/responses/internal_server_error.json" INCLUDE_FLAG = "RelatedPerson:patient" +QUESTIONNAIRE_RESPONSE_SUCCESS = "./api/responses/POST_QuestionnaireResponse/questionnaire_response_success.json" + PATIENT_IDENTIFIERS = ["9000000017", "9000000033"] RELATED_IDENTIFIERS = ["9000000009", "9000000025"]