Skip to content

Commit 9ee07c2

Browse files
committed
Self review
1 parent 1268a3f commit 9ee07c2

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

backend/src/controller/fhir_api_exception_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
_CUSTOM_EXCEPTION_TO_STATUS_MAP: dict[Type[Exception], int] = {
3030
InconsistentResourceVersion: 400,
31-
InconsistentIdentifierError: 400,
32-
InconsistentIdError: 400,
31+
InconsistentIdentifierError: 400, # Identifier refers to the local FHIR identifier composed of system and value.
32+
InconsistentIdError: 400, # ID refers to the top-level ID of the FHIR resource.
3333
InvalidImmunizationId: 400,
3434
InvalidJsonError: 400,
3535
InvalidResourceVersion: 400,

backend/src/models/immunization_record_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@dataclass
77
class ImmunizationRecordMetadata:
8-
"""Simple class to hold data for the Immunization Record Metadata"""
8+
"""Simple data class for the Immunization Record Metadata"""
99

1010
resource_version: int
1111
is_deleted: bool

backend/src/models/utils/validation_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def validate_identifiers_match(new_immunization: dict, existing_immunization: di
105105
return None
106106

107107

108-
def validate_resource_version_matches(
108+
def validate_resource_versions_match(
109109
resource_version_in_request: int, actual_resource_version: int, imms_id: str
110110
) -> None:
111111
"""Checks if the resource version in the request and the resource version of the actual Immunization record matches.

backend/src/service/fhir_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
get_contained_patient,
3636
get_occurrence_datetime,
3737
)
38-
from models.utils.validation_utils import get_vaccine_type, validate_identifiers_match, validate_resource_version_matches
38+
from models.utils.validation_utils import get_vaccine_type, validate_identifiers_match, validate_resource_versions_match
3939
from repository.fhir_repository import ImmunizationRepository
4040

4141
logging.basicConfig(level="INFO")
@@ -164,7 +164,7 @@ def update_immunization(self, imms_id: str, immunization: dict, supplier_system:
164164
validate_identifiers_match(immunization, existing_immunization)
165165

166166
if not existing_resource_meta.is_deleted:
167-
validate_resource_version_matches(resource_version, existing_resource_meta.resource_version, imms_id)
167+
validate_resource_versions_match(resource_version, existing_resource_meta.resource_version, imms_id)
168168

169169
return self.immunization_repo.update_immunization(imms_id, immunization, existing_resource_meta, supplier_system)
170170

backend/tests/models/utils/test_validation_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
obtain_name_field_location,
1313
patient_and_practitioner_value_and_index,
1414
)
15-
from models.utils.validation_utils import validate_identifiers_match, validate_resource_version_matches
15+
from models.utils.validation_utils import validate_identifiers_match, validate_resource_versions_match
1616
from testing_utils.generic_utils import (
1717
load_json_data,
1818
)
@@ -280,12 +280,12 @@ def test_obtain_name_field_location(self):
280280
result = obtain_name_field_location(imms, resource_type, name_value)
281281
self.assertEqual(result, expected_location)
282282

283-
def test_validate_resource_version_matches_passes_when_version_matches(self):
284-
"""Tests validate_resource_version_matches passes when the resource versions match"""
285-
self.assertIsNone(validate_resource_version_matches(3, 3, "12345-id"))
283+
def test_validate_resource_versions_match_passes_when_version_matches(self):
284+
"""Tests validate_resource_versions_match passes when the resource versions match"""
285+
self.assertIsNone(validate_resource_versions_match(3, 3, "12345-id"))
286286

287-
def test_validate_resource_version_matches_raises_error_when_versions_do_not_match(self):
288-
"""Tests validate_resource_version_matches raises a InconsistentResourceVersion when the versions do not
287+
def test_validate_resource_versions_match_raises_error_when_versions_do_not_match(self):
288+
"""Tests validate_resource_versions_match raises a InconsistentResourceVersion when the versions do not
289289
match"""
290290
test_cases = [
291291
(
@@ -299,7 +299,7 @@ def test_validate_resource_version_matches_raises_error_when_versions_do_not_mat
299299
for actual_version, expected_error in test_cases:
300300
with self.subTest(actual_version=actual_version, expected_error=expected_error):
301301
with self.assertRaises(InconsistentResourceVersion) as error:
302-
validate_resource_version_matches(3, actual_version, "12345-id")
302+
validate_resource_versions_match(3, actual_version, "12345-id")
303303

304304
self.assertEqual(str(error.exception), expected_error)
305305

0 commit comments

Comments
 (0)