|
6 | 6 |
|
7 | 7 | from yaml import dump |
8 | 8 |
|
| 9 | +from converter.cisu.create_case.create_case_cisu_constants import ( |
| 10 | + CreateCaseCISUConstants, |
| 11 | +) |
9 | 12 | from converter.cisu.utils import add_to_initial_alert_notes |
10 | 13 | from converter.constants import Constants |
11 | 14 | from converter.utils import ( |
|
25 | 28 | class CreateCaseCISUConverter(BaseCISUConverter): |
26 | 29 | """Handles CISU format conversions""" |
27 | 30 |
|
28 | | - CISU_PATHS_TO_DELETE = [ |
29 | | - "qualification.victims", |
30 | | - "referenceVersion", |
31 | | - "freetext", |
32 | | - "location.geometry.point.coord.heading", |
33 | | - "location.geometry.point.coord.speed", |
34 | | - "location.geometry.sketch", |
35 | | - "location.country", |
36 | | - "location.locID", |
37 | | - "location.locLabel", |
38 | | - "location.city.detail", |
39 | | - "initialAlert.id", |
40 | | - "initialAlert.attachment", |
41 | | - "initialAlert.reporting", |
42 | | - "initialAlert.qualification", |
43 | | - "initialAlert.location", |
44 | | - "initialAlert.callTaker", |
45 | | - "newAlert", |
46 | | - ] |
47 | | - |
48 | | - HEALTH_PATHS_TO_DELETE = [ |
49 | | - "owner", |
50 | | - "patient", |
51 | | - "medicalNote", |
52 | | - "decision", |
53 | | - "perimeter", |
54 | | - "interventionType", |
55 | | - "qualification.origin", |
56 | | - "qualification.details", |
57 | | - "location.detailedAddress.highway", |
58 | | - "location.geometry.point.isAml", |
59 | | - ] |
60 | | - |
61 | | - CISU_PATHS_TO_ADD_TO_INITIAL_ALERT_NOTES = [ |
62 | | - {"path": "$.initialAlert.attachment", "label": "Pièces jointes :"}, |
63 | | - {"path": "$.initialAlert.callTaker", "label": "Contact de l'opérateur SIS :"}, |
64 | | - {"path": "$.freetext", "label": ""}, |
65 | | - {"path": "$.newAlert", "label": "Nouvelles alertes :"}, |
66 | | - ] |
67 | | - |
68 | | - MEDICAL_NOTE_KEY_TRANSLATIONS = { |
69 | | - "freetext:": "Commentaire général :", |
70 | | - "mainVictim:": "Victime principale :", |
71 | | - "count:": "Nombre de victimes :", |
72 | | - } |
73 | | - |
74 | | - DEFAULT_WHATS_HAPPEN = {"code": "C11.06.00", "label": "Autre nature de fait"} |
75 | | - |
76 | 31 | @classmethod |
77 | 32 | def get_rs_message_type(cls) -> str: |
78 | 33 | return "createCaseHealth" |
@@ -152,7 +107,8 @@ def add_victims_to_medical_notes(json_data: Dict[str, Any], sender_id: str): |
152 | 107 | else: |
153 | 108 | formatted_field_value = dump(field_value, allow_unicode=True) |
154 | 109 | translated_text = translate_key_words( |
155 | | - formatted_field_value, cls.MEDICAL_NOTE_KEY_TRANSLATIONS |
| 110 | + formatted_field_value, |
| 111 | + CreateCaseCISUConstants.MEDICAL_NOTE_KEY_TRANSLATIONS, |
156 | 112 | ) |
157 | 113 | add_object_to_medical_notes(json_data, translated_text, sender_id) |
158 | 114 |
|
@@ -195,15 +151,16 @@ def add_object_to_medical_notes( |
195 | 151 | if is_field_completed(output_use_case_json, "$.initialAlert"): |
196 | 152 | add_case_priority(output_use_case_json) |
197 | 153 | add_to_initial_alert_notes( |
198 | | - output_use_case_json, cls.CISU_PATHS_TO_ADD_TO_INITIAL_ALERT_NOTES |
| 154 | + output_use_case_json, |
| 155 | + CreateCaseCISUConstants.CISU_PATHS_TO_ADD_TO_INITIAL_ALERT_NOTES, |
199 | 156 | ) |
200 | 157 | merge_notes_freetext(output_use_case_json) |
201 | 158 |
|
202 | 159 | add_victims_to_medical_notes(output_use_case_json, sender_id) |
203 | 160 |
|
204 | 161 | # - Delete paths - /!\ It must be the last step |
205 | 162 | logger.debug("Removing unnecessary paths") |
206 | | - delete_paths(output_use_case_json, cls.CISU_PATHS_TO_DELETE) |
| 163 | + delete_paths(output_use_case_json, CreateCaseCISUConstants.CISU_PATHS_TO_DELETE) |
207 | 164 |
|
208 | 165 | return cls.format_rs_output_json(output_json, output_use_case_json) |
209 | 166 |
|
@@ -292,14 +249,16 @@ def add_default_external_info_type(json_data: Dict[str, Any]): |
292 | 249 |
|
293 | 250 | if not is_field_completed(output_usecase_json, "$.qualification.whatsHappen"): |
294 | 251 | output_usecase_json["qualification"]["whatsHappen"] = ( |
295 | | - cls.DEFAULT_WHATS_HAPPEN |
| 252 | + CreateCaseCISUConstants.DEFAULT_WHATS_HAPPEN |
296 | 253 | ) |
297 | 254 |
|
298 | 255 | add_default_external_info_type(output_usecase_json) |
299 | 256 |
|
300 | 257 | # Deletions - /!\ it must be done before copying qualification and location fields |
301 | 258 | logger.debug("Removing unnecessary paths") |
302 | | - delete_paths(output_usecase_json, cls.HEALTH_PATHS_TO_DELETE) |
| 259 | + delete_paths( |
| 260 | + output_usecase_json, CreateCaseCISUConstants.HEALTH_PATHS_TO_DELETE |
| 261 | + ) |
303 | 262 |
|
304 | 263 | if is_field_completed(input_usecase_json, "$.initialAlert"): |
305 | 264 | output_usecase_json["initialAlert"]["id"] = f"INAL-{timestamp}-{random_str}" |
|
0 commit comments