toulouse-maelis: add endpoint to declare a vaccination (#76445) #190
|
@ -1955,6 +1955,28 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
self.call('Family', 'updateChildMedicalRecord', updateChildMedicalRecordRequest=payload)
|
||||
return {'data': 'ok'}
|
||||
|
||||
@endpoint(
|
||||
display_category='Famille',
|
||||
description="Ajouter une vaccination à un enfant",
|
||||
name='update-child-add-vaccination',
|
||||
perm='can_access',
|
||||
parameters={
|
||||
'child_id': {'description': "Numéro de l'enfant"},
|
||||
'NameID': {'description': 'Publik NameID'},
|
||||
'family_id': {'description': 'Numéro de DUI'},
|
||||
},
|
||||
post={'request_body': {'schema': {'application/json': family_schemas.VACCIN_SCHEMA}}},
|
||||
)
|
||||
def update_child_add_vaccination(self, request, post_data, child_id, NameID=None, family_id=None):
|
||||
assert family_id or self.get_link(NameID)
|
||||
|
||||
payload = {
|
||||
'numPerson': child_id,
|
||||
'vaccinList': [{'code': post_data['code'], 'vaccinationDate': post_data['vaccinationDate']}],
|
||||
}
|
||||
self.call('Family', 'addChildVaccinList', **payload)
|
||||
return {'data': 'ok'}
|
||||
|
||||
@endpoint(
|
||||
display_category='Famille',
|
||||
description="Mettre à jour des indicateurs d'un enfant",
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:addChildVaccinListResponse xmlns:ns2="family.ws.maelis.sigec.com"/>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -0,0 +1,8 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<soap:Fault>
|
||||
<faultcode>soap:Server</faultcode>
|
||||
<faultstring>Exemple</faultstring>
|
||||
</soap:Fault>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
|
@ -4042,6 +4042,51 @@ def test_update_rl_indicator_wrong_referential_key_error(con, app):
|
|||
)
|
||||
|
||||
|
||||
def test_update_child_add_vaccination(family_service, con, app):
|
||||
def request_check(request):
|
||||
assert request['numPerson'] == 613880
|
||||
assert request['vaccinList'][0]['code'] == '105'
|
||||
assert request['vaccinList'][0]['vaccinationDate'] == datetime.datetime(2023, 4, 9)
|
||||
|
||||
family_service.add_soap_response(
|
||||
'addChildVaccinList',
|
||||
get_xml_file('R_add_child_vaccin_list.xml'),
|
||||
request_check=request_check,
|
||||
)
|
||||
url = get_endpoint('update-child-add-vaccination')
|
||||
params = {
|
||||
'code': '105',
|
||||
'vaccinationDate': '2023-04-09',
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?family_id=1312&child_id=613880', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == 'User not linked to family'
|
||||
|
||||
Link.objects.create(resource=con, family_id='1312', name_id='local')
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params)
|
||||
assert resp.json['err'] == 0
|
||||
|
||||
|
||||
def test_update_child_add_vaccination_soap_error(family_service, con, app):
|
||||
family_service.add_soap_response(
|
||||
'addChildVaccinList',
|
||||
get_xml_file('R_add_child_vaccin_list_soap_error.xml'),
|
||||
)
|
||||
url = get_endpoint('update-child-add-vaccination')
|
||||
params = {
|
||||
'code': '105',
|
||||
'vaccinationDate': '2023-04-09',
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?family_id=1312&child_id=613880', params=params)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['data']['soap_fault']['message'] == 'Exemple'
|
||||
|
||||
|
||||
def test_update_child_indicator(family_service, con, app):
|
||||
def request_check(request):
|
||||
assert [(x['code'], x['isActive']) for x in request.indicatorList] == [
|
||||
|
|
Loading…
Reference in New Issue