toulouse-maelis: return an indicators dict (#72523)
This commit is contained in:
parent
bfbc32b0db
commit
1ecdaa2c9f
|
@ -288,12 +288,16 @@ def remove_id_on_child(child):
|
|||
child['father'] = 'N/A' # dont care yet
|
||||
for person in child['authorizedPersonList']:
|
||||
person['personInfo']['num'] = 'N/A'
|
||||
child['indicatorList'].sort(key=lambda x: x['code'])
|
||||
del child['indicators'] # order may change
|
||||
|
||||
|
||||
def remove_id_on_rlg(rlg):
|
||||
if rlg:
|
||||
rlg['num'] = 'N/A'
|
||||
rlg['lastname'] = 'N/A'
|
||||
rlg['indicatorList'].sort(key=lambda x: x['code'])
|
||||
del rlg['indicators'] # order may change
|
||||
|
||||
|
||||
def remove_id_on_family(family):
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
[
|
||||
{
|
||||
"id": "APPDENTAIRE",
|
||||
"code": "APPDENTAIRE",
|
||||
"text": "Port appareil dentaire",
|
||||
"label": "Port appareil dentaire",
|
||||
"typeDesc": "NONE",
|
||||
"isActive": false
|
||||
},
|
||||
{
|
||||
"id": "AUTRE",
|
||||
"code": "AUTRE",
|
||||
"text": "Autre",
|
||||
"label": "Autre",
|
||||
"typeDesc": "NOTE",
|
||||
"isActive": true
|
||||
},
|
||||
{
|
||||
"id": "AVL",
|
||||
"code": "AVL",
|
||||
"text": "Auxiliaire de Vie loisirs",
|
||||
"label": "Auxiliaire de Vie loisirs",
|
||||
"typeDesc": "NONE",
|
||||
"isActive": false
|
||||
},
|
||||
{
|
||||
"id": "AVS",
|
||||
"code": "AVS",
|
||||
"text": "Auxiliaire de Vie scolaire",
|
||||
"label": "Auxiliaire de Vie scolaire ",
|
||||
"typeDesc": "NONE",
|
||||
"isActive": false
|
||||
},
|
||||
{
|
||||
"id": "ETABSPEC",
|
||||
"code": "ETABSPEC",
|
||||
"text": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"label": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"typeDesc": "NOTE",
|
||||
"isActive": false
|
||||
},
|
||||
{
|
||||
"id": "LENTILLE",
|
||||
"code": "LENTILLE",
|
||||
"text": "Port lentilles de contact",
|
||||
"label": "Port lentilles de contact",
|
||||
"typeDesc": "NONE",
|
||||
"isActive": false
|
||||
},
|
||||
{
|
||||
"id": "LUNETTE",
|
||||
"code": "LUNETTE",
|
||||
"text": "Port de lunettes",
|
||||
"label": "Port de lunettes",
|
||||
"typeDesc": "NONE",
|
||||
"isActive": true
|
||||
},
|
||||
{
|
||||
"id": "MDPH",
|
||||
"code": "MDPH",
|
||||
"text": "Notification MDPH",
|
||||
"label": "Notification MDPH",
|
||||
"typeDesc": "NONE",
|
||||
"isActive": false
|
||||
}
|
||||
]
|
|
@ -0,0 +1,34 @@
|
|||
[
|
||||
{
|
||||
"id": "AVL",
|
||||
"code": "AVL",
|
||||
"text": "Auxiliaire de Vie loisirs",
|
||||
"label": "Auxiliaire de Vie loisirs",
|
||||
"typeDesc": "NONE",
|
||||
"isActive": true
|
||||
},
|
||||
{
|
||||
"id": "AVS",
|
||||
"code": "AVS",
|
||||
"text": "Auxiliaire de Vie scolaire",
|
||||
"label": "Auxiliaire de Vie scolaire ",
|
||||
"typeDesc": "NONE",
|
||||
"isActive": false
|
||||
},
|
||||
{
|
||||
"id": "ETABSPEC",
|
||||
"code": "ETABSPEC",
|
||||
"text": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"label": "Etablissement sp\u00e9cialis\u00e9",
|
||||
"typeDesc": "NOTE",
|
||||
"isActive": true
|
||||
},
|
||||
{
|
||||
"id": "MDPH",
|
||||
"code": "MDPH",
|
||||
"text": "Notification MDPH",
|
||||
"label": "Notification MDPH",
|
||||
"typeDesc": "NONE",
|
||||
"isActive": false
|
||||
}
|
||||
]
|
|
@ -734,7 +734,11 @@ def test_update_rl_indicator(conn, update_data):
|
|||
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')
|
||||
data = diff_family(conn, update_data['name_id'], 'test_update_family.json')
|
||||
|
||||
# check indicator dict
|
||||
indicators = sorted(data['RL2']['indicators'].values(), key=lambda x: x['id'])
|
||||
assert diff(indicators, 'test_rl_indicators.json')
|
||||
|
||||
|
||||
def test_update_child_indicator(conn, update_data):
|
||||
|
@ -757,7 +761,11 @@ def test_update_child_indicator(conn, update_data):
|
|||
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')
|
||||
data = diff_family(conn, update_data['name_id'], 'test_update_family.json')
|
||||
|
||||
# check indicator dict
|
||||
indicators = sorted(data['childList'][0]['indicators'].values(), key=lambda x: x['id'])
|
||||
assert diff(indicators, 'test_child_indicators.json')
|
||||
|
||||
|
||||
def test_update_quotient(conn, create_data):
|
||||
|
|
|
@ -236,6 +236,16 @@ 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_indicators_field(self, referential_name, data):
|
||||
active_indicators = [x['code'] for x in data['indicatorList']]
|
||||
indicators = self.get_referential(referential_name)
|
||||
result = {}
|
||||
for item in indicators:
|
||||
item['isActive'] = item['id'] in active_indicators
|
||||
del item['choiceList'] # no list based indicator on parsifal project
|
||||
result[item['id']] = item
|
||||
data['indicators'] = result
|
||||
|
||||
def add_text_value_to_rl_indicator(self, data):
|
||||
self.add_text_value('RLIndicator', data, ['code'])
|
||||
|
||||
|
@ -256,10 +266,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
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'])
|
||||
self.add_indicators_field('ChildIndicator', data)
|
||||
return data
|
||||
|
||||
def add_text_value_to_person(self, data):
|
||||
|
@ -278,10 +285,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.add_text_value_to_rl_indicator(indicator)
|
||||
for quotient in data['quotientList']:
|
||||
self.add_text_value('Quotient', quotient, ['cdquo'])
|
||||
|
||||
# sort indicators
|
||||
if data['indicatorList']:
|
||||
data['indicatorList'].sort(key=lambda x: x['code'])
|
||||
self.add_indicators_field('RLIndicator', data)
|
||||
|
||||
def add_text_value_to_family(self, data):
|
||||
self.add_text_value('Category', data, ['category'])
|
||||
|
|
|
@ -811,6 +811,8 @@ def test_read_family(family_service, xml, con, app):
|
|||
}
|
||||
data = resp.json['data']['RL1']
|
||||
del data['profession']
|
||||
del data['indicatorList']
|
||||
del data['indicators']
|
||||
assert data == {
|
||||
'num': '613878',
|
||||
'lastname': 'DOE',
|
||||
|
@ -845,22 +847,6 @@ def test_read_family(family_service, xml, con, app):
|
|||
'CAFInfo': None,
|
||||
'civility_text': 'Monsieur',
|
||||
'quality_text': 'PERE',
|
||||
'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',
|
||||
},
|
||||
],
|
||||
'quotientList': [
|
||||
{
|
||||
'cdquo': 'QS',
|
||||
|
@ -883,11 +869,62 @@ def test_read_family(family_service, xml, con, app):
|
|||
],
|
||||
'subscribeActivityList': [],
|
||||
}
|
||||
assert sorted(resp.json['data']['RL1']['indicatorList'], key=lambda x: x['code']) == [
|
||||
{
|
||||
'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',
|
||||
},
|
||||
]
|
||||
assert resp.json['data']['RL1']['indicators'] == {
|
||||
'AVL': {
|
||||
'code': 'AVL',
|
||||
'id': 'AVL',
|
||||
'isActive': True,
|
||||
'label': 'Auxiliaire de Vie loisirs',
|
||||
'text': 'Auxiliaire de Vie loisirs',
|
||||
'typeDesc': 'NONE',
|
||||
},
|
||||
'AVS': {
|
||||
'code': 'AVS',
|
||||
'id': 'AVS',
|
||||
'isActive': False,
|
||||
'label': 'Auxiliaire de Vie scolaire ',
|
||||
'text': 'Auxiliaire de Vie scolaire',
|
||||
'typeDesc': 'NONE',
|
||||
},
|
||||
'ETABSPEC': {
|
||||
'code': 'ETABSPEC',
|
||||
'id': 'ETABSPEC',
|
||||
'isActive': True,
|
||||
'label': 'Etablissement spécialisé',
|
||||
'text': 'Etablissement spécialisé',
|
||||
'typeDesc': 'NOTE',
|
||||
},
|
||||
'MDPH': {
|
||||
'code': 'MDPH',
|
||||
'id': 'MDPH',
|
||||
'isActive': False,
|
||||
'label': 'Notification MDPH',
|
||||
'text': 'Notification MDPH',
|
||||
'typeDesc': 'NONE',
|
||||
},
|
||||
}
|
||||
data = resp.json['data']['childList'][0]
|
||||
del data['medicalRecord']
|
||||
del data['authorizedPersonList']
|
||||
del data['paiInfoBean']
|
||||
del data['indicatorList']
|
||||
del data['indicators']
|
||||
assert data == {
|
||||
'num': '613880',
|
||||
'lastname': 'DOE',
|
||||
|
@ -988,7 +1025,7 @@ def test_read_family(family_service, xml, con, app):
|
|||
'libelle': 'TANTE',
|
||||
},
|
||||
}
|
||||
assert resp.json['data']['childList'][0]['indicatorList'] == [
|
||||
assert sorted(resp.json['data']['childList'][0]['indicatorList'], key=lambda x: x['code']) == [
|
||||
{'choice': None, 'code': 'AUTRE', 'code_text': 'Autre', 'label': 'Autre', 'note': 'rebellious'},
|
||||
{
|
||||
'choice': None,
|
||||
|
@ -998,6 +1035,9 @@ def test_read_family(family_service, xml, con, app):
|
|||
'note': None,
|
||||
},
|
||||
]
|
||||
indicators = resp.json['data']['childList'][0]['indicators']
|
||||
assert len(indicators) == 8
|
||||
assert len([x for x in indicators.values() if x['isActive']]) == 2
|
||||
|
||||
|
||||
def test_read_family_not_linked_error(con, app):
|
||||
|
@ -1092,6 +1132,40 @@ def test_read_rl2(family_service, con, app):
|
|||
'quality_text': 'MERE',
|
||||
'quotientList': [],
|
||||
'indicatorList': [],
|
||||
'indicators': {
|
||||
'AVL': {
|
||||
'code': 'AVL',
|
||||
'id': 'AVL',
|
||||
'isActive': False,
|
||||
'label': 'Auxiliaire de Vie loisirs',
|
||||
'text': 'Auxiliaire de Vie loisirs',
|
||||
'typeDesc': 'NONE',
|
||||
},
|
||||
'AVS': {
|
||||
'code': 'AVS',
|
||||
'id': 'AVS',
|
||||
'isActive': False,
|
||||
'label': 'Auxiliaire de Vie scolaire ',
|
||||
'text': 'Auxiliaire de Vie scolaire',
|
||||
'typeDesc': 'NONE',
|
||||
},
|
||||
'ETABSPEC': {
|
||||
'code': 'ETABSPEC',
|
||||
'id': 'ETABSPEC',
|
||||
'isActive': False,
|
||||
'label': 'Etablissement spécialisé',
|
||||
'text': 'Etablissement spécialisé',
|
||||
'typeDesc': 'NOTE',
|
||||
},
|
||||
'MDPH': {
|
||||
'code': 'MDPH',
|
||||
'id': 'MDPH',
|
||||
'isActive': False,
|
||||
'label': 'Notification MDPH',
|
||||
'text': 'Notification MDPH',
|
||||
'typeDesc': 'NONE',
|
||||
},
|
||||
},
|
||||
'subscribeActivityList': [],
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue