Skip to content

Commit c3bce7b

Browse files
authored
VED-891 Vaccine Product Term (#961)
1 parent de1c0f9 commit c3bce7b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
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(

0 commit comments

Comments
 (0)