Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Port Number in Fhir Requests #13

Open
yuekselba opened this issue Jan 18, 2023 · 2 comments
Open

Duplicate Port Number in Fhir Requests #13

yuekselba opened this issue Jan 18, 2023 · 2 comments

Comments

@yuekselba
Copy link

Hello again :),

I'm facing the problem, that FHIRExtinguisher tries to fetch linked resources by a non valid URL. The port extension :443 gets duplicated.
FHIRExtinguisher tries to request from the URL https://our.fhir.server:443:443/fhir?_getpages=12345...
After some digging in the sources, I found that the nextUrl returned by bundleWrapper.link.find { it.relation == "next" }?.url already is broken.
For a quick fix, I wrote the following patch:

--- a/src/main/kotlin/fhirextinguisher/FhirExtinguisher.kt
+++ b/src/main/kotlin/fhirextinguisher/FhirExtinguisher.kt
@@ -189,7 +189,11 @@ class FhirExtinguisher(
             log.info { "Loading Bundle from $nextUrl" }
             val bundle = fhirClient.fetchResourceFromUrl(bundleClass, nextUrl)
             val bundleWrapper = BundleWrapper(bundleDefintion, bundle)
+
             nextUrl = bundleWrapper.link.find { it.relation == "next" }?.url
+            if (nextUrl != null) {
+                nextUrl = nextUrl.replace(":443:443", ":443")
+            }
             cacheBundleReference(bundleWrapper, columns)
             for (bundleEntry in bundleWrapper.entry) {
                 subtables += processBundleEntry(columns, bundleEntry)

Do you know what goes wrong here? Thank you for your support!

@JohannesOehm
Copy link
Owner

Usually, the FHIR server provides the link to the next page in the Bundle.link.where(relation="next") element. For me it looks like a broken link is already returned by your FHIR server. Usually, a FHIR server itself doesn't know its domain, so the domain has to be provided in the server configuration. The default HAPI FHIR JPA server uses the hapi.fhir.server_address element in the application.yml file, Blaze uses the BASE_URL environment variable in Docker deployment.

What FHIR server are you using? Can you please check what link elements are returned if make the FHIR search request directly to your FHIR server (without FhirExtinguisher) and check if the URL is already broken?

@yuekselba
Copy link
Author

Hi, sorry for the delay. The returned bundle contains a fully functional next link (see below). It looks to me like the Bundle's definition already returns the wrong URL https://docker-framework-app.molit.eu:443:443/fhir?_getpages=8f77e750-f660-4f96-bcc8-943b11701086&_getpagesoffset=520&_count=20&_pretty=true&_bundletype=searchset in BundleWrapper.kt:15. Could you take a look into that? Thank you very much!

"link": [
    {
      "relation": "self",
      "url": "https://docker-framework-app.molit.eu:443/fhir?_getpages=8f77e750-f660-4f96-bcc8-943b11701086&_getpagesoffset=520&_count=20&_pretty=true&_bundletype=searchset"
    },
    {
      "relation": "next",
      "url": "https://docker-framework-app.molit.eu:443/fhir?_getpages=8f77e750-f660-4f96-bcc8-943b11701086&_getpagesoffset=540&_count=20&_pretty=true&_bundletype=searchset"
    },
    {
      "relation": "previous",
      "url": "https://docker-framework-app.molit.eu:443/fhir?_getpages=8f77e750-f660-4f96-bcc8-943b11701086&_getpagesoffset=500&_count=20&_pretty=true&_bundletype=searchset"
    }
  ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants