Skip to content

Commit c518c00

Browse files
committed
Move constants to relevant file
1 parent 6be70e0 commit c518c00

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

lambdas/recordprocessor/src/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
"LOCATION_CODE_TYPE_URI",
5050
]
5151

52+
TPP_V2_SUPPLIER_IDENTIFIER_SYSTEM = "YGA"
53+
TPP_V5_SUPPLIER_IDENTIFIER_SYSTEM = "https://tpp-uk.com/Id/ve/vacc"
54+
EMIS_V2_SUPPLIER_IDENTIFIER_SYSTEM = "YGJ"
55+
EMIS_V5_SUPPLIER_IDENTIFIER_SYSTEM = "https://emishealth.com/identifiers/vacc"
56+
5257

5358
class FileStatus:
5459
"""File status constants"""

lambdas/recordprocessor/src/process_row.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
"""Function to process a single row of a csv file"""
22

33
from common.clients import logger
4-
from constants import Diagnostics
4+
from constants import (
5+
EMIS_V2_SUPPLIER_IDENTIFIER_SYSTEM,
6+
EMIS_V5_SUPPLIER_IDENTIFIER_SYSTEM,
7+
TPP_V2_SUPPLIER_IDENTIFIER_SYSTEM,
8+
TPP_V5_SUPPLIER_IDENTIFIER_SYSTEM,
9+
Diagnostics,
10+
)
511
from convert_to_fhir_imms_resource import convert_to_fhir_imms_resource
612
from utils_for_recordprocessor import create_diagnostics_dictionary
713

8-
TPP_V2_SUPPLIER_IDENTIFIER_SYSTEM = "YGA"
9-
TPP_V5_SUPPLIER_IDENTIFIER_SYSTEM = "https://tpp-uk.com/Id/ve/vacc"
10-
EMIS_V2_SUPPLIER_IDENTIFIER_SYSTEM = "YGJ"
11-
EMIS_V5_SUPPLIER_IDENTIFIER_SYSTEM = "https://emishealth.com/identifiers/vacc"
12-
1314

1415
def process_row(target_disease: list, allowed_operations: set, row: dict) -> dict:
1516
"""
@@ -20,7 +21,7 @@ def process_row(target_disease: list, allowed_operations: set, row: dict) -> dic
2021
action_flag = (row.get("ACTION_FLAG") or "").upper()
2122
unique_id_uri = row.get("UNIQUE_ID_URI")
2223

23-
# This code the above constants can be safely removed once DPS carries out it's data migration to update legacy
24+
# This code the relevant constants can be safely removed once DPS carries out it's data migration to update legacy
2425
# identifiers as it should become redundant. However, it may be worth keeping in case legacy format identifiers are
2526
# received for some reason. Please see issue VED-904 for more information.
2627
if unique_id_uri == TPP_V2_SUPPLIER_IDENTIFIER_SYSTEM:

lambdas/recordprocessor/tests/test_process_row.py

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ def test_process_row_success(self):
160160
Test that process_row gives the expected output.
161161
These tests check that the row is valid and matches the expected output.
162162
"""
163-
self.maxDiff = None
164-
165163
# call 'process_row' with required details
166164
imms_fhir_resource = process_row(TargetDiseaseElements.RSV, Allowed_Operations, ROW_DETAILS)
167165
# validate if the response with expected result
@@ -243,41 +241,37 @@ def test_process_row_missing_unique_id_uri(self):
243241
)
244242
self.assertEqual(response["diagnostics"]["statusCode"], 400)
245243

246-
def test_process_row_successfully_uplifts_legacy_TPP_uri(self):
244+
def test_process_row_successfully_uplifts_legacy_tpp_uri(self):
247245
"""
248246
Test that process_row gives the expected output.
249247
These tests check that the row is valid and matches the expected output.
250248
"""
251-
legacy_TPP_row = deepcopy(ROW_DETAILS)
252-
legacy_TPP_row["UNIQUE_ID_URI"] = "YGA"
253-
254-
expected_successful_result_TPP = deepcopy(expected_successful_result)
255-
expected_successful_result_TPP["identifier"][0]["system"] = "https://tpp-uk.com/Id/ve/vacc"
249+
legacy_tpp_row = deepcopy(ROW_DETAILS)
250+
legacy_tpp_row["UNIQUE_ID_URI"] = "YGA"
256251

257-
self.maxDiff = None
252+
expected_successful_result_tpp = deepcopy(expected_successful_result)
253+
expected_successful_result_tpp["identifier"][0]["system"] = "https://tpp-uk.com/Id/ve/vacc"
258254

259255
# call 'process_row' with required details
260-
imms_fhir_resource = process_row(TargetDiseaseElements.RSV, Allowed_Operations, legacy_TPP_row)
256+
imms_fhir_resource = process_row(TargetDiseaseElements.RSV, Allowed_Operations, legacy_tpp_row)
261257
# validate if the response with expected result
262-
self.assertDictEqual(imms_fhir_resource["fhir_json"], expected_successful_result_TPP)
258+
self.assertDictEqual(imms_fhir_resource["fhir_json"], expected_successful_result_tpp)
263259

264-
def test_process_row_successfully_uplifts_legacy_EMIS_uri(self):
260+
def test_process_row_successfully_uplifts_legacy_emis_uri(self):
265261
"""
266262
Test that process_row gives the expected output.
267263
These tests check that the row is valid and matches the expected output.
268264
"""
269-
legacy_EMIS_row = deepcopy(ROW_DETAILS)
270-
legacy_EMIS_row["UNIQUE_ID_URI"] = "YGJ"
271-
272-
expected_successful_result_EMIS = deepcopy(expected_successful_result)
273-
expected_successful_result_EMIS["identifier"][0]["system"] = "https://emishealth.com/identifiers/vacc"
265+
legacy_emis_row = deepcopy(ROW_DETAILS)
266+
legacy_emis_row["UNIQUE_ID_URI"] = "YGJ"
274267

275-
self.maxDiff = None
268+
expected_successful_result_emis = deepcopy(expected_successful_result)
269+
expected_successful_result_emis["identifier"][0]["system"] = "https://emishealth.com/identifiers/vacc"
276270

277271
# call 'process_row' with required details
278-
imms_fhir_resource = process_row(TargetDiseaseElements.RSV, Allowed_Operations, legacy_EMIS_row)
272+
imms_fhir_resource = process_row(TargetDiseaseElements.RSV, Allowed_Operations, legacy_emis_row)
279273
# validate if the response with expected result
280-
self.assertDictEqual(imms_fhir_resource["fhir_json"], expected_successful_result_EMIS)
274+
self.assertDictEqual(imms_fhir_resource["fhir_json"], expected_successful_result_emis)
281275

282276

283277
if __name__ == "__main__":

0 commit comments

Comments
 (0)