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 f3b7ca9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
21 changes: 20 additions & 1 deletion sandbox/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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"])
Expand All @@ -21,7 +22,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 +77,21 @@ 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"
}
]
}
}
]
}
4 changes: 4 additions & 0 deletions sandbox/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
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 f3b7ca9

Please sign in to comment.