1616 CONSENT_PATIENT ,
1717 INTERNAL_SERVER_ERROR_EXAMPLE ,
1818 CONSENT__STATUS_PARAM_INVALID ,
19- BAD_REQUEST_INCLUDE_PARAM_INVALID
19+ BAD_REQUEST_INCLUDE_PARAM_INVALID ,
2020)
2121
2222FHIR_MIMETYPE = "application/fhir+json"
@@ -28,7 +28,7 @@ def load_json_file(file_name: str) -> dict:
2828 return load (file )
2929
3030
31- def check_for_errors (request : Request , identifier_key : str ) -> Optional [tuple ]:
31+ def check_for_errors (request : Request , identifier_key : str ) -> Optional [tuple ]:
3232 """Check for shared in the request headers and arguments
3333
3434 Args:
@@ -45,31 +45,22 @@ def check_for_errors(request: Request, identifier_key : str) -> Optional[tuple]:
4545 print (f"Identifier_without_system = { identifier_without_system } " )
4646
4747 if not identifier :
48- return (
49- generate_response_from_example (
50- "./api/examples/errors/missing-identifier.yaml"
51- ,
52- 400 )
48+ return generate_response_from_example (
49+ "./api/examples/errors/missing-identifier.yaml" , 400
5350 )
5451 elif identifier and len (identifier_without_system ) != 10 :
5552 # invalid identifier
56- return (
57- generate_response_from_example (
58- "./api/examples/errors/invalid-identifier.yaml"
59- ,
60- 400 )
53+ return generate_response_from_example (
54+ "./api/examples/errors/invalid-identifier.yaml" , 400
6155 )
6256 elif (
6357 isinstance (identifier , str )
6458 and "|" in identifier
6559 and "https://fhir.nhs.uk/Id/nhs-number" != identifier .split ("|" , maxsplit = 2 )[0 ]
6660 ):
6761 # invalid identifier system
68- return (
69- generate_response_from_example (
70- "./api/examples/errors/invalid-identifier-system.yaml"
71- ,
72- 400 )
62+ return generate_response_from_example (
63+ "./api/examples/errors/invalid-identifier-system.yaml" , 400
7364 )
7465
7566
@@ -194,12 +185,12 @@ def generate_response_from_example(example_path: str, status_code: int) -> Respo
194185
195186
196187def check_for_consent_include_params (
197- _include : str ,
188+ _include : str ,
198189 logger : logging .Logger ,
199190 include_none_response_yaml : str ,
200- include_both_response_yaml : str ,
191+ include_both_response_yaml : str ,
201192 include_patient_response_yaml : str = None ,
202- include_performer_response_yaml : str = None
193+ include_performer_response_yaml : str = None ,
203194) -> Response :
204195 """Checks the GET consent request include params and provides the related response
205196
@@ -222,29 +213,32 @@ def check_for_consent_include_params(
222213 and _include != None
223214 ):
224215 return generate_response_from_example (BAD_REQUEST_INCLUDE_PARAM_INVALID , 400 )
225- elif ( _include == CONSENT_PERFORMER ) :
216+ elif _include == CONSENT_PERFORMER :
226217 if include_performer_response_yaml :
227218 return generate_response_from_example (include_performer_response_yaml , 200 )
228219 else :
229220 logger .error ("No consent performer example provided" )
230221 return generate_response_from_example (INTERNAL_SERVER_ERROR_EXAMPLE , 500 )
231- elif ( _include == CONSENT_PATIENT ) :
222+ elif _include == CONSENT_PATIENT :
232223 if include_performer_response_yaml :
233224 return generate_response_from_example (include_patient_response_yaml , 200 )
234225 else :
235226 logger .error ("No consent:patient example provided" )
236227 return generate_response_from_example (INTERNAL_SERVER_ERROR_EXAMPLE , 500 )
237- elif (_include == f"{ CONSENT_PATIENT } ,{ CONSENT_PERFORMER } " or _include == f"{ CONSENT_PERFORMER } ,{ CONSENT_PATIENT } " ):
228+ elif (
229+ _include == f"{ CONSENT_PATIENT } ,{ CONSENT_PERFORMER } "
230+ or _include == f"{ CONSENT_PERFORMER } ,{ CONSENT_PATIENT } "
231+ ):
238232 return generate_response_from_example (include_both_response_yaml , 200 )
239233 else :
240234 return generate_response_from_example (include_none_response_yaml , 200 )
241235
242236
243237def check_for_consent_filtering_params (
244- status : str ,
245- status_active_response_yaml : str ,
246- status_inactive_response_yaml : str ,
247- status_proposed_and_inactive_response_yaml : str
238+ status : str ,
239+ status_active_response_yaml : str ,
240+ status_inactive_response_yaml : str ,
241+ status_proposed_and_inactive_response_yaml : str ,
248242) -> Response :
249243 """Checks the GET consent request status params and provides related response
250244
@@ -257,11 +251,13 @@ def check_for_consent_filtering_params(
257251 Returns:
258252 response: Resultant Response object based on input.
259253 """
260- if ( status == "active" ) :
254+ if status == "active" :
261255 return generate_response_from_example (status_active_response_yaml , 200 )
262- elif ( status == "inactive" ) :
256+ elif status == "inactive" :
263257 return generate_response_from_example (status_inactive_response_yaml , 200 )
264- elif (status == "proposed,inactive" or status == "inactive,proposed" ):
265- return generate_response_from_example (status_proposed_and_inactive_response_yaml , 200 )
258+ elif status == "proposed,inactive" or status == "inactive,proposed" :
259+ return generate_response_from_example (
260+ status_proposed_and_inactive_response_yaml , 200
261+ )
266262 else :
267263 return generate_response_from_example (CONSENT__STATUS_PARAM_INVALID , 400 )
0 commit comments