From a5ccbb62bc7693bf6575f9f6552fb3f6b0a8ed26 Mon Sep 17 00:00:00 2001 From: kamran-iqbal4-NHSD <144686155+kamran-iqbal4-NHSD@users.noreply.github.com> Date: Thu, 16 May 2024 16:35:11 +0100 Subject: [PATCH] NPA-1736: Reworked module import to resolve issue with gunicorn --- sandbox/api/app.py | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/sandbox/api/app.py b/sandbox/api/app.py index 6c8eea7..c286c4b 100644 --- a/sandbox/api/app.py +++ b/sandbox/api/app.py @@ -3,7 +3,21 @@ from flask import Flask, request -import sandbox.api.utils as utils +from .utils import ( + VALIDATE_RELATIONSHIP_009, + VALIDATE_RELATIONSHIP_INCLUDE_009, + VALIDATE_RELATIONSHIP_025, + VALIDATE_RELATIONSHIP_INCLUDE_025, + LIST_RELATIONSHIP, + LIST_RELATIONSHIP_INCLUDE, + ERROR_RESPONSE, + check_for_errors, + check_for_empty, + check_for_validate, + check_for_list, + generate_response, + load_json_file, +) app = Flask(__name__) basicConfig(level=INFO, format="%(asctime)s - %(message)s") @@ -31,43 +45,43 @@ def get_related_persons() -> Union[dict, tuple]: try: # Check Headers - if errors := utils.check_for_errors(request): + if errors := check_for_errors(request): return errors identifier = request.args.get("identifier") patient_identifier = request.args.get("patient:identifier") include = request.args.get("_include") - if empty := utils.check_for_empty(identifier, patient_identifier): + if empty := check_for_empty(identifier, patient_identifier): return empty # Successful request, select response - if zero_nine := utils.check_for_validate( + if zero_nine := check_for_validate( "9000000009", identifier, patient_identifier, include, - utils.VALIDATE_RELATIONSHIP_009, - utils.VALIDATE_RELATIONSHIP_INCLUDE_009, + VALIDATE_RELATIONSHIP_009, + VALIDATE_RELATIONSHIP_INCLUDE_009, ): return zero_nine - if two_five := utils.check_for_validate( + if two_five := check_for_validate( "9000000025", identifier, patient_identifier, include, - utils.VALIDATE_RELATIONSHIP_025, - utils.VALIDATE_RELATIONSHIP_INCLUDE_025, + VALIDATE_RELATIONSHIP_025, + VALIDATE_RELATIONSHIP_INCLUDE_025, ): return two_five - if one_seven := utils.check_for_list( + if one_seven := check_for_list( "9000000017", identifier, include, - utils.LIST_RELATIONSHIP, - utils.LIST_RELATIONSHIP_INCLUDE, + LIST_RELATIONSHIP, + LIST_RELATIONSHIP_INCLUDE, ): return one_seven @@ -75,4 +89,4 @@ 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) + return generate_response(load_json_file(ERROR_RESPONSE), 500)