Skip to content

Commit

Permalink
Merge pull request #610 from hapifhir/cr-6.9.6-snapshot
Browse files Browse the repository at this point in the history
6.10.0 release merge with Clinical Reasoning config
  • Loading branch information
KevinDougan authored Nov 28, 2023
2 parents f147c83 + d1c6b06 commit b578ee3
Show file tree
Hide file tree
Showing 63 changed files with 175,445 additions and 3,731 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,12 @@ NOTE: MS SQL Server by default uses a case-insensitive codepage. This will cause
It is recommended to deploy a case-sensitive database prior to running HAPI FHIR when using MS SQL Server to avoid these and potentially other issues.

## Adding custom interceptors
Custom interceptors can be registered with the server by including the property `hapi.fhir.custom-interceptor-classes`. This will take a comma separated list of fully-qualified class names which will be registered with the server.
Interceptors will be discovered in one of two ways:
Custom interceptors can be registered with the server by including the property `hapi.fhir.custom-interceptor-classes`. This will take a comma separated list of fully-qualified class names which will be registered with the server.
Interceptors will be discovered in one of two ways:

1) discovered from the Spring application context as existing Beans (can be used in conjunction with `hapi.fhir.custom-bean-packages`) or registered with Spring via other methods

or
or

2) classes will be instantiated via reflection if no matching Bean is found

Expand Down
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@
<artifactId>hapi-fhir-jpaserver-mdm</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<!-- This dependency includes the CDS Hooks Server -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-server-cds-hooks</artifactId>
<version>${project.version}</version>
</dependency>
<!-- This dependency includes the OpenAPI Server -->
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ca/uhn/fhir/jpa/starter/AppProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -865,4 +865,4 @@ public boolean getEnable_index_of_type() {
public void setEnable_index_of_type(boolean enable_index_of_type) {
this.enable_index_of_type = enable_index_of_type;
}
}
}
81 changes: 45 additions & 36 deletions src/main/java/ca/uhn/fhir/jpa/starter/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import ca.uhn.fhir.batch2.jobs.config.Batch2JobsConfig;
import ca.uhn.fhir.jpa.batch2.JpaBatch2Config;
import ca.uhn.fhir.jpa.starter.annotations.OnEitherVersion;
import ca.uhn.fhir.jpa.starter.cdshooks.StarterCdsHooksConfig;
import ca.uhn.fhir.jpa.starter.common.FhirTesterConfig;
import ca.uhn.fhir.jpa.starter.cr.StarterCrDstu3Config;
import ca.uhn.fhir.jpa.starter.cr.StarterCrR4Config;
import ca.uhn.fhir.jpa.starter.mdm.MdmConfig;
import ca.uhn.fhir.jpa.subscription.channel.config.SubscriptionChannelConfig;
import ca.uhn.fhir.jpa.subscription.match.config.SubscriptionProcessorConfig;
Expand All @@ -29,6 +32,9 @@
@ServletComponentScan(basePackageClasses = {RestfulServer.class})
@SpringBootApplication(exclude = {ElasticsearchRestClientAutoConfiguration.class, ThymeleafAutoConfiguration.class})
@Import({
StarterCrR4Config.class,
StarterCrDstu3Config.class,
StarterCdsHooksConfig.class,
SubscriptionSubmitterConfig.class,
SubscriptionProcessorConfig.class,
SubscriptionChannelConfig.class,
Expand All @@ -39,51 +45,54 @@
})
public class Application extends SpringBootServletInitializer {

public static void main(String[] args) {
public static void main(String[] args) {

SpringApplication.run(Application.class, args);
SpringApplication.run(Application.class, args);

//Server is now accessible at eg. http://localhost:8080/fhir/metadata
//UI is now accessible at http://localhost:8080/
}
// Server is now accessible at eg. http://localhost:8080/fhir/metadata
// UI is now accessible at http://localhost:8080/
}

@Override
protected SpringApplicationBuilder configure(
SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}

@Autowired
AutowireCapableBeanFactory beanFactory;
@Autowired
AutowireCapableBeanFactory beanFactory;

@Bean
@Conditional(OnEitherVersion.class)
public ServletRegistrationBean hapiServletRegistration(RestfulServer restfulServer) {
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
beanFactory.autowireBean(restfulServer);
servletRegistrationBean.setServlet(restfulServer);
servletRegistrationBean.addUrlMappings("/fhir/*");
servletRegistrationBean.setLoadOnStartup(1);
@Bean
@Conditional(OnEitherVersion.class)
public ServletRegistrationBean hapiServletRegistration(RestfulServer restfulServer) {
ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
beanFactory.autowireBean(restfulServer);
servletRegistrationBean.setServlet(restfulServer);
servletRegistrationBean.addUrlMappings("/fhir/*");
servletRegistrationBean.setLoadOnStartup(1);

return servletRegistrationBean;
}
return servletRegistrationBean;
}

@Bean
public ServletRegistrationBean overlayRegistrationBean() {
@Bean
public ServletRegistrationBean overlayRegistrationBean() {

AnnotationConfigWebApplicationContext annotationConfigWebApplicationContext = new AnnotationConfigWebApplicationContext();
annotationConfigWebApplicationContext.register(FhirTesterConfig.class);
AnnotationConfigWebApplicationContext annotationConfigWebApplicationContext =
new AnnotationConfigWebApplicationContext();
annotationConfigWebApplicationContext.register(FhirTesterConfig.class);

DispatcherServlet dispatcherServlet = new DispatcherServlet(
annotationConfigWebApplicationContext);
dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);
dispatcherServlet.setContextConfigLocation(FhirTesterConfig.class.getName());
DispatcherServlet dispatcherServlet = new DispatcherServlet(annotationConfigWebApplicationContext);
dispatcherServlet.setContextClass(AnnotationConfigWebApplicationContext.class);
dispatcherServlet.setContextConfigLocation(FhirTesterConfig.class.getName());

ServletRegistrationBean registrationBean = new ServletRegistrationBean();
registrationBean.setServlet(dispatcherServlet);
registrationBean.addUrlMappings("/*");
registrationBean.setLoadOnStartup(1);
return registrationBean;
ServletRegistrationBean registrationBean = new ServletRegistrationBean();
registrationBean.setServlet(dispatcherServlet);
registrationBean.addUrlMappings("/*");
registrationBean.setLoadOnStartup(1);
return registrationBean;
}

}
// @Bean
// IRepositoryFactory repositoryFactory(DaoRegistry theDaoRegistry, RestfulServer theRestfulServer) {
// return rd -> new HapiFhirRepository(theDaoRegistry, rd, theRestfulServer);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,32 @@ public class ExtraStaticFilesConfigurer implements WebMvcConfigurer {
public ExtraStaticFilesConfigurer(AppProperties appProperties) {

rootContextPath = appProperties.getStaticLocationPrefix();
if(rootContextPath.endsWith("/"))
if (rootContextPath.endsWith("/"))
rootContextPath = rootContextPath.substring(0, rootContextPath.lastIndexOf('/'));

staticLocation = appProperties.getStaticLocation();
if(staticLocation.endsWith("/"))
staticLocation = staticLocation.substring(0, staticLocation.lastIndexOf('/'));

if (staticLocation.endsWith("/")) staticLocation = staticLocation.substring(0, staticLocation.lastIndexOf('/'));
}


