Skip to content

Commit 258d80a

Browse files
authored
Merge pull request #336 from ansforge/fix/converter-initial-alert-caller-language
Fix/converter initial alert caller language
2 parents 6494635 + 82a4975 commit 258d80a

File tree

7 files changed

+460
-27
lines changed

7 files changed

+460
-27
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Constants:
2+
INITIAL_ALERT_CALLER_LANGUAGE_KEY = "initialAlert.caller.language"
3+
INITIAL_ALERT_CALLER_LANGUAGE_PATH = f"$.{INITIAL_ALERT_CALLER_LANGUAGE_KEY}"
4+
5+
INITIAL_ALERT_NOTES_PATH = "$.initialAlert.notes"

converter/converter/versions/create_case_health/create_case_health_converter.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
)
1010
from converter.versions.base_message_converter import BaseMessageConverter
1111
from converter.versions.create_case_health.v1_v2.constants import V1V2Constants
12-
from converter.versions.create_case_health.v1_v2.utils import validate_diagnosis_code
12+
from converter.versions.create_case_health.v1_v2.utils import (
13+
update_language,
14+
validate_diagnosis_code,
15+
)
1316
from converter.versions.create_case_health.v2_v3.constants import V2V3Constants
1417
from converter.versions.utils import (
1518
reverse_map_to_new_value,
@@ -42,11 +45,7 @@ def convert_v1_to_v2(cls, input_json: Dict[str, Any]) -> Dict[str, Any]:
4245
"$.initialAlert.caller.type",
4346
V1V2Constants.CALLER_TYPE_MAPPING,
4447
)
45-
map_to_new_value(
46-
output_use_case_json,
47-
"$.initialAlert.caller.language",
48-
V1V2Constants.V1_TO_V2_LANGUAGE,
49-
)
48+
update_language(output_use_case_json, V1V2Constants.V1_TO_V2_LANGUAGE)
5049

5150
patients = get_field_value(output_use_case_json, "$.patient")
5251
if patients is not None:
@@ -88,17 +87,6 @@ def convert_v1_to_v2(cls, input_json: Dict[str, Any]) -> Dict[str, Any]:
8887

8988
@classmethod
9089
def convert_v2_to_v1(cls, input_json: Dict[str, Any]) -> Dict[str, Any]:
91-
def update_language(json_data: Dict[str, Any]):
92-
language = get_field_value(json_data, "$.initialAlert.caller.language")
93-
if language in V1V2Constants.V1_TO_V2_LANGUAGE:
94-
map_to_new_value(
95-
json_data,
96-
"$.initialAlert.caller.language",
97-
V1V2Constants.V2_TO_V1_LANGUAGE,
98-
)
99-
else:
100-
delete_paths(json_data, ["initialAlert.caller.language"])
101-
10290
def update_practitioner_contact(json_data: Dict[str, Any], patient_index: int):
10391
practitioner_contact_type = get_field_value(
10492
json_data,
@@ -141,7 +129,7 @@ def update_practitioner_contact(json_data: Dict[str, Any], patient_index: int):
141129
"$.initialAlert.caller.callbackContact.type",
142130
V1V2Constants.V2_TO_V1_CALLER_CONTACT_TYPE,
143131
)
144-
update_language(output_use_case_json)
132+
update_language(output_use_case_json, V1V2Constants.V2_TO_V1_LANGUAGE)
145133

146134
patients = get_field_value(output_use_case_json, "$.patient")
147135
if patients is not None:

converter/converter/versions/create_case_health/v1_v2/utils.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import datetime
2+
3+
from converter.versions.create_case_health.constants import Constants
4+
from converter.utils import get_field_value, map_to_new_value, delete_paths, set_value
15
import re
26
from typing import Any, Dict
37

48
from converter.utils import (
59
add_to_medical_notes,
6-
delete_paths,
7-
get_field_value,
810
)
911
from converter.versions.create_case_health.v1_v2.constants import V1V2Constants
1012

