diff --git a/functests/toulouse_maelis/conftest.py b/functests/toulouse_maelis/conftest.py
index 9564ed71..81f1be28 100644
--- a/functests/toulouse_maelis/conftest.py
+++ b/functests/toulouse_maelis/conftest.py
@@ -370,6 +370,15 @@ def create_data(request, conn):
for child in create_family_payload['childList']:
child['lastname'] = lastname
+ # test insurance here because it cannot be reset
+ create_family_payload['childList'][0]['insurance'] = {
+ 'company': 'Total Disaster Insurance',
+ 'contractNumber': '123',
+ 'memberNumber': '456',
+ 'contractStart': '2022-01-01',
+ 'contractEnd': '2022-12-31',
+ }
+
url = conn + '/create-family?NameID=%s' % name_id
resp = requests.post(url, json=create_family_payload)
resp.raise_for_status()
@@ -381,9 +390,10 @@ def create_data(request, conn):
return {
'name_id': name_id, # linked
'family_id': str(create_result['data']['number']),
+ 'family_payload': create_family_payload,
'lastname': lastname,
'rl1_num': data['RL1']['num'],
- 'family_payload': create_family_payload,
+ 'bart_num': data['childList'][0]['num'],
'data': data,
}
diff --git a/functests/toulouse_maelis/data/test_create_family.json b/functests/toulouse_maelis/data/test_create_family.json
index 12ee696c..c3f5dafc 100644
--- a/functests/toulouse_maelis/data/test_create_family.json
+++ b/functests/toulouse_maelis/data/test_create_family.json
@@ -154,7 +154,13 @@
}
]
},
- "insurance": null,
+ "insurance": {
+ "company": "Total Disaster Insurance",
+ "contractNumber": "123",
+ "memberNumber": "456",
+ "contractStart": "2022-01-01T00:00:00+01:00",
+ "contractEnd": "2022-12-31T00:00:00+01:00"
+ },
"paiInfoBean": {
"code": "PAIMED",
"dateDeb": "2022-09-01T00:00:00+02:00",
diff --git a/functests/toulouse_maelis/data/test_update_child_insurance.json b/functests/toulouse_maelis/data/test_update_child_insurance.json
new file mode 100644
index 00000000..77c494eb
--- /dev/null
+++ b/functests/toulouse_maelis/data/test_update_child_insurance.json
@@ -0,0 +1,7 @@
+{
+ "company": "Armagedon Colapse",
+ "contractNumber": "444",
+ "memberNumber": "555",
+ "contractStart": "2022-01-02T00:00:00+01:00",
+ "contractEnd": "2022-12-31T00:00:00+01:00"
+}
diff --git a/functests/toulouse_maelis/test_family.py b/functests/toulouse_maelis/test_family.py
index c71e5cc3..db5006d4 100644
--- a/functests/toulouse_maelis/test_family.py
+++ b/functests/toulouse_maelis/test_family.py
@@ -552,6 +552,27 @@ def test_update_child(conn, update_data, create_data):
assert resp.json()['err'] == 0
assert diff_family(conn, update_data['name_id'], 'test_update_family.json')
+ # update Bart insurance (on create_data as it cannot be reset)
+ unlink(conn, create_data['name_id'])
+ link(conn, create_data)
+ payload = copy.deepcopy(create_data['family_payload']['childList'][0])
+ for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList', 'indicatorList':
+ if key in payload:
+ del payload[key]
+ payload['insurance'] = {
+ 'company': 'Armagedon Colapse',
+ 'contractNumber': '444',
+ 'memberNumber': '555',
+ 'contractStart': '2022-01-02',
+ 'contractEnd': '2022-12-31',
+ }
+ url = conn + '/update-child?NameID=%s&child_id=%s' % (create_data['name_id'], create_data['bart_num'])
+ resp = requests.post(url, json=payload)
+ resp.raise_for_status()
+ res = resp.json()
+ assert res['err'] == 0
+ assert diff_child(conn, create_data['name_id'], 0, 'test_update_child_insurance.json', 'insurance')
+
def test_update_child_dietcode(conn, update_data):
unlink(conn, update_data['name_id'])
diff --git a/passerelle/contrib/toulouse_maelis/family_schemas.py b/passerelle/contrib/toulouse_maelis/family_schemas.py
index a43ff695..22a2ace9 100644
--- a/passerelle/contrib/toulouse_maelis/family_schemas.py
+++ b/passerelle/contrib/toulouse_maelis/family_schemas.py
@@ -499,6 +499,37 @@ PAIINFO_SCHEMA = {
'additionalProperties': False,
}
+INSURANCE_SCHEMA = {
+ '$schema': 'http://json-schema.org/draft-04/schema#',
+ 'title': 'Insurace',
+ 'description': "Informations sur l'assurance",
+ 'type': 'object',
+ 'properties': {
+ 'company': {
+ 'description': "Compagnie d'assurrance",
+ 'oneOf': [{'type': 'string'}, {'type': 'null'}],
+ },
+ 'contractNumber': {
+ 'description': 'Numéro du contrat',
+ 'oneOf': [{'type': 'string'}, {'type': 'null'}],
+ },
+ 'memberNumber': {
+ 'description': 'Numéro de membre',
+ 'oneOf': [{'type': 'string'}, {'type': 'null'}],
+ },
+ 'contractStart': {
+ 'description': 'Date de début du contrat',
+ 'type': 'string',
+ 'pattern': '^([0-9]{4}-[0-9]{2}-[0-9]{2}){0,1}$',
+ },
+ 'contractEnd': {
+ 'description': 'Date de fin du contrat',
+ 'type': 'string',
+ 'pattern': '^([0-9]{4}-[0-9]{2}-[0-9]{2}){0,1}$',
+ },
+ },
+}
+
CHILD_SCHEMA = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'title': 'Child',
@@ -530,6 +561,7 @@ CHILD_SCHEMA = {
},
'medicalRecord': {'oneOf': [MEDICALRECORD_SCHEMA, {'type': 'null'}]},
'paiInfoBean': {'oneOf': [PAIINFO_SCHEMA, {'type': 'null'}]},
+ 'insurance': {'oneOf': [INSURANCE_SCHEMA, {'type': 'null'}]},
'authorizedPersonList': {
'oneOf': [
{
diff --git a/tests/data/toulouse_maelis/R_read_family.xml b/tests/data/toulouse_maelis/R_read_family.xml
index b23d33cd..d28bc67c 100644
--- a/tests/data/toulouse_maelis/R_read_family.xml
+++ b/tests/data/toulouse_maelis/R_read_family.xml
@@ -185,6 +185,13 @@
1970-01-11T00:00:00+01:00
+
+ Total Disaster Insurance
+ 123
+ 456
+ 2022-01-01T00:00:00+01:00
+ 2022-12-31T00:00:00+01:00
+
613963
MME
diff --git a/tests/data/toulouse_maelis/R_read_family_relax.xml b/tests/data/toulouse_maelis/R_read_family_relax.xml
index 37f9e649..363d9b12 100644
--- a/tests/data/toulouse_maelis/R_read_family_relax.xml
+++ b/tests/data/toulouse_maelis/R_read_family_relax.xml
@@ -185,6 +185,13 @@
1970-01-11T00:00:00+01:00
+
+ Total Disaster Insurance
+ 123
+ 456
+ 2022-01-01T00:00:00+01:00
+ 2022-12-31T00:00:00+01:00
+
613963
MME
diff --git a/tests/data/toulouse_maelis/R_read_family_reordered.xml b/tests/data/toulouse_maelis/R_read_family_reordered.xml
index 8186cc29..966fb694 100644
--- a/tests/data/toulouse_maelis/R_read_family_reordered.xml
+++ b/tests/data/toulouse_maelis/R_read_family_reordered.xml
@@ -185,6 +185,13 @@
1970-01-11T00:00:00+01:00
+
+ Total Disaster Insurance
+ 123
+ 456
+ 2022-01-01T00:00:00+01:00
+ 2022-12-31T00:00:00+01:00
+
613963
MME
diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py
index e32bb589..d801a69c 100644
--- a/tests/test_toulouse_maelis.py
+++ b/tests/test_toulouse_maelis.py
@@ -904,7 +904,13 @@ def test_read_family(family_service, xml, con, app):
'dietcode_text': '3- RÉGIME SANS VIANDE',
'bPhoto': True,
'bLeaveAlone': False,
- 'insurance': None,
+ 'insurance': {
+ 'company': 'Total Disaster Insurance',
+ 'contractEnd': '2022-12-31T00:00:00+01:00',
+ 'contractNumber': '123',
+ 'contractStart': '2022-01-01T00:00:00+01:00',
+ 'memberNumber': '456',
+ },
'subscribeSchoolList': [],
'mother': {'num': 613963, 'civility': 'MME', 'firstname': 'JANE', 'lastname': 'DOE'},
'father': {'num': 613878, 'civility': 'M.', 'firstname': 'JHON', 'lastname': 'DOE'},
@@ -1293,6 +1299,11 @@ def test_create_family(family_service, con, app):
'childList/0/dietcode': 'RSV',
'childList/0/medicalRecord/vaccinList/0/code': 'DTC',
'childList/0/medicalRecord/vaccinList/0/vaccinationDate': '1940-07-26',
+ 'childList/0/insurance/company': 'Total Disaster Insurance',
+ 'childList/0/insurance/contractNumber': '123',
+ 'childList/0/insurance/memberNumber': '456',
+ 'childList/0/insurance/contractStart': '2022-01-01',
+ 'childList/0/insurance/contractEnd': '2022-12-31',
}
resp = app.post_json(url + '?NameID=local', params=params)
@@ -1447,6 +1458,11 @@ def test_update_family(family_service, con, app):
'childList/0/paiInfoBean/code': 'PAIALI',
'childList/0/medicalRecord/vaccinList/0/code': 'DTC',
'childList/0/medicalRecord/vaccinList/0/vaccinationDate': '1940-07-26',
+ 'childList/0/insurance/company': 'Armagedon Colapse',
+ 'childList/0/insurance/contractNumber': '444',
+ 'childList/0/insurance/memberNumber': '555',
+ 'childList/0/insurance/contractStart': '2022-01-02',
+ 'childList/0/insurance/contractEnd': '2022-12-31',
'childList/1/num': '613880', # update child
'childList/1/firstname': 'Brunelle',
'childList/1/lastname': 'Doe',
@@ -1967,6 +1983,11 @@ def test_create_child(family_service, con, app):
'sexe': 'F',
'birth/dateBirth': '1943-01-19',
'birth/place': 'Port Arthur',
+ 'insurance/company': 'Total Disaster Insurance',
+ 'insurance/contractNumber': '123',
+ 'insurance/memberNumber': '456',
+ 'insurance/contractStart': '2022-01-01',
+ 'insurance/contractEnd': '2022-12-31',
}
Link.objects.create(resource=con, family_id='1312', name_id='local')
@@ -2073,6 +2094,11 @@ def test_update_child(family_service, con, app):
'birth/place': 'Port Arthur',
'bPhoto': True,
'bLeaveAlone': False,
+ 'insurance/company': 'Armagedon Colapse',
+ 'insurance/contractNumber': '444',
+ 'insurance/memberNumber': '555',
+ 'insurance/contractStart': '2022-01-02',
+ 'insurance/contractEnd': '2022-12-31',
}
Link.objects.create(resource=con, family_id='1312', name_id='local')