HAPI FHIR JPA Server (Spring Boot) managing multiple FHIR specifications simultaneously

54 views
Skip to first unread message

Alexandre Savaris

unread,
Nov 18, 2024, 12:45:38 PM11/18/24
to HAPI FHIR
Hello!

I'm using the HAPI FHIR JPA Server, configured to use the HAPI FHIR version 7.4.5 and the FHIR R4 specification, forked from https://github.com/hapifhir/hapi-fhir-jpaserver-starter . This version uses Spring Boot, which injects the RestfulServer instance wherever necessary and registers the RestfulServer using ServletRegistrationBean, as follows.

@Bean
@Conditional(OnEitherVersion.class)
public ServletRegistrationBean hapiServletRegistration(RestfulServer restfulServer) {

ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
beanFactory.autowireBean(restfulServer);
servletRegistrationBean.setServlet(restfulServer);
servletRegistrationBean.addUrlMappings("/fhir/r4/*");
servletRegistrationBean.setLoadOnStartup(1);

return servletRegistrationBean;
}

As far as I know by exploring the code, the server registers a single servlet and configures it using a single application.yaml file. So, it is possible to register a second servlet and configure it to, let's say, manage requests for the R3 (DSTU3) specification (as follows).

    @Bean
    @Conditional(OnEitherVersion.class)
    public ServletRegistrationBean hapiServletRegistrationR3() {

        RestfulServer restfulServer = new RestfulServer(FhirContext.forDstu3Cached());
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
        beanFactory.autowireBean(restfulServer);
        servletRegistrationBean.setServlet(restfulServer);
        servletRegistrationBean.addUrlMappings("/fhir/r3/*");
        servletRegistrationBean.setLoadOnStartup(2);

        return servletRegistrationBean;
    }

I'd like to know the implications of such an approach. Will the server be able to manage requests for both R3 (DSTU3) and R4? Are there other configurations to be made, or even more customizations needed to the codebase?

Has anyone configured or customized the HAPI FHIR JPA Server (with Spring Boot) for working with two FHIR specifications simultaneously?

Thanks in advance.

Best regards,
Alexandre Savaris.

Reply all
Reply to author
Forward
0 new messages