toulouse_maelis: add FSL webservice (#69045)
This commit is contained in:
parent
c8097f4b2d
commit
5b08c35515
|
@ -158,6 +158,20 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
for person in data[kind + 'PersonList']:
|
||||
add_text_value('Civility', person, ['civility'])
|
||||
add_text_value('Quality', person, ['quality'])
|
||||
|
||||
# convert O/N string into boolean
|
||||
for child in data['childList']:
|
||||
if child.get('fsl'):
|
||||
for key in (
|
||||
'allergieAlimentaire',
|
||||
'allergieRespiratoire',
|
||||
'allergieAutre',
|
||||
'allergieMedicament',
|
||||
'asthme',
|
||||
'flPAI',
|
||||
'flImage',
|
||||
):
|
||||
child['fsl'][key] = bool(child['fsl'][key] == 'O')
|
||||
return data
|
||||
|
||||
def replace_null_values(self, dico):
|
||||
|
@ -781,6 +795,39 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.call('Family', 'updateChildPAI', personNumber=child_id, **post_data)
|
||||
return {'data': 'ok'}
|
||||
|
||||
@endpoint(
|
||||
display_category='Famille',
|
||||
description="Créer ou mettre à jour la fiche sanitaire d'un enfant",
|
||||
name='update-child-fsl',
|
||||
perm='can_access',
|
||||
parameters={
|
||||
'NameID': {'description': 'Publik NameID'},
|
||||
'child_id': {'description': "Numéro de l'enfant"},
|
||||
},
|
||||
post={'request_body': {'schema': {'application/json': schemas.FSL_SCHEMA}}},
|
||||
)
|
||||
def update_child_fsl(self, request, NameID, child_id, post_data):
|
||||
self.get_link(NameID)
|
||||
|
||||
# maelis expect strings O/N
|
||||
for key in (
|
||||
'allergieAlimentaire',
|
||||
'allergieRespiratoire',
|
||||
'allergieAutre',
|
||||
'allergieMedicament',
|
||||
'asthme',
|
||||
'flPAI',
|
||||
'flImage',
|
||||
):
|
||||
post_data[key] = 'O' if post_data.get(key) else 'N'
|
||||
|
||||
# use None to empty optional date passed as an empty string by date filter
|
||||
if post_data.get('dtcPrap1') == '':
|
||||
post_data['dtcPrap1'] = None
|
||||
|
||||
self.call('Family', 'createOrUpdateFSL', arg0=child_id, arg1=post_data)
|
||||
return {'data': 'ok'}
|
||||
|
||||
|
||||
class Link(models.Model):
|
||||
resource = models.ForeignKey(ToulouseMaelis, on_delete=models.CASCADE)
|
||||
|
|
|
@ -286,36 +286,36 @@ FSL_SCHEMA = {
|
|||
},
|
||||
'allergieAlimentaire': {
|
||||
'description': 'Allergie alimentaire',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
'oneOf': [{'type': 'null'}] + BOOLEAN_TYPES,
|
||||
},
|
||||
'allergieRespiratoire': {
|
||||
'description': 'Allergie respiratoire',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
'oneOf': [{'type': 'null'}] + BOOLEAN_TYPES,
|
||||
},
|
||||
'allergieAutre': {
|
||||
'description': 'Allergie autre',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
'oneOf': [{'type': 'null'}] + BOOLEAN_TYPES,
|
||||
},
|
||||
'allergieMedicament': {
|
||||
'description': 'Allergie médicament',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
'oneOf': [{'type': 'null'}] + BOOLEAN_TYPES,
|
||||
},
|
||||
'asthme': {
|
||||
'description': 'Asthmatique',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
'oneOf': [{'type': 'null'}] + BOOLEAN_TYPES,
|
||||
},
|
||||
'flPAI': {
|
||||
'description': 'PAI',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
'oneOf': [{'type': 'null'}] + BOOLEAN_TYPES,
|
||||
},
|
||||
'flImage': {
|
||||
'description': 'Autorisation photo',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
'oneOf': [{'type': 'null'}] + BOOLEAN_TYPES,
|
||||
},
|
||||
'dtcPrap1': {
|
||||
'description': 'Date du dernier rappel DT Polio',
|
||||
'type': 'string',
|
||||
'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$',
|
||||
'pattern': '^([0-9]{4}-[0-9]{2}-[0-9]{2}){0,1}$',
|
||||
},
|
||||
'obsMed1': {
|
||||
'description': 'Observation médecin 1',
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<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:createOrUpdateFSL xmlns:ns0="family.ws.maelis.sigec.com">
|
||||
<arg0>613878</arg0>
|
||||
<arg1>
|
||||
<dateDeb>2022-01-01</dateDeb>
|
||||
<dateFin>2022-12-31</dateFin>
|
||||
<allergieAlimentaire>O</allergieAlimentaire>
|
||||
<allergieRespiratoire>O</allergieRespiratoire>
|
||||
<allergieAutre>O</allergieAutre>
|
||||
<allergieMedicament>O</allergieMedicament>
|
||||
<asthme>N</asthme>
|
||||
<flPAI>N</flPAI>
|
||||
<flImage>N</flImage>
|
||||
<dtcPrap1>2022-02-22</dtcPrap1>
|
||||
<obsMed1>some obsMed1 text</obsMed1>
|
||||
<obsMed2>some obsMed2 text</obsMed2>
|
||||
<obsMed3>some obsMed3 text</obsMed3>
|
||||
<obsDir1>some obsDir1 text</obsDir1>
|
||||
<obsDir2>some obsDir2 text</obsDir2>
|
||||
<obsDir3>some obsDir3 text</obsDir3>
|
||||
<obsAssist1>some obsAssist1 text</obsAssist1>
|
||||
<obsAssist2>some obsAssist2 text</obsAssist2>
|
||||
<obsAssist3>some obsAssist3 text</obsAssist3>
|
||||
<cons1Med>some cons1Med text</cons1Med>
|
||||
<cons2Med>some cons2Med text</cons2Med>
|
||||
</arg1>
|
||||
</ns0:createOrUpdateFSL>
|
||||
</soap-env:Body>
|
||||
</soap-env:Envelope>
|
|
@ -0,0 +1,5 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:createOrUpdateFSLResponse xmlns:ns2="family.ws.maelis.sigec.com"/>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -0,0 +1,15 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<soap:Fault>
|
||||
<faultcode>soap:Server</faultcode>
|
||||
<faultstring>Une erreur est survenue : java.sql.SQLException: ORA-12899: valeur trop grande pour la colonne "MAELIS"."H_FICHESAN"."FS_OBSMED1" (réelle : 71, maximum : 70)
|
||||
</faultstring>
|
||||
<detail>
|
||||
<ns1:MaelisFamilyException xmlns:ns1="family.ws.maelis.sigec.com">
|
||||
<message xmlns:ns2="family.ws.maelis.sigec.com">Une erreur est survenue : java.sql.SQLException: ORA-12899: valeur trop grande pour la colonne "MAELIS"."H_FICHESAN"."FS_OBSMED1" (réelle : 71, maximum : 70)
|
||||
</message>
|
||||
</ns1:MaelisFamilyException>
|
||||
</detail>
|
||||
</soap:Fault>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -70,6 +70,8 @@ UPDATE_FAMILY_500 = FakedResponse(content=get_xml_file('R_update_family_soap_err
|
|||
UPDATE_DIETCODE = FakedResponse(content=get_xml_file('R_update_child_dietcode.xml'), status_code=200)
|
||||
UPDATE_PAI = FakedResponse(content=get_xml_file('R_update_child_pai.xml'), status_code=200)
|
||||
UPDATE_PAI_500 = FakedResponse(content=get_xml_file('R_update_child_pai_soap_error.xml'), status_code=500)
|
||||
UPDATE_FSL = FakedResponse(content=get_xml_file('R_update_child_fsl.xml'), status_code=200)
|
||||
UPDATE_FSL_500 = FakedResponse(content=get_xml_file('R_update_child_fsl_soap_error.xml'), status_code=500)
|
||||
|
||||
|
||||
def assert_sent_payload(mocked_post, query_file):
|
||||
|
@ -618,13 +620,13 @@ def test_read_family(mocked_post, mocked_get, con, app):
|
|||
assert resp.json['data']['childList'][0]['fsl'] == {
|
||||
'dateDeb': '2022-01-01T00:00:00+01:00',
|
||||
'dateFin': '2022-12-31T00:00:00+01:00',
|
||||
'allergieAlimentaire': 'O',
|
||||
'allergieRespiratoire': 'O',
|
||||
'allergieAutre': 'O',
|
||||
'allergieMedicament': 'O',
|
||||
'asthme': 'N',
|
||||
'flPAI': 'N',
|
||||
'flImage': 'N',
|
||||
'allergieAlimentaire': True,
|
||||
'allergieRespiratoire': True,
|
||||
'allergieAutre': True,
|
||||
'allergieMedicament': True,
|
||||
'asthme': False,
|
||||
'flPAI': False,
|
||||
'flImage': False,
|
||||
'dtcPrap1': '2022-02-22T00:00:00+01:00',
|
||||
'obsMed1': 'some obsMed1 text',
|
||||
'obsMed2': 'some obsMed2 text',
|
||||
|
@ -1908,3 +1910,72 @@ def test_update_child_pai_soap_error(mocked_post, mocked_get, con, app):
|
|||
assert 'Une erreur est survenue' in resp.json['err_desc']
|
||||
assert 'valeur trop grande' in resp.json['err_desc']
|
||||
assert 'maximum : 500' in resp.json['err_desc']
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_update_child_fsl(mocked_post, mocked_get, con, app):
|
||||
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
||||
mocked_post.return_value = UPDATE_FSL
|
||||
url = get_endpoint('update-child-fsl')
|
||||
params = {
|
||||
'dateDeb': '2022-01-01',
|
||||
'dateFin': '2022-12-31',
|
||||
'allergieAlimentaire': True,
|
||||
'allergieRespiratoire': True,
|
||||
'allergieAutre': True,
|
||||
'allergieMedicament': True,
|
||||
'asthme': False,
|
||||
'flPAI': False,
|
||||
'flImage': False,
|
||||
'dtcPrap1': '2022-02-22',
|
||||
'obsMed1': 'some obsMed1 text',
|
||||
'obsMed2': 'some obsMed2 text',
|
||||
'obsMed3': 'some obsMed3 text',
|
||||
'obsDir1': 'some obsDir1 text',
|
||||
'obsDir2': 'some obsDir2 text',
|
||||
'obsDir3': 'some obsDir3 text',
|
||||
'obsAssist1': 'some obsAssist1 text',
|
||||
'obsAssist2': 'some obsAssist2 text',
|
||||
'obsAssist3': 'some obsAssist3 text',
|
||||
'cons1Med': 'some cons1Med text',
|
||||
'cons2Med': 'some cons2Med text',
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
|
||||
assert_sent_payload(mocked_post, 'Q_update_child_fsl.xml')
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data'] == 'ok'
|
||||
|
||||
|
||||
def test_update_child_fsl_not_linked_error(con, app):
|
||||
url = get_endpoint('update-child-fsl')
|
||||
params = {
|
||||
'dateDeb': '2022-01-01',
|
||||
'dateFin': '2022-12-31',
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
|
||||
assert resp.json['err'] == 'not-linked'
|
||||
assert resp.json['err_desc'] == 'User not linked to family'
|
||||
|
||||
|
||||
@mock.patch('passerelle.utils.Request.get')
|
||||
@mock.patch('passerelle.utils.Request.post')
|
||||
def test_update_child_fsl_soap_error(mocked_post, mocked_get, con, app):
|
||||
mocked_get.return_value = FAMILY_SERVICE_WSDL
|
||||
mocked_post.return_value = UPDATE_FSL_500
|
||||
url = get_endpoint('update-child-fsl')
|
||||
params = {
|
||||
'dateDeb': '2022-01-01',
|
||||
'dateFin': '2022-12-31',
|
||||
'obsMed1': 'a' * 71,
|
||||
}
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
|
||||
assert resp.json['err'] == 'Family-createOrUpdateFSL-soap:Server'
|
||||
assert 'Une erreur est survenue' in resp.json['err_desc']
|
||||
assert 'valeur trop grande' in resp.json['err_desc']
|
||||
assert 'maximum : 70' in resp.json['err_desc']
|
||||
|
|
Loading…
Reference in New Issue