Skip to content

Commit e0006b6

Browse files
authored
Merge branch 'master' into VED-349-OAS-Update
2 parents 38f2ddf + b2dabcc commit e0006b6

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

+691
-300
lines changed

config/common/disease_mapping.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@
1616
}
1717
]
1818
},
19+
{
20+
"vacc_type": "COVID19",
21+
"diseases": [
22+
{
23+
"code": "840539006",
24+
"term": "Disease caused by severe acute respiratory syndrome coronavirus 2"
25+
}
26+
]
27+
},
1928
{
2029
"vacc_type": "FLU",
2130
"diseases": [

config/dev/permissions_config.json

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"FLU.CRUDS",
77
"MMR.CRUDS",
88
"RSV.CRUDS"
9-
]
9+
],
10+
"ods_codes": ["DPSFULL"]
1011
},
1112
{
1213
"supplier": "DPSREDUCED",
@@ -15,7 +16,8 @@
1516
"FLU.CRUD",
1617
"MMR.CRUD",
1718
"RSV.CRUD"
18-
]
19+
],
20+
"ods_codes": ["DPSREDUCED"]
1921
},
2022
{
2123
"supplier": "MAVIS",
@@ -25,26 +27,30 @@
2527
"MENACWY.CRUDS",
2628
"MMR.CRUDS",
2729
"FLU.CRUDS"
28-
]
30+
],
31+
"ods_codes": ["V0V8L"]
2932
},
3033
{
3134
"supplier": "SONAR",
3235
"permissions": [
3336
"FLU.CD"
34-
]
37+
],
38+
"ods_codes": ["8HK48"]
3539
},
3640
{
3741
"supplier": "EVA",
3842
"permissions": [
3943
"COVID19.CUD"
40-
]
44+
],
45+
"ods_codes": ["8HA94"]
4146
},
4247
{
4348
"supplier": "RAVS",
4449
"permissions": [
4550
"RSV.CRUDS",
4651
"MMR.CRUDS"
47-
]
52+
],
53+
"ods_codes": ["X8E5B"]
4854
},
4955
{
5056
"supplier": "AGEM-RAVS-Integration",
@@ -61,7 +67,8 @@
6167
"HPV.CRUDS",
6268
"3IN1.CRUDS",
6369
"MENACWY.CRUDS"
64-
]
70+
],
71+
"ods_codes": ["YGM41", "YGJ"]
6572
},
6673
{
6774
"supplier": "TPP",
@@ -71,7 +78,8 @@
7178
"HPV.CRUDS",
7279
"3IN1.CRUDS",
7380
"MENACWY.CRUDS"
74-
]
81+
],
82+
"ods_codes": ["YGA"]
7583
},
7684
{
7785
"supplier": "MEDICUS",
@@ -81,7 +89,8 @@
8189
"HPV.CRUDS",
8290
"3IN1.CRUDS",
8391
"MENACWY.CRUDS"
84-
]
92+
],
93+
"ods_codes": ["YGMYW"]
8594
},
8695
{
8796
"supplier": "Test_App",

config/preprod/permissions_config.json

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"FLU.CRUDS",
77
"MMR.CRUDS",
88
"RSV.CRUDS"
9-
]
9+
],
10+
"ods_codes": ["DPSFULL"]
1011
},
1112
{
1213
"supplier": "DPSREDUCED",
@@ -15,7 +16,8 @@
1516
"FLU.CRUDS",
1617
"MMR.CRUDS",
1718
"RSV.CRUDS"
18-
]
19+
],
20+
"ods_codes": ["DPSREDUCED"]
1921
},
2022
{
2123
"supplier": "MAVIS",
@@ -25,14 +27,16 @@
2527
"MENACWY.CRUDS",
2628
"MMR.CRUDS",
2729
"FLU.CRUDS"
28-
]
30+
],
31+
"ods_codes": ["V0V8L"]
2932
},
3033
{
3134
"supplier": "RAVS",
3235
"permissions": [
3336
"RSV.CRUDS",
3437
"MMR.CRUDS"
35-
]
38+
],
39+
"ods_codes": ["X8E5B"]
3640
},
3741
{
3842
"supplier": "AGEM-RAVS-Integration",
@@ -49,7 +53,8 @@
4953
"HPV.CRUDS",
5054
"3IN1.CRUDS",
5155
"MENACWY.CRUDS"
52-
]
56+
],
57+
"ods_codes": ["YGM41", "YGJ"]
5358
},
5459
{
5560
"supplier": "TPP",
@@ -59,7 +64,8 @@
5964
"HPV.CRUDS",
6065
"3IN1.CRUDS",
6166
"MENACWY.CRUDS"
62-
]
67+
],
68+
"ods_codes": ["YGA"]
6369
},
6470
{
6571
"supplier": "MEDICUS",
@@ -69,7 +75,8 @@
6975
"HPV.CRUDS",
7076
"3IN1.CRUDS",
7177
"MENACWY.CRUDS"
72-
]
78+
],
79+
"ods_codes": ["YGMYW"]
7380
},
7481
{
7582
"supplier": "Test_App",

config/prod/permissions_config.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
"supplier": "DPSFULL",
44
"permissions": [
55
"RSV.CRUDS"
6-
]
6+
],
7+
"ods_codes": ["DPSFULL"]
78
},
89
{
910
"supplier": "DPSREDUCED",
1011
"permissions": [
1112
"RSV.CRUDS"
12-
]
13+
],
14+
"ods_codes": ["DPSREDUCED"]
1315
},
1416
{
1517
"supplier": "RAVS",
1618
"permissions": [
1719
"RSV.RS"
18-
]
20+
],
21+
"ods_codes": ["X8E5B"]
1922
}
2023
]

