toulouse-maelis: ajouter le département aux informations de naissances #209

Merged
nroche merged 8 commits from wip/76608-parsifal-birth-county into main 2023-04-17 17:28:51 +02:00
3 changed files with 65 additions and 0 deletions
Showing only changes of commit 10224eebbf - Show all commits

View File

@ -132,6 +132,10 @@ BIRTH_SCHEMA = {
'description': 'Commune de naissance (depuis référentiel)',
'oneOf': [{'type': 'string'}, {'type': 'null'}],
},
'cdDepartment': {
'description': 'Département naissance (depuis référentiel)',
'oneOf': [{'type': 'string'}, {'type': 'null'}],
},
'countryCode': {
'description': 'Pays de naissance (depuis référentiel)',
'oneOf': [{'type': 'string'}, {'type': 'null'}],

View File

@ -555,6 +555,18 @@ class ToulouseMaelis(BaseResource, HTTPResource):
'Vaccin', post_data, keys + ['vaccinList', i, 'code'], required=False
)
def check_and_adapt_birth_payload_in_referential(self, post_data, parent_keys=None):
keys = parent_keys or []
self.assert_post_data_in_referential(
'Town', post_data, keys + ['birth', 'communeCode'], required=False
)
self.assert_post_data_in_referential(
'County', post_data, keys + ['birth', 'cdDepartment'], required=False
)
self.assert_post_data_in_referential(
'Country', post_data, keys + ['birth', 'countryCode'], required=False
)
def check_and_adapt_child_pai_payoad_in_referential(self, post_data, parent_keys=None):
keys = parent_keys or []
self.assert_post_data_in_referential('PAI', post_data, keys + ['code'])
@ -588,6 +600,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
post_data, keys + ['medicalRecord']
)
self.check_and_adapt_update_indicator_payload_in_referential('ChildIndicator', post_data, keys)
self.check_and_adapt_birth_payload_in_referential(post_data, keys)
def check_and_adapt_person_payload_in_referential(self, post_data, parent_keys=None):
keys = parent_keys or []
@ -626,6 +639,7 @@ class ToulouseMaelis(BaseResource, HTTPResource):
self.assert_post_data_in_referential('Quality', post_data, keys + ['quality'])
self.check_and_adapt_update_coordinate_payload_in_referential(post_data, keys)
self.check_and_adapt_update_indicator_payload_in_referential('RLIndicator', post_data, keys)
self.check_and_adapt_birth_payload_in_referential(post_data, keys)
def check_and_adapt_create_rl1_payload_in_referential(self, post_data):
self.assert_post_data_in_referential('Category', post_data, ['category'])

View File

