Skip to content

Commit 953e840

Browse files
authored
Merge branch 'master' into VED-789-Schema-Validation
2 parents 004d1a2 + de1c0f9 commit 953e840

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+138
-109
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ version: 2
77
updates:
88
- package-ecosystem: "docker"
99
directories:
10-
- "/batch_processor_filter"
1110
- "/infrastructure/grafana/non-prod/docker"
12-
- "/lambdas/filenameprocessor"
1311
- "/lambdas/ack_backend"
12+
- "/lambdas/batch_processor_filter"
1413
- "/lambdas/delta_backend"
14+
- "/lambdas/filenameprocessor"
15+
- "/lambdas/mesh_processor"
1516
- "/lambdas/recordprocessor"
16-
- "/mesh_processor"
1717
- "/sandbox"
1818
schedule:
1919
interval: "daily"
@@ -50,14 +50,14 @@ updates:
5050
directories:
5151
- "/"
5252
- "/backend"
53-
- "/batch_processor_filter"
54-
- "/mesh_processor"
55-
- "/lambdas/recordprocessor"
5653
- "/lambdas/ack_backend"
54+
- "/lambdas/batch_processor_filter"
5755
- "/lambdas/delta_backend"
5856
- "/lambdas/filenameprocessor"
5957
- "/lambdas/id_sync"
58+
- "/lambdas/mesh_processor"
6059
- "/lambdas/mns_subscription"
60+
- "/lambdas/recordprocessor"
6161
- "/lambdas/redis_sync"
6262
- "/lambdas/shared"
6363
- "/tests/e2e"

.github/workflows/quality-checks.yml

Lines changed: 25 additions & 25 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 -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
@@ -128,7 +117,7 @@ jobs:
128117
continue-on-error: true
129118
run: |
130119
poetry install
131-
poetry run coverage run -m unittest discover -p "*batch*.py" || echo "recordforwarder tests failed" >> ../failed_tests.txt
120+
poetry run coverage run --source=src -m unittest discover -p "*batch*.py" || echo "recordforwarder tests failed" >> ../failed_tests.txt
132121
poetry run coverage xml -o ../recordforwarder-coverage.xml
133122
134123
- name: Run unittest with coverage-fhir-api
@@ -139,18 +128,9 @@ jobs:
139128
continue-on-error: true
140129
run: |
141130
poetry install
142-
poetry run coverage run -m unittest discover || echo "fhir-api tests failed" >> ../failed_tests.txt
131+
poetry run coverage run --source=src -m unittest discover || echo "fhir-api tests failed" >> ../failed_tests.txt
143132
poetry run coverage xml -o ../backend-coverage.xml
144133
145-
- name: Run unittest with coverage-mesh-processor
146-
working-directory: mesh_processor
147-
id: meshprocessor
148-
continue-on-error: true
149-
run: |
150-
poetry install
151-
poetry run coverage run -m unittest discover || echo "mesh_processor tests failed" >> ../failed_tests.txt
152-
poetry run coverage xml -o ../mesh_processor-coverage.xml
153-
154134
- name: Run unittest with coverage-ack-lambda
155135
working-directory: lambdas/ack_backend
156136
id: acklambda
@@ -162,6 +142,17 @@ jobs:
162142
poetry run coverage run --source=src -m unittest discover || echo "ack-lambda tests failed" >> ../../failed_tests.txt
163143
poetry run coverage xml -o ../../ack-lambda-coverage.xml
164144
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+
165156
- name: Run unittest with coverage-delta
166157
working-directory: lambdas/delta_backend
167158
id: delta
@@ -170,7 +161,7 @@ jobs:
170161
continue-on-error: true
171162
run: |
172163
poetry install
173-
poetry run coverage run -m unittest discover || echo "delta tests failed" >> ../../failed_tests.txt
164+
poetry run coverage run --source=src -m unittest discover || echo "delta tests failed" >> ../../failed_tests.txt
174165
poetry run coverage xml -o ../../delta-coverage.xml
175166
176167
- name: Run unittest with filenameprocessor-coverage
@@ -181,7 +172,7 @@ jobs:
181172
continue-on-error: true
182173
run: |
183174
poetry install
184-
poetry run coverage run -m unittest discover || echo "filenameprocessor tests failed" >> ../../failed_tests.txt
175+
poetry run coverage run --source=src -m unittest discover || echo "filenameprocessor tests failed" >> ../../failed_tests.txt
185176
poetry run coverage xml -o ../../filenameprocessor-coverage.xml
186177
187178
- name: Run unittest with id_sync
@@ -195,6 +186,15 @@ jobs:
195186
poetry run coverage run --rcfile=.coveragerc --source=src -m unittest discover || echo "id_sync tests failed" >> ../../failed_tests.txt
196187
poetry run coverage xml -o ../../id_sync-coverage.xml
197188
189+
- name: Run unittest with coverage-mesh-processor
190+
working-directory: lambdas/mesh_processor
191+
id: meshprocessor
192+
continue-on-error: true
193+
run: |
194+
poetry install
195+
poetry run coverage run --source=src -m unittest discover || echo "mesh_processor tests failed" >> ../../failed_tests.txt
196+
poetry run coverage xml -o ../../mesh_processor-coverage.xml
197+
198198
- name: Run unittest with coverage-mns-subscription
199199
working-directory: lambdas/mns_subscription
200200
id: mns_subscription
@@ -203,7 +203,7 @@ jobs:
203203
continue-on-error: true
204204
run: |
205205
poetry install
206-
poetry run coverage run -m unittest discover || echo "mns_subscription tests failed" >> ../../failed_tests.txt
206+
poetry run coverage run --source=src -m unittest discover || echo "mns_subscription tests failed" >> ../../failed_tests.txt
207207
poetry run coverage report -m
208208
poetry run coverage xml -o ../../mns_subscription-coverage.xml
209209

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 mesh_processor lambdas/ack_backend lambdas/delta_backend lambdas/filenameprocessor lambdas/id_sync 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/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test:
99
@PYTHONPATH=src:tests python -m unittest
1010

1111
coverage-run:
12-
@PYTHONPATH=src:tests coverage run -m unittest discover
12+
@PYTHONPATH=src:tests coverage run --source=src -m unittest discover
1313

1414
coverage-report:
1515
coverage report -m

backend/src/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Urls:
1111

1212
nhs_number = "https://fhir.nhs.uk/Id/nhs-number"
1313
vaccination_procedure = "https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-VaccinationProcedure"
14-
snomed = "http://snomed.info/sct"
14+
snomed = "http://snomed.info/sct" # NOSONAR(S5332)
1515
nhs_number_verification_status_structure_definition = (
1616
"https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-NHSNumberVerificationStatus"
1717
)

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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"path": "backend",
88
},
99
{
10-
"path": "mesh_processor",
10+
"path": "lambdas/ack_backend",
1111
},
1212
{
13-
"path": "lambdas/ack_backend",
13+
"path": "lambdas/batch_processor_filter",
1414
},
1515
{
1616
"path": "lambdas/delta_backend",
@@ -21,6 +21,9 @@
2121
{
2222
"path": "lambdas/id_sync",
2323
},
24+
{
25+
"path": "lambdas/mesh_processor",
26+
},
2427
{
2528
"path": "lambdas/mns_subscription",
2629
},

0 commit comments

Comments
 (0)