Add test so verify hybrid

This commit is contained in:
Jens Kristian Villadsen
2025-03-31 23:17:29 +02:00
parent ec0af6cae0
commit 00a10777f6
2 changed files with 22 additions and 36 deletions

View File

@@ -39,30 +39,19 @@ public class FhirServerConfigR4 {
if (values.size() == 1 && "*".equalsIgnoreCase(values.iterator().next().getSystem())) {
var remoteSystem = values.iterator().next();
theValidationSupport.addValidationSupport(
0, new RemoteTerminologyServiceValidationSupport(theFhirContext, remoteSystem.getUrl()) {
@Override
public CodeValidationResult validateCode(
ValidationSupportContext theValidationSupportContext,
ConceptValidationOptions theOptions,
String theCodeSystem,
String theCode,
String theDisplay,
String theValueSetUrl) {
return super.validateCode(
theValidationSupportContext,
theOptions,
theCodeSystem,
theCode,
theDisplay,
theValueSetUrl);
}
});
0, new RemoteTerminologyServiceValidationSupport(theFhirContext, remoteSystem.getUrl()));
return theValidationSupport;
// If there are multiple remote terminology services, then add each one to the validation chain
} else {
values.forEach((remoteSystem) -> theValidationSupport.addValidationSupport(
0, new RemoteTerminologyServiceValidationSupport(theFhirContext, remoteSystem.getUrl()) {
@Override
public boolean isCodeSystemSupported(
ValidationSupportContext theValidationSupportContext, String theSystem) {
return remoteSystem.getSystem().equalsIgnoreCase(theSystem);
}
@Override
public CodeValidationResult validateCode(
ValidationSupportContext theValidationSupportContext,

View File

@@ -19,20 +19,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.DateType;
import org.hl7.fhir.r4.model.BooleanType;
import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.r4.model.IdType;
import org.hl7.fhir.r4.model.Measure;
import org.hl7.fhir.r4.model.MeasureReport;
import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Period;
import org.hl7.fhir.r4.model.StringType;
import org.hl7.fhir.r4.model.Subscription;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
@@ -77,12 +64,13 @@ import static org.opencds.cqf.fhir.utility.r4.Parameters.stringPart;
"hapi.fhir.implementationguides.dk-core.name=hl7.fhir.dk.core",
"hapi.fhir.implementationguides.dk-core.version=1.1.0",
"hapi.fhir.auto_create_placeholder_reference_targets=true",
"hibernate.search.enabled=true",
// Override is currently required when using MDM as the construction of the MDM
// beans are ambiguous as they are constructed multiple places. This is evident
// when running in a spring boot environment
"spring.main.allow-bean-definition-overriding=true",
"hapi.fhir.remote_terminology_service.snomed.system=http://snomed.info/sct",
"hapi.fhir.remote_terminology_service.snomed.url=http://tx.fhir.org/r4",
"hapi.fhir.remote_terminology_service.snomed.url=http://tx.fhir.org/r4"
})
class ExampleServerR4IT implements IServerSupport {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerR4IT.class);
@@ -366,9 +354,18 @@ class ExampleServerR4IT implements IServerSupport {
@Test
void testValidateRemoteTerminology() {
Parameters result = ourClient.operation().onType(ValueSet.class).named("$validate-code").withParameter(Parameters.class, "code", new StringType("22298006")).andParameter("system", new UriType("http://snomed.info/sct")).execute();
assertEquals(true, ((BooleanType) result.getParameterValue("result")).getValue());
assertEquals("Myocardial infarction", ((StringType) result.getParameterValue("display")).getValue());
String testCodeSystem = "http://foo/cs";
String testValueSet = "http://foo/vs";
ourClient.create().resource(new CodeSystem().setUrl(testCodeSystem).addConcept(new CodeSystem.ConceptDefinitionComponent().setCode("yes")).addConcept(new CodeSystem.ConceptDefinitionComponent().setCode("no"))).execute();
ourClient.create().resource(new ValueSet().setUrl(testValueSet).setCompose(new ValueSet.ValueSetComposeComponent().addInclude(new ValueSet.ConceptSetComponent().setSystem(testValueSet)))).execute();
Parameters remoteResult = ourClient.operation().onType(ValueSet.class).named("$validate-code").withParameter(Parameters.class, "code", new StringType("22298006")).andParameter("system", new UriType("http://snomed.info/sct")).execute();
assertEquals(true, ((BooleanType) remoteResult.getParameterValue("result")).getValue());
assertEquals("Myocardial infarction", ((StringType) remoteResult.getParameterValue("display")).getValue());
Parameters localResult = ourClient.operation().onType(CodeSystem.class).named("$validate-code").withParameter(Parameters.class, "url", new UrlType(testCodeSystem)).andParameter("coding", new Coding(testCodeSystem, "yes", null))/*.andParameter( "code", new StringType("yes"))*/.execute();
assertEquals(true, ((BooleanType) localResult.getParameterValue("result")).getValue());
}
@BeforeEach