From 6910022ade95d4ea19a16e60f8eccc41b74fb6a2 Mon Sep 17 00:00:00 2001 From: dogukan10 Date: Wed, 4 Sep 2024 15:25:16 +0300 Subject: [PATCH] :bug: Handle the '_skip' pagination parameter in addition to '_page' parameter while executing the next page request --- .../scala/io/onfhir/client/OnFhirNetworkClient.scala | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/onfhir-client/src/main/scala/io/onfhir/client/OnFhirNetworkClient.scala b/onfhir-client/src/main/scala/io/onfhir/client/OnFhirNetworkClient.scala index 1e48e471..ac961422 100644 --- a/onfhir-client/src/main/scala/io/onfhir/client/OnFhirNetworkClient.scala +++ b/onfhir-client/src/main/scala/io/onfhir/client/OnFhirNetworkClient.scala @@ -82,10 +82,18 @@ case class OnFhirNetworkClient(serverBaseUrl:String, interceptors:Seq[IHttpReque override def next[T <: FHIRPaginatedBundle](bundle: T): Future[T] = { val nextPageParams = Uri.apply(bundle.getNext()).query().toMultiMap val previousPageParams = bundle.request.request.queryParams + // Identify the pagination parameter by comparing the "next" link's parameters with the previous request's parameters val paginationParam = nextPageParams.find { - case (pn, pv) => !previousPageParams.contains(pn) || previousPageParams(pn).toSet != pv.toSet - }.getOrElse(throw FhirClientException(s"Problem in response no pagination param found in response!")) + case (pn, pv) => + // Check if the parameter is either "_page" or "_skip" + (pn.contentEquals("_page") || pn.contentEquals("_skip")) && + // Ensure that either the parameter does not exist in the previous request, + // or it has a different value compared to the "next" link's parameter + (!previousPageParams.contains(pn) || previousPageParams(pn).toSet != pv.toSet) + } + // If no pagination parameter is found, throw an exception indicating a problem with the FHIR client response + .getOrElse(throw FhirClientException(s"Problem in response no pagination param found in response!")) //Set the new page bundle.request match {