Skip to content

Commit 0dc9ecd

Browse files
authored
Merge branch 'master' into VED-26-add-private-subnets-2
2 parents c76d6c8 + 2f648bb commit 0dc9ecd

28 files changed

+213
-471
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
id: filenameprocessor
4141
continue-on-error: true
4242
run: |
43-
poetry env use 3.10
43+
poetry env use 3.11
4444
poetry install
4545
poetry run coverage run -m unittest discover || echo "filenameprocessor tests failed" >> ../failed_tests.txt
4646
poetry run coverage xml -o ../filenameprocessor-coverage.xml
@@ -50,7 +50,7 @@ jobs:
5050
id: recordprocessor
5151
continue-on-error: true
5252
run: |
53-
poetry env use 3.10
53+
poetry env use 3.11
5454
poetry install
5555
poetry run coverage run -m unittest discover || echo "recordprocessor tests failed" >> ../failed_tests.txt
5656
poetry run coverage xml -o ../recordprocessor-coverage.xml

delta_backend/src/delta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def send_message(record, queue_url=failure_queue_url):
6666

6767
def get_vaccine_type(patient_sort_key: str) -> str:
6868
vaccine_type = patient_sort_key.split("#")[0]
69-
return str.strip(str.upper(vaccine_type))
69+
return str.strip(str.lower(vaccine_type))
7070

7171
def get_imms_id(primary_key: str) -> str:
7272
return primary_key.split("#")[1]

delta_backend/tests/utils_for_converter_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def get_event_record(imms_id, event_name, operation, supplier="EMIS"):
179179
"ApproximateCreationDateTime": 1690896000,
180180
"NewImage": {
181181
"PK": {"S": pk},
182-
"PatientSK": {"S": "Covid19#ca8ba2c6-2383-4465-b456-c1174c21cf31"},
182+
"PatientSK": {"S": "COVID19#ca8ba2c6-2383-4465-b456-c1174c21cf31"},
183183
"IdentifierPK": {"S": "system#1"},
184184
"Operation": {"S": operation},
185185
"SupplierSystem": {"S": supplier},
@@ -195,15 +195,15 @@ def get_event_record(imms_id, event_name, operation, supplier="EMIS"):
195195
"ApproximateCreationDateTime": 1690896000,
196196
"Keys": {
197197
"PK": {"S": pk},
198-
"PatientSK": {"S": "Covid19#ca8ba2c6-2383-4465-b456-c1174c21cf31"},
198+
"PatientSK": {"S": "COVID19#ca8ba2c6-2383-4465-b456-c1174c21cf31"},
199199
"SupplierSystem": {"S": supplier},
200200
"Resource": {"S": ValuesForTests.json_value_for_test},
201201
}
202202
}
203203
}
204204

