Skip to content

Commit 5739d95

Browse files
authored
Merge pull request #404 from ansforge/converter/rc-ri-operationid
Converter : Replacement du champ missionId par operationId dans le RC-RI
2 parents bc732f0 + 7e3e12a commit 5739d95

3 files changed

Lines changed: 20 additions & 2 deletions

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])

converter/tests/fixtures/RC-RI/RC-RI_V3.0_exhaustive_fill.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"resourceId": "fr.fire.sis076.cgo-076.resource.VSAV3A",
3939
"requestId": "fr.fire.sis076.cgo-076.request.177",
4040
"centerName": "Centre de Secours 76 - A",
41-
"missionId": "fr.fire.sis076.cgo-076.mission.177",
41+
"operationId": "fr.fire.sis076.cgo-076.mission.177",
4242
"centerCity": "75011",
4343
"orgId": "fr.fire.sdis76.cgo-076",
4444
"name": "VSAV 76 - 22D8",

0 commit comments

Comments
 (0)