Unit Test work - still cannot get Dstu3 working after several attempts, but included the skelton of a test to capture the effort anyways.

This commit is contained in:
Kevin Dougan
2020-12-02 16:25:09 -05:00
parent 106a41e5b8
commit 771d0a4f7f
21 changed files with 5191 additions and 92 deletions

View File

@@ -21,6 +21,7 @@ import org.springframework.context.annotation.Configuration;
@EnableConfigurationProperties
public class AppProperties {
private Boolean cql_enabled = false;
private Boolean empi_enabled = false;
private Boolean allow_cascading_deletes = false;
private Boolean allow_contains_searches = true;
@@ -85,6 +86,14 @@ public class AppProperties {
this.partitioning = partitioning;
}
public Boolean getCql_enabled() {
return cql_enabled;
}
public void setCql_enabled(Boolean cql_enabled) {
this.cql_enabled = cql_enabled;
}
public Boolean getEmpi_enabled() {
return empi_enabled;
}
@@ -93,7 +102,6 @@ public class AppProperties {
this.empi_enabled = empi_enabled;
}
public Cors getCors() {
return cors;
}

View File

@@ -32,8 +32,8 @@ public class Application extends SpringBootServletInitializer {
System.setProperty("spring.batch.job.enabled", "false");
SpringApplication.run(Application.class, args);
//Server is now accessible at eg. http://localhost:8080/hapi-fhir-jpaserver/fhir/metadata
//UI is now accessible at http://localhost:8080/hapi-fhir-jpaserver/
//Server is now accessible at eg. http://localhost:8080/fhir/metadata
//UI is now accessible at http://localhost:8080/
}
@Override

View File

@@ -2,6 +2,8 @@ package ca.uhn.fhir.jpa.starter;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.cql.provider.CqlProviderLoader;
import ca.uhn.fhir.empi.provider.EmpiProviderLoader;
import ca.uhn.fhir.interceptor.api.IInterceptorBroadcaster;
import ca.uhn.fhir.interceptor.api.IInterceptorService;
import ca.uhn.fhir.jpa.api.config.DaoConfig;
@@ -97,6 +99,10 @@ public class BaseJpaRestfulServer extends RestfulServer {
@Autowired
ApplicationContext myApplicationContext;
// These are set only if the features are enabled
private CqlProviderLoader cqlProviderLoader;
private EmpiProviderLoader empiProviderLoader;
public BaseJpaRestfulServer() {
}
@@ -121,10 +127,21 @@ public class BaseJpaRestfulServer extends RestfulServer {
}
setFhirContext(fhirSystemDao.getContext());
FhirVersionEnum fhirVersion = fhirSystemDao.getContext().getVersion().getVersion();
if (fhirVersion == FhirVersionEnum.DSTU3 || fhirVersion == FhirVersionEnum.R4) {
if (appProperties.getCql_enabled()) {
cqlProviderLoader = myApplicationContext.getBean(CqlProviderLoader.class);
cqlProviderLoader.loadProvider();
}
if (appProperties.getEmpi_enabled()) {
empiProviderLoader = myApplicationContext.getBean(EmpiProviderLoader.class);
empiProviderLoader.loadProvider();
}
}
registerProviders(resourceProviders.createProviders());
registerProvider(jpaSystemProvider);
FhirVersionEnum fhirVersion = fhirSystemDao.getContext().getVersion().getVersion();
/*
* The conformance provider exports the supported resources, search parameters, etc for
* this server. The JPA version adds resourceProviders counts to the exported statement, so it

View File

@@ -4,11 +4,9 @@ import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.jpa.config.BaseJavaConfigR4;
import ca.uhn.fhir.jpa.search.DatabaseBackedPagingProvider;
import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition;
import ca.uhn.fhir.jpa.starter.cql.CqlConfigR4;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.*;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
@@ -18,6 +16,7 @@ import javax.sql.DataSource;
@Configuration
@Conditional(OnR4Condition.class)
@Import(CqlConfigR4.class)
public class FhirServerConfigR4 extends BaseJavaConfigR4 {
@Autowired

View File

@@ -7,8 +7,8 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
public class CqlConfigCondition implements Condition {
@Override
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
String property = conditionContext.getEnvironment().getProperty("hapi.fhir.cql_enabled");
public boolean matches(ConditionContext theConditionContext, AnnotatedTypeMetadata theAnnotatedTypeMetadata) {
String property = theConditionContext.getEnvironment().getProperty("hapi.fhir.cql_enabled");
boolean enabled = Boolean.parseBoolean(property);
return enabled;
}

View File

@@ -1,13 +1,10 @@
package ca.uhn.fhir.jpa.starter.cql;
import ca.uhn.fhir.cql.config.CqlR4Config;
import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@Configuration
@Conditional({OnR4Condition.class, CqlConfigCondition.class})
@Conditional({CqlConfigCondition.class})
@Import({CqlR4Config.class})
public class CqlConfigR4 {
}