0003-toulouse-maelis-manage-emergency-person-list-on-crea.patch
passerelle/contrib/toulouse_maelis/models.py | ||
---|---|---|
623 | 623 |
parameters={'NameID': {'description': 'Publik NameID'}}, |
624 | 624 |
post={'request_body': {'schema': {'application/json': schemas.UPDATE_FAMILY_SCHEMA}}}, |
625 | 625 |
) |
626 | 626 |
def update_family(self, request, NameID, post_data): |
627 | 627 |
family_id = self.get_link(NameID).family_id |
628 | 628 |
self.assert_family_payload_in_referential(post_data) |
629 | 629 |
self.replace_null_values(post_data) |
630 | 630 | |
631 |
# adapt payload to use same input as create_family |
|
632 |
if len(post_data.get('emergencyPersonList', [])): |
|
633 |
persons = post_data.pop('emergencyPersonList') |
|
634 |
post_data['emergencyPersonList'] = [{'personList': persons}] |
|
635 | ||
631 | 636 |
response = self.call('Family', 'updateFamily', dossierNumber=family_id, **post_data) |
632 | 637 |
data = serialize_object(response) |
633 | 638 |
family_id = data.get('number') |
634 | 639 |
errors = data.get('childErrorList') |
635 | 640 |
if errors: |
636 | 641 |
err_codes = [x.split(':')[0][:4] for x in errors] |
637 | 642 |
raise APIError(' ; '.join(errors), err_code=', '.join(err_codes)) |
638 | 643 |
return {'data': data} |
passerelle/contrib/toulouse_maelis/schemas.py | ||
---|---|---|
117 | 117 |
}, |
118 | 118 |
}, |
119 | 119 |
'unflatten': True, |
120 | 120 |
'additionalProperties': False, |
121 | 121 |
} |
122 | 122 |
EMERGENCY_PERSON_SCHEMA['properties'].update(PERSON_PROPERTIES) |
123 | 123 | |
124 | 124 | |
125 |
EMERGENCY_PERSON_LIST_SCHEMA = { |
|
126 |
'$schema': 'http://json-schema.org/draft-04/schema#', |
|
127 |
'title': 'Family persons', |
|
128 |
'description': "Liste des personnes à prévenir en cas d'urgence", |
|
129 |
'type': 'object', |
|
130 |
'properties': { |
|
131 |
'personList': { |
|
132 |
'oneOf': [ |
|
133 |
{ |
|
134 |
'type': 'array', |
|
135 |
'items': EMERGENCY_PERSON_SCHEMA, |
|
136 |
}, |
|
137 |
{'type': 'null'}, |
|
138 |
], |
|
139 |
}, |
|
140 |
}, |
|
141 |
} |
|
142 | ||
143 | ||
144 | 125 |
AUTHORIZED_PERSON_SCHEMA = { |
145 | 126 |
'$schema': 'http://json-schema.org/draft-04/schema#', |
146 | 127 |
'title': 'Family persons', |
147 | 128 |
'description': "Personnes autorisées à venir chercher l'enfant", |
148 | 129 |
'type': 'object', |
149 | 130 |
'required': ['personInfo', 'personQuality'], |
150 | 131 |
'properties': { |
151 | 132 |
'personInfo': { |
... | ... | |
600 | 581 |
'oneOf': [{'type': 'string'}, {'type': 'null'}], |
601 | 582 |
}, |
602 | 583 |
'rl1': RLINFO_SCHEMA, |
603 | 584 |
'rl2': RLINFO_SCHEMA, |
604 | 585 |
'emergencyPersonList': { |
605 | 586 |
'oneOf': [ |
606 | 587 |
{ |
607 | 588 |
'type': 'array', |
608 |
'items': EMERGENCY_PERSON_LIST_SCHEMA,
|
|
589 |
'items': EMERGENCY_PERSON_SCHEMA, |
|
609 | 590 |
}, |
610 | 591 |
{'type': 'null'}, |
611 | 592 |
], |
612 | 593 |
}, |
613 | 594 |
'childList': { |
614 | 595 |
'oneOf': [ |
615 | 596 |
{ |
616 | 597 |
'type': 'array', |
tests/test_toulouse_maelis.py | ||
---|---|---|
1247 | 1247 |
'rl1/birth/dateBirth': '1938-07-26', |
1248 | 1248 |
'rl1/birth/place': 'Rabbat', |
1249 | 1249 |
'rl1/adresse/street1': 'Chateau', |
1250 | 1250 |
'rl1/adresse/town': 'Paris', |
1251 | 1251 |
'rl1/adresse/zipcode': '75014', |
1252 | 1252 |
'rl1/adresse/numComp': 'B', |
1253 | 1253 |
'rl1/profession/codeCSP': 'ART', |
1254 | 1254 |
'rl1/CAFInfo/organ': 'A10007752822', |
1255 |
'emergencyPersonList/0/personList/0/civility': 'MME',
|
|
1256 |
'emergencyPersonList/0/personList/0/firstname': 'Keny',
|
|
1257 |
'emergencyPersonList/0/personList/0/lastname': 'Arkana',
|
|
1258 |
'emergencyPersonList/0/personList/0/sexe': 'F',
|
|
1259 |
'emergencyPersonList/0/personList/0/dateBirth': '1982-12-20',
|
|
1260 |
'emergencyPersonList/0/personList/0/quality': 'T',
|
|
1255 |
'emergencyPersonList/0/civility': 'MME', |
|
1256 |
'emergencyPersonList/0/firstname': 'Keny', |
|
1257 |
'emergencyPersonList/0/lastname': 'Arkana', |
|
1258 |
'emergencyPersonList/0/sexe': 'F', |
|
1259 |
'emergencyPersonList/0/dateBirth': '1982-12-20', |
|
1260 |
'emergencyPersonList/0/quality': 'T', |
|
1261 | 1261 |
'childList/0/lastname': 'Zimmerman', # add child |
1262 | 1262 |
'childList/0/firstname': 'Robert', |
1263 | 1263 |
'childList/0/sexe': 'M', |
1264 | 1264 |
'childList/0/birth/dateBirth': '1941-05-24', |
1265 | 1265 |
'childList/0/birth/place': 'Duluth', |
1266 | 1266 |
'childList/0/dietcode': 'RSV', |
1267 | 1267 |
'childList/0/paiInfoBean/code': 'PAIALI', |
1268 | 1268 |
'childList/0/medicalRecord/vaccinList/0/code': 'DTC', |
... | ... | |
1382 | 1382 |
'rl1/birth/dateBirth': '1938-07-26', |
1383 | 1383 |
'rl1/birth/place': 'Rabbat', |
1384 | 1384 |
'rl1/adresse/street1': 'Chateau', |
1385 | 1385 |
'rl1/adresse/town': 'Paris', |
1386 | 1386 |
'rl1/adresse/zipcode': '75014', |
1387 | 1387 |
'rl1/adresse/numComp': 'B', |
1388 | 1388 |
'rl1/profession/codeCSP': 'ART', |
1389 | 1389 |
'rl1/CAFInfo/organ': 'A10007752822', |
1390 |
'emergencyPersonList/0/personList/0/civility': 'MME',
|
|
1391 |
'emergencyPersonList/0/personList/0/firstname': 'Keny',
|
|
1392 |
'emergencyPersonList/0/personList/0/lastname': 'Arkana',
|
|
1393 |
'emergencyPersonList/0/personList/0/sexe': 'F',
|
|
1394 |
'emergencyPersonList/0/personList/0/dateBirth': '1982-12-20',
|
|
1395 |
'emergencyPersonList/0/personList/0/quality': 'T',
|
|
1390 |
'emergencyPersonList/0/civility': 'MME', |
|
1391 |
'emergencyPersonList/0/firstname': 'Keny', |
|
1392 |
'emergencyPersonList/0/lastname': 'Arkana', |
|
1393 |
'emergencyPersonList/0/sexe': 'F', |
|
1394 |
'emergencyPersonList/0/dateBirth': '1982-12-20', |
|
1395 |
'emergencyPersonList/0/quality': 'T', |
|
1396 | 1396 |
'childList/0/lastname': 'Zimmerman', |
1397 | 1397 |
'childList/0/firstname': 'Robert', |
1398 | 1398 |
'childList/0/sexe': 'M', |
1399 | 1399 |
'childList/0/birth/dateBirth': '1941-05-24', |
1400 | 1400 |
'childList/0/birth/place': 'Duluth', |
1401 | 1401 |
'childList/0/dietcode': 'RSV', |
1402 | 1402 |
'childList/0/paiInfoBean/code': 'PAIALI', |
1403 | 1403 |
'childList/0/medicalRecord/vaccinList/0/code': 'plop', |
1404 |
- |