toulouse_maelis: add more referentials (#67782)

This commit is contained in:
Nicolas Roche 2022-07-26 17:03:57 +02:00
parent 54f2e4c4ef
commit 074d363400
7 changed files with 711 additions and 4 deletions

View File

@ -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',

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:readDietCodeListResponse xmlns:ns2="family.ws.maelis.sigec.com">
<itemList>
<code>BB</code>
<libelle>REPAS BEBE</libelle>
</itemList>
<itemList>
<code>MSP</code>
<libelle>REPAS MOYEN SANS PORC</libelle>
</itemList>
<itemList>
<code>MSV</code>
<libelle>REPAS MOYEN SANS VIANDE</libelle>
</itemList>
<itemList>
<code>MST</code>
<libelle>REPAS MOYEN STANDARD</libelle>
</itemList>
<itemList>
<code>STD</code>
<libelle>1- REPAS STANDARD</libelle>
</itemList>
<itemList>
<code>RSP</code>
<libelle>2- RÉGIME SANS PORC</libelle>
</itemList>
<itemList>
<code>RSV</code>
<libelle>3- RÉGIME SANS VIANDE</libelle>
</itemList>
<itemList>
<code>PAI</code>
<libelle>4- PROTOCOLE D'ACCUEIL INDIVIDUALISÉ</libelle>
</itemList>
</ns2:readDietCodeListResponse>
</soap:Body>
</soap:Envelope>

View File

@ -0,0 +1,376 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:readOrganListResponse xmlns:ns2="family.ws.maelis.sigec.com">
<organList>
<code>LEVENS</code>
<id>A10004460232</id>
</organList>
<organList>
<code>LA COLLE SUR LOUP</code>
<id>A10007752822</id>
</organList>
<organList>
<code>ASSIM</code>
<id>A10001133770</id>
</organList>
<organList>
<code>EZE</code>
<id>A10007751483</id>
</organList>
<organList>
<code>LUCERAM</code>
<id>A10008152785</id>
</organList>
<organList>
<code>SAINT ANDRE LE MANOIR</code>
<id>A10008170056</id>
</organList>
<organList>
<code>LA TRINITE ENFANTS PLACES</code>
<id>A10008425613</id>
</organList>
<organList>
<code>MONTJOYE</code>
<id>A10001496896</id>
</organList>
<organList>
<code>FOYER DE L'ENFANCE DES AM</code>
<id>A10001715627</id>
</organList>
<organList>
<code>LA TRINITE</code>
<id>A10007182676</id>
</organList>
<organList>
<code>PUGET SUR ARGENS</code>
<id>A10010030250</id>
</organList>
<organList>
<code>BEAUSOLEIL</code>
<id>A10001481849</id>
</organList>
<organList>
<code>SAINT JEAN CAP FERRAT</code>
<id>A10000980674</id>
</organList>
<organList>
<code>BERRE LES ALPES</code>
<id>A10000980692</id>
</organList>
<organList>
<code>VILLE DE NICE</code>
<id>A10001314895</id>
</organList>
<organList>
<code>PEP 06 - CORNICHE</code>
<id>A10001474792</id>
</organList>
<organList>
<code>PEP 06 MADELEINE</code>
<id>A10001474782</id>
</organList>
<organList>
<code>VALBONNE SOPHIA ANTIPOLIS</code>
<id>A10007182941</id>
</organList>
<organList>
<code>GATTIERES</code>
<id>A10007182961</id>
</organList>
<organList>
<code>FONDATION DE NICE</code>
<id>A10010601009</id>
<libelle>PATRONAGE ST PIERRE ACTES</libelle>
</organList>
<organList>
<code>CANNES</code>
<id>A10001427675</id>
</organList>
<organList>
<code>VILLEFRANCHE SUR MER</code>
<id>A10000802907</id>
</organList>
<organList>
<code>SAINT ANDRE DE LA ROCHE</code>
<id>A10000802910</id>
</organList>
<organList>
<code>SAINT LAURENT DU VAR</code>
<id>A10007751693</id>
</organList>
<organList>
<code>LA TOUR</code>
<id>A10007751913</id>
</organList>
<organList>
<code>IME CORNICHE FLEURIE</code>
<id>A10001039676</id>
</organList>
<organList>
<code>VENCE</code>
<id>A10001612084</id>
</organList>
<organList>
<code>ANTIBES</code>
<id>A10000980566</id>
</organList>
<organList>
<code>ASPREMONT</code>
<id>A10000980567</id>
</organList>
<organList>
<code>CAGNES SUR MER</code>
<id>A10000980568</id>
</organList>
<organList>
<code>CASTAGNIERS</code>
<id>A10000980569</id>
</organList>
<organList>
<code>CONTES</code>
<id>A10000980570</id>
</organList>
<organList>
<code>FALICON</code>
<id>A10000980571</id>
</organList>
<organList>
<code>GILETTE</code>
<id>A10000980572</id>
</organList>
<organList>
<code>TOUET DE L ESCARENE</code>
<id>A10000980573</id>
</organList>
<organList>
<code>CAP D AIL</code>
<id>A10001715572</id>
</organList>
<organList>
<code>MENTON</code>
<id>A10000980575</id>
</organList>
<organList>
<code>ROQUEBRUNE CAP MARTIN</code>
<id>A10000980577</id>
</organList>
<organList>
<code>VALLAURIS</code>
<id>A10000980584</id>
</organList>
<organList>
<code>TOURRETTE LEVENS</code>
<id>A10001715581</id>
</organList>
<organList>
<code>ASSOCIATION LOU MERILHOUN LEVENS</code>
<id>A10004071438</id>
</organList>
<organList>
<code>BEAULIEU SUR MER</code>
<id>A10007179260</id>
</organList>
<organList>
<code>APAJH</code>
<id>A10000980388</id>
</organList>
<organList>
<code>CARROS</code>
<id>A10007751440</id>
</organList>
<organList>
<code>BLAUSASC</code>
<id>A10007751441</id>
</organList>
<organList>
<code>ATIAM</code>
<id>A10000979354</id>
</organList>
<organList>
<code>UDAF</code>
<id>A10000979370</id>
</organList>
<organList>
<code>ALVA 06</code>
<id>A10000979372</id>
</organList>
<organList>
<code>IES CLEMENT ADER</code>
<id>A10000979373</id>
</organList>
<organList>
<code>ALC L OLIVIER</code>
<id>A10000979374</id>
</organList>
<organList>
<code>IESEDA LES CHANTERELLES</code>
<id>A10000979375</id>
</organList>
<organList>
<code>IME TERRASSES</code>
<id>A10000979376</id>
</organList>
<organList>
<code>SAINT PAUL DE VENCE</code>
<id>A10007751879</id>
</organList>
<organList>
<code>VILLENEUVE LOUBET</code>
<id>A10007753594</id>
</organList>
<organList>
<code>TOURETTES-SUR-LOUP</code>
<id>A10013129309</id>
</organList>
<organList>
<code>COLOMARS</code>
<id>A10013447888</id>
</organList>
<organList>
<code>BREIL SUR ROYA</code>
<id>A10015115495</id>
</organList>
<organList>
<code>GRASSE</code>
<id>A10015255908</id>
</organList>
<organList>
<code>SAINT BLAISE</code>
<id>A10016957436</id>
</organList>
<organList>
<code>BONSON</code>
<id>A10013128210</id>
</organList>
<organList>
<code>CANTARON</code>
<id>A10013128217</id>
</organList>
<organList>
<code>MANDELIEU</code>
<id>A10015126217</id>
</organList>
<organList>
<code>THEOULE SUR MER</code>
<id>A10015528233</id>
</organList>
<organList>
<code>ASCROS</code>
<id>A10016401771</id>
</organList>
<organList>
<code>CANNES LA BOCCA</code>
<id>A10016990309</id>
</organList>
<organList>
<code>LA GAUDE</code>
<id>A10012498607</id>
</organList>
<organList>
<code>DRAP</code>
<id>A10013123067</id>
</organList>
<organList>
<code>MALAUSSENE</code>
<id>A10014621894</id>
</organList>
<organList>
<code>ROQUEFORT LES PINS</code>
<id>A10014922597</id>
</organList>
<organList>
<code>L ESCARENE</code>
<id>A10014927854</id>
</organList>
<organList>
<code>MOUGINS</code>
<id>A10014938988</id>
</organList>
<organList>
<code>SOSPEL</code>
<id>A10013129048</id>
</organList>
<organList>
<code>LE CANNET</code>
<id>A10013459160</id>
</organList>
<organList>
<code>SAINT MARTIN DU VAR</code>
<id>A10015677583</id>
</organList>
<organList>
<code>BIOT</code>
<id>A10017265908</id>
</organList>
<organList>
<code>PEILLON</code>
<id>A10000980576</id>
</organList>
<organList>
<code>LES ARCS</code>
<id>A10024933344</id>
</organList>
<organList>
<code>LA TURBIE</code>
<id>A10024933368</id>
</organList>
<organList>
<code>SAINT JULIEN</code>
<id>A10024933442</id>
</organList>
<organList>
<code>SAINT JEANNET</code>
<id>A10021971554</id>
</organList>
<organList>
<code>PEILLE</code>
<id>A10019717953</id>
</organList>
<organList>
<code>REGIME GENERAL</code>
<id>g</id>
</organList>
<organList>
<code>REGIMES AUTRES</code>
<id>a</id>
</organList>
<organList>
<code>REGIME MSA</code>
<id>a11003995450</id>
</organList>
<organList>
<code>REGIME SNCF</code>
<id>a11013011612</id>
</organList>
<organList>
<code>REGIME GENERAL MONACO</code>
<id>a11017891473</id>
</organList>
<organList>
<code>REGIME EDF/GDF - TITULAIRE</code>
<id>a11015961838</id>
</organList>
<organList>
<code>REGIME MONACO</code>
<id>a11015961839</id>
</organList>
<organList>
<code>TRIBUNAL DE GRANDE INSTANCE DE NICE</code>
<id>a11025419517</id>
</organList>
<organList>
<code>LA ROQUETTE SUR VAR</code>
<id>A10026769374</id>
</organList>
<organList>
<code>BAR-SUR-LOUP</code>
<id>A10027856948</id>
</organList>
<organList>
<code>TOUET SUR VAR</code>
<id>A10029519260</id>
</organList>
</ns2:readOrganListResponse>
</soap:Body>
</soap:Envelope>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:readPAIListResponse xmlns:ns2="family.ws.maelis.sigec.com">
<itemList>
<code>PAIALI</code>
<libelle>ALIMENTAIRE</libelle>
</itemList>
<itemList>
<code>PAIO</code>
<libelle>AUTRE</libelle>
</itemList>
<itemList>
<code>PAIMED</code>
<libelle>MEDICAL</libelle>
</itemList>
<itemList>
<code>PAI2</code>
<libelle>MEDICAL ET ALIMENTAIRE</libelle>
</itemList>
</ns2:readPAIListResponse>
</soap:Body>
</soap:Envelope>

View File

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:readQuotientListResponse xmlns:ns2="family.ws.maelis.sigec.com">
<itemList>
<code>QF</code>
<libelle>GRILLE DE QUOTIENT</libelle>
</itemList>
<itemList>
<code>QCLSH</code>
<libelle>QUOTIENT CENTRE AERE</libelle>
</itemList>
<itemList>
<code>QJEU</code>
<libelle>QUOTIENT JEUNESSE</libelle>
</itemList>
<itemList>
<code>QS</code>
<libelle>QUOTIENT SCOLAIRE</libelle>
</itemList>
<itemList>
<code>QSPORT</code>
<libelle>QUOTIENT SPORT</libelle>
</itemList>
<itemList>
<code>MOY ECO</code>
<libelle>REVENU MOYEN ( MENSUEL OU ANNUEL)</libelle>
</itemList>
</ns2:readQuotientListResponse>
</soap:Body>
</soap:Envelope>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:readVaccinListResponse xmlns:ns2="family.ws.maelis.sigec.com">
<itemList>
<code>BCG</code>
<libelle>BCG</libelle>
</itemList>
<itemList>
<code>CIB</code>
<libelle>CONTRE-INDICATION TEMPORAIRE AU BCG</libelle>
</itemList>
<itemList>
<code>MONO</code>
<libelle>CONTROLE DU BCG (+)</libelle>
</itemList>
<itemList>
<code>MONON</code>
<libelle>CONTROLE DU BCG (-)</libelle>
</itemList>
<itemList>
<code>DTC</code>
<libelle>DIPHTERIE TETANOS COQUELUCHE</libelle>
</itemList>
<itemList>
<code>DTCP</code>
<libelle>DIPHTERIE-TETANOS-COQUELUCHE-POLIO</libelle>
</itemList>
<itemList>
<code>DTP</code>
<libelle>DIPHTERIE-TETANOS-POLIO</libelle>
</itemList>
<itemList>
<code>HEP</code>
<libelle>HEPATITE</libelle>
</itemList>
<itemList>
<code>HEPA B</code>
<libelle>HEPATITE B</libelle>
</itemList>
<itemList>
<code>IN</code>
<libelle>INFANRIX</libelle>
</itemList>
<itemList>
<code>HIB</code>
<libelle>MENINGITE</libelle>
</itemList>
<itemList>
<code>PENT</code>
<libelle>PENTACOQ</libelle>
</itemList>
<itemList>
<code>PENTH</code>
<libelle>PENT'HIBEST</libelle>
</itemList>
<itemList>
<code>P</code>
<libelle>POLIO</libelle>
</itemList>
<itemList>
<code>ROR</code>
<libelle>ROUGEOLE-OREILLONS-RUBEOLE</libelle>
</itemList>
<itemList>
<code>ROUX</code>
<libelle>ROUVAX</libelle>
</itemList>
<itemList>
<code>TETANOS</code>
<libelle>TETANOS</libelle>
</itemList>
<itemList>
<code>TPOLIO</code>
<libelle>TETANOS POLIO</libelle>
</itemList>
<itemList>
<code>TETR</code>
<libelle>TETRACOQ</libelle>
</itemList>
<itemList>
<code>T.POLIO</code>
<libelle>T.POLIO</libelle>
</itemList>
</ns2:readVaccinListResponse>
</soap:Body>
</soap:Envelope>

View File

@ -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):