delta_backend/src/extractor.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ def _get_patient(self):
2929
return next((c for c in contained if isinstance(c, dict) and c.get("resourceType") == "Patient"), "")
3030

3131
def _get_valid_names(self, names, occurrence_time):
32-
32+
3333
official_names = [n for n in names if n.get("use") == "official" and self._is_current_period(n, occurrence_time)]
3434
if official_names:
3535
return official_names[0]
3636

3737
valid_names = [n for n in names if self._is_current_period(n, occurrence_time) and n.get("use") != "old"]
3838
if valid_names:
3939
return valid_names[0]
40-
41-
return names[0]
42-
40+
41+
return names[0]
42+
4343

4444

4545
def _get_person_names(self):
@@ -56,9 +56,9 @@ def _get_person_names(self):
5656

5757
if person_forename and person_surname:
5858
return person_forename, person_surname
59-
59+
6060
return "", ""
61-
61+
6262
def _get_practitioner_names(self):
6363
contained = self.fhir_json_data.get("contained", [])
6464
occurrence_time = self._get_occurance_date_time()
@@ -282,8 +282,8 @@ def extract_valid_address(self):
282282
)
283283

284284
return selected_address.get("postalCode") or self.DEFAULT_POSTCODE
285-
286-
def extract_date_time(self) -> str:
285+
286+
def extract_date_time(self) -> str:
287287
date = self.fhir_json_data.get("occurrenceDateTime","")
288288
if date:
289289
return self._convert_date_to_safe_format(ConversionFieldName.DATE_AND_TIME, date)
@@ -321,7 +321,7 @@ def extract_primary_source(self) -> bool | str:
321321
primary_source = self.fhir_json_data.get("primarySource")
322322

323323
if isinstance(primary_source, bool):
324-
return primary_source
324+
return str(primary_source).upper()
325325
return ""
326326

327327
def extract_vaccination_procedure_code(self) -> str:

delta_backend/tests/test_convert_primary_source.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,27 @@
66
from common.mappings import ConversionFieldName
77

