Skip to content

Commit 8e09019

Browse files
authored
Merge pull request #362 from ansforge/fix/converter/rpis-v3-to-v2
fix/converter : Conversion v3→v2 avec codes CISU v2.0 mappés vers valeurs génériques v1.18
2 parents a5684d7 + bef9b84 commit 8e09019

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

converter/converter/versions/rpis/rpis_constants.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ class RpisConstants:
55
REGULATION_MEDICAL_LEVEL_PATH = "$.regulation.medicalLevel"
66
ORIENTATION_MEDICAL_LEVEL_PATH = "$.orientation.decision.medicalLevel"
77
V3_TO_V2_MEDICAL_LEVEL_MAPPING = {"SANS": "MED"}
8+
9+
# Code mapping paths and fallback values for v3 to v2 conversion
10+
WHATS_HAPPEN_CODE_PATH = "$.regulation.whatsHappen.code"
11+
HEALTH_MOTIVE_CODE_PATH = "$.regulation.healthMotive.code"
12+
LOCATION_TYPE_PATH = "$.intervention.location.type"
13+
14+
# Fallback codes for v3 to v2 conversion (all v2 codes map to these generic v1.18 codes)
15+
WHATS_HAPPEN_FALLBACK = "C11.06.00" # Autre nature de fait
16+
HEALTH_MOTIVE_FALLBACK = "M06.04" # Autre motif
17+
LOCATION_FALLBACK = "L07.01.00" # Autre lieu d'intervention

converter/converter/versions/rpis/rpis_converter.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Dict, Any
22

3-
from converter.utils import map_to_new_value
3+
from converter.utils import map_to_new_value, update_json_value
44
from converter.versions.base_message_converter import BaseMessageConverter
55
from converter.versions.rpis.rpis_constants import RpisConstants
66
from converter.versions.utils import reverse_map_to_new_value
@@ -47,4 +47,23 @@ def convert_v3_to_v2(cls, input_json: Dict[str, Any]) -> Dict[str, Any]:
4747
RpisConstants.V3_TO_V2_RESOURCE_TYPE_MAPPING,
4848
)
4949

50+
# Map v2 codes to v1.18 fallback values
51+
update_json_value(
52+
output_use_case_json,
53+
RpisConstants.WHATS_HAPPEN_CODE_PATH,
54+
RpisConstants.WHATS_HAPPEN_FALLBACK,
55+
)
56+
57+
update_json_value(
58+
output_use_case_json,
59+
RpisConstants.HEALTH_MOTIVE_CODE_PATH,
60+
RpisConstants.HEALTH_MOTIVE_FALLBACK,
61+
)
62+
63+
update_json_value(
64+
output_use_case_json,
65+
RpisConstants.LOCATION_TYPE_PATH,
66+
RpisConstants.LOCATION_FALLBACK,
67+
)
68+
5069
return cls.format_output_json(output_json, output_use_case_json)

0 commit comments

Comments
 (0)