Skip to content

Commit

Permalink
✨ Handle missing next page parameters gracefully to support Firely Se…
Browse files Browse the repository at this point in the history
…rver, avoiding exceptions when pagination parameters are absent.
  • Loading branch information
Dogukan Cavdaroglu committed Nov 29, 2024
1 parent dd2bed8 commit efc25e8
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ case class OnFhirNetworkClient(serverBaseUrl: String, interceptors: Seq[IHttpReq
// 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! Next page params: $nextPageParams"))

//Set the new page
bundle.request match {
case srb: FhirSearchRequestBuilder => srb.page = Some(paginationParam._1, paginationParam._2.head)
case hrb: FhirHistoryRequestBuilder => hrb.page = Some(paginationParam._1, paginationParam._2.head)
}.orNull
// If a pagination parameter is found, update the request to set the new page value.
if(paginationParam != null){
//Set the new page
bundle.request match {
case srb: FhirSearchRequestBuilder => srb.page = Some(paginationParam._1, paginationParam._2.head)
case hrb: FhirHistoryRequestBuilder => hrb.page = Some(paginationParam._1, paginationParam._2.head)
}
}


Expand Down

0 comments on commit efc25e8

Please sign in to comment.