Merge branch 'hapi-master' into feat/remote-terminology-support

This commit is contained in:
Jens Kristian Villadsen
2025-04-29 10:03:35 +02:00
16 changed files with 99 additions and 90 deletions

View File

@@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import java.io.IOException;
import java.util.stream.Collectors;
import static ca.uhn.hapi.fhir.cdshooks.config.CdsHooksConfig.CDS_HOOKS_OBJECT_MAPPER_FACTORY;
import static org.opencds.cqf.fhir.cr.hapi.config.test.TestCdsHooksConfig.CDS_HOOKS_OBJECT_MAPPER_FACTORY;
@Configurable
public class CdsHooksServlet extends HttpServlet {

View File

@@ -5,14 +5,16 @@ import ca.uhn.fhir.jpa.starter.cr.CrCommonConfig;
import ca.uhn.fhir.jpa.starter.cr.CrConfigCondition;
import ca.uhn.fhir.jpa.starter.cr.CrProperties;
import ca.uhn.hapi.fhir.cdshooks.api.ICdsHooksDaoAuthorizationSvc;
import ca.uhn.hapi.fhir.cdshooks.config.CdsHooksConfig;
import ca.uhn.hapi.fhir.cdshooks.svc.CdsHooksContextBooter;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrServiceRegistry;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrSettings;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.ICdsCrServiceRegistry;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.CdsCrDiscoveryServiceRegistry;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.ICdsCrDiscoveryServiceRegistry;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.opencds.cqf.fhir.cr.hapi.cdshooks.CdsCrServiceRegistry;
import org.opencds.cqf.fhir.cr.hapi.cdshooks.CdsCrSettings;
import org.opencds.cqf.fhir.cr.hapi.cdshooks.ICdsCrServiceRegistry;
import org.opencds.cqf.fhir.cr.hapi.cdshooks.discovery.CdsCrDiscoveryServiceRegistry;
import org.opencds.cqf.fhir.cr.hapi.cdshooks.discovery.ICdsCrDiscoveryServiceRegistry;
import org.opencds.cqf.fhir.cr.hapi.config.CrCdsHooksConfig;
import org.opencds.cqf.fhir.cr.hapi.config.RepositoryConfig;
import org.opencds.cqf.fhir.cr.hapi.config.test.TestCdsHooksConfig;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
@@ -22,27 +24,14 @@ import org.springframework.context.annotation.Import;
@Configuration
@Conditional({CdsHooksConfigCondition.class, CrConfigCondition.class})
@Import({CdsHooksConfig.class, CrCommonConfig.class})
@Import({RepositoryConfig.class, TestCdsHooksConfig.class, CrCdsHooksConfig.class, CrCommonConfig.class})
public class StarterCdsHooksConfig {
// @Bean
// CdsPrefetchSvc cdsPrefetchSvc(
// CdsResolutionStrategySvc theCdsResolutionStrategySvc,
// CdsPrefetchDaoSvc theResourcePrefetchDao,
// CdsPrefetchFhirClientSvc theResourcePrefetchFhirClient,
// ICdsHooksDaoAuthorizationSvc theCdsHooksDaoAuthorizationSvc) {
// return new ModuleConfigurationPrefetchSvc(
// theCdsResolutionStrategySvc,
// theResourcePrefetchDao,
// theResourcePrefetchFhirClient,
// theCdsHooksDaoAuthorizationSvc);
// }
@Bean
public ICdsCrDiscoveryServiceRegistry cdsCrDiscoveryServiceRegistry() {
CdsCrDiscoveryServiceRegistry registry = new CdsCrDiscoveryServiceRegistry();
registry.unregister(FhirVersionEnum.R4);
registry.register(FhirVersionEnum.R4, UpdatedCrDiscoveryServiceR4.class);
registry.register(FhirVersionEnum.R4, UpdatedCrDiscoveryService.class);
return registry;
}
@@ -50,7 +39,7 @@ public class StarterCdsHooksConfig {
public ICdsCrServiceRegistry cdsCrServiceRegistry() {
CdsCrServiceRegistry registry = new CdsCrServiceRegistry();
registry.unregister(FhirVersionEnum.R4);
registry.register(FhirVersionEnum.R4, UpdatedCdsCrServiceR4.class);
registry.register(FhirVersionEnum.R4, UpdatedCdsCrService.class);
return registry;
}

View File

@@ -0,0 +1,44 @@
package ca.uhn.fhir.jpa.starter.cdshooks;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.api.server.cdshooks.CdsServiceRequestJson;
import ca.uhn.hapi.fhir.cdshooks.api.ICdsConfigService;
import org.hl7.fhir.instance.model.api.IBaseParameters;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.opencds.cqf.fhir.api.Repository;
import org.opencds.cqf.fhir.cr.hapi.cdshooks.CdsCrService;
import org.opencds.cqf.fhir.utility.adapter.IAdapterFactory;
import static org.opencds.cqf.fhir.utility.Constants.APPLY_PARAMETER_DATA;
public class UpdatedCdsCrService extends CdsCrService {
private final IAdapterFactory adapterFactory;
public UpdatedCdsCrService(
RequestDetails theRequestDetails, Repository theRepository, ICdsConfigService theCdsConfigService) {
super(theRequestDetails, theRepository, theCdsConfigService);
adapterFactory = IAdapterFactory.forFhirContext(theRepository.fhirContext());
}
@Override
public IBaseParameters encodeParams(CdsServiceRequestJson theJson) {
var parameters = adapterFactory.createParameters(super.encodeParams(theJson));
if (parameters.hasParameter(APPLY_PARAMETER_DATA)) {
parameters.addParameter(
"useServerData",
booleanTypeForVersion(parameters.fhirContext().getVersion().getVersion(), false));
}
return (IBaseParameters) parameters.get();
}
private IPrimitiveType<Boolean> booleanTypeForVersion(FhirVersionEnum fhirVersion, boolean value) {
return switch (fhirVersion) {
case DSTU2 -> new org.hl7.fhir.dstu2.model.BooleanType(value);
case DSTU3 -> new org.hl7.fhir.dstu3.model.BooleanType(value);
case R4 -> new org.hl7.fhir.r4.model.BooleanType(value);
case R5 -> new org.hl7.fhir.r5.model.BooleanType(value);
default -> throw new IllegalArgumentException("unknown or unsupported FHIR version");
};
}
}

View File

@@ -1,28 +0,0 @@
package ca.uhn.fhir.jpa.starter.cdshooks;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.api.server.cdshooks.CdsServiceRequestJson;
import ca.uhn.hapi.fhir.cdshooks.api.ICdsConfigService;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrServiceR4;
import org.hl7.fhir.r4.model.BooleanType;
import org.hl7.fhir.r4.model.Parameters;
import org.opencds.cqf.fhir.api.Repository;
import static ca.uhn.hapi.fhir.cdshooks.svc.cr.CdsCrConstants.APPLY_PARAMETER_DATA;
import static org.opencds.cqf.fhir.utility.r4.Parameters.part;
public class UpdatedCdsCrServiceR4 extends CdsCrServiceR4 {
public UpdatedCdsCrServiceR4(
RequestDetails theRequestDetails, Repository theRepository, ICdsConfigService theCdsConfigService) {
super(theRequestDetails, theRepository, theCdsConfigService);
}
@Override
public Parameters encodeParams(CdsServiceRequestJson theJson) {
Parameters parameters = super.encodeParams(theJson);
if (parameters.hasParameter(APPLY_PARAMETER_DATA)) {
parameters.addParameter(part("useServerData", new BooleanType(false)));
}
return parameters;
}
}

View File

@@ -0,0 +1,12 @@
package ca.uhn.fhir.jpa.starter.cdshooks;
import org.hl7.fhir.instance.model.api.IIdType;
import org.opencds.cqf.fhir.api.Repository;
import org.opencds.cqf.fhir.cr.hapi.cdshooks.discovery.CrDiscoveryService;
public class UpdatedCrDiscoveryService extends CrDiscoveryService {
public UpdatedCrDiscoveryService(IIdType thePlanDefinitionId, Repository theRepository) {
super(thePlanDefinitionId, theRepository);
maxUriLength = 6000;
}
}

View File

@@ -1,12 +0,0 @@
package ca.uhn.fhir.jpa.starter.cdshooks;
import ca.uhn.hapi.fhir.cdshooks.svc.cr.discovery.CrDiscoveryServiceR4;
import org.hl7.fhir.instance.model.api.IIdType;
import org.opencds.cqf.fhir.api.Repository;
public class UpdatedCrDiscoveryServiceR4 extends CrDiscoveryServiceR4 {
public UpdatedCrDiscoveryServiceR4(IIdType thePlanDefinitionId, Repository theRepository) {
super(thePlanDefinitionId, theRepository);
myMaxUriLength = 6000;
}
}

View File

@@ -156,8 +156,8 @@ public class FhirServerConfigCommon {
jpaStorageSettings.setPreExpandValueSets(appProperties.getPre_expand_value_sets());
jpaStorageSettings.setEnableTaskPreExpandValueSets(appProperties.getEnable_task_pre_expand_value_sets());
jpaStorageSettings.setPreExpandValueSetsDefaultCount(appProperties.getPre_expand_value_sets_default_count());
jpaStorageSettings.setPreExpandValueSetsMaxCount(appProperties.getPre_expand_value_sets_max_count());
jpaStorageSettings.setPreExpandValueSetsDefaultCount(appProperties.getPre_expand_value_sets_default_count());
jpaStorageSettings.setMaximumExpansionSize(appProperties.getMaximum_expansion_size());
jpaStorageSettings.setIndexMissingFields(

View File

@@ -1,8 +1,5 @@
package ca.uhn.fhir.jpa.starter.cr;
import ca.uhn.fhir.cr.common.CodeCacheResourceChangeListener;
import ca.uhn.fhir.cr.common.CqlThreadFactory;
import ca.uhn.fhir.cr.common.ElmCacheResourceChangeListener;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.cache.IResourceChangeListenerRegistry;
import ca.uhn.fhir.jpa.cache.ResourceChangeListenerRegistryInterceptor;
@@ -19,6 +16,9 @@ import org.opencds.cqf.cql.engine.runtime.Code;
import org.opencds.cqf.fhir.cql.EvaluationSettings;
import org.opencds.cqf.fhir.cql.engine.retrieve.RetrieveSettings;
import org.opencds.cqf.fhir.cql.engine.terminology.TerminologySettings;
import org.opencds.cqf.fhir.cr.hapi.common.CodeCacheResourceChangeListener;
import org.opencds.cqf.fhir.cr.hapi.common.CqlThreadFactory;
import org.opencds.cqf.fhir.cr.hapi.common.ElmCacheResourceChangeListener;
import org.opencds.cqf.fhir.cr.measure.CareGapsProperties;
import org.opencds.cqf.fhir.cr.measure.MeasureEvaluationOptions;
import org.opencds.cqf.fhir.utility.ValidationProfile;

View File

@@ -1,11 +1,11 @@
package ca.uhn.fhir.jpa.starter.cr;
import ca.uhn.fhir.cr.config.dstu3.ApplyOperationConfig;
import ca.uhn.fhir.cr.config.dstu3.CrDstu3Config;
import ca.uhn.fhir.cr.config.dstu3.DataRequirementsOperationConfig;
import ca.uhn.fhir.cr.config.dstu3.EvaluateOperationConfig;
import ca.uhn.fhir.cr.config.dstu3.PackageOperationConfig;
import ca.uhn.fhir.jpa.starter.annotations.OnDSTU3Condition;
import org.opencds.cqf.fhir.cr.hapi.config.dstu3.ApplyOperationConfig;
import org.opencds.cqf.fhir.cr.hapi.config.dstu3.CrDstu3Config;
import org.opencds.cqf.fhir.cr.hapi.config.dstu3.DataRequirementsOperationConfig;
import org.opencds.cqf.fhir.cr.hapi.config.dstu3.EvaluateOperationConfig;
import org.opencds.cqf.fhir.cr.hapi.config.dstu3.PackageOperationConfig;
import org.springframework.context.annotation.*;
@Configuration

View File

@@ -1,14 +1,14 @@
package ca.uhn.fhir.jpa.starter.cr;
import ca.uhn.fhir.cr.config.r4.ApplyOperationConfig;
import ca.uhn.fhir.cr.config.r4.CrR4Config;
import ca.uhn.fhir.cr.config.r4.DataRequirementsOperationConfig;
import ca.uhn.fhir.cr.config.r4.EvaluateOperationConfig;
import ca.uhn.fhir.cr.config.r4.ExtractOperationConfig;
import ca.uhn.fhir.cr.config.r4.PackageOperationConfig;
import ca.uhn.fhir.cr.config.r4.PopulateOperationConfig;
import ca.uhn.fhir.cr.config.r4.QuestionnaireOperationConfig;
import ca.uhn.fhir.jpa.starter.annotations.OnR4Condition;
import org.opencds.cqf.fhir.cr.hapi.config.r4.ApplyOperationConfig;
import org.opencds.cqf.fhir.cr.hapi.config.r4.CrR4Config;
import org.opencds.cqf.fhir.cr.hapi.config.r4.DataRequirementsOperationConfig;
import org.opencds.cqf.fhir.cr.hapi.config.r4.EvaluateOperationConfig;
import org.opencds.cqf.fhir.cr.hapi.config.r4.ExtractOperationConfig;
import org.opencds.cqf.fhir.cr.hapi.config.r4.PackageOperationConfig;
import org.opencds.cqf.fhir.cr.hapi.config.r4.PopulateOperationConfig;
import org.opencds.cqf.fhir.cr.hapi.config.r4.QuestionnaireOperationConfig;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

View File

@@ -124,7 +124,7 @@ hapi:
data:
search_parameter_mode: USE_SEARCH_PARAMETERS # AUTO, USE_SEARCH_PARAMETERS, FILTER_IN_MEMORY
terminology_parameter_mode: FILTER_IN_MEMORY # AUTO, USE_VALUE_SET_URL, USE_INLINE_CODES, FILTER_IN_MEMORY
profile_mode: OFF # ENFORCED, DECLARED, OPTIONAL, TRUST, OFF
profile_mode: DECLARED # ENFORCED, DECLARED, OPTIONAL, TRUST, OFF
cdshooks:
enabled: true

View File

@@ -1,7 +1,6 @@
package ca.uhn.fhir.jpa.starter;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.cr.config.RepositoryConfig;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.jpa.searchparam.config.NicknameServiceConfig;
import ca.uhn.fhir.jpa.starter.cdshooks.StarterCdsHooksConfig;
@@ -9,7 +8,6 @@ import ca.uhn.fhir.parser.IParser;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.hapi.fhir.cdshooks.api.ICdsServiceRegistry;
import ca.uhn.hapi.fhir.cdshooks.config.CdsHooksConfig;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@@ -22,6 +20,9 @@ import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.opencds.cqf.fhir.cr.hapi.config.CrCdsHooksConfig;
import org.opencds.cqf.fhir.cr.hapi.config.RepositoryConfig;
import org.opencds.cqf.fhir.cr.hapi.config.test.TestCdsHooksConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
@@ -39,7 +40,8 @@ import static org.junit.jupiter.api.Assertions.fail;
Application.class,
NicknameServiceConfig.class,
RepositoryConfig.class,
CdsHooksConfig.class,
TestCdsHooksConfig.class,
CrCdsHooksConfig.class,
StarterCdsHooksConfig.class
}, properties = {
"spring.profiles.include=storageSettingsTest",
@@ -116,7 +118,7 @@ class CdsHooksServletIT implements IServerSupport {
}
@Test
void testCdsHooks() throws IOException, InterruptedException {
void testCdsHooks() throws IOException {
loadBundle("r4/HelloWorld-Bundle.json", ourCtx, ourClient);
await().atMost(10000, TimeUnit.MILLISECONDS).until(() -> hasCdsServices());
var cdsRequest = "{\n" +

View File

@@ -1,7 +1,6 @@
package ca.uhn.fhir.jpa.starter;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.cr.config.RepositoryConfig;
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.api.CacheControlDirective;
@@ -19,6 +18,7 @@ import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.opencds.cqf.fhir.cr.hapi.config.RepositoryConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;

View File

@@ -1,7 +1,6 @@
package ca.uhn.fhir.jpa.starter;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.cr.config.RepositoryConfig;
import ca.uhn.fhir.jpa.searchparam.config.NicknameServiceConfig;
import ca.uhn.fhir.jpa.starter.cr.CrProperties;
import ca.uhn.fhir.model.primitive.IdDt;
@@ -25,6 +24,7 @@ import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.opencds.cqf.fhir.cr.hapi.config.RepositoryConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;