@ -2160,6 +2160,7 @@ def test_create_family(family_service, con, app):
'rl1/lastname': 'Doe',
'rl1/quality': 'AU',
'rl1/birth/communeCode': None,
'rl1/birth/cdDepartment': '91',
'rl1/birth/countryCode': '99350',
'rl1/birth/dateBirth': '1938-07-26',
'rl1/birth/place': 'Rabbat',
@ -2183,6 +2184,7 @@ def test_create_family(family_service, con, app):
'childList/0/birth/dateBirth': '1941-05-24',
'childList/0/birth/place': 'Saint-louis',
'childList/0/birth/communeCode': '91122',
'childList/0/birth/cdDepartment': '91',
'childList/0/birth/countryCode': '99100',
'childList/0/dietcode': 'RSV',
'childList/0/medicalRecord/vaccinList/0/code': 'DTC',
@ -2281,6 +2283,7 @@ def test_create_family_wrong_referential_key_error(con, app):
'rl1/lastname': 'Doe',
'rl1/quality': 'AU',
'rl1/birth/communeCode': None,
'rl1/birth/cdDepartment': '91',
'rl1/birth/countryCode': '99350',
'rl1/birth/dateBirth': '1938-07-26',
'rl1/birth/place': 'Rabbat',
@ -2297,6 +2300,7 @@ def test_create_family_wrong_referential_key_error(con, app):
'childList/0/birth/dateBirth': '1941-05-24',
'childList/0/birth/place': 'Saint-louis',
'childList/0/birth/communeCode': '91122',
'childList/0/birth/cdDepartment': '91',
'childList/0/birth/countryCode': '99100',
'childList/0/dietcode': 'RSV',
'childList/0/medicalRecord/vaccinList/0/code': 'plop',
@ -2319,6 +2323,15 @@ def test_create_family_wrong_referential_key_error(con, app):
== "rl1/profession/situation key value 'plop' do not belong to 'ProfessionalSituation' referential"
)
params['rl1/profession/situation'] = '01'
params['childList/0/birth/cdDepartment'] = 'plop'
resp = app.post_json(url + '?NameID=local', params=params)
assert resp.json['err'] == 1
assert (
resp.json['err_desc']
== "childList/0/birth/cdDepartment key value 'plop' do not belong to 'County' referential"
)
def test_update_family(family_service, con, app):
def request_check(request):
@ -2336,6 +2349,7 @@ def test_update_family(family_service, con, app):
'rl1/lastname': 'Doe',
'rl1/quality': 'AU',
'rl1/birth/communeCode': None,
'rl1/birth/cdDepartment': '91',
'rl1/birth/countryCode': '99350',
'rl1/birth/dateBirth': '1938-07-26',
'rl1/birth/place': 'Rabbat',
@ -2357,6 +2371,9 @@ def test_update_family(family_service, con, app):
'childList/0/sexe': 'M',
'childList/0/birth/dateBirth': '1941-05-24',
'childList/0/birth/place': 'Duluth',
'childList/0/birth/communeCode': '91122',
'childList/0/birth/cdDepartment': '91',
'childList/0/birth/countryCode': '99100',
'childList/0/dietcode': 'RSV',
'childList/0/paiInfoBean/code': 'PAIALI',
'childList/0/medicalRecord/vaccinList/0/code': 'DTC',
@ -2457,6 +2474,7 @@ def test_update_family_wrong_referential_key_error(con, app):
'rl1/lastname': 'Doe',
'rl1/quality': 'AU',
'rl1/birth/communeCode': None,
'rl1/birth/cdDepartment': '91',
'rl1/birth/countryCode': '99350',
'rl1/birth/dateBirth': '1938-07-26',
'rl1/birth/place': 'Rabbat',
@ -2478,6 +2496,9 @@ def test_update_family_wrong_referential_key_error(con, app):
'childList/0/sexe': 'M',
'childList/0/birth/dateBirth': '1941-05-24',
'childList/0/birth/place': 'Duluth',
'childList/0/birth/communeCode': '91122',
'childList/0/birth/cdDepartment': '91',
'childList/0/birth/countryCode': '99100',
'childList/0/dietcode': 'RSV',
'childList/0/paiInfoBean/code': 'PAIALI',
'childList/0/medicalRecord/vaccinList/0/code': 'plop',
@ -2501,6 +2522,15 @@ def test_update_family_wrong_referential_key_error(con, app):
== "rl1/profession/situation key value 'plop' do not belong to 'ProfessionalSituation' referential"
)
params['rl1/profession/situation'] = '01'
params['childList/0/birth/communeCode'] = 'plop'
resp = app.post_json(url + '?NameID=local', params=params)
assert resp.json['err'] == 1
assert (
resp.json['err_desc']
== "childList/0/birth/communeCode key value 'plop' do not belong to 'Town' referential"
)
def test_create_rl1(family_service, con, app):
family_service.add_soap_response('createFamily', get_xml_file('R_create_family.xml'))
@ -2592,6 +2622,15 @@ def test_create_rl1_wrong_referential_key_error(con, app):
== "rl1/adresse/numComp key value 'plop' do not belong to 'Complement' referential"
)
params['rl1/adresse/numComp'] = 'B'
params['rl1/birth/countryCode'] = 'plop'
resp = app.post_json(url + '?NameID=local', params=params)
assert resp.json['err'] == 1
assert (
resp.json['err_desc']
== "rl1/birth/countryCode key value 'plop' do not belong to 'Country' referential"
)
def test_create_rl1_maelis_error(family_service, con, app):
family_service.add_soap_response('createFamily', get_xml_file('R_create_family_error.xml'))
@ -2973,6 +3012,14 @@ def test_create_child_wrong_referential_key_error(con, app):
assert resp.json['err'] == 1
assert resp.json['err_desc'] == "sexe key value 'plop' do not belong to 'Sex' required referential"
params['sexe'] = 'F'
params['birth/cdDepartment'] = 'plop'
resp = app.post_json(url + '?NameID=local', params=params)
assert resp.json['err'] == 1
assert (
resp.json['err_desc'] == "birth/cdDepartment key value 'plop' do not belong to 'County' referential"
)
def test_create_child_connection_error(family_service, con, app):
family_service.add_soap_response('createChild', ConnectionError('No address associated with hostname'))