diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py
index edbe4e16..32eb31a7 100644
--- a/passerelle/contrib/toulouse_maelis/models.py
+++ b/passerelle/contrib/toulouse_maelis/models.py
@@ -89,10 +89,16 @@ class ToulouseMaelis(BaseResource, HTTPResource):
data = cache.get(cache_key)
if data is None:
response = self.call('Family', 'read' + referential_name + 'List')
- data = {
- 'list': [{'id': x.code, 'text': x.libelle} for x in response],
- 'dict': {x.code: x.libelle for x in response},
- }
+ if referential_name == 'Organ':
+ data = {
+ 'list': [{'id': x.id, 'text': x.code} for x in response],
+ 'dict': {x.id: x.code for x in response},
+ }
+ else:
+ data = {
+ 'list': [{'id': x.code, 'text': x.libelle} for x in response],
+ 'dict': {x.code: x.libelle for x in response},
+ }
# put in cache for two hours
cache.set(cache_key, data, 3600 * 2)
return data
@@ -205,6 +211,33 @@ class ToulouseMaelis(BaseResource, HTTPResource):
uniq_text.add(item['text'])
return {'data': uniq_data}
+ @endpoint(
+ display_category='Famille',
+ description='Liste des régimes alimentaires',
+ name='read-dietcode-list',
+ perm='can_access',
+ )
+ def read_dietcode_list(self, request):
+ return {'data': self.get_referential('DietCode')['list']}
+
+ @endpoint(
+ display_category='Famille',
+ description='Liste des organismes (CAF)',
+ name='read-organ-list',
+ perm='can_access',
+ )
+ def read_organ_list(self, request):
+ return {'data': self.get_referential('Organ')['list']}
+
+ @endpoint(
+ display_category='Famille',
+ description="Liste des projet d'accueil individualisés",
+ name='read-pai-list',
+ perm='can_access',
+ )
+ def read_pai_list(self, request):
+ return {'data': self.get_referential('PAI')['list']}
+
@endpoint(
display_category='Famille',
description='liste des qualités du référenciel',
@@ -214,6 +247,15 @@ class ToulouseMaelis(BaseResource, HTTPResource):
def read_quality_list(self, request):
return {'data': self.get_referential('Quality')['list']}
+ @endpoint(
+ display_category='Famille',
+ description='Liste des quotients',
+ name='read-quotient-list',
+ perm='can_access',
+ )
+ def read_quotient_list(self, request):
+ return {'data': self.get_referential('Quotient')['list']}
+
@endpoint(
display_category='Famille',
description='Liste des sexes',
@@ -232,6 +274,15 @@ class ToulouseMaelis(BaseResource, HTTPResource):
def read_situation_list(self, request):
return {'data': self.get_referential('Situation')['list']}
+ @endpoint(
+ display_category='Famille',
+ description='Liste des vaccins',
+ name='read-vaccin-list',
+ perm='can_access',
+ )
+ def read_vaccin_list(self, request):
+ return {'data': self.get_referential('Vaccin')['list']}
+
@endpoint(
display_category='Famille',
description='Lier un compte usager à une famille',
diff --git a/tests/data/toulouse_maelis/R_read_dietcode_list.xml b/tests/data/toulouse_maelis/R_read_dietcode_list.xml
new file mode 100644
index 00000000..be6a01da
--- /dev/null
+++ b/tests/data/toulouse_maelis/R_read_dietcode_list.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+ BB
+ REPAS BEBE
+
+
+ MSP
+ REPAS MOYEN SANS PORC
+
+
+ MSV
+ REPAS MOYEN SANS VIANDE
+
+
+ MST
+ REPAS MOYEN STANDARD
+
+
+ STD
+ 1- REPAS STANDARD
+
+
+ RSP
+ 2- RÉGIME SANS PORC
+
+
+ RSV
+ 3- RÉGIME SANS VIANDE
+
+
+ PAI
+ 4- PROTOCOLE D'ACCUEIL INDIVIDUALISÉ
+
+
+
+
diff --git a/tests/data/toulouse_maelis/R_read_organ_list.xml b/tests/data/toulouse_maelis/R_read_organ_list.xml
new file mode 100644
index 00000000..c4bcfa43
--- /dev/null
+++ b/tests/data/toulouse_maelis/R_read_organ_list.xml
@@ -0,0 +1,376 @@
+
+
+
+
+
+ LEVENS
+ A10004460232
+
+
+ LA COLLE SUR LOUP
+ A10007752822
+
+
+ ASSIM
+ A10001133770
+
+
+ EZE
+ A10007751483
+
+
+ LUCERAM
+ A10008152785
+
+
+ SAINT ANDRE LE MANOIR
+ A10008170056
+
+
+ LA TRINITE ENFANTS PLACES
+ A10008425613
+
+
+ MONTJOYE
+ A10001496896
+
+
+ FOYER DE L'ENFANCE DES AM
+ A10001715627
+
+
+ LA TRINITE
+ A10007182676
+
+
+ PUGET SUR ARGENS
+ A10010030250
+
+
+ BEAUSOLEIL
+ A10001481849
+
+
+ SAINT JEAN CAP FERRAT
+ A10000980674
+
+
+ BERRE LES ALPES
+ A10000980692
+
+
+ VILLE DE NICE
+ A10001314895
+
+
+ PEP 06 - CORNICHE
+ A10001474792
+
+
+ PEP 06 MADELEINE
+ A10001474782
+
+
+ VALBONNE SOPHIA ANTIPOLIS
+ A10007182941
+
+
+ GATTIERES
+ A10007182961
+
+
+ FONDATION DE NICE
+ A10010601009
+ PATRONAGE ST PIERRE ACTES
+
+
+ CANNES
+ A10001427675
+
+
+ VILLEFRANCHE SUR MER
+ A10000802907
+
+
+ SAINT ANDRE DE LA ROCHE
+ A10000802910
+
+
+ SAINT LAURENT DU VAR
+ A10007751693
+
+
+ LA TOUR
+ A10007751913
+
+
+ IME CORNICHE FLEURIE
+ A10001039676
+
+
+ VENCE
+ A10001612084
+
+
+ ANTIBES
+ A10000980566
+
+
+ ASPREMONT
+ A10000980567
+
+
+ CAGNES SUR MER
+ A10000980568
+
+
+ CASTAGNIERS
+ A10000980569
+
+
+ CONTES
+ A10000980570
+
+
+ FALICON
+ A10000980571
+
+
+ GILETTE
+ A10000980572
+
+
+ TOUET DE L ESCARENE
+ A10000980573
+
+
+ CAP D AIL
+ A10001715572
+
+
+ MENTON
+ A10000980575
+
+
+ ROQUEBRUNE CAP MARTIN
+ A10000980577
+
+
+ VALLAURIS
+ A10000980584
+
+
+ TOURRETTE LEVENS
+ A10001715581
+
+
+ ASSOCIATION LOU MERILHOUN LEVENS
+ A10004071438
+
+
+ BEAULIEU SUR MER
+ A10007179260
+
+
+ APAJH
+ A10000980388
+
+
+ CARROS
+ A10007751440
+
+
+ BLAUSASC
+ A10007751441
+
+
+ ATIAM
+ A10000979354
+
+
+ UDAF
+ A10000979370
+
+
+ ALVA 06
+ A10000979372
+
+
+ IES CLEMENT ADER
+ A10000979373
+
+
+ ALC L OLIVIER
+ A10000979374
+
+
+ IESEDA LES CHANTERELLES
+ A10000979375
+
+
+ IME TERRASSES
+ A10000979376
+
+
+ SAINT PAUL DE VENCE
+ A10007751879
+
+
+ VILLENEUVE LOUBET
+ A10007753594
+
+
+ TOURETTES-SUR-LOUP
+ A10013129309
+
+
+ COLOMARS
+ A10013447888
+
+
+ BREIL SUR ROYA
+ A10015115495
+
+
+ GRASSE
+ A10015255908
+
+
+ SAINT BLAISE
+ A10016957436
+
+
+ BONSON
+ A10013128210
+
+
+ CANTARON
+ A10013128217
+
+
+ MANDELIEU
+ A10015126217
+
+
+ THEOULE SUR MER
+ A10015528233
+
+
+ ASCROS
+ A10016401771
+
+
+ CANNES LA BOCCA
+ A10016990309
+
+
+ LA GAUDE
+ A10012498607
+
+
+ DRAP
+ A10013123067
+
+
+ MALAUSSENE
+ A10014621894
+
+
+ ROQUEFORT LES PINS
+ A10014922597
+
+
+ L ESCARENE
+ A10014927854
+
+
+ MOUGINS
+ A10014938988
+
+
+ SOSPEL
+ A10013129048
+
+
+ LE CANNET
+ A10013459160
+
+
+ SAINT MARTIN DU VAR
+ A10015677583
+
+
+ BIOT
+ A10017265908
+
+
+ PEILLON
+ A10000980576
+
+
+ LES ARCS
+ A10024933344
+
+
+ LA TURBIE
+ A10024933368
+
+
+ SAINT JULIEN
+ A10024933442
+
+
+ SAINT JEANNET
+ A10021971554
+
+
+ PEILLE
+ A10019717953
+
+
+ REGIME GENERAL
+ g
+
+
+ REGIMES AUTRES
+ a
+
+
+ REGIME MSA
+ a11003995450
+
+
+ REGIME SNCF
+ a11013011612
+
+
+ REGIME GENERAL MONACO
+ a11017891473
+
+
+ REGIME EDF/GDF - TITULAIRE
+ a11015961838
+
+
+ REGIME MONACO
+ a11015961839
+
+
+ TRIBUNAL DE GRANDE INSTANCE DE NICE
+ a11025419517
+
+
+ LA ROQUETTE SUR VAR
+ A10026769374
+
+
+ BAR-SUR-LOUP
+ A10027856948
+
+
+ TOUET SUR VAR
+ A10029519260
+
+
+
+
diff --git a/tests/data/toulouse_maelis/R_read_pai_list.xml b/tests/data/toulouse_maelis/R_read_pai_list.xml
new file mode 100644
index 00000000..5b176347
--- /dev/null
+++ b/tests/data/toulouse_maelis/R_read_pai_list.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ PAIALI
+ ALIMENTAIRE
+
+
+ PAIO
+ AUTRE
+
+
+ PAIMED
+ MEDICAL
+
+
+ PAI2
+ MEDICAL ET ALIMENTAIRE
+
+
+
+
diff --git a/tests/data/toulouse_maelis/R_read_quotient_list.xml b/tests/data/toulouse_maelis/R_read_quotient_list.xml
new file mode 100644
index 00000000..3f800e92
--- /dev/null
+++ b/tests/data/toulouse_maelis/R_read_quotient_list.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+ QF
+ GRILLE DE QUOTIENT
+
+
+ QCLSH
+ QUOTIENT CENTRE AERE
+
+
+ QJEU
+ QUOTIENT JEUNESSE
+
+
+ QS
+ QUOTIENT SCOLAIRE
+
+
+ QSPORT
+ QUOTIENT SPORT
+
+
+ MOY ECO
+ REVENU MOYEN ( MENSUEL OU ANNUEL)
+
+
+
+
diff --git a/tests/data/toulouse_maelis/R_read_vaccin_list.xml b/tests/data/toulouse_maelis/R_read_vaccin_list.xml
new file mode 100644
index 00000000..fa91b49a
--- /dev/null
+++ b/tests/data/toulouse_maelis/R_read_vaccin_list.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+ BCG
+ BCG
+
+
+ CIB
+ CONTRE-INDICATION TEMPORAIRE AU BCG
+
+
+ MONO
+ CONTROLE DU BCG (+)
+
+
+ MONON
+ CONTROLE DU BCG (-)
+
+
+ DTC
+ DIPHTERIE TETANOS COQUELUCHE
+
+
+ DTCP
+ DIPHTERIE-TETANOS-COQUELUCHE-POLIO
+
+
+ DTP
+ DIPHTERIE-TETANOS-POLIO
+
+
+ HEP
+ HEPATITE
+
+
+ HEPA B
+ HEPATITE B
+
+
+ IN
+ INFANRIX
+
+
+ HIB
+ MENINGITE
+
+
+ PENT
+ PENTACOQ
+
+
+ PENTH
+ PENT'HIBEST
+
+
+ P
+ POLIO
+
+
+ ROR
+ ROUGEOLE-OREILLONS-RUBEOLE
+
+
+ ROUX
+ ROUVAX
+
+
+ TETANOS
+ TETANOS
+
+
+ TPOLIO
+ TETANOS POLIO
+
+
+ TETR
+ TETRACOQ
+
+
+ T.POLIO
+ T.POLIO
+
+
+
+
diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py
index 45386403..c7afee71 100644
--- a/tests/test_toulouse_maelis.py
+++ b/tests/test_toulouse_maelis.py
@@ -45,8 +45,13 @@ READ_FAMILY = FakedResponse(content=get_xml_file('R_read_family.xml'), status_co
READ_CATEGORIES = FakedResponse(content=get_xml_file('R_read_category_list.xml'), status_code=200)
READ_CIVILITIES = FakedResponse(content=get_xml_file('R_read_civility_list.xml'), status_code=200)
READ_CSP = FakedResponse(content=get_xml_file('R_read_csp_list.xml'), status_code=200)
+READ_DIETCODE = FakedResponse(content=get_xml_file('R_read_dietcode_list.xml'), status_code=200)
+READ_ORGAN = FakedResponse(content=get_xml_file('R_read_organ_list.xml'), status_code=200)
+READ_PAI = FakedResponse(content=get_xml_file('R_read_pai_list.xml'), status_code=200)
READ_QUALITIES = FakedResponse(content=get_xml_file('R_read_quality_list.xml'), status_code=200)
+READ_QUOTIENT = FakedResponse(content=get_xml_file('R_read_quotient_list.xml'), status_code=200)
READ_SITUATIONS = FakedResponse(content=get_xml_file('R_read_situation_list.xml'), status_code=200)
+READ_VACCIN = FakedResponse(content=get_xml_file('R_read_vaccin_list.xml'), status_code=200)
IS_RL_EXISTS_TRUE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'true', status_code=200)
IS_RL_EXISTS_FALSE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'false', status_code=200)
IS_CHILD_EXISTS_TRUE = FakedResponse(content=get_xml_file('R_is_child_exists.xml') % b'true', status_code=200)
@@ -331,6 +336,63 @@ def test_read_csp_list(mocked_post, mocked_get, con, app):
]
+@mock.patch('passerelle.utils.Request.get')
+@mock.patch('passerelle.utils.Request.post')
+def test_read_dietcode_list(mocked_post, mocked_get, con, app):
+ mocked_get.return_value = FAMILY_SERVICE_WSDL
+ mocked_post.return_value = READ_DIETCODE
+ url = get_endpoint('read-dietcode-list')
+
+ resp = app.get(url)
+ assert resp.json['err'] == 0
+ assert resp.json['data'] == [
+ {'id': 'BB', 'text': 'REPAS BEBE'},
+ {'id': 'MSP', 'text': 'REPAS MOYEN SANS PORC'},
+ {'id': 'MSV', 'text': 'REPAS MOYEN SANS VIANDE'},
+ {'id': 'MST', 'text': 'REPAS MOYEN STANDARD'},
+ {'id': 'STD', 'text': '1- REPAS STANDARD'},
+ {'id': 'RSP', 'text': '2- RÉGIME SANS PORC'},
+ {'id': 'RSV', 'text': '3- RÉGIME SANS VIANDE'},
+ {'id': 'PAI', 'text': "4- PROTOCOLE D'ACCUEIL INDIVIDUALISÉ"},
+ ]
+
+
+@mock.patch('passerelle.utils.Request.get')
+@mock.patch('passerelle.utils.Request.post')
+def test_read_organ_list(mocked_post, mocked_get, con, app):
+ mocked_get.return_value = FAMILY_SERVICE_WSDL
+ mocked_post.return_value = READ_ORGAN
+ url = get_endpoint('read-organ-list')
+
+ resp = app.get(url)
+ assert resp.json['err'] == 0
+ assert len(resp.json['data']) == 92
+ assert resp.json['data'][:5] == [
+ {'id': 'A10004460232', 'text': 'LEVENS'},
+ {'id': 'A10007752822', 'text': 'LA COLLE SUR LOUP'},
+ {'id': 'A10001133770', 'text': 'ASSIM'},
+ {'id': 'A10007751483', 'text': 'EZE'},
+ {'id': 'A10008152785', 'text': 'LUCERAM'},
+ ]
+
+
+@mock.patch('passerelle.utils.Request.get')
+@mock.patch('passerelle.utils.Request.post')
+def test_read_pai_list(mocked_post, mocked_get, con, app):
+ mocked_get.return_value = FAMILY_SERVICE_WSDL
+ mocked_post.return_value = READ_PAI
+ url = get_endpoint('read-pai-list')
+
+ resp = app.get(url)
+ assert resp.json['err'] == 0
+ assert resp.json['data'] == [
+ {'id': 'PAIALI', 'text': 'ALIMENTAIRE'},
+ {'id': 'PAIO', 'text': 'AUTRE'},
+ {'id': 'PAIMED', 'text': 'MEDICAL'},
+ {'id': 'PAI2', 'text': 'MEDICAL ET ALIMENTAIRE'},
+ ]
+
+
@mock.patch('passerelle.utils.Request.get')
@mock.patch('passerelle.utils.Request.post')
def test_read_quality_list(mocked_post, mocked_get, con, app):
@@ -361,6 +423,25 @@ def test_read_quality_list(mocked_post, mocked_get, con, app):
]
+@mock.patch('passerelle.utils.Request.get')
+@mock.patch('passerelle.utils.Request.post')
+def test_read_quotient_list(mocked_post, mocked_get, con, app):
+ mocked_get.return_value = FAMILY_SERVICE_WSDL
+ mocked_post.return_value = READ_QUOTIENT
+ url = get_endpoint('read-quotient-list')
+
+ resp = app.get(url)
+ assert resp.json['err'] == 0
+ assert resp.json['data'] == [
+ {'id': 'QF', 'text': 'GRILLE DE QUOTIENT'},
+ {'id': 'QCLSH', 'text': 'QUOTIENT CENTRE AERE'},
+ {'id': 'QJEU', 'text': 'QUOTIENT JEUNESSE'},
+ {'id': 'QS', 'text': 'QUOTIENT SCOLAIRE'},
+ {'id': 'QSPORT', 'text': 'QUOTIENT SPORT'},
+ {'id': 'MOY ECO', 'text': 'REVENU MOYEN ( MENSUEL OU ANNUEL)'},
+ ]
+
+
def test_read_sex_list(con, app):
url = get_endpoint('read-sex-list')
@@ -394,6 +475,25 @@ def test_read_situation_list(mocked_post, mocked_get, con, app):
]
+@mock.patch('passerelle.utils.Request.get')
+@mock.patch('passerelle.utils.Request.post')
+def test_read_vaccin_list(mocked_post, mocked_get, con, app):
+ mocked_get.return_value = FAMILY_SERVICE_WSDL
+ mocked_post.return_value = READ_VACCIN
+ url = get_endpoint('read-vaccin-list')
+
+ resp = app.get(url)
+ assert resp.json['err'] == 0
+ assert len(resp.json['data']) == 20
+ assert resp.json['data'][:5] == [
+ {'id': 'BCG', 'text': 'BCG'},
+ {'id': 'CIB', 'text': 'CONTRE-INDICATION TEMPORAIRE AU BCG'},
+ {'id': 'MONO', 'text': 'CONTROLE DU BCG (+)'},
+ {'id': 'MONON', 'text': 'CONTROLE DU BCG (-)'},
+ {'id': 'DTC', 'text': 'DIPHTERIE TETANOS COQUELUCHE'},
+ ]
+
+
@mock.patch('passerelle.utils.Request.get')
@mock.patch('passerelle.utils.Request.post')
def test_read_family(mocked_post, mocked_get, con, app):