205205
expected_static_values = {
206-
"VaccineType": "COVID19",
206+
"VaccineType": "covid19",
207207
"SupplierSystem": "EMIS",
208208
"Source": "test-source",
209209
"ImmsID": "12345",

filenameprocessor/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/python:3.10 AS base
1+
FROM public.ecr.aws/lambda/python:3.11 AS base
22

33
# Create non-root user
44
RUN mkdir -p /home/appuser && \

filenameprocessor/batch.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM public.ecr.aws/lambda/python:3.10 as base
1+
FROM public.ecr.aws/lambda/python:3.11 as base
22

33
RUN pip install "poetry~=1.5.0"
44

filenameprocessor/poetry.lock

Lines changed: 10 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

filenameprocessor/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = ["Your Name <[email protected]>"]
77
packages = [{ include = "src" }]
88

99
[tool.poetry.dependencies]
10-
python = "~3.10"
10+
python = "~3.11"
1111
"fhir.resources" = "~7.0.2"
1212
boto3 = "~1.38.42"
1313
boto3-stubs-lite = { extras = ["dynamodb"], version = "~1.38.42" }

filenameprocessor/src/constants.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
AUDIT_TABLE_QUEUE_NAME_GSI = "queue_name_index"
1717
AUDIT_TABLE_FILENAME_GSI = "filename_index"
1818

19-
PERMISSIONS_CONFIG_FILE_KEY = "permissions_config.json"
19+
SUPPLIER_PERMISSIONS_HASH_KEY = "supplier_permissions"
2020
VACCINE_TYPE_TO_DISEASES_HASH_KEY = "vacc_to_diseases"
2121

2222
ERROR_TYPE_TO_STATUS_CODE_MAP = {
@@ -60,10 +60,11 @@ class Constants:
6060
"8J1100001": "PINNACLE",
6161
"8HK48": "SONAR",
6262
"YGA": "TPP",
63+
"V0V8L": "MAVIS",
64+
"X8E5B": "RAVS",
6365
"0DE": "AGEM-NIVS",
6466
"0DF": "NIMS",
6567
"8HA94": "EVA",
66-
"X26": "RAVS",
6768
"YGMYH": "MEDICAL_DIRECTOR",
6869
"W00": "WELSH_DA_1",
6970
"W000": "WELSH_DA_2",

filenameprocessor/src/elasticache.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
"Upload the content from a config file in S3 to ElastiCache (Redis)"
2-
31
import json
4-
from clients import s3_client, redis_client
5-
from constants import PERMISSIONS_CONFIG_FILE_KEY, VACCINE_TYPE_TO_DISEASES_HASH_KEY
6-
7-
8-
def upload_to_elasticache(file_key: str, bucket_name: str) -> None:
9-
"""Uploads the config file content from S3 to ElastiCache (Redis)."""
10-
config_file = s3_client.get_object(Bucket=bucket_name, Key=file_key)
11-
config_file_content = config_file["Body"].read().decode("utf-8")
12-
# Use the file_key as the Redis key and file content as the value
13-
redis_client.set(file_key, config_file_content)
2+
from clients import redis_client
3+
from constants import VACCINE_TYPE_TO_DISEASES_HASH_KEY, SUPPLIER_PERMISSIONS_HASH_KEY
144

155

16-
def get_permissions_config_json_from_cache() -> dict:
6+
def get_supplier_permissions_from_cache(supplier_system: str) -> list[str]:
177
"""Gets and returns the permissions config file content from ElastiCache (Redis)."""
18-
return json.loads(redis_client.get(PERMISSIONS_CONFIG_FILE_KEY))
8+
permissions_str = redis_client.hget(SUPPLIER_PERMISSIONS_HASH_KEY, supplier_system)
9+
return json.loads(permissions_str) if permissions_str else []
1910

2011

2112
def get_valid_vaccine_types_from_cache() -> list[str]:

filenameprocessor/src/file_name_processor.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from make_and_upload_ack_file import make_and_upload_the_ack_file
1515
from audit_table import upsert_audit_table, get_next_queued_file_details, ensure_file_is_not_a_duplicate
1616
from clients import logger
17-
from elasticache import upload_to_elasticache
1817
from logging_decorator import logging_decorator
1918
from supplier_permissions import validate_vaccine_type_permissions
2019
from errors import (
@@ -140,17 +139,6 @@ def handle_record(record) -> dict:
140139
"supplier": supplier
141140
}
142141

143-
elif "config" in bucket_name:
144-
try:
145-
upload_to_elasticache(file_key, bucket_name)
146-
logger.info("%s content successfully uploaded to cache", file_key)
147-
message = "File content successfully uploaded to cache"
148-
return {"statusCode": 200, "message": message, "file_key": file_key}
149-
except Exception as error: # pylint: disable=broad-except
150-
logger.error("Error uploading to cache for file '%s': %s", file_key, error)
151-
message = "Failed to upload file content to cache"
152-
return {"statusCode": 500, "message": message, "file_key": file_key, "error": str(error)}
153-
154142
else:
155143
try:
156144
vaccine_type, supplier = validate_file_key(file_key)

0 commit comments

Comments
 (0)