diff --git a/converter/converter/cisu/resources_info/resources_info_cisu_constants.py b/converter/converter/cisu/resources_info/resources_info_cisu_constants.py index 9d8f7b97a..0732a3e47 100644 --- a/converter/converter/cisu/resources_info/resources_info_cisu_constants.py +++ b/converter/converter/cisu/resources_info/resources_info_cisu_constants.py @@ -2,6 +2,8 @@ class ResourcesInfoCISUConstants: RESOURCE_PATH = "$.resource" STATE_PATH = "$.state" VEHICLE_TYPE_PATH = "$.vehicleType" + MISSION_ID_PATH = "$.missionId" + OPERATION_ID_PATH = "$.operationId" CASE_ID_FIELD = "caseId" RESOURCE_ID_KEY = "resourceId" diff --git a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py b/converter/converter/cisu/resources_info/resources_info_cisu_converter.py index 86e5530a0..7449c5b60 100644 --- a/converter/converter/cisu/resources_info/resources_info_cisu_converter.py +++ b/converter/converter/cisu/resources_info/resources_info_cisu_converter.py @@ -15,7 +15,7 @@ get_last_rc_ri_by_case_id, get_rs_messages_by_case_id, ) -from converter.utils import get_field_value, set_value, delete_paths +from converter.utils import get_field_value, set_value, delete_paths, switch_field_name import logging logger = logging.getLogger(__name__) @@ -70,6 +70,13 @@ def _build_rs_ri_from_cisu(cls, edxl_json: Dict[str, Any]) -> Dict[str, Any]: # RS-RI does not carry GPS position — remove it if present delete_paths(resource, [ResourcesInfoCISUConstants.POSITION_KEY]) + # Map operationId to missionId + switch_field_name( + resource, + ResourcesInfoCISUConstants.OPERATION_ID_PATH, + ResourcesInfoCISUConstants.MISSION_ID_PATH, + ) + return cls.format_rs_output_json(output_json, output_use_case_json) @classmethod @@ -317,6 +324,7 @@ def _convert_resources_to_cisu( cls._translate_to_cisu_vehicle_type(resource) cls._keep_last_state(resource) cls._remove_patient_id(resource) + cls._replace_operation_id_by_mission_id(resource) converted_resources.append(resource) except ConversionError: @@ -324,6 +332,14 @@ def _convert_resources_to_cisu( return converted_resources + @classmethod + def _replace_operation_id_by_mission_id(cls, resource): + switch_field_name( + resource, + ResourcesInfoCISUConstants.MISSION_ID_PATH, + ResourcesInfoCISUConstants.OPERATION_ID_PATH, + ) + @classmethod def _remove_patient_id(cls, resource): delete_paths(resource, [ResourcesInfoCISUConstants.PATIENT_ID_KEY]) diff --git a/converter/tests/fixtures/RC-RI/RC-RI_V3.0_exhaustive_fill.json b/converter/tests/fixtures/RC-RI/RC-RI_V3.0_exhaustive_fill.json index d39c1aea9..fed743cb4 100644 --- a/converter/tests/fixtures/RC-RI/RC-RI_V3.0_exhaustive_fill.json +++ b/converter/tests/fixtures/RC-RI/RC-RI_V3.0_exhaustive_fill.json @@ -38,7 +38,7 @@ "resourceId": "fr.fire.sis076.cgo-076.resource.VSAV3A", "requestId": "fr.fire.sis076.cgo-076.request.177", "centerName": "Centre de Secours 76 - A", - "missionId": "fr.fire.sis076.cgo-076.mission.177", + "operationId": "fr.fire.sis076.cgo-076.mission.177", "centerCity": "75011", "orgId": "fr.fire.sdis76.cgo-076", "name": "VSAV 76 - 22D8",