88
class TestPrimarySourceFlatJson(unittest.TestCase):
9-
9+
1010
def setUp(self):
1111
self.request_json_data = copy.deepcopy(ValuesForTests.json_data)
12-
12+
1313
def _run_primary_source_test(self, expected_result):
1414
"""Helper function to run the test"""
1515
self.converter = Converter(json.dumps(self.request_json_data))
1616
flat_json = self.converter.run_conversion()
1717
self.assertEqual(flat_json.get(ConversionFieldName.PRIMARY_SOURCE), expected_result)
18-
18+
1919
def test_primary_source_true(self):
2020
"""Should return True when primarySource is true"""
2121
self.request_json_data["primarySource"] = True
22-
self._run_primary_source_test(expected_result=True)
22+
self._run_primary_source_test(expected_result="TRUE")
2323

2424
def test_primary_source_false(self):
2525
"""Should return False when primarySource is false"""
2626
self.request_json_data["primarySource"] = False
27-
self._run_primary_source_test(expected_result=False)
28-
27+
self._run_primary_source_test(expected_result="FALSE")
28+
2929
def test_primary_source_missing(self):
3030
"""Should return None when primarySource is missing"""
3131
self.request_json_data.pop("primarySource", None)
3232
self._run_primary_source_test(expected_result="")
33-

delta_backend/tests/utils_for_converter_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def get_expected_imms(expected_action_flag):
228228
"PERFORMING_PROFESSIONAL_FORENAME": "Florence",
229229
"PERFORMING_PROFESSIONAL_SURNAME": "Nightingale",
230230
"RECORDED_DATE": "20210207",
231-
"PRIMARY_SOURCE": True,
231+
"PRIMARY_SOURCE": "TRUE",
232232
"VACCINATION_PROCEDURE_CODE": "13246814444444",
233233
"VACCINATION_PROCEDURE_TERM": "Test Value string 123456 COVID19 vaccination",
234234
"DOSE_SEQUENCE": "1",
@@ -266,7 +266,7 @@ def get_expected_imms(expected_action_flag):
266266
"PERFORMING_PROFESSIONAL_FORENAME": "Florence",
267267
"PERFORMING_PROFESSIONAL_SURNAME": "Nightingale",
268268
"RECORDED_DATE": "20210207",
269-
"PRIMARY_SOURCE": True,
269+
"PRIMARY_SOURCE": "TRUE",
270270
"VACCINATION_PROCEDURE_CODE": "13246814444444",
271271
"VACCINATION_PROCEDURE_TERM": "Administration of first dose of severe acute respiratory syndrome coronavirus 2 vaccine (procedure)",
272272
"DOSE_SEQUENCE": 1,
@@ -304,7 +304,7 @@ def get_expected_imms(expected_action_flag):
304304
"PERFORMING_PROFESSIONAL_FORENAME": "Florence",
305305
"PERFORMING_PROFESSIONAL_SURNAME": "Nightingale",
306306
"RECORDED_DATE": "20210207",
307-
"PRIMARY_SOURCE": True,
307+
"PRIMARY_SOURCE": "TRUE",
308308
"VACCINATION_PROCEDURE_CODE": "13246814444444",
309309
"VACCINATION_PROCEDURE_TERM": "Test Value string 123456 COVID19 vaccination",
310310
"DOSE_SEQUENCE": "1",
@@ -457,7 +457,7 @@ def get_expected_imms_error_output(expected_action_flag):
457457
"PERFORMING_PROFESSIONAL_FORENAME": "Florence",
458458
"PERFORMING_PROFESSIONAL_SURNAME": "Nightingale",
459459
"RECORDED_DATE": "20210207",
460-
"PRIMARY_SOURCE": True,
460+
"PRIMARY_SOURCE": "TRUE",
461461
"VACCINATION_PROCEDURE_CODE": "13246814444444",
462462
"VACCINATION_PROCEDURE_TERM": "Administration of first dose of severe acute respiratory syndrome coronavirus 2 vaccine (procedure)",
463463
"DOSE_SEQUENCE": 1,

