FHIR Chat · STU3 and R4 within on Server · hapi

Stream: hapi

Topic: STU3 and R4 within on Server


view this post on Zulip Andreas Mautsch (May 03 2021 at 13:49):

Hello everybody ..

view this post on Zulip Andreas Mautsch (May 03 2021 at 13:52):

I guess this is not the first time someone asks .. but is it possible to implement STU3 and R4 at the same time inside the same HAPI FHir Spring Boot Application ? Unfortunately we have a requirement like this .. I invested about 2 hours of time and at least the application bootstrapped.

I tried to differantiate bei having 2 urls /fhir/dstu3 and /fhir/r4 ... only the first one works ... as getting this far involved some hacky code, I suspect its not desired to do something like this ?

view this post on Zulip Craig McClendon (May 03 2021 at 14:13):

I suspect that it's possible, though I haven't tried. But I would looking to save the headaches unless there really is some shared state you need to maintain between the two. If you are already ok with two different base URLs, I assume it is much easier to run two instances - or even use a reverse proxy if you want to have them running on the same port/machine.

That said, we use the plain server implementation (not the JPA), and we register the FHIR server servlet with SpringBoot like this:

    @Bean
    public ServletRegistrationBean<?> v1FhirServletRegistrationBean(RestfulServer v1FhirServlet) {
        ServletRegistrationBean<?> s = new ServletRegistrationBean<>(v1FhirServlet, fhirServerBaseContextPath + "/*");
        s.setName("fhirsvr");
        return s;
    }

With a little Spring-fu, I suspect you could register more than one servlet on different base-urls.

view this post on Zulip Craig McClendon (May 03 2021 at 14:20):

.. If you're using the JPA version of HAPI, that could present additional problems if you cannot share a single DB configuration between the two versions. SpringBoot doesn't well support having multiple JPA configurations within the same application context because there are a bunch of hidden beans it uses for things like transaction management which are not easily separated.

view this post on Zulip Andreas Mautsch (May 03 2021 at 14:43):

ok thank you very much for the fast answer .. basically registering to ServletRegistrationBeans is what I did
additionally the component scanning needs to be fixed at multiple occasions .. looks very hacky though and still doesn not work finally
i also thought about deploying two instances and using a reverse proxy .. while this is possible its not my first choice, because this will affect the development process as well as the resource usage

jpa is not a thing currently .. thanks again


Last updated: Apr 12 2022 at 19:14 UTC