@Override
public void addResourceHandlers(ResourceHandlerRegistry theRegistry) {
theRegistry.addResourceHandler(rootContextPath + "/**").addResourceLocations(staticLocation);
}

@Override
public void addViewControllers(ViewControllerRegistry registry) {
String path = URI.create(staticLocation).getPath();
String lastSegment = path.substring(path.lastIndexOf('/') + 1);
public void addResourceHandlers(ResourceHandlerRegistry theRegistry) {
theRegistry.addResourceHandler(rootContextPath + "/**").addResourceLocations(staticLocation);
}

registry.addViewController(rootContextPath).setViewName("redirect:" + rootContextPath + "/" + lastSegment + "/index.html");
@Override
public void addViewControllers(ViewControllerRegistry registry) {
String path = URI.create(staticLocation).getPath();
String lastSegment = path.substring(path.lastIndexOf('/') + 1);

registry.addViewController(rootContextPath + "/*").setViewName("redirect:" + rootContextPath + "/" + lastSegment + "/index.html");
registry.addViewController(rootContextPath)
.setViewName("redirect:" + rootContextPath + "/" + lastSegment + "/index.html");

registry.addViewController(rootContextPath + "/" + lastSegment + "/").setViewName("redirect:" + rootContextPath + "/" + lastSegment + "/index.html");
registry.addViewController(rootContextPath + "/*")
.setViewName("redirect:" + rootContextPath + "/" + lastSegment + "/index.html");

registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}
registry.addViewController(rootContextPath + "/" + lastSegment + "/")
.setViewName("redirect:" + rootContextPath + "/" + lastSegment + "/index.html");

}
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public class OnCorsPresent implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {

AppProperties config = Binder.get(conditionContext.getEnvironment()).bind("hapi.fhir", AppProperties.class).orElse(null);
AppProperties config = Binder.get(conditionContext.getEnvironment())
.bind("hapi.fhir", AppProperties.class)
.orElse(null);
if (config == null) return false;
if (config.getCors() == null) return false;
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import org.springframework.core.type.AnnotatedTypeMetadata;

public class OnDSTU2Condition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
FhirVersionEnum version = FhirVersionEnum.forVersionString(conditionContext.
getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase());
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
FhirVersionEnum version = FhirVersionEnum.forVersionString(conditionContext
.getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase());

return version == FhirVersionEnum.DSTU2;

}
return version == FhirVersionEnum.DSTU2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import org.springframework.core.type.AnnotatedTypeMetadata;

