Skip to content

Commit

Permalink
NPA-2676 Add QuestionnaireResponse Sandbox response
Browse files Browse the repository at this point in the history
  • Loading branch information
JackPlowman committed May 16, 2024
1 parent 37c6abc commit b88a401
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sandbox/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -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
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "information",
"code": "informational",
"details": {
"coding": [
{
"code": "HDJ2123F",
"display": "HDJ2123F"
}
]
}
}
]
}
2 changes: 2 additions & 0 deletions sandbox/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down

0 comments on commit b88a401

Please sign in to comment.