diff --git a/converter/converter/cisu/cisu_converter.py b/converter/converter/cisu/cisu_converter.py index 463a7e3f40..ba63ec54d0 100644 --- a/converter/converter/cisu/cisu_converter.py +++ b/converter/converter/cisu/cisu_converter.py @@ -6,11 +6,15 @@ from yaml import dump -from .utils import add_to_initial_alert_notes +from converter.constants import Constants + +from .utils import add_to_initial_alert_notes, update_health_motive_code from ..utils import delete_paths, get_field_value, get_recipient, get_sender, is_field_completed, translate_key_words class CISUConverterV3: - """Handles CISU format conversions""" + # Todo: revert change when all editors use the new CISU nomenclature or are in V3 or above + def __init__(self, target_version: str): + self.target_version = target_version CISU_PATHS_TO_DELETE = [ "qualification.victims", @@ -62,7 +66,7 @@ class CISUConverterV3: DEFAULT_WHATS_HAPPEN = {"code": "C11.06.00", "label":"Autre nature de fait"} @classmethod - def from_cisu(cls, input_json: Dict[str, Any]) -> Dict[str, Any]: + def from_cisu(cls, input_json: Dict[str, Any], target_version: str) -> Dict[str, Any]: """ Convert from CISU to Health format @@ -143,6 +147,9 @@ def add_object_to_medical_notes(json_data: Dict[str, Any], note_text: str, sende # - Updates output_use_case_json['owner'] = get_recipient(input_json) + if target_version != Constants.V3_VERSION: + # /!\ it must be done before copying qualification + update_health_motive_code(output_use_case_json, True) set_default_location_freetext(output_use_case_json) add_location_detail(output_use_case_json) @@ -240,6 +247,9 @@ def add_default_external_info_type(json_data: Dict[str,Any]): if not is_field_completed(output_usecase_json,'$.qualification.whatsHappen'): output_usecase_json['qualification']['whatsHappen'] = cls.DEFAULT_WHATS_HAPPEN + # /!\ it must be done before copying qualification + update_health_motive_code(output_usecase_json, False) + add_default_external_info_type(output_usecase_json) # Deletions - /!\ it must be done before copying qualification and location fields diff --git a/converter/converter/cisu/constants.py b/converter/converter/cisu/constants.py new file mode 100644 index 0000000000..df9e13f8ee --- /dev/null +++ b/converter/converter/cisu/constants.py @@ -0,0 +1,6 @@ +class Constants: + MRSM_CISU_UPDATED_NOMENCLATURE_FILE = './mrms_cisu_updated_nomenclature.csv' + MR0_LABEL = "CodeCisuMR0" + MR1_LABEL = "CodeCisuMR1" + OLD_MR_LABEL = "CodeCisu V1.3" + CSV_DELIMITER = ';' diff --git a/converter/converter/cisu/mrms_cisu_updated_nomenclature.csv b/converter/converter/cisu/mrms_cisu_updated_nomenclature.csv new file mode 100644 index 0000000000..17616387ff --- /dev/null +++ b/converter/converter/cisu/mrms_cisu_updated_nomenclature.csv @@ -0,0 +1,202 @@ +CodeCisuMR0;CodeCisuMR1;CodeCisu V1.3 +M20.00;[Null];M01.00 +M22.00;M22.11;M01.01 +M22.00;[Null];M01.02 +M22.00;M22.21;M01.02 +M50.00;M50.35;M01.02 +M60.00;M60.03;M01.02 +M22.00;M22.01;M01.03 +M31.00;M31.01;M01.03 +M31.00;M31.02;M01.03 +M31.00;M31.03;M01.03 +M31.00;M31.13;M01.03 +M50.00;M50.33;M01.03 +M50.00;M50.53;M01.03 +M41.00;[Null];M02.00 +M41.00;M41.41;M02.00 +M41.00;M41.51;M02.00 +M41.00;M41.61;M02.00 +M45.00;[Null];M02.00 +M24.00;M24.01;M02.02 +M46.00;M46.21;M02.03 +M46.00;M46.22;M02.03 +M46.00;M46.29;M02.03 +M46.00;M46.02;M02.04 +M46.00;M46.03;M02.04 +M46.00;M46.12;M02.04 +M46.00;M46.13;M02.04 +M46.00;M46.09;M02.05 +M46.00;M46.19;M02.05 +M24.00;M24.91;M02.06 +M24.00;M24.92;M02.06 +M41.00;M41.21;M02.06 +M41.00;M41.29;M02.06 +M41.00;M41.39;M02.06 +M41.00;M41.49;M02.06 +M41.00;M41.59;M02.06 +M41.00;M41.69;M02.06 +M45.00;M45.33;M02.06 +M24.00;[Null];M02.07 +M24.00;M24.11;M02.07 +M41.00;M41.22;M02.07 +M41.00;M41.31;M02.07 +M41.00;M41.42;M02.07 +M41.00;M41.52;M02.07 +M41.00;M41.53;M02.07 +M41.00;M41.54;M02.07 +M41.00;M41.55;M02.07 +M41.00;M41.62;M02.07 +M41.00;M41.64;M02.07 +M41.00;M41.65;M02.07 +M41.00;M41.66;M02.07 +M45.00;M45.02;M02.07 +M45.00;M45.03;M02.07 +M45.00;M45.05;M02.07 +M45.00;M45.06;M02.07 +M45.00;M45.07;M02.07 +M45.00;M45.31;M02.07 +M45.00;M45.32;M02.07 +M46.00;[Null];M02.07 +M46.00;M46.01;M02.07 +M46.00;M46.11;M02.07 +M41.00;M41.11;M02.08 +M41.00;M41.32;M02.08 +M45.00;M45.01;M02.08 +M45.00;M45.08;M02.08 +M45.00;M45.09;M02.08 +M80.00;M80.01;M03.01 +M80.00;M80.02;M03.01 +M80.00;M80.03;M03.01 +M80.00;M80.04;M03.01 +M80.00;M80.05;M03.01 +M80.00;M80.06;M03.01 +M80.00;M80.07;M03.01 +M80.00;M80.08;M03.01 +M32.00;M32.95;M03.02 +M60.00;M60.05;M03.02 +M80.00;[Null];M03.02 +M80.00;M80.11;M03.02 +M80.00;M80.12;M03.02 +M80.00;M80.13;M03.02 +M80.00;M80.14;M03.02 +M80.00;M80.15;M03.02 +M80.00;M80.19;M03.02 +M60.00;M60.31;M03.06 +M60.00;M60.32;M03.06 +M60.00;M60.33;M03.06 +M60.00;M60.34;M03.06 +M60.00;M60.35;M03.06 +M60.00;M60.36;M03.06 +M60.00;M60.37;M03.06 +M60.00;M60.38;M03.06 +M60.00;M60.39;M03.06 +M60.00;M60.40;M03.06 +M60.00;M60.41;M03.06 +M60.00;M60.49;M03.06 +M32.00;[Null];M03.07 +M32.00;M32.91;M03.07 +M32.00;M32.99;M03.07 +M32.00;M32.01;M03.08 +M32.00;M32.02;M03.08 +M32.00;M32.03;M03.08 +M32.00;M32.04;M03.08 +M32.00;M32.05;M03.08 +M32.00;M32.51;M03.09 +M32.00;M32.57;M03.09 +M32.00;M32.31;M03.10 +M32.00;M32.32;M03.10 +M32.00;M32.34;M03.10 +M32.00;M32.35;M03.10 +M32.00;M32.39;M03.10 +M32.00;M32.52;M03.10 +M32.00;M32.54;M03.10 +M32.00;M32.55;M03.10 +M32.00;M32.92;M03.11 +M60.00;M60.01;M03.11 +M60.00;M60.08;M03.11 +M31.00;[Null];M03.12 +M31.00;M31.11;M03.12 +M31.00;M31.12;M03.12 +M31.00;M31.19;M03.12 +M31.00;M31.91;M03.12 +M31.00;M31.92;M03.12 +M31.00;M31.93;M03.12 +M31.00;M31.94;M03.12 +M31.00;M31.99;M03.12 +M30.00;[Null];M03.13 +M30.00;M30.61;M03.13 +M30.00;M30.91;M03.13 +M30.00;M30.92;M03.13 +M30.00;M30.93;M03.13 +M30.00;M30.95;M03.13 +M30.00;M30.96;M03.13 +M60.00;M60.94;M03.14 +M90.00;M90.41;M03.14 +M90.00;M90.71;M03.14 +M90.00;M90.11;M03.15 +M90.00;M90.12;M03.15 +M90.00;M90.13;M03.15 +M90.00;M90.14;M03.15 +M90.00;M90.16;M03.15 +M90.00;M90.17;M03.15 +M90.00;M90.19;M03.15 +M90.00;M90.61;M03.16 +M90.00;M90.63;M03.17 +M24.00;M24.02;M03.18 +M24.00;M24.29;M03.18 +M24.00;M24.21;M03.19 +M24.00;M24.25;M03.19 +M24.00;M24.26;M03.19 +M24.00;M24.28;M03.19 +M60.00;M60.21;M03.20 +M60.00;M60.26;M03.20 +M90.00;M90.51;M03.21 +M90.00;M90.53;M03.21 +M90.00;M90.54;M03.21 +M90.00;M90.55;M03.21 +M90.00;M90.59;M03.21 +M32.00;M32.11;M03.23 +M32.00;M32.21;M03.23 +M32.00;M32.22;M03.23 +M32.00;M32.25;M03.23 +M32.00;M32.24;M03.23 +M50.00;M50.22;M03.23 +M50.00;M50.32;M03.23 +M50.00;M50.52;M03.23 +M24.00;M24.27;M03.24 +M90.00;M90.52;M03.24 +M60.00;[Null];M03.26 +M60.00;M60.51;M03.26 +M60.00;M60.53;M03.26 +M60.00;M60.59;M03.26 +M60.00;M60.91;M03.26 +M60.00;M60.96;M03.26 +M60.00;M60.92;M03.27 +M90.00;M90.01;M03.28 +M32.00;M32.36;M03.29 +M60.00;M60.93;M03.30 +M50.00;[Null];M04.00 +M50.00;M50.21;M04.00 +M50.00;M50.29;M04.00 +M50.00;M50.31;M04.00 +M50.00;M50.39;M04.00 +M50.00;M50.54;M04.00 +M50.00;M50.51;M04.02 +M50.00;M50.25;M04.03 +M90.00;M90.64;M04.04 +M50.00;M50.11;M04.05 +M50.00;M50.12;M04.05 +M50.00;M50.15;M04.05 +M50.00;M50.16;M04.05 +M90.00;M90.65;M05.01 +M90.00;M90.62;M05.02 +M98.00;[Null];M06.01 +M98.00;M98.01;M06.01 +M98.00;M98.11;M06.01 +M98.00;M98.21;M06.01 +M98.00;M98.31;M06.01 +M90.00;M90.31;M06.02 +M41.00;M41.01;M06.03 +M30.00;M30.97;M06.04 +M90.00;[Null];M06.04 +M90.00;M90.21;M06.05 diff --git a/converter/converter/cisu/utils.py b/converter/converter/cisu/utils.py index 774ea08cd5..165da04663 100644 --- a/converter/converter/cisu/utils.py +++ b/converter/converter/cisu/utils.py @@ -1,6 +1,10 @@ from typing import Any, Dict, List +import csv +import os from yaml import dump + +from converter.cisu.constants import Constants from ..utils import concatenate_values, get_field_value, is_field_completed def add_object_to_initial_alert_notes(json_data: Dict[str, Any], note_text: str): @@ -22,3 +26,44 @@ def add_field_to_initial_alert_notes(data: Dict[str, Any], path_and_label: Dict[ def add_to_initial_alert_notes(data: Dict[str, Any], paths: List[Dict[str, str]]): for path in paths: add_field_to_initial_alert_notes(data, path) + +def find_in_cisu_nomenclature(search_value: str, search_columns: list, return_column: str, filename: str) -> str: + file_path = os.path.join(os.path.dirname(__file__), filename) + with open(file_path, newline='', encoding='utf-8') as csvfile: + reader = csv.DictReader(csvfile, delimiter=Constants.CSV_DELIMITER) + for row in reader: + for col in search_columns: + if row.get(col, '').strip() == search_value: + return row.get(return_column) + return None + +def get_deprecated_code_cisu_from_health_motive(health_motive_code: str) -> str: + return find_in_cisu_nomenclature( + health_motive_code, + [Constants.MR0_LABEL, Constants.MR1_LABEL], + Constants.OLD_MR_LABEL, + Constants.MRSM_CISU_UPDATED_NOMENCLATURE_FILE + ) + +def get_code_cisu_mr0_from_health_motive(health_motive_code: str) -> str: + return find_in_cisu_nomenclature( + health_motive_code, + [Constants.OLD_MR_LABEL], + Constants.MR0_LABEL, + Constants.MRSM_CISU_UPDATED_NOMENCLATURE_FILE + ) + +def update_health_motive_code(json_data: Dict[str, Any], isCodeDeprecated: bool): + health_motive_code = get_field_value(json_data, '$.qualification.healthMotive.code') + + if health_motive_code is not None: + if isCodeDeprecated: + updated_health_motive_code = get_deprecated_code_cisu_from_health_motive(health_motive_code) + else: + updated_health_motive_code = get_code_cisu_mr0_from_health_motive(health_motive_code) + + if updated_health_motive_code is not None: + json_data['qualification']['healthMotive'] = { + 'code': updated_health_motive_code, + 'label': get_field_value(json_data, '$.qualification.healthMotive.label') + } diff --git a/converter/converter/constants.py b/converter/converter/constants.py index 133b8f2b75..6ee76ceff2 100644 --- a/converter/converter/constants.py +++ b/converter/converter/constants.py @@ -3,6 +3,10 @@ class Constants: V2_GITHUB_TAG="release/2.x-maintenance" V3_GITHUB_TAG="3.0.0" + V3_VERSION="v3" + V2_VERSION="v2" + V1_VERSION="v1" + EDXL_HEALTH_TO_FIRE_ENVELOPE_PATH="tests/edxl_envelope_health_to_fire.json" EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH="tests/edxl_envelope_fire_to_health.json" EDXL_HEALTH_TO_HEALTH_ENVELOPE_PATH="tests/edxl_envelope_health_to_health.json" diff --git a/converter/converter/conversion_strategy/cisu_conversion_strategy.py b/converter/converter/conversion_strategy/cisu_conversion_strategy.py index 3adc494e2d..12ae7684a0 100644 --- a/converter/converter/conversion_strategy/cisu_conversion_strategy.py +++ b/converter/converter/conversion_strategy/cisu_conversion_strategy.py @@ -8,7 +8,7 @@ def cisu_conversion_strategy(edxl_json, source_version, target_version): TO_CISU = "to_CISU" FROM_CISU = "from_CISU" - MAINTAINED_CISU_VERSION = "v3" + MAINTAINED_CISU_VERSION = Constants.V3_VERSION # Compute direction based on sender / recipient sender = get_sender(edxl_json) @@ -25,12 +25,12 @@ def cisu_conversion_strategy(edxl_json, source_version, target_version): raise ValueError(f"Unknown target version {target_version}. Must be: {MAINTAINED_CISU_VERSION}") rs_json_message = health_conversion_strategy(edxl_json, source_version, MAINTAINED_CISU_VERSION) - return CISUConverterV3.to_cisu(rs_json_message) + return CISUConverterV3(target_version).to_cisu(rs_json_message) elif direction == FROM_CISU: if source_version != MAINTAINED_CISU_VERSION: raise ValueError(f"Unknown source version {source_version}. Must be: {MAINTAINED_CISU_VERSION}") - rc_json_message = CISUConverterV3.from_cisu(edxl_json) + rc_json_message = CISUConverterV3.from_cisu(edxl_json, target_version) return health_conversion_strategy(rc_json_message, MAINTAINED_CISU_VERSION, target_version) else: raise ValueError('Invalid direction parameter') diff --git a/converter/converter/versions/base_message_converter.py b/converter/converter/versions/base_message_converter.py index 29fa3a4583..55269e06fe 100644 --- a/converter/converter/versions/base_message_converter.py +++ b/converter/converter/versions/base_message_converter.py @@ -1,4 +1,7 @@ -version_order_list = ["v1", "v2", "v3"] +from converter.constants import Constants + + +version_order_list = [Constants.V1_VERSION, Constants.V2_VERSION, Constants.V3_VERSION] class BaseMessageConverter: def __init__(self): @@ -54,37 +57,37 @@ def convert(cls, source_version, target_version, edxl_json): @classmethod def upgrade(cls, source_version, source_version_index, edxl_json): - if source_version == "v1": + if source_version == Constants.V1_VERSION: return cls.convert_v1_to_v2(edxl_json) - elif source_version == "v2": + elif source_version == Constants.V2_VERSION: return cls.convert_v2_to_v3(edxl_json) else: cls.raise_conversion_impossible_error(source_version, version_order_list[source_version_index + 1]) @classmethod def downgrade(cls, source_version, source_version_index, edxl_json): - if source_version == "v2": + if source_version == Constants.V2_VERSION: return cls.convert_v2_to_v1(edxl_json) - elif source_version == "v3": + elif source_version == Constants.V3_VERSION: return cls.convert_v3_to_v2(edxl_json) else: cls.raise_conversion_impossible_error(source_version, version_order_list[source_version_index - 1]) @classmethod def convert_v1_to_v2(cls, edxl_json): - cls.raise_conversion_not_implemented_error("v1", "v2") + cls.raise_conversion_not_implemented_error(Constants.V1_VERSION, Constants.V2_VERSION) @classmethod def convert_v2_to_v1(cls, edxl_json): - cls.raise_conversion_not_implemented_error("v2", "v1") + cls.raise_conversion_not_implemented_error(Constants.V2_VERSION, Constants.V1_VERSION) @classmethod def convert_v2_to_v3(cls, edxl_json): - cls.raise_conversion_not_implemented_error("v2", "v3") + cls.raise_conversion_not_implemented_error(Constants.V2_VERSION, Constants.V3_VERSION) @classmethod def convert_v3_to_v2(cls, edxl_json): - cls.raise_conversion_not_implemented_error("v3", "v2") + cls.raise_conversion_not_implemented_error(Constants.V3_VERSION, Constants.V2_VERSION) @classmethod def raise_conversion_not_implemented_error(cls, source_version, target_version): diff --git a/converter/tests/fixtures/RC-EDA/RC-EDA_exhaustive_fill.json b/converter/tests/fixtures/RC-EDA/RC-EDA_exhaustive_fill.json index 4841c0a03f..4fcd512cc2 100644 --- a/converter/tests/fixtures/RC-EDA/RC-EDA_exhaustive_fill.json +++ b/converter/tests/fixtures/RC-EDA/RC-EDA_exhaustive_fill.json @@ -10,7 +10,7 @@ "label": "Obstétrique" }, "healthMotive": { - "code": "M03.02", + "code": "M41.01", "label": "Autre problème obstétrique non hémorragique" }, "victims": { @@ -158,7 +158,7 @@ "label": "Obstétrique" }, "healthMotive": { - "code": "M03.02", + "code": "M41.01", "label": "Autre problème obstétrique non hémorragique" }, "victims": { diff --git a/converter/tests/fixtures/RC-EDA/RC-EDA_exhaustive_fill_bis.json b/converter/tests/fixtures/RC-EDA/RC-EDA_exhaustive_fill_bis.json index 60aa767cde..ea9110fdcf 100644 --- a/converter/tests/fixtures/RC-EDA/RC-EDA_exhaustive_fill_bis.json +++ b/converter/tests/fixtures/RC-EDA/RC-EDA_exhaustive_fill_bis.json @@ -10,7 +10,7 @@ "label": "Obstétrique" }, "healthMotive": { - "code": "M03.02", + "code": "M90.00", "label": "Autre problème obstétrique non hémorragique" }, "victims": { @@ -158,7 +158,7 @@ "label": "Obstétrique" }, "healthMotive": { - "code": "M03.02", + "code": "M90.00", "label": "Autre problème obstétrique non hémorragique" }, "victims": { diff --git a/converter/tests/fixtures/RS-EDA/cisu_case/RS-EDA_exhaustive_fill.json b/converter/tests/fixtures/RS-EDA/cisu_case/RS-EDA_exhaustive_fill.json index 577f44d3e1..a51e70b94d 100644 --- a/converter/tests/fixtures/RS-EDA/cisu_case/RS-EDA_exhaustive_fill.json +++ b/converter/tests/fixtures/RS-EDA/cisu_case/RS-EDA_exhaustive_fill.json @@ -12,7 +12,7 @@ "label": "Domicile ; Lieu d'habitation collectif ou foyer d'hébergement ; escaliers" }, "healthMotive": { - "code": "M02.07", + "code": "M03.01", "label": "Traumatisme sérieux, plaie intermédiaire" }, "details": { diff --git a/converter/tests/snapshots/snap_test_cisu_converter.py b/converter/tests/snapshots/snap_test_cisu_converter.py index 0335f8d06c..a80dbaf9e3 100644 --- a/converter/tests/snapshots/snap_test_cisu_converter.py +++ b/converter/tests/snapshots/snap_test_cisu_converter.py @@ -50,7 +50,7 @@ "label": "Obst\\u00e9trique" }, "healthMotive": { - "code": "M03.02", + "code": "M03.14", "label": "Autre probl\\u00e8me obst\\u00e9trique non h\\u00e9morragique" }, "locationKind": { @@ -216,7 +216,7 @@ "label": "Obst\\u00e9trique" }, "healthMotive": { - "code": "M03.02", + "code": "M06.03", "label": "Autre probl\\u00e8me obst\\u00e9trique non h\\u00e9morragique" }, "locationKind": { @@ -439,7 +439,7 @@ "label": "Domicile ; Lieu d\'habitation collectif ou foyer d\'h\\u00e9bergement ; escaliers" }, "healthMotive": { - "code": "M02.07", + "code": "M24.00", "label": "Traumatisme s\\u00e9rieux, plaie interm\\u00e9diaire" }, "riskThreat": [ @@ -536,7 +536,7 @@ "label": "Domicile ; Lieu d\'habitation collectif ou foyer d\'h\\u00e9bergement ; escaliers" }, "healthMotive": { - "code": "M02.07", + "code": "M24.00", "label": "Traumatisme s\\u00e9rieux, plaie interm\\u00e9diaire" }, "riskThreat": [ @@ -655,7 +655,7 @@ "label": "Domicile ; Lieu d\'habitation collectif ou foyer d\'h\\u00e9bergement ; escaliers" }, "healthMotive": { - "code": "M02.07", + "code": "M80.00", "label": "Traumatisme s\\u00e9rieux, plaie interm\\u00e9diaire" }, "riskThreat": [ @@ -764,7 +764,7 @@ "label": "Domicile ; Lieu d\'habitation collectif ou foyer d\'h\\u00e9bergement ; escaliers" }, "healthMotive": { - "code": "M02.07", + "code": "M80.00", "label": "Traumatisme s\\u00e9rieux, plaie interm\\u00e9diaire" }, "riskThreat": [ diff --git a/converter/tests/test_cisu_converter.py b/converter/tests/test_cisu_converter.py index 68a04f7881..8e90b972f8 100644 --- a/converter/tests/test_cisu_converter.py +++ b/converter/tests/test_cisu_converter.py @@ -22,7 +22,7 @@ def validate_health_format(result): TestHelper.conversion_tests_runner( sample_dir=Constants.RC_EDA_TAG, envelope_file=Constants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH, - converter_method=CISUConverterV3.from_cisu, + converter_method=lambda edxl_json: CISUConverterV3.from_cisu(edxl_json, Constants.V1_VERSION), target_schema=RS_EDA_SCHEMA, additional_validation=validate_health_format ) @@ -44,7 +44,7 @@ def validate_health_format(result): TestHelper.conversion_tests_runner( sample_dir=Constants.RC_EDA_TAG, envelope_file=Constants.EDXL_FIRE_TO_HEALTH_ENVELOPE_PATH, - converter_method=CISUConverterV3.from_cisu, + converter_method=lambda edxl_json: CISUConverterV3.from_cisu(edxl_json, Constants.V3_VERSION), target_schema=RS_EDA_SCHEMA, additional_validation=validate_health_format, online_tag="main" # ToDo: migrate to "v3" once tag is available @@ -76,9 +76,8 @@ def test_snapshot_RS_EDA_exhaustive_message(self, mock_choices, mock_now): mock_choices.choices.return_value = "f5de" message = TestHelper.create_edxl_json_from_sample(self.edxl_envelope_health_to_fire_path, self.fixtures_folder_path + "RS-EDA/cisu_case/RS-EDA_exhaustive_fill.json") - converter = CISUConverterV3() - output_data = converter.to_cisu(message) + output_data = CISUConverterV3.to_cisu(message) self.assertMatchSnapshot(json.dumps(output_data, indent=2)) @patch('converter.cisu.cisu_converter.random') @@ -86,9 +85,8 @@ def test_snapshot_RC_EDA_exhaustive_message(self, mock_choices): mock_choices.choices.side_effect = ["f5de7hj", "a3b2YH8", "c9d8jk9","he9i0kz"] message = TestHelper.create_edxl_json_from_sample(self.edxl_envelope_fire_to_health_path, self.fixtures_folder_path + "RC-EDA/RC-EDA_exhaustive_fill.json") - converter = CISUConverterV3() - output_data = converter.from_cisu(message) + output_data = CISUConverterV3.from_cisu(message, Constants.V1_VERSION) self.assertMatchSnapshot(json.dumps(output_data, indent=2)) @patch("converter.cisu.cisu_converter.datetime") @@ -100,9 +98,8 @@ def test_snapshot_RS_EDA_required_field_message(self,mock_choices, mock_now): mock_choices.choices.return_value = "f5de" message = TestHelper.create_edxl_json_from_sample(self.edxl_envelope_health_to_fire_path, self.fixtures_folder_path + "RS-EDA/cisu_case/RS-EDA_required_fields.json") - converter = CISUConverterV3() - output_data = converter.to_cisu(message) + output_data = CISUConverterV3.to_cisu(message) self.assertMatchSnapshot(json.dumps(output_data, indent=2)) @patch('converter.cisu.cisu_converter.random') @@ -110,9 +107,8 @@ def test_snapshot_RC_EDA_required_field_message(self, mock_choices): mock_choices.choices.side_effect = ["f5de7hj", "a3b2YH8", "c9d8jk9","he9i0kz"] message = TestHelper.create_edxl_json_from_sample(self.edxl_envelope_fire_to_health_path, self.fixtures_folder_path + "RC-EDA/RC-EDA_required_fields.json") - converter = CISUConverterV3() - output_data = converter.from_cisu(message) + output_data = CISUConverterV3.from_cisu(message, Constants.V1_VERSION) self.assertMatchSnapshot(json.dumps(output_data, indent=2)) @@ -125,9 +121,8 @@ def test_snapshot_RS_EDA_exhaustive_bis_message(self,mock_choices, mock_now): mock_choices.choices.return_value = "f5de" message = TestHelper.create_edxl_json_from_sample(self.edxl_envelope_health_to_fire_path, self.fixtures_folder_path + "RS-EDA/cisu_case/RS-EDA_exhaustive_fill_bis.json") - converter = CISUConverterV3() - output_data = converter.to_cisu(message) + output_data = CISUConverterV3.to_cisu(message) self.assertMatchSnapshot(json.dumps(output_data, indent=2)) @patch('converter.cisu.cisu_converter.random') @@ -135,16 +130,14 @@ def test_snapshot_RC_EDA_exhaustive_bis_message(self, mock_choices): mock_choices.choices.side_effect = ["f5de7hj", "a3b2YH8", "c9d8jk9","he9i0kz"] message = TestHelper.create_edxl_json_from_sample(self.edxl_envelope_fire_to_health_path, self.fixtures_folder_path + "RC-EDA/RC-EDA_exhaustive_fill_bis.json") - converter = CISUConverterV3() - - output_data = converter.from_cisu(message) + output_data = CISUConverterV3.from_cisu(message, Constants.V1_VERSION) self.assertMatchSnapshot(json.dumps(output_data, indent=2)) class TestVictimsCount(TestCase): def setUp(self): self.fixtures_folder_path = "tests/fixtures/" - self.converter = CISUConverterV3() + self.converter = CISUConverterV3 def test_count_victims_1(self):