public class OnDSTU3Condition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
FhirVersionEnum version = FhirVersionEnum.forVersionString(conditionContext.
getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase());
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
FhirVersionEnum version = FhirVersionEnum.forVersionString(conditionContext
.getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase());

return version == FhirVersionEnum.DSTU3;

}
return version == FhirVersionEnum.DSTU3;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,28 @@

public class OnEitherVersion extends AnyNestedCondition {

OnEitherVersion() {
super(ConfigurationPhase.REGISTER_BEAN);
}
OnEitherVersion() {
super(ConfigurationPhase.REGISTER_BEAN);
}

@Override
protected ConditionOutcome getFinalMatchOutcome(MemberMatchOutcomes memberOutcomes) {
ConditionOutcome result = super.getFinalMatchOutcome(memberOutcomes);
return result;
}
@Override
protected ConditionOutcome getFinalMatchOutcome(MemberMatchOutcomes memberOutcomes) {
ConditionOutcome result = super.getFinalMatchOutcome(memberOutcomes);
return result;
}

@Conditional(OnDSTU2Condition.class)
static class OnDSTU2 {
}
@Conditional(OnDSTU2Condition.class)
static class OnDSTU2 {}

@Conditional(OnDSTU3Condition.class)
static class OnDSTU3 {
}
@Conditional(OnDSTU3Condition.class)
static class OnDSTU3 {}

@Conditional(OnR4Condition.class)
static class OnR4 {
}
@Conditional(OnR4Condition.class)
static class OnR4 {}

@Conditional(OnR4BCondition.class)
static class OnR4B {
}

@Conditional(OnR5Condition.class)
static class OnR5 {
}
static class OnR4B {}

}
@Conditional(OnR5Condition.class)
static class OnR5 {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public class OnImplementationGuidesPresent implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {

AppProperties config = Binder.get(conditionContext.getEnvironment()).bind("hapi.fhir", AppProperties.class).orElse(null);
AppProperties config = Binder.get(conditionContext.getEnvironment())
.bind("hapi.fhir", AppProperties.class)
.orElse(null);
if (config == null) return false;
if (config.getImplementationGuides() == null) return false;
return !config.getImplementationGuides().isEmpty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
public class OnR4BCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
String version = conditionContext.
getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase();
String version = conditionContext
.getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase();

return FhirVersionEnum.R4B.name().equals(version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import org.springframework.core.type.AnnotatedTypeMetadata;

public class OnR4Condition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
FhirVersionEnum version = FhirVersionEnum.forVersionString(conditionContext.
getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase());
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
FhirVersionEnum version = FhirVersionEnum.forVersionString(conditionContext
.getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase());

return version == FhirVersionEnum.R4;

}
return version == FhirVersionEnum.R4;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
import org.springframework.core.type.AnnotatedTypeMetadata;

public class OnR5Condition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
FhirVersionEnum version = FhirVersionEnum.forVersionString(conditionContext.
getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase());
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
FhirVersionEnum version = FhirVersionEnum.forVersionString(conditionContext
.getEnvironment()
.getProperty("hapi.fhir.fhir_version")
.toUpperCase());

return version == FhirVersionEnum.R5;

}
return version == FhirVersionEnum.R5;
}
}
Loading

0 comments on commit b578ee3

Please sign in to comment.