@@ -61,3 +63,33 @@ def validate_diagnosis_code(
6163
[{"path": f"hypothesis.{diagnosis_type}", "label": code_label}],
6264
)
6365
delete_paths(patient_data, [f"hypothesis.{diagnosis_type}"])
66+
67+
68+
def update_language(message: Dict[str, Any], language_map: Dict[str, str]) -> None:
69+
language = get_field_value(message, Constants.INITIAL_ALERT_CALLER_LANGUAGE_PATH)
70+
if language in language_map:
71+
map_to_new_value(
72+
message,
73+
Constants.INITIAL_ALERT_CALLER_LANGUAGE_PATH,
74+
language_map,
75+
)
76+
else:
77+
add_to_initial_alert_notes(message, f"Langue du requérant: {language}")
78+
delete_paths(message, [Constants.INITIAL_ALERT_CALLER_LANGUAGE_KEY])
79+
80+
81+
def add_to_initial_alert_notes(
82+
message: Dict[str, Any],
83+
note: str,
84+
) -> None:
85+
current_notes = get_field_value(message, Constants.INITIAL_ALERT_NOTES_PATH)
86+
if not current_notes:
87+
current_notes = []
88+
89+
note_to_add = {
90+
"freetext": note,
91+
"creation": datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S+00:00"),
92+
}
93+
94+
current_notes.append(note_to_add)
95+
set_value(message, Constants.INITIAL_ALERT_NOTES_PATH, current_notes)
Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
{
2+
"createCaseHealth": {
3+
"qualification": {
4+
"origin": "112",
5+
"riskThreat": [
6+
{
7+
"code": "R01",
8+
"label": "libellé R01"
9+
}
10+
],
11+
"whatsHappen": {
12+
"code": "C02.15.01",
13+
"label": "libellé de C021501"
14+
},
15+
"locationKind": {
16+
"code": "L01.00.00",
17+
"label": "libellé type de lieu"
18+
},
19+
"healthMotive": {
20+
"code": "M03.11",
21+
"label": "libellé motif de recours"
22+
},
23+
"details": {
24+
"status": " ACTIF",
25+
"attribution": "PEDIA",
26+
"priority": "P1",
27+
"careLevel": "R3"
28+
}
29+
},
30+
"location": {
31+
"geometry": {
32+
"point": {
33+
"coord": {
34+
"lat": 37.7749,
35+
"lon": 122.4194,
36+
"height": 16,
37+
"precision": "INCONNUE"
38+
},
39+
"isAml": true
40+
},
41+
"obsDatime": "2025-02-27T06:30:00+01:00"
42+
},
43+
"name": "nom du lieu",
44+
"externalLocationId": [
45+
{
46+
"source": "SIREN",
47+
"value": "123456789"
48+
}
49+
],
50+
"detailedAddress": {
51+
"highway": {
52+
"name": "A4",
53+
"pk": "PK10",
54+
"direction": "est"
55+
},
56+
"complete": "12 rue de nulle part",
57+
"number": "12",
58+
"wayName": {
59+
"complete": "rue de nulle part",
60+
"type": "rue",
61+
"name": "de nulle part"
62+
}
63+
},
64+
"city": {
65+
"name": "nowhere",
66+
"inseeCode": "99999"
67+
},
68+
"access": {
69+
"floor": "1",
70+
"roomNumber": "12",
71+
"interphone": "45678",
72+
"accessCode": ["4598"],
73+
"elevator": "z",
74+
"buildingName": "E",
75+
"entrance": "EST",
76+
"entity": "Service",
77+
"phoneNumber": "+33156487811"
78+
},
79+
"externalInfo": [
80+
{
81+
"freetext": "BAN",
82+
"type": "PHOTO",
83+
"uri": "identifiantBAN"
84+
}
85+
],
86+
"freetext": "infos complémentaires sur le lieu"
87+
},
88+
"initialAlert": {
89+
"caller": {
90+
"callerContact": {
91+
"channel": "PERSONNE",
92+
"type": "TEL",
93+
"detail": "+33645897846457895"
94+
},
95+
"callbackContact": {
96+
"channel": "ECALL",
97+
"type": "FAX",
98+
"detail": "uriducontact"
99+
},
100+
"language": "AX",
101+
"type": "MEDSOS",
102+
"communication": "LANGUE",
103+
"freetext": "infos supp sur le requérant",
104+
"detailedName": {
105+
"complete": "prénom et nom du requérant",
106+
"lastName": "nom du requérant",
107+
"firstName": "prénom du requérant"
108+
}
109+
},
110+
"reception": "2025-02-13T15:00:00+01:00",
111+
"notes": [
112+
{
113+
"creation": "2025-02-27T00:00:00+01:00",
114+
"freetext": "commentaire alerte initiale"
115+
},
116+
{
117+
"creation": "2025-02-27T00:00:00+01:00",
118+
"freetext": "commentaire alerte initiale 2"
119+
}
120+
]
121+
},
122+
"caseId": "fr.health.samu770.DRFR157702400400055",
123+
"senderCaseId": "DRFR157702400400055",
124+
"creation": "2025-02-27T01:15:00+01:00",
125+
"perimeter": "AMU",
126+
"interventionType": "PRIMAIRE",
127+
"owner": "fr.health.samu770",
128+
"patient": [
129+
{
130+
"idPat": "fr.health.samu770.patient.DRFR157702400400055.1",
131+
"administrativeFile": {
132+
"externalId": [
133+
{
134+
"source": "NIR",
135+
"value": "154088045698715"
136+
}
137+
]
138+
},
139+
"identity": {
140+
"strictFeatures": {
141+
"birthName": "Nom de naissance",
142+
"birthDate": "1954-08-12",
143+
"sex": "MASC"
144+
},
145+
"nonStrictFeatures": {
146+
"complete": "prénom et nom",
147+
"lastName": "nom",
148+
"firstName": "prénom"
149+
}
150+
},
151+
"healthMotive": {
152+
"code": "M01.00",
153+
"label": "Détresse vitale"
154+
},
155+
"detail": {
156+
"weight": 80,
157+
"height": 178,
158+
"age": "P80Y",
159+
"careLevel": "R2"
160+
},
161+
"hypothesis": {
162+
"mainDiagnosis": {
163+
"code": "J14",
164+
"label": " Pneumopathie due à Haemophilus influenzae"
165+
},
166+
"otherDiagnosis": [
167+
{
168+
"code": "MAUVAISCODE",
169+
"label": "Faux code"
170+
},
171+
{
172+
"code": "E11.9",
173+
"label": "Diabète sucré de type 2 sans complication"
174+
}
175+
]
176+
}
177+
},
178+
{
179+
"idPat": "fr.health.samu770.patient.DRFR157702400400055.2",
180+
"administrativeFile": {
181+
"externalId": [
182+
{
183+
"source": "DOSSARD",
184+
"value": "blablabla"
185+
}
186+
]
187+
},
188+
"identity": {
189+
"strictFeatures": {
190+
"birthName": "nom de naissance 2",
191+
"birthDate": "1959-05-23",
192+
"sex": "FEM"
193+
},
194+
"nonStrictFeatures": {
195+
"complete": "prénom et nom 2",
196+
"lastName": "nom 2",
197+
"firstName": "prénom 2"
198+
}
199+
},
200+
"healthMotive": {
201+
"code": "M02.01",
202+
"label": "Blessure"
203+
},
204+
"detail": {
205+
"weight": 54,
206+
"height": 160,
207+
"age": "P65Y",
208+
"careLevel": "R4"
209+
},
210+
"hypothesis": {
211+
"mainDiagnosis": {
212+
"code": "4A00",
213+
"label": "Code CIM11"
214+
},
215+
"otherDiagnosis": [
216+
{
217+
"code": "MAUVAISCODE",
218+
"label": "Pas CIM 10"
219+
}
220+
]
221+
}
222+
}
223+
],
224+
"medicalNote": [
225+
{
226+
"operator": {
227+
"label": "Label 1",
228+
"role": "ARM"
229+
},
230+
"idPat": "fr.health.samu770.patient.DRFR157702400400055.1",
231+
"idObs": "fr.health.samu770.medicalNote.nimpnawak",
232+
"creation": "2025-02-27T12:06:00+01:00",
233+
"freetext": "Note liée à un patient n°1"
234+
},
235+
{
236+
"operator": {
237+
"label": "label 2",
238+
"role": "AUTRE"
239+
},
240+
"idObs": "fr.health.samu770.medicalNote.onsenfout",
241+
"creation": "2025-02-27T00:00:00+01:00",
242+
"freetext": "note médicale non liée à patient n°2"
243+
}
244+
],
245+
"decision": [
246+
{
247+
"operator": {
248+
"label": "label 3",
249+
"role": "MEDECIN"
250+
},
251+
"idPat": "fr.health.samu770.patient.DRFR157702400400055.1",
252+
"creation": "2025-02-27T00:00:00+01:00",
253+
"decisionType": "CONSEIL",
254+
"resourceType": "TSU ",
255+
"vehiculeType": "AMB-GV",
256+
"medicalTransport": true,
257+
"orientationType": "EPHAD"
258+
},
259+
{
260+
"operator": {
261+
"role": "INFIRMIER"
262+
},
263+
"idPat": "fr.health.samu770.patient.DRFR157702400400055.2",
264+
"creation": "2025-02-27T18:00:00+01:00",
265+
"decisionType": "ORIENT",
266+
"resourceType": "LIB",
267+
"vehiculeType": "VLM",
268+
"orientationType": "URGENCES"
269+
}
270+
],
271+
"additionalInformation": {
272+
"customMap": [
273+
{
274+
"key": "test",
275+
"label": "test",
276+
"value": "test",
277+
"freetext": "test"
278+
}
279+
]
280+
}
281+
}
282+
}

0 commit comments

Comments
 (0)