Skip to content

Commit 880a429

Browse files
committed
Merge branch 'master' into VED-815-coverage-runs
2 parents 09b938f + e0b2c70 commit 880a429

26 files changed

+99
-73
lines changed

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ version: 2
77
updates:
88
- package-ecosystem: "docker"
99
directories:
10-
- "/batch_processor_filter"
1110
- "/infrastructure/grafana/non-prod/docker"
1211
- "/lambdas/ack_backend"
12+
- "/lambdas/batch_processor_filter"
1313
- "/lambdas/delta_backend"
1414
- "/lambdas/filenameprocessor"
1515
- "/lambdas/mesh_processor"
@@ -50,8 +50,8 @@ updates:
5050
directories:
5151
- "/"
5252
- "/backend"
53-
- "/batch_processor_filter"
5453
- "/lambdas/ack_backend"
54+
- "/lambdas/batch_processor_filter"
5555
- "/lambdas/delta_backend"
5656
- "/lambdas/filenameprocessor"
5757
- "/lambdas/id_sync"

.github/workflows/quality-checks.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,6 @@ jobs:
9797
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
9898
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
9999
100-
- name: Run unittest with batchprocessorfilter-coverage
101-
working-directory: batch_processor_filter
102-
id: batchprocessorfilter
103-
env:
104-
PYTHONPATH: ${{ github.workspace }}/batch_processor_filter/src:${{ github.workspace }}/batch_processor_filter/tests
105-
continue-on-error: true
106-
run: |
107-
poetry install
108-
poetry run coverage run --source=src -m unittest discover || echo "batchprocessorfilter tests failed" >> ../failed_tests.txt
109-
poetry run coverage xml -o ../batchprocessorfilter-coverage.xml
110-
111100
- name: Run unittest with recordprocessor-coverage
112101
working-directory: lambdas/recordprocessor
113102
id: recordprocessor
@@ -153,6 +142,17 @@ jobs:
153142
poetry run coverage run --source=src -m unittest discover || echo "ack-lambda tests failed" >> ../../failed_tests.txt
154143
poetry run coverage xml -o ../../ack-lambda-coverage.xml
155144
145+
- name: Run unittest with batchprocessorfilter-coverage
146+
working-directory: lambdas/batch_processor_filter
147+
id: batchprocessorfilter
148+
env:
149+
PYTHONPATH: ${{ env.LAMBDA_PATH }}/batch_processor_filter/src:${{ env.LAMBDA_PATH }}/batch_processor_filter/tests:${{ env.SHARED_PATH }}/src
150+
continue-on-error: true
151+
run: |
152+
poetry install
153+
poetry run coverage run --source=src -m unittest discover || echo "batchprocessorfilter tests failed" >> ../../failed_tests.txt
154+
poetry run coverage xml -o ../../batchprocessorfilter-coverage.xml
155+
156156
- name: Run unittest with coverage-delta
157157
working-directory: lambdas/delta_backend
158158
id: delta

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL=/usr/bin/env bash -euo pipefail
22

3-
PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS = backend batch_processor_filter lambdas/ack_backend lambdas/delta_backend lambdas/filenameprocessor lambdas/id_sync lambdas/mesh_processor lambdas/mns_subscription lambdas/recordprocessor lambdas/redis_sync lambdas/shared
3+
PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS = backend lambdas/ack_backend lambdas/batch_processor_filter lambdas/delta_backend lambdas/filenameprocessor lambdas/id_sync lambdas/mesh_processor lambdas/mns_subscription lambdas/recordprocessor lambdas/redis_sync lambdas/shared
44
PYTHON_PROJECT_DIRS = tests/e2e tests/e2e_batch quality_checks $(PYTHON_PROJECT_DIRS_WITH_UNIT_TESTS)
55

66
.PHONY: install lint format format-check clean publish build-proxy release initialise-all-python-venvs update-all-python-dependencies run-all-python-unit-tests build-all-docker-images

backend/src/models/fhir_immunization_pre_validators.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def validate(self):
9696
self.pre_validate_value_codeable_concept,
9797
self.pre_validate_extension_length,
9898
self.pre_validate_vaccination_procedure_code,
99+
self.pre_validate_vaccination_procedure_display,
99100
self.pre_validate_vaccine_code,
100101
]
101102

