wip/72523-maelis-correct-indicators (#72523) #10
|
@ -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'])
|
||||
|
||||
|
@ -246,7 +256,6 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.add_text_value('Civility', data, ['personInfo', 'civility'])
|
||||
self.add_text_value('Quality', data, ['personQuality', 'code'])
|
||||
self.add_text_value('Sex', data, ['personInfo', 'sexe'])
|
||||
return data
|
||||
|
||||
def add_text_value_to_child(self, data):
|
||||
self.add_text_value('Sex', data, ['sexe'])
|
||||
|
@ -256,11 +265,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'])
|
||||
return data
|
||||
self.add_indicators_field('ChildIndicator', data)
|
||||
|
||||
def add_text_value_to_person(self, data):
|
||||
self.add_text_value('Civility', data, ['civility'])
|
||||
|
@ -278,10 +283,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'])
|
||||
|
@ -293,7 +295,6 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.add_text_value_to_child(child)
|
||||
for person in data['emergencyPersonList']:
|
||||
self.add_text_value_to_person(person)
|
||||
return data
|
||||
|
||||
def get_child_person(self, family_id, child_id, person_id):
|
||||
data = self.get_child_person_raw(family_id, child_id, person_id)
|
||||
|
@ -371,6 +372,8 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
data = post_data
|
||||
for key in keys:
|
||||
data = data[key]
|
||||
if 'isAuthHospital' in data:
|
||||
data['isAuthHospital'] = self.encode_bool(data['isAuthHospital'])
|
||||
|
||||
for i in range(0, len(data.get('vaccinList', []))):
|
||||
self.assert_post_data_in_referential(
|
||||
|
@ -396,6 +399,9 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
data = post_data
|
||||
for key in keys:
|
||||
data = data[key]
|
||||
for key in 'bPhoto', 'bLeaveAlone':
|
||||
if key in data:
|
||||
data[key] = self.encode_bool(data[key])
|
||||
|
||||
if 'dietcode' in data:
|
||||
self.assert_post_data_in_referential('DietCode', post_data, keys + ['dietcode'], required=False)
|
||||
|
@ -425,6 +431,15 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
)
|
||||
self.assert_post_data_in_referential('Organ', post_data, keys + ['CAFInfo', 'organ'], required=False)
|
||||
|
||||
data = post_data
|
||||
for key in keys:
|
||||
data = data[key]
|
||||
if 'contact' in data:
|
||||
data = data['contact']
|
||||
for key in 'isContactMail', 'isContactSms', 'isInvoicePdf':
|
||||
if key in data:
|
||||
data[key] = self.encode_bool(data[key])
|
||||
|
||||
def assert_rl_payload_in_referential(self, post_data, parent_keys=None):
|
||||
keys = parent_keys or []
|
||||
self.assert_post_data_in_referential('Civility', post_data, keys + ['civility'])
|
||||
|
@ -450,6 +465,8 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
)
|
||||
for i in range(0, len(post_data.get('childList') or [])):
|
||||
self.assert_child_payload_in_referential(post_data, ['childList', i])
|
||||
if 'flagCom' in post_data:
|
||||
post_data['flagCom'] = self.encode_bool(post_data['flagCom'])
|
||||
|
||||
def replace_null_values(self, dico):
|
||||
'''send null fields as empty SOAP tag to tell maelis to empty the value'''
|
||||
|
|
|
@ -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': [],
|
||||
}
|
||||
|
||||
|
@ -1262,6 +1336,7 @@ def test_create_family(family_service, con, app):
|
|||
params = {
|
||||
'category': 'ACCEUI',
|
||||
'situation': 'C',
|
||||
'flagCom': False,
|
||||
'rl1/civility': 'M.',
|
||||
'rl1/firstname': 'Jhon',
|
||||
'rl1/lastname': 'Doe',
|
||||
|
@ -1275,6 +1350,7 @@ def test_create_family(family_service, con, app):
|
|||
'rl1/adresse/town': 'Paris',
|
||||
'rl1/adresse/zipcode': '75014',
|
||||
'rl1/adresse/numComp': 'B',
|
||||
'rl1/contact/isContactMail': True,
|
||||
'rl1/profession/codeCSP': 'ART',
|
||||
'rl1/CAFInfo/organ': 'A10007752822',
|
||||
'emergencyPersonList/0/civility': 'MME',
|
||||
|
@ -2156,6 +2232,7 @@ def test_update_coordinate(family_service, con, app):
|
|||
'adresse/street2': None,
|
||||
'adresse/town': 'Paris',
|
||||
'adresse/zipcode': '75014',
|
||||
'contact/isContactMail': True,
|
||||
'profession/codeCSP': 'ART',
|
||||
'profession/profession': 'informaticien',
|
||||
'profession/employerName': 'EO',
|
||||
|
|
Loading…
Reference in New Issue