Adding support for '*' cornercase
This commit is contained in:
@@ -928,7 +928,8 @@ public class AppProperties {
|
||||
request_tenant_partitioning_mode = theRequest_tenant_partitioning_mode;
|
||||
}
|
||||
}
|
||||
public static class RemoteSystem{
|
||||
|
||||
public static class RemoteSystem {
|
||||
private String system;
|
||||
private String url;
|
||||
|
||||
|
||||
@@ -30,20 +30,60 @@ public class FhirServerConfigR4 {
|
||||
|
||||
@Bean(name = "myHybridRemoteValidationSupportChain")
|
||||
@Conditional({OnR4Condition.class, OnRemoteTerminologyPresent.class})
|
||||
public IValidationSupport addRemoteValidation(ValidationSupportChain theValidationSupport, FhirContext theFhirContext, AppProperties theAppProperties)
|
||||
{
|
||||
theAppProperties.getRemoteTerminologyServicesMap().forEach((key, remoteSystem) -> {
|
||||
theValidationSupport.addValidationSupport(0 , new RemoteTerminologyServiceValidationSupport(theFhirContext, remoteSystem.getUrl()){
|
||||
@Override
|
||||
public CodeValidationResult validateCode(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, String theValueSetUrl) {
|
||||
if (remoteSystem.getSystem().equalsIgnoreCase(theCodeSystem)) {
|
||||
return super.validateCode(theValidationSupportContext, theOptions, theCodeSystem, theCode, theDisplay, theValueSetUrl);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
});
|
||||
public IValidationSupport addRemoteValidation(
|
||||
ValidationSupportChain theValidationSupport, FhirContext theFhirContext, AppProperties theAppProperties) {
|
||||
var values = theAppProperties.getRemoteTerminologyServicesMap().values();
|
||||
|
||||
// If the remote terminology service is "*" and is the only one then forward all requests to the remote
|
||||
// terminology service
|
||||
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);
|
||||
}
|
||||
});
|
||||
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 CodeValidationResult validateCode(
|
||||
ValidationSupportContext theValidationSupportContext,
|
||||
ConceptValidationOptions theOptions,
|
||||
String theCodeSystem,
|
||||
String theCode,
|
||||
String theDisplay,
|
||||
String theValueSetUrl) {
|
||||
if (remoteSystem.getSystem().equalsIgnoreCase(theCodeSystem)) {
|
||||
return super.validateCode(
|
||||
theValidationSupportContext,
|
||||
theOptions,
|
||||
theCodeSystem,
|
||||
theCode,
|
||||
theDisplay,
|
||||
theValueSetUrl);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
}
|
||||
return theValidationSupport;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ public class OnRemoteTerminologyPresent implements Condition {
|
||||
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata metadata) {
|
||||
|
||||
AppProperties config = Binder.get(conditionContext.getEnvironment())
|
||||
.bind("hapi.fhir", AppProperties.class)
|
||||
.orElse(null);
|
||||
.bind("hapi.fhir", AppProperties.class)
|
||||
.orElse(null);
|
||||
if (config == null) return false;
|
||||
if (config.getRemoteTerminologyServicesMap() == null) return false;
|
||||
return !config.getRemoteTerminologyServicesMap().isEmpty();
|
||||
|
||||
Reference in New Issue
Block a user