@@ -590,7 +591,7 @@ def pre_validate_vaccination_procedure_code(self, values: dict) -> dict:
590591
(legacy CSV field name: VACCINATION_PROCEDURE_CODE) exists, then it is a non-empty string
591592
"""
592593
url = "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-" + "VaccinationProcedure"
593-
system = "http://snomed.info/sct"
594+
system = Urls.snomed
594595
field_type = "code"
595596
field_location = generate_field_location_for_extension(url, system, field_type)
596597
try:
@@ -600,14 +601,30 @@ def pre_validate_vaccination_procedure_code(self, values: dict) -> dict:
600601
except (KeyError, IndexError):
601602
pass
602603

604+
def pre_validate_vaccination_procedure_display(self, values: dict) -> dict:
605+
"""
606+
Pre-validate that, if extension[?(@.url=='https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-
607+
VaccinationProcedure')].valueCodeableConcept.coding[?(@.system=='http://snomed.info/sct')].display
608+
(legacy CSV field name: VACCINATION_PROCEDURE_TERM) exists, then it is a non-empty string
609+
"""
610+
url = "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-" + "VaccinationProcedure"
611+
system = Urls.snomed
612+
field_type = "display"
613+
field_location = generate_field_location_for_extension(url, system, field_type)
614+
try:
615+
field_value = get_generic_extension_value(values, url, system, field_type)
616+
PreValidation.for_string(field_value, field_location)
617+
except (KeyError, IndexError):
618+
pass
619+
603620
def pre_validate_vaccination_situation_code(self, values: dict) -> dict:
604621
"""
605622
Pre-validate that, if extension[?(@.url=='https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-
606623
VaccinationSituation')].valueCodeableConcept.coding[?(@.system=='http://snomed.info/sct')].code
607624
(legacy CSV field name: VACCINATION_SITUATION_CODE) exists, then it is a non-empty string
608625
"""
609626
url = "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-VaccinationSituation"
610-
system = "http://snomed.info/sct"
627+
system = Urls.snomed
611628
field_type = "code"
612629
field_location = generate_field_location_for_extension(url, system, field_type)
613630
try:
@@ -623,7 +640,7 @@ def pre_validate_vaccination_situation_display(self, values: dict) -> dict:
623640
(legacy CSV field name: VACCINATION_SITUATION_TERM) exists, then it is a non-empty string
624641
"""
625642
url = "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-VaccinationSituation"
626-
system = "http://snomed.info/sct"
643+
system = Urls.snomed
627644
field_type = "display"
628645
field_location = generate_field_location_for_extension(url, system, field_type)
629646
try:
@@ -702,7 +719,7 @@ def pre_validate_disease_type_coding_codes(self, values: dict) -> dict:
702719
Pre-validate that, if protocolApplied[0].targetDisease[{i}].coding[?(@.system=='http://snomed.info/sct')].code
703720
exists, then it is a non-empty string
704721
"""
705-
url = "http://snomed.info/sct"
722+
url = Urls.snomed
706723
try:
707724
for i in range(len(values["protocolApplied"][0]["targetDisease"])):
708725
field_location = f"protocolApplied[0].targetDisease[{i}].coding[?(@.system=='{url}')].code"
@@ -761,7 +778,7 @@ def pre_validate_site_coding_code(self, values: dict) -> dict:
761778
Pre-validate that, if site.coding[?(@.system=='http://snomed.info/sct')].code
762779
(legacy CSV field name: SITE_OF_VACCINATION_CODE) exists, then it is a non-empty string
763780
"""
764-
url = "http://snomed.info/sct"
781+
url = Urls.snomed
765782
field_location = f"site.coding[?(@.system=='{url}')].code"
766783
try:
767784
site_coding_code = [x for x in values["site"]["coding"] if x.get("system") == url][0]["code"]
@@ -774,7 +791,7 @@ def pre_validate_site_coding_display(self, values: dict) -> dict:
774791
Pre-validate that, if site.coding[?(@.system=='http://snomed.info/sct')].display
775792
(legacy CSV field name: SITE_OF_VACCINATION_TERM) exists, then it is a non-empty string
776793
"""
777-
url = "http://snomed.info/sct"
794+
url = Urls.snomed
778795
field_location = f"site.coding[?(@.system=='{url}')].display"
779796
try:
780797
field_value = [x for x in values["site"]["coding"] if x.get("system") == url][0]["display"]
@@ -795,7 +812,7 @@ def pre_validate_route_coding_code(self, values: dict) -> dict:
795812
Pre-validate that, if route.coding[?(@.system=='http://snomed.info/sct')].code
796813
(legacy CSV field name: ROUTE_OF_VACCINATION_CODE) exists, then it is a non-empty string
797814
"""
798-
url = "http://snomed.info/sct"
815+
url = Urls.snomed
799816
field_location = f"route.coding[?(@.system=='{url}')].code"
800817
try:
801818
field_value = [x for x in values["route"]["coding"] if x.get("system") == url][0]["code"]
@@ -808,7 +825,7 @@ def pre_validate_route_coding_display(self, values: dict) -> dict:
808825
Pre-validate that, if route.coding[?(@.system=='http://snomed.info/sct')].display
809826
(legacy CSV field name: ROUTE_OF_VACCINATION_TERM) exists, then it is a non-empty string
810827
"""
811-
url = "http://snomed.info/sct"
828+
url = Urls.snomed
812829
field_location = f"route.coding[?(@.system=='{url}')].display"
813830
try:
814831
field_value = [x for x in values["route"]["coding"] if x.get("system") == url][0]["display"]
@@ -951,7 +968,7 @@ def pre_validate_vaccine_code(self, values: dict) -> dict:
951968
NOTE: vaccineCode is a mandatory FHIR field. A value of None will be rejected by the
952969
FHIR model before pre-validators are run.
953970
"""
954-
url = "http://snomed.info/sct"
971+
url = Urls.snomed
955972
field_location = f"vaccineCode.coding[?(@.system=='{url}')].code"
956973
try:
957974
field_value = [x for x in values["vaccineCode"]["coding"] if x.get("system") == url][0]["code"]

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_vaccination_procedure_display(self):
1408+
"""Test test_pre_validate_vaccination_procedure_display accepts valid values and rejects invalid values"""
1409+
ValidatorModelTests.test_string_value(
1410+
self,
1411+
field_location="extension[?(@.url=='https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-VaccinationProcedure')].valueCodeableConcept.coding[?(@.system=='http://snomed.info/sct')].display",
1412+
valid_strings_to_test=["DUMMY"],
1413+
)
1414+
14071415

14081416
class TestImmunizationModelPreValidationRulesForReduceValidation(unittest.TestCase):
14091417
"""Test immunization pre validation rules on the FHIR model using the status="reduce validation" data"""

batch_processor_filter/src/logger.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

batch_processor_filter/src/send_log_to_firehose.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

immunisation-fhir-api.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
{
1010
"path": "lambdas/ack_backend",
1111
},
12+
{
13+
"path": "lambdas/batch_processor_filter",
14+
},
1215
{
1316
"path": "lambdas/delta_backend",
1417
},

infrastructure/instance/batch_processor_filter_lambda.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Define the directory containing the Docker image and calculate its SHA-256 hash for triggering redeployments
22
locals {
3-
batch_processor_filter_lambda_dir = abspath("${path.root}/../../batch_processor_filter")
3+
batch_processor_filter_lambda_dir = abspath("${path.root}/../../lambdas/batch_processor_filter")
44
batch_processor_filter_lambda_files = fileset(local.batch_processor_filter_lambda_dir, "**")
55
batch_processor_filter_lambda_dir_sha = sha1(join("", [for f in local.batch_processor_filter_lambda_files : filesha1("${local.batch_processor_filter_lambda_dir}/${f}")]))
66
}
@@ -15,8 +15,9 @@ resource "aws_ecr_repository" "batch_processor_filter_lambda_repository" {
1515

1616
# Module for building and pushing Docker image to ECR
1717
module "batch_processor_filter_docker_image" {
18-
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
19-
version = "8.1.2"
18+
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
19+
version = "8.1.2"
20+
docker_file_path = "./batch_processor_filter/Dockerfile"
2021

2122
create_ecr_repo = false
2223
ecr_repo = aws_ecr_repository.batch_processor_filter_lambda_repository.name
@@ -39,9 +40,10 @@ module "batch_processor_filter_docker_image" {
3940

4041
platform = "linux/amd64"
4142
use_image_tag = false
42-
source_path = local.batch_processor_filter_lambda_dir
43+
source_path = abspath("${path.root}/../../lambdas")
4344
triggers = {
44-
dir_sha = local.batch_processor_filter_lambda_dir_sha
45+
dir_sha = local.batch_processor_filter_lambda_dir_sha
46+
shared_dir_sha = local.shared_dir_sha
4547
}
4648
}
4749

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,31 @@ RUN mkdir -p /home/appuser && \
55
echo 'appuser:x:1001:' >> /etc/group && \
66
chown -R 1001:1001 /home/appuser && pip install "poetry~=2.1.4"
77

8-
COPY poetry.lock pyproject.toml README.md ./
8+
# Install Poetry dependencies
9+
# Copy batch_processor_filter Poetry files
10+
COPY ./batch_processor_filter/poetry.lock ./batch_processor_filter/pyproject.toml ./
11+
12+
# Install batch_processor_filter dependencies
13+
WORKDIR /var/task
914
RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main
15+
1016
# -----------------------------
1117
FROM base AS build
12-
COPY src .
18+
19+
# Set working directory back to Lambda task root
20+
WORKDIR /var/task
21+
22+
# Copy shared source code
23+
COPY ./shared/src/common ./common
24+
25+
# Copy batch_processor_filter source code
26+
COPY ./batch_processor_filter/src .
27+
28+
# Set correct permissions
1329
RUN chmod 644 $(find . -type f) && chmod 755 $(find . -type d)
30+
1431
# Switch to the non-root user for running the container
1532
USER 1001:1001
33+
34+
# Set the Lambda handler
1635
CMD ["lambda_handler.lambda_handler"]

0 commit comments

Comments
 (0)