Skip to content

Commit faf5c87

Browse files
authored
Merge branch 'master' into VED-789-Schema-Validation
2 parents ae1f056 + 185d315 commit faf5c87

File tree

6 files changed

+37
-4
lines changed

6 files changed

+37
-4
lines changed

backend/src/models/fhir_immunization_pre_validators.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def validate(self):
9898
self.pre_validate_vaccination_procedure_code,
9999
self.pre_validate_vaccination_procedure_display,
100100
self.pre_validate_vaccine_code,
101+
self.pre_validate_vaccine_display,
101102
]
102103

103104
for method in validation_methods:
@@ -976,3 +977,16 @@ def pre_validate_vaccine_code(self, values: dict) -> dict:
976977
PreValidation.for_snomed_code(field_value, field_location)
977978
except (KeyError, IndexError):
978979
pass
980+
981+
def pre_validate_vaccine_display(self, values: dict) -> dict:
982+
"""
983+
Pre-validate that, if vaccineCode.coding[?(@.system=='http://snomed.info/sct')].display
984+
(legacy CSV field : VACCINE_PRODUCT_TERM) exists, then it is a non-empty string
985+
"""
986+
url = Urls.snomed
987+
field_location = f"vaccineCode.coding[?(@.system=='{url}')].display"
988+
try:
989+
field_value = [x for x in values["vaccineCode"]["coding"] if x.get("system") == url][0]["display"]
990+
PreValidation.for_string(field_value, field_location)
991+
except (KeyError, IndexError):
992+
pass

backend/tests/test_immunization_pre_validator.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,14 @@ def test_pre_validate_vaccine_code(self):
14041404
actual_error_messages,
14051405
)
14061406

1407+
def test_pre_validate_vaccine_display(self):
1408+
"""Test test_pre_validate_vaccine_display accepts valid values and rejects invalid values"""
1409+
ValidatorModelTests.test_string_value(
1410+
self,
1411+
field_location="vaccineCode.coding[?(@.system=='http://snomed.info/sct')].display",
1412+
valid_strings_to_test=["DUMMY"],
1413+
)
1414+
14071415
def test_pre_validate_vaccination_procedure_display(self):
14081416
"""Test test_pre_validate_vaccination_procedure_display accepts valid values and rejects invalid values"""
14091417
ValidatorModelTests.test_string_value(

lambdas/batch_processor_filter/src/batch_processor_filter_service.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from batch_file_repository import BatchFileRepository
88
from common.clients import get_sqs_client, logger
99
from common.log_firehose import send_log_to_firehose
10-
from constants import QUEUE_URL, FileNotProcessedReason, FileStatus
10+
from constants import QUEUE_URL, SPLUNK_FIREHOSE_STREAM_NAME, FileNotProcessedReason, FileStatus
1111
from exceptions import EventAlreadyProcessingForSupplierAndVaccTypeError
1212

1313
BATCH_AUDIT_REPOSITORY = BatchAuditRepository()
@@ -72,4 +72,7 @@ def apply_filter(self, batch_file_created_event: BatchFileCreatedEvent) -> None:
7272

7373
successful_log_message = f"File forwarded for processing by ECS. Filename: {filename}"
7474
logger.info(successful_log_message)
75-
send_log_to_firehose({**batch_file_created_event, "message": successful_log_message})
75+
send_log_to_firehose(
76+
stream_name=SPLUNK_FIREHOSE_STREAM_NAME,
77+
log_data={**batch_file_created_event, "message": successful_log_message},
78+
)

lambdas/batch_processor_filter/tests/test_lambda_handler.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
AUDIT_TABLE_FILENAME_GSI,
2727
AUDIT_TABLE_NAME,
2828
AUDIT_TABLE_QUEUE_NAME_GSI,
29+
SPLUNK_FIREHOSE_STREAM_NAME,
2930
AuditTableKeys,
3031
FileStatus,
3132
)
@@ -299,7 +300,8 @@ def test_lambda_handler_processes_event_successfully(self):
299300
]
300301
)
301302
self.mock_firehose_send_log.assert_called_once_with(
302-
{**self.default_batch_file_event, "message": expected_success_log_message}
303+
stream_name=SPLUNK_FIREHOSE_STREAM_NAME,
304+
log_data={**self.default_batch_file_event, "message": expected_success_log_message},
303305
)
304306

305307
def test_lambda_handler_processes_event_successfully_when_event_for_same_supplier_and_vacc_already_processed(
@@ -345,4 +347,6 @@ def test_lambda_handler_processes_event_successfully_when_event_for_same_supplie
345347
call(expected_success_log_message),
346348
]
347349
)
348-
self.mock_firehose_send_log.assert_called_once_with({**test_event, "message": expected_success_log_message})
350+
self.mock_firehose_send_log.assert_called_once_with(
351+
stream_name=SPLUNK_FIREHOSE_STREAM_NAME, log_data={**test_event, "message": expected_success_log_message}
352+
)

lambdas/batch_processor_filter/tests/testing_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"FILE_NAME_GSI": "filename_index",
1111
"QUEUE_NAME_GSI": "queue_name_index",
1212
"SOURCE_BUCKET_NAME": "immunisation-batch-internal-dev-data-sources",
13+
"SPLUNK_FIREHOSE_STREAM_NAME": "immunisation-batch-internal-dev-splunk-stream",
1314
"ACK_BUCKET_NAME": "immunisation-batch-internal-dev-data-destinations",
1415
}
1516

lambdas/shared/src/common/log_firehose.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
from common.clients import logger
55

66

7+
# Not keen on including blocking calls in function code to forward log data to Splunk (via Firehose)
8+
# Consider simply logging and setting up CW subscription filters to forward to Firehose
9+
# https://docs.aws.amazon.com/firehose/latest/dev/writing-with-cloudwatch-logs.html
710
def send_log_to_firehose(stream_name: str, log_data: dict) -> None:
811
"""Sends the log_message to Firehose"""
912
try:

0 commit comments

Comments
 (0)