1- from logging import INFO , basicConfig , getLogger
1+ from logging import getLogger
22from typing import Union
33
44from flask import request
1616 GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PATIENT ,
1717 GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PERFORMER ,
1818 GET_CONSENT_BY_ID__INVALID_ID_ERROR ,
19- GET_CONSENT_BY_ID__MISSING_ID_ERROR
19+ GET_CONSENT_BY_ID__MISSING_ID_ERROR ,
20+ BAD_REQUEST_INCLUDE_PARAM_INVALID ,
21+ INVALIDATED_RESOURCE
2022)
2123from .utils import (
2224 generate_response_from_example ,
2325 check_for_consent_include_params
2426)
2527
28+
2629def get_consent_by_id_response (identifier : str ) -> Union [dict , tuple ]:
2730 """Sandbox API for GET /Consent/{id}
2831
2932 Returns:
3033 Union[dict, tuple]: Response for GET /Consent/{id}
3134 """
3235 try :
33- _include = request .args .getlist ("_include" )
36+ params = request .args .to_dict ()
37+ if not "_include" in params and len (params ) > 0 :
38+ return generate_response_from_example (BAD_REQUEST_INCLUDE_PARAM_INVALID , 422 )
39+ else :
40+ _include = request .args .getlist ("_include" )
3441
3542 if identifier == "74eed847-ca25-4e76-8cf2-f2c2d7842a7a" :
3643 return check_for_consent_include_params (
@@ -48,6 +55,8 @@ def get_consent_by_id_response(identifier: str) -> Union[dict, tuple]:
4855 GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PATIENT ,
4956 GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PERFORMER
5057 )
58+ elif identifier == "a0922245-1072-40c3-8f4e-a7490c10d365" :
59+ return generate_response_from_example (INVALIDATED_RESOURCE , 404 )
5160 elif identifier == " " or identifier is None :
5261 return generate_response_from_example (GET_CONSENT_BY_ID__MISSING_ID_ERROR , 400 )
5362 else :
0 commit comments