Skip to content

Commit 7e3e12a

Browse files
committed
feat(converter): translate missionId to operationId
1 parent e3499be commit 7e3e12a

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

converter/converter/cisu/resources_info/resources_info_cisu_constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ class ResourcesInfoCISUConstants:
22
RESOURCE_PATH = "$.resource"
33
STATE_PATH = "$.state"
44
VEHICLE_TYPE_PATH = "$.vehicleType"
5+
MISSION_ID_PATH = "$.missionId"
6+
OPERATION_ID_PATH = "$.operationId"
57

68
CASE_ID_FIELD = "caseId"
79
RESOURCE_ID_KEY = "resourceId"

converter/converter/cisu/resources_info/resources_info_cisu_converter.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
get_last_rc_ri_by_case_id,
1616
get_rs_messages_by_case_id,
1717
)
18-
from converter.utils import get_field_value, set_value, delete_paths
18+
from converter.utils import get_field_value, set_value, delete_paths, switch_field_name
1919
import logging
2020

2121
logger = logging.getLogger(__name__)
@@ -70,6 +70,13 @@ def _build_rs_ri_from_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]:
7070
# RS-RI does not carry GPS position — remove it if present
7171
delete_paths(resource, [ResourcesInfoCISUConstants.POSITION_KEY])
7272

73+
# Map operationId to missionId
74+
switch_field_name(
75+
resource,
76+
ResourcesInfoCISUConstants.OPERATION_ID_PATH,
77+
ResourcesInfoCISUConstants.MISSION_ID_PATH,
78+
)
79+
7380
return cls.format_rs_output_json(output_json, output_use_case_json)
7481

7582
@classmethod
@@ -317,13 +324,22 @@ def _convert_resources_to_cisu(
317324
cls._translate_to_cisu_vehicle_type(resource)
318325
cls._keep_last_state(resource)
319326
cls._remove_patient_id(resource)
327+
cls._replace_operation_id_by_mission_id(resource)
320328

321329
converted_resources.append(resource)
322330
except ConversionError:
323331
continue
324332

325333
return converted_resources
326334

335+
@classmethod
336+
def _replace_operation_id_by_mission_id(cls, resource):
337+
switch_field_name(
338+
resource,
339+
ResourcesInfoCISUConstants.MISSION_ID_PATH,
340+
ResourcesInfoCISUConstants.OPERATION_ID_PATH,
341+
)
342+
327343
@classmethod
328344
def _remove_patient_id(cls, resource):
329345
delete_paths(resource, [ResourcesInfoCISUConstants.PATIENT_ID_KEY])

0 commit comments

Comments
 (0)