filenameprocessor/src/constants.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
SUPPLIER_PERMISSIONS_HASH_KEY = "supplier_permissions"
2020
VACCINE_TYPE_TO_DISEASES_HASH_KEY = "vacc_to_diseases"
21+
ODS_CODE_TO_SUPPLIER_SYSTEM_HASH_KEY = "ods_code_to_supplier"
2122

2223
ERROR_TYPE_TO_STATUS_CODE_MAP = {
2324
VaccineTypePermissionsError: 403,
@@ -52,27 +53,3 @@ class AuditTableKeys:
5253
class Constants:
5354
"""Constants for the filenameprocessor lambda"""
5455
VALID_VERSIONS = ["V5"]
55-
56-
# Mappings from ODS code to supplier name.
57-
# NOTE: Any ODS code not found in this dictionary's keys is invalid for this service
58-
ODS_TO_SUPPLIER_MAPPINGS = {
59-
"YGM41": "EMIS",
60-
"8J1100001": "PINNACLE",
61-
"8HK48": "SONAR",
62-
"YGA": "TPP",
63-
"V0V8L": "MAVIS",
64-
"X8E5B": "RAVS",
65-
"0DE": "AGEM-NIVS",
66-
"0DF": "NIMS",
67-
"8HA94": "EVA",
68-
"YGMYH": "MEDICAL_DIRECTOR",
69-
"W00": "WELSH_DA_1",
70-
"W000": "WELSH_DA_2",
71-
"ZT001": "NORTHERN_IRELAND_DA",
72-
"YA7": "SCOTLAND_DA",
73-
"N2N9I": "COVID19_VACCINE_RESOLUTION_SERVICEDESK",
74-
"YGJ": "EMIS",
75-
"YGMYW": "MEDICUS",
76-
"DPSREDUCED": "DPSREDUCED",
77-
"DPSFULL": "DPSFULL",
78-
}

filenameprocessor/src/elasticache.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import json
22
from clients import redis_client
3-
from constants import VACCINE_TYPE_TO_DISEASES_HASH_KEY, SUPPLIER_PERMISSIONS_HASH_KEY
3+
from constants import (
4+
VACCINE_TYPE_TO_DISEASES_HASH_KEY,
5+
SUPPLIER_PERMISSIONS_HASH_KEY,
6+
ODS_CODE_TO_SUPPLIER_SYSTEM_HASH_KEY
7+
)
48

59

610
def get_supplier_permissions_from_cache(supplier_system: str) -> list[str]:
@@ -11,3 +15,7 @@ def get_supplier_permissions_from_cache(supplier_system: str) -> list[str]:
1115

1216
def get_valid_vaccine_types_from_cache() -> list[str]:
1317
return redis_client.hkeys(VACCINE_TYPE_TO_DISEASES_HASH_KEY)
18+
19+
20+
def get_supplier_system_from_cache(ods_code: str) -> str:
21+
return redis_client.hget(ODS_CODE_TO_SUPPLIER_SYSTEM_HASH_KEY, ods_code)

filenameprocessor/src/file_key_validation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from re import match
44
from datetime import datetime
55
from constants import Constants
6-
from elasticache import get_valid_vaccine_types_from_cache
7-
from utils_for_filenameprocessor import identify_supplier
6+
from elasticache import get_valid_vaccine_types_from_cache, get_supplier_system_from_cache
87
from errors import InvalidFileKeyError
98

109

@@ -46,7 +45,7 @@ def validate_file_key(file_key: str) -> tuple[str, str]:
4645
ods_code = file_key_parts_without_extension[3]
4746
timestamp = file_key_parts_without_extension[4]
4847
extension = file_key.split(".")[1]
49-
supplier = identify_supplier(ods_code)
48+
supplier = get_supplier_system_from_cache(ods_code)
5049

5150
valid_vaccine_types = get_valid_vaccine_types_from_cache()
5251

0 commit comments

Comments
 (0)