@@ -224,7 +224,7 @@ def generate_response_from_example(example_path: str, status_code: int) -> Respo
224224
225225
226226def check_for_consent_include_params (
227- _include : str ,
227+ _include : list [ str ] ,
228228 include_none_response_yaml : str ,
229229 include_both_response_yaml : str ,
230230 include_patient_response_yaml : str = None ,
@@ -233,7 +233,7 @@ def check_for_consent_include_params(
233233 """Checks the GET consent request include params and provides the related response
234234
235235 Args:
236- _include (str): The include parameter supplied to the request
236+ _include (list[ str] ): The include parameters supplied to the request
237237 include_none_response_yaml (str): Bundle to return when include params are empty
238238 include_both_response_yaml (str): Bundle to return when include param is Consent:performer,Consent:patient
239239 include_patient_response_yaml (str): (optional) Bundle to return when include param is Consent:patient
@@ -243,56 +243,59 @@ def check_for_consent_include_params(
243243 response: Resultant Response object based on input.
244244 """
245245 if (
246- _include != CONSENT_PERFORMER
247- and _include != CONSENT_PATIENT
248- and _include != f"{ CONSENT_PATIENT } ,{ CONSENT_PERFORMER } "
249- and _include != f"{ CONSENT_PERFORMER } ,{ CONSENT_PATIENT } "
246+ CONSENT_PERFORMER not in _include
247+ and CONSENT_PATIENT not in _include
250248 and _include is not None
251249 ):
252250 return generate_response_from_example (BAD_REQUEST_INCLUDE_PARAM_INVALID , 400 )
253- elif _include == CONSENT_PERFORMER :
254- if include_performer_response_yaml :
255- return generate_response_from_example (include_performer_response_yaml , 200 )
256- else :
257- logger .error ("No consent performer example provided" )
258- return generate_response_from_example (INTERNAL_SERVER_ERROR_EXAMPLE , 500 )
259- elif _include == CONSENT_PATIENT :
260- if include_performer_response_yaml :
261- return generate_response_from_example (include_patient_response_yaml , 200 )
262- else :
263- logger .error ("No consent:patient example provided" )
264- return generate_response_from_example (INTERNAL_SERVER_ERROR_EXAMPLE , 500 )
251+ elif len (_include ) == 1 :
252+ if _include == CONSENT_PERFORMER :
253+ if include_performer_response_yaml :
254+ return generate_response_from_example (include_performer_response_yaml , 200 )
255+ else :
256+ logger .error ("No consent performer example provided" )
257+ return generate_response_from_example (INTERNAL_SERVER_ERROR_EXAMPLE , 500 )
258+ elif _include == CONSENT_PATIENT :
259+ if include_performer_response_yaml :
260+ return generate_response_from_example (include_patient_response_yaml , 200 )
261+ else :
262+ logger .error ("No consent:patient example provided" )
263+ return generate_response_from_example (INTERNAL_SERVER_ERROR_EXAMPLE , 500 )
265264 elif (
266- _include == f"{ CONSENT_PATIENT } ,{ CONSENT_PERFORMER } "
267- or _include == f"{ CONSENT_PERFORMER } ,{ CONSENT_PATIENT } "
265+ len (_include ) == 2
266+ and CONSENT_PATIENT in _include
267+ and CONSENT_PERFORMER in _include
268268 ):
269269 return generate_response_from_example (include_both_response_yaml , 200 )
270+ elif _include > 2 :
271+ return generate_response_from_example (BAD_REQUEST_INCLUDE_PARAM_INVALID , 400 )
270272 else :
271273 return generate_response_from_example (include_none_response_yaml , 200 )
272274
273275
274276def check_for_consent_filtering_params (
275- status : str ,
277+ status : list [ str ] ,
276278 status_active_response_yaml : str ,
277279 status_inactive_response_yaml : str ,
278280 status_proposed_and_active_response_yaml : str ,
279281) -> Response :
280282 """Checks the GET consent request status params and provides related response
281283
282284 Args:
283- status (str): The status parameter supplied to the request
285+ status (list[ str] ): The status parameters supplied to the request
284286 status_active_response_yaml (str): Bundle to return when status param is 'active'
285287 status_inactive_response_yaml (str): Bundle to return when status param is 'inactive'
286288 status_proposed_and_active_response_yaml (str): Bundle to return when status param is 'proposed,inactive'
287289
288290 Returns:
289291 response: Resultant Response object based on input.
290292 """
291- if status == "active" :
292- return generate_response_from_example (status_active_response_yaml , 200 )
293- elif status == "inactive" :
294- return generate_response_from_example (status_inactive_response_yaml , 200 )
295- elif status == "proposed,active" or status == "active,proposed" :
293+ if len (status ) == 1 :
294+ if status == "active" :
295+ return generate_response_from_example (status_active_response_yaml , 200 )
296+ elif status == "inactive" :
297+ return generate_response_from_example (status_inactive_response_yaml , 200 )
298+ elif status == ["active" ,"proposed" ] or status == ["proposed" ,"active" ]:
296299 return generate_response_from_example (
297300 status_proposed_and_active_response_yaml , 200
298301 )
0 commit comments