Skip to content

Commit c8070dc

Browse files
committed
Moved action flag
1 parent 4f14e39 commit c8070dc

File tree

7 files changed

+17
-53
lines changed

7 files changed

+17
-53
lines changed

delta_backend/src/conversion_layout.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ def __init__(self, fhir_data):
111111
}
112112
},
113113
{
114-
"fieldNameFHIR": "id",
114+
"fieldNameFHIR": "",
115115
"fieldNameFlat": "ACTION_FLAG",
116116
"expression": {
117-
"expressionName": "Change To",
118-
"expressionType": "CHANGETO",
119-
"expressionRule": "update"
117+
"expressionName": "",
118+
"expressionType": "",
119+
"expressionRule": ""
120120
}
121121
},
122122
{

delta_backend/src/delta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def handler(event, context):
7272
operation = new_image["Operation"]["S"]
7373
action_flag = ActionFlag.CREATE if operation == Operation.CREATE else operation
7474
resource_json = json.loads(new_image["Resource"]["S"])
75-
FHIRConverter = Converter(json.dumps(resource_json))
75+
FHIRConverter = Converter(json.dumps(resource_json), action_flag = action_flag)
7676
flat_json = FHIRConverter.run_conversion() # Get the flat JSON
7777
error_records = FHIRConverter.get_error_records()
7878
flat_json["ACTION_FLAG"] = action_flag

delta_backend/src/delta_converter.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
# Converter
1313
class Converter:
1414

15-
def __init__(self, fhir_data, summarise=False, report_unexpected_exception=True):
15+
def __init__(self, fhir_data, action_flag = "UPDATE", summarise=False, report_unexpected_exception=True):
1616
self.converted = {}
1717
self.error_records = []
18+
self.action_flag = action_flag
1819
self.fhir_data = fhir_data
1920
self.summarise = summarise
2021
self.report_unexpected_exception = report_unexpected_exception
@@ -59,11 +60,13 @@ def _convertData(self, expression):
5960
### TODO: Remove this after refactoring all fields to be extracted with the Extractor
6061
values = self.data_parser.get_key_value(fhir_field, flat_field, expr_type, expr_rule)
6162
###
62-
63-
for val in values:
64-
converted = self.conversion_checker.convertData(expr_type, expr_rule, fhir_field, val)
65-
if converted is not None:
66-
self.converted[flat_field] = converted
63+
if flat_field == "ACTION_FLAG":
64+
self.converted[flat_field] = self.action_flag
65+
else:
66+
for val in values:
67+
converted = self.conversion_checker.convertData(expr_type, expr_rule, fhir_field, val)
68+
if converted is not None:
69+
self.converted[flat_field] = converted
6770

6871
except Exception as e:
6972
return self._log_error(f"Conversion error [{e.__class__.__name__}]: {e}", code=exception_messages.PARSING_ERROR)

delta_backend/src/json_field_extractor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,4 +319,4 @@ def extract_location_code_type_uri(self) -> str:
319319
identifier = location.get("identifier", {})
320320
return identifier.get("system", self.ODS_ORG_CODE_SYSTEM_URL)
321321

322-
return self.ODS_ORG_CODE_SYSTEM_URL
322+
return self.ODS_ORG_CODE_SYSTEM_URL

delta_backend/tests/sample_data/Final Example.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

delta_backend/tests/test_convert_person_dob.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ def _run_person_dob_test(self, expected_site_code):
1515
self.converter = Converter(json.dumps(self.request_json_data))
1616
flat_json = self.converter.run_conversion()
1717
self.assertEqual(flat_json.get("PERSON_DOB"), expected_site_code)
18-
19-
20-

delta_backend/tests/utils_for_converter_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def get_expected_imms(expected_action_flag):
259259
"SITE_CODE_TYPE_URI": "https://fhir.nhs.uk/Id/ods-organization-code",
260260
"UNIQUE_ID": "ACME-vacc123456",
261261
"UNIQUE_ID_URI": "https://supplierABC/identifiers/vacc",
262-
"ACTION_FLAG": "update",
262+
"ACTION_FLAG": "UPDATE",
263263
"PERFORMING_PROFESSIONAL_FORENAME": "Florence",
264264
"PERFORMING_PROFESSIONAL_SURNAME": "Nightingale",
265265
"RECORDED_DATE": "20210207",
@@ -297,7 +297,7 @@ def get_expected_imms(expected_action_flag):
297297
"SITE_CODE_TYPE_URI": "https://fhir.nhs.uk/Id/ods-organization-code",
298298
"UNIQUE_ID": "ACME-vacc123456",
299299
"UNIQUE_ID_URI": "https://supplierABC/identifiers/vacc",
300-
"ACTION_FLAG": "update",
300+
"ACTION_FLAG": "UPDATE",
301301
"PERFORMING_PROFESSIONAL_FORENAME": "Florence",
302302
"PERFORMING_PROFESSIONAL_SURNAME": "Nightingale",
303303
"RECORDED_DATE": "20210207",

0 commit comments

Comments
 (0)