Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/authorisation/authoriser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json

from authorisation.api_operation_code import ApiOperationCode
from clients import redis_client, logger
from clients import logger, redis_client
from constants import SUPPLIER_PERMISSIONS_HASH_KEY


Expand Down
1 change: 0 additions & 1 deletion backend/src/controller/aws_apig_event_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from typing import Optional

from aws_lambda_typing.events import APIGatewayProxyEventV1

from controller.constants import SUPPLIER_SYSTEM_HEADER_NAME
from models.errors import UnauthorizedError
from utils import dict_utils
Expand Down
8 changes: 4 additions & 4 deletions backend/src/controller/fhir_api_exception_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from constants import GENERIC_SERVER_ERROR_DIAGNOSTICS_MESSAGE
from controller.aws_apig_response_utils import create_response
from models.errors import (
UnauthorizedVaxError,
UnauthorizedError,
Code,
ResourceNotFoundError,
create_operation_outcome,
Severity,
Code,
UnauthorizedError,
UnauthorizedVaxError,
create_operation_outcome,
)

_CUSTOM_EXCEPTION_TO_STATUS_MAP: dict[Type[Exception], int] = {
Expand Down
17 changes: 8 additions & 9 deletions backend/src/controller/fhir_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@
from typing import Optional

from aws_lambda_typing.events import APIGatewayProxyEventV1

from controller.aws_apig_event_utils import (
get_supplier_system_header,
get_path_parameter,
get_supplier_system_header,
)
from controller.aws_apig_response_utils import create_response
from controller.constants import E_TAG_HEADER_NAME
from controller.fhir_api_exception_handler import fhir_api_exception_handler
from models.errors import (
Severity,
Code,
create_operation_outcome,
UnauthorizedError,
ResourceNotFoundError,
UnhandledResponseError,
ValidationError,
IdentifierDuplicationError,
ParameterException,
ResourceNotFoundError,
Severity,
UnauthorizedError,
UnauthorizedVaxError,
UnhandledResponseError,
ValidationError,
create_operation_outcome,
)
from models.utils.generic_utils import check_keys_in_sources
from parameter_parser import process_params, process_search_params, create_query_string
from parameter_parser import create_query_string, process_params, process_search_params
from repository.fhir_repository import ImmunizationRepository, create_table
from service.fhir_service import FhirService, UpdateOutcome, get_service_url

Expand Down
2 changes: 1 addition & 1 deletion backend/src/create_imms_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from controller.fhir_controller import FhirController, make_controller
from local_lambda import load_string
from log_structure import function_info
from models.errors import Severity, Code, create_operation_outcome
from models.errors import Code, Severity, create_operation_outcome

logging.basicConfig(level="INFO")
logger = logging.getLogger()
Expand Down
2 changes: 1 addition & 1 deletion backend/src/delete_imms_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from controller.aws_apig_response_utils import create_response
from controller.fhir_controller import FhirController, make_controller
from log_structure import function_info
from models.errors import Severity, Code, create_operation_outcome
from models.errors import Code, Severity, create_operation_outcome

logging.basicConfig(level="INFO")
logger = logging.getLogger()
Expand Down
5 changes: 2 additions & 3 deletions backend/src/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from constants import Urls
from models.utils.generic_utils import (
is_actor_referencing_contained_resource,
get_contained_practitioner,
get_contained_patient,
get_contained_practitioner,
is_actor_referencing_contained_resource,
)


Expand Down Expand Up @@ -63,7 +63,6 @@ def replace_organization_values(imms: dict) -> dict:
"""
for performer in imms.get("performer", [{}]):
if performer.get("actor", {}).get("type") == "Organization":

# Obfuscate or set the identifier value and system.
identifier = performer["actor"].get("identifier", {})
if identifier.get("value") is not None:
Expand Down
7 changes: 3 additions & 4 deletions backend/src/forwarding_batch_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
from datetime import datetime

import simplejson as json

from batch.batch_filename_to_events_mapper import BatchFilenameToEventsMapper
from clients import sqs_client
from controller.fhir_batch_controller import (
ImmunizationBatchController,
make_batch_controller,
)
from models.errors import (
MessageNotSuccessfulError,
RecordProcessorError,
CustomValidationError,
IdentifierDuplicationError,
ResourceNotFoundError,
MessageNotSuccessfulError,
RecordProcessorError,
ResourceFoundError,
ResourceNotFoundError,
)
from repository.fhir_batch_repository import create_table

Expand Down
1 change: 0 additions & 1 deletion backend/src/models/fhir_immunization.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Immunization FHIR R4B validator"""

from fhir.resources.R4B.immunization import Immunization

from models.fhir_immunization_post_validators import PostValidators
from models.fhir_immunization_pre_validators import PreValidators
from models.utils.validation_utils import get_vaccine_type
Expand Down
2 changes: 1 addition & 1 deletion backend/src/models/fhir_immunization_post_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from models.field_locations import FieldLocations
from models.field_names import FieldNames
from models.mandation_functions import MandationFunctions
from models.utils.base_utils import obtain_field_value, obtain_field_location
from models.utils.base_utils import obtain_field_location, obtain_field_value
from models.validation_sets import ValidationSets


Expand Down
10 changes: 5 additions & 5 deletions backend/src/models/fhir_immunization_pre_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from models.constants import Constants
from models.errors import MandatoryError
from models.utils.generic_utils import (
get_generic_extension_value,
generate_field_location_for_extension,
check_for_unknown_elements,
patient_name_given_field_location,
generate_field_location_for_extension,
get_generic_extension_value,
patient_and_practitioner_value_and_index,
patient_name_family_field_location,
practitioner_name_given_field_location,
patient_name_given_field_location,
practitioner_name_family_field_location,
patient_and_practitioner_value_and_index,
practitioner_name_given_field_location,
)
from models.utils.pre_validator_utils import PreValidation

Expand Down
4 changes: 2 additions & 2 deletions backend/src/models/field_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from constants import Urls
from models.utils.generic_utils import (
generate_field_location_for_extension,
patient_name_given_field_location,
patient_name_family_field_location,
practitioner_name_given_field_location,
patient_name_given_field_location,
practitioner_name_family_field_location,
practitioner_name_given_field_location,
)


Expand Down
2 changes: 1 addition & 1 deletion backend/src/models/obtain_field_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from models.utils.generic_utils import (
get_contained_patient,
get_contained_practitioner,
is_organization,
get_generic_extension_value,
is_organization,
patient_and_practitioner_value_and_index,
)

Expand Down
2 changes: 0 additions & 2 deletions backend/src/models/utils/base_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
"""Utils for backend src code"""

from models.field_locations import FieldLocations

from models.obtain_field_value import ObtainFieldValue


FIELD_LOCATIONS = FieldLocations()


Expand Down
9 changes: 5 additions & 4 deletions backend/src/models/utils/generic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
import datetime
import json
import urllib.parse
from typing import Literal, Union, Optional, Dict, Any
from typing import Any, Dict, Literal, Optional, Union

from fhir.resources.R4B.bundle import (
Bundle as FhirBundle,
)
from fhir.resources.R4B.bundle import (
BundleEntry,
BundleLink,
BundleEntrySearch,
BundleLink,
)
from fhir.resources.R4B.immunization import Immunization
from stdnum.verhoeff import validate

from models.constants import Constants
from stdnum.verhoeff import validate


def get_contained_resource(imms: dict, resource: Literal["Patient", "Practitioner", "QuestionnaireResponse"]):
Expand Down
5 changes: 2 additions & 3 deletions backend/src/models/utils/pre_validator_utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from datetime import datetime, date
from datetime import date, datetime
from decimal import Decimal
from typing import Union

from .generic_utils import nhs_number_mod11_check, is_valid_simple_snomed
from .generic_utils import is_valid_simple_snomed, nhs_number_mod11_check


class PreValidation:

@staticmethod
def for_string(
field_value: str,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/models/utils/validation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from models.field_names import FieldNames
from models.obtain_field_value import ObtainFieldValue
from models.utils.base_utils import obtain_field_location

from .generic_utils import create_diagnostics_error


Expand All @@ -27,7 +28,6 @@ def get_target_disease_codes(immunization: dict):

# For each item in the target disease list, extract the snomed code
for i, element in enumerate(target_disease):

try:
code = [x["code"] for x in element["coding"] if x.get("system") == Urls.snomed][0]
except (KeyError, IndexError) as error:
Expand Down
1 change: 0 additions & 1 deletion backend/src/not_found_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def not_found_handler(event, context):


def not_found(event, _context):

if event.get("httpMethod") not in ALLOWED_METHODS:
response = {
"statusCode": 405,
Expand Down
3 changes: 1 addition & 2 deletions backend/src/parameter_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import datetime
from dataclasses import dataclass
from typing import Optional
from urllib.parse import parse_qs, urlencode, quote
from urllib.parse import parse_qs, quote, urlencode

from aws_lambda_typing.events import APIGatewayProxyEventV1

from clients import redis_client
from models.constants import Constants
from models.errors import ParameterException
Expand Down
8 changes: 3 additions & 5 deletions backend/src/repository/fhir_batch_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import boto3
import botocore.exceptions
import simplejson as json
from boto3.dynamodb.conditions import Key, Attr

from boto3.dynamodb.conditions import Attr, Key
from clients import logger
from models.errors import (
UnhandledResponseError,
IdentifierDuplicationError,
ResourceNotFoundError,
ResourceFoundError,
ResourceNotFoundError,
UnhandledResponseError,
)


Expand Down Expand Up @@ -94,7 +93,6 @@ def __init__(self, imms: dict, vax_type: str, supplier: str, version: int):


class ImmunizationBatchRepository:

def create_immunization(
self,
immunization: any,
Expand Down
9 changes: 4 additions & 5 deletions backend/src/repository/fhir_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@
import simplejson as json
from boto3.dynamodb.conditions import Attr, Key
from botocore.config import Config
from mypy_boto3_dynamodb.service_resource import DynamoDBServiceResource, Table
from responses import logger

from models.errors import (
IdentifierDuplicationError,
ResourceNotFoundError,
UnhandledResponseError,
IdentifierDuplicationError,
)
from models.utils.validation_utils import (
get_vaccine_type,
check_identifier_system_value,
get_vaccine_type,
)
from mypy_boto3_dynamodb.service_resource import DynamoDBServiceResource, Table
from responses import logger


def create_table(table_name=None, endpoint_url=None, region_name="eu-west-2"):
Expand Down
6 changes: 3 additions & 3 deletions backend/src/search_imms_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import urllib.parse
import uuid

from aws_lambda_typing import context as context_, events

from aws_lambda_typing import context as context_
from aws_lambda_typing import events
from constants import GENERIC_SERVER_ERROR_DIAGNOSTICS_MESSAGE, MAX_RESPONSE_SIZE_BYTES
from controller.aws_apig_response_utils import create_response
from controller.fhir_controller import FhirController, make_controller
from log_structure import function_info
from models.errors import Severity, Code, create_operation_outcome
from models.errors import Code, Severity, create_operation_outcome

logging.basicConfig(level="INFO")
logger = logging.getLogger()
Expand Down
7 changes: 2 additions & 5 deletions backend/src/service/fhir_batch_service.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from pydantic import ValidationError

from models.errors import CustomValidationError
from models.errors import MandatoryError
from models.errors import CustomValidationError, MandatoryError
from models.fhir_immunization import ImmunizationValidator

from pydantic import ValidationError
from repository.fhir_batch_repository import ImmunizationBatchRepository

IMMUNIZATION_VALIDATOR = ImmunizationValidator()
Expand Down
Loading
Loading