toulouse-maelis: manage indicators (#71964)
This commit is contained in:
parent
9c04bde02f
commit
6e53fe0b09
|
@ -62,6 +62,17 @@ FAMILY_PAYLOAD = {
|
|||
'number': '123',
|
||||
'organ': 'A10007752822',
|
||||
},
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'AVL',
|
||||
'isActive': True,
|
||||
},
|
||||
{
|
||||
'code': 'ETABSPEC',
|
||||
'note': 'SNPP',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
},
|
||||
'childList': [
|
||||
{
|
||||
|
@ -107,6 +118,17 @@ FAMILY_PAYLOAD = {
|
|||
},
|
||||
],
|
||||
},
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'LUNETTE',
|
||||
'isActive': True,
|
||||
},
|
||||
{
|
||||
'code': 'AUTRE',
|
||||
'note': 'rebellious',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
'authorizedPersonList': [
|
||||
{
|
||||
'personInfo': {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -107,7 +107,22 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
"indicatorList": [],
|
||||
"indicatorList": [
|
||||
{
|
||||
"code": "AUTRE",
|
||||
"label": "Autre",
|
||||
"note": "rebellious",
|
||||
"choice": null,
|
||||
"code_text": "Autre"
|
||||
},
|
||||
{
|
||||
"code": "LUNETTE",
|
||||
"label": "Port de lunettes",
|
||||
"note": null,
|
||||
"choice": null,
|
||||
"code_text": "Port de lunettes"
|
||||
}
|
||||
],
|
||||
"medicalRecord": {
|
||||
"familyDoctor": {
|
||||
"name": "MONROE",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -58,7 +58,22 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
"indicatorList": [],
|
||||
"indicatorList": [
|
||||
{
|
||||
"code": "AUTRE",
|
||||
"label": "Autre",
|
||||
"note": "rebellious",
|
||||
"choice": null,
|
||||
"code_text": "Autre"
|
||||
},
|
||||
{
|
||||
"code": "LUNETTE",
|
||||
"label": "Port de lunettes",
|
||||
"note": null,
|
||||
"choice": null,
|
||||
"code_text": "Port de lunettes"
|
||||
}
|
||||
],
|
||||
"medicalRecord": {
|
||||
"familyDoctor": {
|
||||
"name": "MONROE",
|
||||
|
|
|
@ -92,7 +92,22 @@
|
|||
"organ": "A10007752822",
|
||||
"organ_text": "LA COLLE SUR LOUP"
|
||||
},
|
||||
"indicatorList": [],
|
||||
"indicatorList": [
|
||||
{
|
||||
"code": "AVL",
|
||||
"label": "Auxiliaire de Vie loisirs",
|
||||
"note": null,
|
||||
"choice": null,
|
||||
"code_text": "Auxiliaire de Vie loisirs"
|
||||
},
|
||||
{
|
||||
"code": "ETABSPEC",
|
||||
"label": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"note": "SNPP",
|
||||
"choice": null,
|
||||
"code_text": "Etablissement sp\u00e9cialis\u00e9"
|
||||
}
|
||||
],
|
||||
"quotientList": [],
|
||||
"subscribeActivityList": [],
|
||||
"civility_text": "Monsieur",
|
||||
|
@ -160,7 +175,22 @@
|
|||
}
|
||||
}
|
||||
],
|
||||
"indicatorList": [],
|
||||
"indicatorList": [
|
||||
{
|
||||
"code": "AUTRE",
|
||||
"label": "Autre",
|
||||
"note": "rebellious",
|
||||
"choice": null,
|
||||
"code_text": "Autre"
|
||||
},
|
||||
{
|
||||
"code": "LUNETTE",
|
||||
"label": "Port de lunettes",
|
||||
"note": null,
|
||||
"choice": null,
|
||||
"code_text": "Port de lunettes"
|
||||
}
|
||||
],
|
||||
"medicalRecord": {
|
||||
"familyDoctor": {
|
||||
"name": "MONROE",
|
||||
|
|
|
@ -46,7 +46,22 @@
|
|||
"organ": "A10007752822",
|
||||
"organ_text": "LA COLLE SUR LOUP"
|
||||
},
|
||||
"indicatorList": [],
|
||||
"indicatorList": [
|
||||
{
|
||||
"code": "AVL",
|
||||
"label": "Auxiliaire de Vie loisirs",
|
||||
"note": null,
|
||||
"choice": null,
|
||||
"code_text": "Auxiliaire de Vie loisirs"
|
||||
},
|
||||
{
|
||||
"code": "ETABSPEC",
|
||||
"label": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"note": "SNPP",
|
||||
"choice": null,
|
||||
"code_text": "Etablissement sp\u00e9cialis\u00e9"
|
||||
}
|
||||
],
|
||||
"quotientList": [],
|
||||
"subscribeActivityList": [],
|
||||
"civility_text": "Monsieur",
|
||||
|
|
|
@ -50,6 +50,16 @@ FAMILY_RESET_PAYLOAD = {
|
|||
'number': 'reset', # cannot be removed
|
||||
'organ': '',
|
||||
},
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'AVL',
|
||||
'isActive': False,
|
||||
},
|
||||
{
|
||||
'code': 'ETABSPEC',
|
||||
'isActive': False,
|
||||
},
|
||||
],
|
||||
},
|
||||
'childList': [
|
||||
{
|
||||
|
@ -87,6 +97,17 @@ FAMILY_RESET_PAYLOAD = {
|
|||
'hospital': '',
|
||||
'vaccinList': [],
|
||||
},
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'LUNETTE',
|
||||
'isActive': False,
|
||||
},
|
||||
{
|
||||
'code': 'AUTRE',
|
||||
'note': 'rebellious',
|
||||
'isActive': False,
|
||||
},
|
||||
],
|
||||
# setting authorizedPersonList to None will remove the list
|
||||
'authorizedPersonList': [
|
||||
{
|
||||
|
@ -284,7 +305,7 @@ def test_create_rl2(conn, create_data, update_data):
|
|||
# no unicity restriction on RL2 (duplicate RL2 from update_data)
|
||||
url = conn + '/create-rl2?NameID=%s' % create_data['name_id']
|
||||
payload = copy.deepcopy(update_data['family_payload']['rl2'])
|
||||
for key in 'contact', 'profession', 'CAFInfo':
|
||||
for key in 'contact', 'profession', 'CAFInfo', 'indicatorList':
|
||||
del payload[key]
|
||||
resp = requests.post(url, json=payload)
|
||||
resp.raise_for_status()
|
||||
|
@ -302,7 +323,7 @@ def test_update_rlg(conn, update_data, rl):
|
|||
|
||||
# reset responsable legal
|
||||
payload = copy.deepcopy(FAMILY_RESET_PAYLOAD[rlg])
|
||||
for key in 'adresse', 'contact', 'profession', 'CAFInfo':
|
||||
for key in 'adresse', 'contact', 'profession', 'CAFInfo', 'indicatorList':
|
||||
if key in payload:
|
||||
del payload[key]
|
||||
resp = requests.post(url, json=payload)
|
||||
|
@ -356,7 +377,7 @@ def test_update_rlg(conn, update_data, rl):
|
|||
|
||||
# restore RL1
|
||||
payload = copy.deepcopy(update_data['family_payload'][rlg])
|
||||
for key in 'adresse', 'contact', 'profession', 'CAFInfo':
|
||||
for key in 'adresse', 'contact', 'profession', 'CAFInfo', 'indicatorList':
|
||||
if payload.get(key):
|
||||
del payload[key]
|
||||
resp = requests.post(url, json=payload)
|
||||
|
@ -468,7 +489,7 @@ def test_update_child(conn, update_data, create_data):
|
|||
# side effect: the authorized person list is copied by the connector (from Lisa to Maggie)
|
||||
url = conn + '/update-child?NameID=%s&child_id=%s' % (update_data['name_id'], update_data['lisa_num'])
|
||||
payload = copy.deepcopy(update_data['family_payload']['childList'][2]) # Maggie content
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList':
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList', 'indicatorList':
|
||||
if key in payload:
|
||||
del payload[key]
|
||||
assert payload['firstname'] == 'Maggie'
|
||||
|
@ -484,7 +505,7 @@ def test_update_child(conn, update_data, create_data):
|
|||
# restore Maggie
|
||||
url = conn + '/update-child?NameID=%s&child_id=%s' % (update_data['name_id'], update_data['maggie_num'])
|
||||
payload = copy.deepcopy(update_data['family_payload']['childList'][2])
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList':
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList', 'indicatorList':
|
||||
if key in payload:
|
||||
del payload[key]
|
||||
resp = requests.post(url, json=payload)
|
||||
|
@ -495,7 +516,7 @@ def test_update_child(conn, update_data, create_data):
|
|||
# rename to an existing child on other family
|
||||
url = conn + '/update-child?NameID=%s&child_id=%s' % (update_data['name_id'], update_data['bart_num'])
|
||||
payload = copy.deepcopy(create_data['family_payload']['childList'][1])
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList':
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList', 'indicatorList':
|
||||
if key in payload:
|
||||
del payload[key]
|
||||
resp = requests.post(url, json=payload)
|
||||
|
@ -507,7 +528,7 @@ def test_update_child(conn, update_data, create_data):
|
|||
|
||||
# reset Bart
|
||||
payload = copy.deepcopy(FAMILY_RESET_PAYLOAD['childList'][0])
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList':
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList', 'indicatorList':
|
||||
if key in payload:
|
||||
del payload[key]
|
||||
resp = requests.post(url, json=payload)
|
||||
|
@ -517,7 +538,7 @@ def test_update_child(conn, update_data, create_data):
|
|||
|
||||
# restore Bart
|
||||
payload = copy.deepcopy(update_data['family_payload']['childList'][0])
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList':
|
||||
for key in 'dietcode', 'paiInfoBean', 'medicalRecord', 'authorizedPersonList', 'indicatorList':
|
||||
if key in payload:
|
||||
del payload[key]
|
||||
resp = requests.post(url, json=payload)
|
||||
|
@ -685,3 +706,49 @@ def test_child_person(conn, update_data):
|
|||
resp.raise_for_status()
|
||||
assert resp.json()['err'] == 0
|
||||
assert diff_family(conn, update_data['name_id'], 'test_update_family.json')
|
||||
|
||||
|
||||
def test_update_rl_indicator(conn, update_data):
|
||||
unlink(conn, update_data['name_id'])
|
||||
link(conn, update_data)
|
||||
url = conn + '/update-rl-indicator?NameID=%s&rl_id=%s' % (
|
||||
update_data['name_id'],
|
||||
update_data['rl2_num'],
|
||||
)
|
||||
|
||||
# reset RL indicators
|
||||
payload = {'indicatorList': FAMILY_RESET_PAYLOAD['rl2']['indicatorList']}
|
||||
resp = requests.post(url, json=payload)
|
||||
resp.raise_for_status()
|
||||
assert resp.json()['err'] == 0
|
||||
assert diff_rlg(conn, update_data['name_id'], 1, 'test_rl_indicator.json', key='indicatorList')
|
||||
|
||||
# restore RL indicators
|
||||
payload = {'indicatorList': update_data['family_payload']['rl2']['indicatorList']}
|
||||
resp = requests.post(url, json=payload)
|
||||
resp.raise_for_status()
|
||||
assert resp.json()['err'] == 0
|
||||
assert diff_family(conn, update_data['name_id'], 'test_update_family.json')
|
||||
|
||||
|
||||
def test_update_child_indicator(conn, update_data):
|
||||
unlink(conn, update_data['name_id'])
|
||||
link(conn, update_data)
|
||||
url = conn + '/update-child-indicator?NameID=%s&child_id=%s' % (
|
||||
update_data['name_id'],
|
||||
update_data['bart_num'],
|
||||
)
|
||||
|
||||
# reset Bart indicators
|
||||
payload = {'indicatorList': FAMILY_RESET_PAYLOAD['childList'][0]['indicatorList']}
|
||||
resp = requests.post(url, json=payload)
|
||||
resp.raise_for_status()
|
||||
assert resp.json()['err'] == 0
|
||||
assert diff_child(conn, update_data['name_id'], 0, 'test_child_indicator.json', key='indicatorList')
|
||||
|
||||
# restore Bart indicators
|
||||
payload = {'indicatorList': update_data['family_payload']['childList'][0]['indicatorList']}
|
||||
resp = requests.post(url, json=payload)
|
||||
resp.raise_for_status()
|
||||
assert resp.json()['err'] == 0
|
||||
assert diff_family(conn, update_data['name_id'], 'test_update_family.json')
|
||||
|
|
|
@ -235,6 +235,12 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
if isinstance(data, dict) and last_key in data and data[last_key] is not None:
|
||||
data[last_key + '_text'] = self.get_referential_value(referential_name, data[last_key])
|
||||
|
||||
def add_text_value_to_rl_indicator(self, data):
|
||||
self.add_text_value('RLIndicator', data, ['code'])
|
||||
|
||||
def add_text_value_to_child_indicator(self, data):
|
||||
self.add_text_value('ChildIndicator', data, ['code'])
|
||||
|
||||
def add_text_value_to_child_person(self, data):
|
||||
self.add_text_value('Civility', data, ['personInfo', 'civility'])
|
||||
self.add_text_value('Quality', data, ['personQuality', 'code'])
|
||||
|
@ -247,6 +253,12 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.add_text_value('PAI', data, ['paiInfoBean', 'code'])
|
||||
for person in data['authorizedPersonList']:
|
||||
self.add_text_value_to_child_person(person)
|
||||
for indicator in data['indicatorList']:
|
||||
self.add_text_value_to_child_indicator(indicator)
|
||||
|
||||
# sort indicators
|
||||
if data['indicatorList']:
|
||||
data['indicatorList'].sort(key=lambda x: x['code'])
|
||||
return data
|
||||
|
||||
def add_text_value_to_person(self, data):
|
||||
|
@ -260,6 +272,12 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.add_text_value('Complement', data, ['adresse', 'numComp'])
|
||||
self.add_text_value('CSP', data, ['profession', 'codeCSP'])
|
||||
self.add_text_value('Organ', data, ['CAFInfo', 'organ'])
|
||||
for indicator in data['indicatorList']:
|
||||
self.add_text_value_to_rl_indicator(indicator)
|
||||
|
||||
# sort indicators
|
||||
if data['indicatorList']:
|
||||
data['indicatorList'].sort(key=lambda x: x['code'])
|
||||
|
||||
def add_text_value_to_family(self, data):
|
||||
self.add_text_value('Category', data, ['category'])
|
||||
|
@ -326,6 +344,17 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
key_value = data
|
||||
self.assert_key_in_referential(referential_name, key_value, '/'.join(str(x) for x in keys), required)
|
||||
|
||||
def assert_update_indicator_payload_in_referential(self, referential, post_data, parent_keys=None):
|
||||
keys = parent_keys or []
|
||||
data = post_data
|
||||
for key in keys:
|
||||
data = data[key]
|
||||
|
||||
for i in range(0, len(data.get('indicatorList', []))):
|
||||
self.assert_post_data_in_referential(
|
||||
referential, post_data, keys + ['indicatorList', i, 'code'], required=True
|
||||
)
|
||||
|
||||
def assert_child_medical_record_payload_in_referential(self, post_data, parent_keys=None):
|
||||
keys = parent_keys or []
|
||||
data = post_data
|
||||
|
@ -364,6 +393,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
if 'medicalRecord' in data:
|
||||
# dead code as updateFamily seems not to modify medicalRecord
|
||||
self.assert_child_medical_record_payload_in_referential(post_data, keys + ['medicalRecord'])
|
||||
self.assert_update_indicator_payload_in_referential('ChildIndicator', post_data, keys)
|
||||
|
||||
def assert_person_payload_in_referential(self, post_data, parent_keys=None):
|
||||
keys = parent_keys or []
|
||||
|
@ -386,6 +416,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.assert_post_data_in_referential('Civility', post_data, keys + ['civility'])
|
||||
self.assert_post_data_in_referential('Quality', post_data, keys + ['quality'])
|
||||
self.assert_update_coordinate_payload_in_referential(post_data, keys)
|
||||
self.assert_update_indicator_payload_in_referential('RLIndicator', post_data, keys)
|
||||
|
||||
def assert_create_rl1_payload_in_referential(self, post_data):
|
||||
self.assert_post_data_in_referential('Category', post_data, ['category'])
|
||||
|
@ -1033,6 +1064,24 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.call('Family', 'updateCoordinate', numDossier=family_id, numPerson=rl_id, **post_data)
|
||||
return {'data': 'ok'}
|
||||
|
||||
@endpoint(
|
||||
display_category='Famille',
|
||||
description="Mise à jour des indicateurs d'un responsable légal",
|
||||
name='update-rl-indicator',
|
||||
perm='can_access',
|
||||
parameters={
|
||||
'NameID': {'description': 'Publik NameID'},
|
||||
'rl_id': {'description': 'Numéro du représentant légal'},
|
||||
},
|
||||
post={'request_body': {'schema': {'application/json': schemas.UPDATE_INDICATOR_SCHEMA}}},
|
||||
)
|
||||
def update_rl_indicator(self, request, NameID, rl_id, post_data):
|
||||
self.get_link(NameID)
|
||||
self.assert_update_indicator_payload_in_referential('RLIndicator', post_data)
|
||||
|
||||
self.call('Family', 'updatePersonIndicatorList', numPerson=rl_id, **post_data)
|
||||
return {'data': 'ok'}
|
||||
|
||||
@endpoint(
|
||||
display_category='Famille',
|
||||
description="Création d'une personne à prévenir en cas d'urgence",
|
||||
|
@ -1304,6 +1353,24 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.call('Family', 'updateChildMedicalRecord', updateChildMedicalRecordRequest=payload)
|
||||
return {'data': 'ok'}
|
||||
|
||||
@endpoint(
|
||||
display_category='Famille',
|
||||
description="Mise à jour des indicateurs d'un enfant",
|
||||
name='update-child-indicator',
|
||||
perm='can_access',
|
||||
parameters={
|
||||
'NameID': {'description': 'Publik NameID'},
|
||||
'child_id': {'description': "Numéro de l'enfant"},
|
||||
},
|
||||
post={'request_body': {'schema': {'application/json': schemas.UPDATE_INDICATOR_SCHEMA}}},
|
||||
)
|
||||
def update_child_indicator(self, request, NameID, child_id, post_data):
|
||||
self.get_link(NameID)
|
||||
self.assert_update_indicator_payload_in_referential('ChildIndicator', post_data)
|
||||
|
||||
self.call('Family', 'updatePersonIndicatorList', numPerson=child_id, **post_data)
|
||||
return {'data': 'ok'}
|
||||
|
||||
|
||||
class Link(models.Model):
|
||||
resource = models.ForeignKey(ToulouseMaelis, on_delete=models.CASCADE)
|
||||
|
|
|
@ -178,6 +178,29 @@ BIRTH_SCHEMA = {
|
|||
},
|
||||
}
|
||||
|
||||
INDICATOR_SCHEMA = {
|
||||
'$schema': 'http://json-schema.org/draft-04/schema#',
|
||||
'title': 'Address',
|
||||
'description': 'Indicateurs',
|
||||
'type': 'object',
|
||||
'required': ['code', 'isActive'],
|
||||
'properties': {
|
||||
'code': {
|
||||
'description': "Code de l'indicateur (depuis référentiel)",
|
||||
'type': 'string',
|
||||
'pattern': '.+',
|
||||
},
|
||||
'note': {
|
||||
'description': "Commentaire pour les indicateurs de type NOTE",
|
||||
'oneOf': [{'type': 'string'}, {'type': 'null'}],
|
||||
},
|
||||
'isActive': {
|
||||
'description': "True pour ajouter/modifier l'indicateur (défault) ou False pour le retirer",
|
||||
'oneOf': BOOLEAN_TYPES,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
ID_PROPERTIES = {
|
||||
'firstname': {
|
||||
'description': 'Prénom',
|
||||
|
@ -350,6 +373,15 @@ RLINFO_SCHEMA = {
|
|||
'contact': {'oneOf': [CONTACT_SCHEMA, {'type': 'null'}]},
|
||||
'profession': {'oneOf': [PROFESSION_SCHEMA, {'type': 'null'}]},
|
||||
'CAFInfo': {'oneOf': [CAFINFO_SCHEMA, {'type': 'null'}]},
|
||||
'indicatorList': {
|
||||
'oneOf': [
|
||||
{
|
||||
'type': 'array',
|
||||
'items': INDICATOR_SCHEMA,
|
||||
},
|
||||
{'type': 'null'},
|
||||
],
|
||||
},
|
||||
},
|
||||
'unflatten': True,
|
||||
'additionalProperties': False,
|
||||
|
@ -542,6 +574,15 @@ CHILD_SCHEMA = {
|
|||
{'type': 'null'},
|
||||
],
|
||||
},
|
||||
'indicatorList': {
|
||||
'oneOf': [
|
||||
{
|
||||
'type': 'array',
|
||||
'items': INDICATOR_SCHEMA,
|
||||
},
|
||||
{'type': 'null'},
|
||||
],
|
||||
},
|
||||
},
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
@ -622,12 +663,14 @@ del UPDATE_RL1_SCHEMA['properties']['adresse']
|
|||
del UPDATE_RL1_SCHEMA['properties']['contact']
|
||||
del UPDATE_RL1_SCHEMA['properties']['profession']
|
||||
del UPDATE_RL1_SCHEMA['properties']['CAFInfo']
|
||||
del UPDATE_RL1_SCHEMA['properties']['indicatorList']
|
||||
|
||||
CREATE_RL2_SCHEMA = copy.deepcopy(RLINFO_SCHEMA)
|
||||
CREATE_RL2_SCHEMA['unflatten'] = True
|
||||
del CREATE_RL2_SCHEMA['properties']['contact']
|
||||
del CREATE_RL2_SCHEMA['properties']['profession']
|
||||
del CREATE_RL2_SCHEMA['properties']['CAFInfo']
|
||||
del CREATE_RL2_SCHEMA['properties']['indicatorList']
|
||||
|
||||
UPDATE_RL2_SCHEMA = copy.deepcopy(UPDATE_RL1_SCHEMA)
|
||||
|
||||
|
@ -637,6 +680,7 @@ del CREATE_CHILD_SCHEMA['properties']['dietcode']
|
|||
del CREATE_CHILD_SCHEMA['properties']['medicalRecord']
|
||||
del CREATE_CHILD_SCHEMA['properties']['paiInfoBean']
|
||||
del CREATE_CHILD_SCHEMA['properties']['authorizedPersonList']
|
||||
del CREATE_CHILD_SCHEMA['properties']['indicatorList']
|
||||
|
||||
UPDATE_CHILD_SCHEMA = copy.deepcopy(CREATE_CHILD_SCHEMA)
|
||||
|
||||
|
@ -655,3 +699,20 @@ UPDATE_COORDINATE_SCHEMA = {
|
|||
'unflatten': True,
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
||||
UPDATE_INDICATOR_SCHEMA = {
|
||||
'$schema': 'http://json-schema.org/draft-04/schema#',
|
||||
'title': 'Update indicators',
|
||||
'description': 'Mise à jour des indicateurs',
|
||||
'type': 'object',
|
||||
'required': ['indicatorList'],
|
||||
'properties': {
|
||||
'indicatorList': {
|
||||
'type': 'array',
|
||||
'items': INDICATOR_SCHEMA,
|
||||
'minItems': 1,
|
||||
}
|
||||
},
|
||||
'additionalProperties': False,
|
||||
'unflatten': True,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap-env:Header>
|
||||
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
|
||||
<wsse:UsernameToken>
|
||||
<wsse:Username>maelis-webservice</wsse:Username>
|
||||
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">maelis-password</wsse:Password>
|
||||
</wsse:UsernameToken>
|
||||
</wsse:Security>
|
||||
</soap-env:Header>
|
||||
<soap-env:Body>
|
||||
<ns0:updatePersonIndicatorList xmlns:ns0="family.ws.maelis.sigec.com">
|
||||
<numPerson>613880</numPerson>
|
||||
<indicatorList>
|
||||
<code>LUNETTE</code>
|
||||
<isActive>true</isActive>
|
||||
</indicatorList>
|
||||
<indicatorList>
|
||||
<code>AUTRE</code>
|
||||
<note>rebellious</note>
|
||||
<isActive>true</isActive>
|
||||
</indicatorList>
|
||||
</ns0:updatePersonIndicatorList>
|
||||
</soap-env:Body>
|
||||
</soap-env:Envelope>
|
|
@ -0,0 +1,24 @@
|
|||
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap-env:Header>
|
||||
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
|
||||
<wsse:UsernameToken>
|
||||
<wsse:Username>maelis-webservice</wsse:Username>
|
||||
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">maelis-password</wsse:Password>
|
||||
</wsse:UsernameToken>
|
||||
</wsse:Security>
|
||||
</soap-env:Header>
|
||||
<soap-env:Body>
|
||||
<ns0:updatePersonIndicatorList xmlns:ns0="family.ws.maelis.sigec.com">
|
||||
<numPerson>613878</numPerson>
|
||||
<indicatorList>
|
||||
<code>AVL</code>
|
||||
<isActive>true</isActive>
|
||||
</indicatorList>
|
||||
<indicatorList>
|
||||
<code>ETABSPEC</code>
|
||||
<note>SNPP</note>
|
||||
<isActive>true</isActive>
|
||||
</indicatorList>
|
||||
</ns0:updatePersonIndicatorList>
|
||||
</soap-env:Body>
|
||||
</soap-env:Envelope>
|
|
@ -36,6 +36,15 @@
|
|||
<profession>
|
||||
<addressPro/>
|
||||
</profession>
|
||||
<indicatorList>
|
||||
<code>ETABSPEC</code>
|
||||
<label>Etablissement spécialisé</label>
|
||||
<note>SNPP</note>
|
||||
</indicatorList>
|
||||
<indicatorList>
|
||||
<code>AVL</code>
|
||||
<label>Auxiliaire de Vie loisirs</label>
|
||||
</indicatorList>
|
||||
</RL1>
|
||||
<RL2>
|
||||
<num>613879</num>
|
||||
|
@ -120,6 +129,15 @@
|
|||
<libelle>TANTE</libelle>
|
||||
</personQuality>
|
||||
</authorizedPersonList>
|
||||
<indicatorList>
|
||||
<code>LUNETTE</code>
|
||||
<label>Port de lunettes</label>
|
||||
</indicatorList>
|
||||
<indicatorList>
|
||||
<code>AUTRE</code>
|
||||
<label>Autre</label>
|
||||
<note>rebellious</note>
|
||||
</indicatorList>
|
||||
<medicalRecord>
|
||||
<familyDoctor>
|
||||
<name>DRE</name>
|
||||
|
|
|
@ -36,6 +36,15 @@
|
|||
<profession>
|
||||
<addressPro/>
|
||||
</profession>
|
||||
<indicatorList>
|
||||
<code>ETABSPEC</code>
|
||||
<label>Etablissement spécialisé</label>
|
||||
<note>SNPP</note>
|
||||
</indicatorList>
|
||||
<indicatorList>
|
||||
<code>AVL</code>
|
||||
<label>Auxiliaire de Vie loisirs</label>
|
||||
</indicatorList>
|
||||
</RL1>
|
||||
<RL2>
|
||||
<num>613879</num>
|
||||
|
@ -120,6 +129,15 @@
|
|||
<libelle>TANTE</libelle>
|
||||
</personQuality>
|
||||
</authorizedPersonList>
|
||||
<indicatorList>
|
||||
<code>LUNETTE</code>
|
||||
<label>Port de lunettes</label>
|
||||
</indicatorList>
|
||||
<indicatorList>
|
||||
<code>AUTRE</code>
|
||||
<label>Autre</label>
|
||||
<note>rebellious</note>
|
||||
</indicatorList>
|
||||
<medicalRecord>
|
||||
<familyDoctor>
|
||||
<name>DRE</name>
|
||||
|
|
|
@ -36,6 +36,15 @@
|
|||
<profession>
|
||||
<addressPro/>
|
||||
</profession>
|
||||
<indicatorList>
|
||||
<code>ETABSPEC</code>
|
||||
<label>Etablissement spécialisé</label>
|
||||
<note>SNPP</note>
|
||||
</indicatorList>
|
||||
<indicatorList>
|
||||
<code>AVL</code>
|
||||
<label>Auxiliaire de Vie loisirs</label>
|
||||
</indicatorList>
|
||||
</RL1>
|
||||
<RL2>
|
||||
<num>613879</num>
|
||||
|
@ -120,6 +129,15 @@
|
|||
<libelle>TANTE</libelle>
|
||||
</personQuality>
|
||||
</authorizedPersonList>
|
||||
<indicatorList>
|
||||
<code>LUNETTE</code>
|
||||
<label>Port de lunettes</label>
|
||||
</indicatorList>
|
||||
<indicatorList>
|
||||
<code>AUTRE</code>
|
||||
<label>Autre</label>
|
||||
<note>rebellious</note>
|
||||
</indicatorList>
|
||||
<medicalRecord>
|
||||
<familyDoctor>
|
||||
<name>DRE</name>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:updatePersonIndicatorListResponse
|
||||
xmlns:ns2="family.ws.maelis.sigec.com"/>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -66,6 +66,7 @@ UPDATE_MEDICAL_500 = FakedResponse(
|
|||
content=get_xml_file('R_update_child_medical_record_soap_error.xml'), status_code=500
|
||||
)
|
||||
UPDATE_CHILD_AUTO = FakedResponse(content=get_xml_file('R_update_child_authorization.xml'), status_code=200)
|
||||
UPDATE_INDICATOR = FakedResponse(content=get_xml_file('R_update_indicator.xml'), status_code=200)
|
||||
|
||||
|
||||
def assert_sent_payload(mocked_post, query_file):
|
||||
|
@ -704,13 +705,29 @@ def test_read_family(mocked_post, mocked_get, read_family, con, app):
|
|||
'civility_text': 'Monsieur',
|
||||
'quality_text': 'PERE',
|
||||
'quotientList': [],
|
||||
'indicatorList': [],
|
||||
'indicatorList': [
|
||||
{
|
||||
'choice': None,
|
||||
'code': 'AVL',
|
||||
'code_text': 'Auxiliaire de Vie loisirs',
|
||||
'label': 'Auxiliaire de Vie loisirs',
|
||||
'note': None,
|
||||
},
|
||||
{
|
||||
'choice': None,
|
||||
'code': 'ETABSPEC',
|
||||
'code_text': 'Etablissement spécialisé',
|
||||
'label': 'Etablissement spécialisé',
|
||||
'note': 'SNPP',
|
||||
},
|
||||
],
|
||||
'subscribeActivityList': [],
|
||||
}
|
||||
data = resp.json['data']['childList'][0]
|
||||
del data['medicalRecord']
|
||||
del data['authorizedPersonList']
|
||||
del data['paiInfoBean']
|
||||
del data['indicatorList']
|
||||
assert data == {
|
||||
'num': '613880',
|
||||
'lastname': 'DOE',
|
||||
|
@ -728,7 +745,6 @@ def test_read_family(mocked_post, mocked_get, read_family, con, app):
|
|||
'bPhoto': True,
|
||||
'bLeaveAlone': False,
|
||||
'insurance': None,
|
||||
'indicatorList': [],
|
||||
'subscribeSchoolList': [],
|
||||
'mother': {'num': 613963, 'civility': 'MME', 'firstname': 'JANE', 'lastname': 'DOE'},
|
||||
'father': {'num': 613878, 'civility': 'M.', 'firstname': 'JHON', 'lastname': 'DOE'},
|
||||
|
@ -812,6 +828,16 @@ def test_read_family(mocked_post, mocked_get, read_family, con, app):
|
|||
'libelle': 'TANTE',
|
||||
},
|
||||
}
|
||||
assert resp.json['data']['childList'][0]['indicatorList'] == [
|
||||
{'choice': None, 'code': 'AUTRE', 'code_text': 'Autre', 'label': 'Autre', 'note': 'rebellious'},
|
||||
{
|
||||
'choice': None,
|
||||
'code': 'LUNETTE',
|
||||
'code_text': 'Port de lunettes',
|
||||
'label': 'Port de lunettes',
|
||||
'note': None,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_read_family_not_linked_error(con, app):
|
||||
|
@ -2770,3 +2796,183 @@ def test_update_child_medical_record_wrong_referential_key_error(con, app):
|
|||
resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
|
||||
assert resp.json['err'] == 'wrong-key'
|
||||
assert resp.json['err_desc'] == "vaccinList/1/code key value 'plop' do not belong to 'Vaccin' referential"
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_update_rl_indicator(mocked_post, mocked_get, con, app):
|
||||
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
||||
mocked_post.return_value = UPDATE_INDICATOR
|
||||
url = get_endpoint('update-rl-indicator')
|
||||
params = {
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'AVL',
|
||||
'isActive': True,
|
||||
},
|
||||
{
|
||||
'code': 'ETABSPEC',
|
||||
'note': 'SNPP',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params)
|
||||
assert_sent_payload(mocked_post, 'Q_update_rl_indicator.xml')
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] == 'ok'
|
||||
|
||||
|
||||
def test_update_rl_indicator_not_linked_error(con, app):
|
||||
url = get_endpoint('update-rl-indicator')
|
||||
params = {
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'AVL',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params)
|
||||
assert resp.json['err'] == 'not-linked'
|
||||
assert resp.json['err_desc'] == 'User not linked to family'
|
||||
|
||||
|
||||
def test_update_rl_indicator_no_indicator_error(con, app):
|
||||
url = get_endpoint('update-rl-indicator')
|
||||
params = {'indicatorList': []}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'indicatorList: [] is too short'
|
||||
|
||||
|
||||
def test_update_rl_indicator_empty_referential_key_error(con, app):
|
||||
url = get_endpoint('update-rl-indicator')
|
||||
params = {
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': '',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == "indicatorList/0/code: '' does not match '.+'"
|
||||
|
||||
|
||||
def test_update_rl_indicator_wrong_referential_key_error(con, app):
|
||||
url = get_endpoint('update-rl-indicator')
|
||||
params = {
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'plop',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params)
|
||||
assert resp.json['err'] == 'wrong-key'
|
||||
assert (
|
||||
resp.json['err_desc']
|
||||
== "indicatorList/0/code key value 'plop' do not belong to 'RLIndicator' required referential"
|
||||
)
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_update_child_indicator(mocked_post, mocked_get, con, app):
|
||||
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
||||
mocked_post.return_value = UPDATE_INDICATOR
|
||||
url = get_endpoint('update-child-indicator')
|
||||
params = {
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'LUNETTE',
|
||||
'isActive': True,
|
||||
},
|
||||
{
|
||||
'code': 'AUTRE',
|
||||
'note': 'rebellious',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params)
|
||||
assert_sent_payload(mocked_post, 'Q_update_child_indicator.xml')
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] == 'ok'
|
||||
|
||||
|
||||
def test_update_child_indicator_not_linked_error(con, app):
|
||||
url = get_endpoint('update-child-indicator')
|
||||
params = {
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'LUNETTE',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params)
|
||||
assert resp.json['err'] == 'not-linked'
|
||||
assert resp.json['err_desc'] == 'User not linked to family'
|
||||
|
||||
|
||||
def test_update_child_indicator_no_indicator_error(con, app):
|
||||
url = get_endpoint('update-child-indicator')
|
||||
params = {'indicatorList': []}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'indicatorList: [] is too short'
|
||||
|
||||
|
||||
def test_update_child_indicator_empty_referential_key_error(con, app):
|
||||
url = get_endpoint('update-child-indicator')
|
||||
params = {
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': '',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == "indicatorList/0/code: '' does not match '.+'"
|
||||
|
||||
|
||||
def test_update_child_indicator_wrong_referential_key_error(con, app):
|
||||
url = get_endpoint('update-child-indicator')
|
||||
params = {
|
||||
'indicatorList': [
|
||||
{
|
||||
'code': 'plop',
|
||||
'isActive': True,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params)
|
||||
assert resp.json['err'] == 'wrong-key'
|
||||
assert (
|
||||
resp.json['err_desc']
|
||||
== "indicatorList/0/code key value 'plop' do not belong to 'ChildIndicator' required referential"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue