Skip to content

Commit

Permalink
Merge pull request #76 from srdc/searchafter-update
Browse files Browse the repository at this point in the history
🐛 fix searchafter problem in OnFhirNetworkClient
  • Loading branch information
sinaci authored Oct 8, 2024
2 parents c64a66b + c5724ed commit 4fc375c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ case class OnFhirNetworkClient(serverBaseUrl:String, interceptors:Seq[IHttpReque
nextPageParams.find {
case (pn, pv) =>
// Check if the parameter is either "_page" or "_skip"
(pn.contentEquals("_page") || pn.contentEquals("_skip")) &&
(pn.contentEquals("_page") || pn.contentEquals("_skip") || pn.contentEquals("_searchafter")) &&
// 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!"))
.getOrElse(throw FhirClientException(s"Problem in response no pagination param found in response! Next page params: $nextPageParams"))

//Set the new page
bundle.request match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scala.io.Source
import org.specs2.concurrent.ExecutionEnv
import org.specs2.runner.JUnitRunner

import scala.concurrent.duration.DurationInt
import scala.concurrent.duration.{DurationInt, FiniteDuration}
import scala.concurrent.{Await, Future}
import scala.language.postfixOps

Expand Down Expand Up @@ -249,8 +249,8 @@ class OnFhirLocalClientTest extends OnFhirTest {
.where("_sort", "-_lastUpdated")
.toIterator()

itr.next().map(b => FHIRUtil.extractValue[String](b.searchResults.head, "id")) must be_==("obshemoglobin").await
itr.next().map(b => FHIRUtil.extractValue[String](b.searchResults.head, "id")) must be_==("obsglucose").await
itr.next().map(b => FHIRUtil.extractValue[String](b.searchResults.head, "id")) must be_==("obshemoglobin").awaitFor(2 seconds)
itr.next().map(b => FHIRUtil.extractValue[String](b.searchResults.head, "id")) must be_==("obsglucose").awaitFor(2 seconds)
}

"should help searching resources - compartment search" in {
Expand Down

0 comments on commit 4fc375c

Please sign in to comment.