diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py index dbe3158a..1ecddb06 100644 --- a/passerelle/contrib/toulouse_maelis/models.py +++ b/passerelle/contrib/toulouse_maelis/models.py @@ -180,19 +180,6 @@ class ToulouseMaelis(BaseResource, HTTPResource): self.add_text_value('PAI', data, ['paiInfoBean', 'code']) for person in data['authorizedPersonList']: self.add_text_value_to_child_person(person) - - # convert O/N string into boolean - if data.get('fsl'): - for key in ( - 'allergieAlimentaire', - 'allergieRespiratoire', - 'allergieAutre', - 'allergieMedicament', - 'asthme', - 'flPAI', - 'flImage', - ): - data['fsl'][key] = bool(data['fsl'][key] == 'O') return data def add_text_value_to_person(self, data): @@ -1096,39 +1083,6 @@ 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'} - @endpoint( display_category='Famille', description="Créer ou mettre à jour les données médicales d'un enfant", diff --git a/passerelle/contrib/toulouse_maelis/schemas.py b/passerelle/contrib/toulouse_maelis/schemas.py index 026c49b9..a75332e2 100644 --- a/passerelle/contrib/toulouse_maelis/schemas.py +++ b/passerelle/contrib/toulouse_maelis/schemas.py @@ -246,103 +246,6 @@ CHILDBIRTH_SCHEMA = { }, } -FSL_SCHEMA = { - '$schema': 'http://json-schema.org/draft-04/schema#', - 'title': 'FSL', - 'description': 'Informations sur la fiche sanitaire', - 'type': 'object', - 'properties': { - 'dateDeb': { - 'description': 'Date de début', - 'type': 'string', - 'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$', - }, - 'dateFin': { - 'description': 'Date de fin', - 'type': 'string', - 'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$', - }, - 'allergieAlimentaire': { - 'description': 'Allergie alimentaire', - 'oneOf': BOOLEAN_TYPES + [{'type': 'null'}], - }, - 'allergieRespiratoire': { - 'description': 'Allergie respiratoire', - 'oneOf': BOOLEAN_TYPES + [{'type': 'null'}], - }, - 'allergieAutre': { - 'description': 'Allergie autre', - 'oneOf': BOOLEAN_TYPES + [{'type': 'null'}], - }, - 'allergieMedicament': { - 'description': 'Allergie médicament', - 'oneOf': BOOLEAN_TYPES + [{'type': 'null'}], - }, - 'asthme': { - 'description': 'Asthmatique', - 'oneOf': BOOLEAN_TYPES + [{'type': 'null'}], - }, - 'flPAI': { - 'description': 'PAI', - 'oneOf': BOOLEAN_TYPES + [{'type': 'null'}], - }, - 'flImage': { - 'description': 'Autorisation photo', - 'oneOf': BOOLEAN_TYPES + [{'type': 'null'}], - }, - 'dtcPrap1': { - 'description': 'Date du dernier rappel DT Polio', - 'type': 'string', - 'pattern': '^([0-9]{4}-[0-9]{2}-[0-9]{2}){0,1}$', - }, - 'obsMed1': { - 'description': 'Observation médecin 1', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'obsMed2': { - 'description': 'Observation médecin 2', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'obsMed3': { - 'description': 'Observation médecin 3', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'obsDir1': { - 'description': 'Observation directeur 1', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'obsDir2': { - 'description': 'Observation directeur 2', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'obsDir3': { - 'description': 'Observation directeur 3', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'obsAssist1': { - 'description': 'Observation assistant sanitaire 1', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'obsAssist2': { - 'description': 'Observation assistant sanitaire 2', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'obsAssist3': { - 'description': 'Observation assistant sanitaire 3', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'cons1Med': { - 'description': 'Conseil médecin 1', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - 'cons2Med': { - 'description': 'Conseil médecin 2', - 'oneOf': [{'type': 'string'}, {'type': 'null'}], - }, - }, - 'additionalProperties': False, -} - DOCTORADDRESS_SCHEMA = { '$schema': 'http://json-schema.org/draft-04/schema#', 'title': 'Doctor address', @@ -489,7 +392,6 @@ CHILD_SCHEMA = { 'description': 'Autorisation à partir seul', 'oneOf': BOOLEAN_TYPES, }, - 'fsl': {'oneOf': [FSL_SCHEMA, {'type': 'null'}]}, 'medicalRecord': {'oneOf': [MEDICALRECORD_SCHEMA, {'type': 'null'}]}, 'paiInfoBean': {'oneOf': [PAIINFO_SCHEMA, {'type': 'null'}]}, }, @@ -633,7 +535,6 @@ UPDATE_FAMILY_SCHEMA = { CREATE_FAMILY_SCHEMA = copy.deepcopy(UPDATE_FAMILY_SCHEMA) CREATE_FAMILY_SCHEMA['required'] = ['rl1', 'categorie', 'situation'] create_family_child_schema = CREATE_FAMILY_SCHEMA['properties']['childList']['oneOf'][0]['items'] -del create_family_child_schema['properties']['fsl'] del create_family_child_schema['properties']['bPhoto'] del create_family_child_schema['properties']['bLeaveAlone'] del create_family_child_schema['properties']['paiInfoBean'] @@ -665,7 +566,6 @@ UPDATE_RL2_SCHEMA = copy.deepcopy(UPDATE_RL1_SCHEMA) CREATE_CHILD_SCHEMA = copy.deepcopy(CHILD_SCHEMA) CREATE_CHILD_SCHEMA['unflatten'] = True del CREATE_CHILD_SCHEMA['properties']['dietcode'] -del CREATE_CHILD_SCHEMA['properties']['fsl'] del CREATE_CHILD_SCHEMA['properties']['medicalRecord'] del CREATE_CHILD_SCHEMA['properties']['paiInfoBean'] diff --git a/tests/data/toulouse_maelis/FamilyService.wsdl b/tests/data/toulouse_maelis/FamilyService.wsdl index aa2a2d84..e44374b8 100644 --- a/tests/data/toulouse_maelis/FamilyService.wsdl +++ b/tests/data/toulouse_maelis/FamilyService.wsdl @@ -802,7 +802,6 @@ - @@ -2724,4 +2723,4 @@ Cette méthode permet de mettre à jour les informations relatives au PAI pour u - \ No newline at end of file + diff --git a/tests/data/toulouse_maelis/Q_update_child_fsl.xml b/tests/data/toulouse_maelis/Q_update_child_fsl.xml deleted file mode 100644 index f47fa565..00000000 --- a/tests/data/toulouse_maelis/Q_update_child_fsl.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - maelis-webservice - maelis-password - - - - - - 613878 - - 2022-01-01 - 2022-12-31 - O - O - O - O - N - N - N - 2022-02-22 - some obsMed1 text - some obsMed2 text - some obsMed3 text - some obsDir1 text - some obsDir2 text - some obsDir3 text - some obsAssist1 text - some obsAssist2 text - some obsAssist3 text - some cons1Med text - some cons2Med text - - - - diff --git a/tests/data/toulouse_maelis/R_read_family.xml b/tests/data/toulouse_maelis/R_read_family.xml index fa5a3a7f..20a6dd00 100644 --- a/tests/data/toulouse_maelis/R_read_family.xml +++ b/tests/data/toulouse_maelis/R_read_family.xml @@ -97,29 +97,6 @@ 1943-01-19T00:00:00+01:00 RSV - - 2022-01-01T00:00:00+01:00 - 2022-12-31T00:00:00+01:00 - O - O - O - O - N - N - N - 2022-02-22T00:00:00+01:00 - some obsMed1 text - some obsMed2 text - some obsMed3 text - some obsDir1 text - some obsDir2 text - some obsDir3 text - some obsAssist1 text - some obsAssist2 text - some obsAssist3 text - some cons1Med text - some cons2Med text - true false diff --git a/tests/data/toulouse_maelis/R_read_family_relax.xml b/tests/data/toulouse_maelis/R_read_family_relax.xml index 3cd75eb8..1ace41f1 100644 --- a/tests/data/toulouse_maelis/R_read_family_relax.xml +++ b/tests/data/toulouse_maelis/R_read_family_relax.xml @@ -96,29 +96,6 @@ 1943-01-19T00:00:00+01:00 RSV - - 2022-01-01T00:00:00+01:00 - 2022-12-31T00:00:00+01:00 - O - O - O - O - N - N - N - 2022-02-22T00:00:00+01:00 - some obsMed1 text - some obsMed2 text - some obsMed3 text - some obsDir1 text - some obsDir2 text - some obsDir3 text - some obsAssist1 text - some obsAssist2 text - some obsAssist3 text - some cons1Med text - some cons2Med text - true false diff --git a/tests/data/toulouse_maelis/R_read_family_reordered.xml b/tests/data/toulouse_maelis/R_read_family_reordered.xml index d6a4b5db..f1eb3bb3 100644 --- a/tests/data/toulouse_maelis/R_read_family_reordered.xml +++ b/tests/data/toulouse_maelis/R_read_family_reordered.xml @@ -97,29 +97,6 @@ 1943-01-19T00:00:00+01:00 RSV - - 2022-01-01T00:00:00+01:00 - 2022-12-31T00:00:00+01:00 - O - O - O - O - N - N - N - 2022-02-22T00:00:00+01:00 - some obsMed1 text - some obsMed2 text - some obsMed3 text - some obsDir1 text - some obsDir2 text - some obsDir3 text - some obsAssist1 text - some obsAssist2 text - some obsAssist3 text - some cons1Med text - some cons2Med text - true false diff --git a/tests/data/toulouse_maelis/R_update_child_fsl.xml b/tests/data/toulouse_maelis/R_update_child_fsl.xml deleted file mode 100644 index d263173c..00000000 --- a/tests/data/toulouse_maelis/R_update_child_fsl.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py index dcbdd2fb..f0dd39f3 100644 --- a/tests/test_toulouse_maelis.py +++ b/tests/test_toulouse_maelis.py @@ -71,9 +71,7 @@ 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) -UPDATE_MEDICAL = FakedResponse(content=get_xml_file('R_update_child_fsl.xml'), status_code=200) +UPDATE_MEDICAL = FakedResponse(content=get_xml_file('R_update_child_medical_record.xml'), status_code=200) UPDATE_MEDICAL_500 = FakedResponse( content=get_xml_file('R_update_child_medical_record_soap_error.xml'), status_code=500 ) @@ -614,7 +612,6 @@ def test_read_family(mocked_post, mocked_get, read_family, con, app): 'subscribeActivityList': [], } data = resp.json['data']['childList'][0] - del data['fsl'] del data['medicalRecord'] del data['authorizedPersonList'] del data['paiInfoBean'] @@ -651,29 +648,6 @@ def test_read_family(mocked_post, mocked_get, read_family, con, app): 'dateFin': '2022-12-31T00:00:00+01:00', 'description': 'bla bla PAI', } - assert resp.json['data']['childList'][0]['fsl'] == { - 'dateDeb': '2022-01-01T00:00:00+01:00', - 'dateFin': '2022-12-31T00:00:00+01:00', - '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', - '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', - } assert resp.json['data']['childList'][0]['medicalRecord'] == { "familyDoctor": { "name": "DRE", @@ -2656,75 +2630,6 @@ def test_update_child_pai_soap_error(mocked_post, mocked_get, con, app): 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'] - - @mock.patch('passerelle.utils.Request.get') @mock.patch('passerelle.utils.Request.post') def test_update_child_medical_record(mocked_post, mocked_get, con, app):