Merge remote-tracking branch 'remotes/origin/master' into im_20200728_term_multi_version_support

This commit is contained in:
ianmarshall 2020-08-21 10:16:49 -04:00
commit 29b293f179
4 changed files with 53 additions and 9 deletions

View File

@ -0,0 +1,6 @@
---
type: add
issue: 2045
title: "The `RemoteTerminologyServiceValidationSupport` class used for connecting to a remote terminology service
will no longer attempt to perform code validation for fields where the code system is implied, since there is no
FHIR operation allowing this style of validation to be performed remotely."

View File

@ -23,7 +23,6 @@ package ca.uhn.fhir.jpa.migrate.taskdef;
import ca.uhn.fhir.util.StopWatch; import ca.uhn.fhir.util.StopWatch;
import ca.uhn.fhir.util.VersionEnum; import ca.uhn.fhir.util.VersionEnum;
import com.google.common.collect.ForwardingMap; import com.google.common.collect.ForwardingMap;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.apache.commons.lang3.concurrent.BasicThreadFactory;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -33,8 +32,17 @@ import org.springframework.jdbc.core.RowCallbackHandler;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.*; import java.util.ArrayList;
import java.util.concurrent.*; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
public abstract class BaseColumnCalculatorTask extends BaseTableColumnTask { public abstract class BaseColumnCalculatorTask extends BaseTableColumnTask {
@ -43,19 +51,27 @@ public abstract class BaseColumnCalculatorTask extends BaseTableColumnTask {
private int myBatchSize = 10000; private int myBatchSize = 10000;
private ThreadPoolExecutor myExecutor; private ThreadPoolExecutor myExecutor;
public void setBatchSize(int theBatchSize) { /**
myBatchSize = theBatchSize; * Constructor
*/
public BaseColumnCalculatorTask(VersionEnum theRelease, String theVersion) {
this(theRelease.toString(), theVersion);
} }
/** /**
* Constructor * Constructor
*/ */
public BaseColumnCalculatorTask(VersionEnum theRelease, String theVersion) { public BaseColumnCalculatorTask(String theRelease, String theVersion) {
super(theRelease.toString(), theVersion); super(theRelease, theVersion);
}
public void setBatchSize(int theBatchSize) {
myBatchSize = theBatchSize;
} }
/** /**
* Allows concrete implementations to decide if they should be skipped. * Allows concrete implementations to decide if they should be skipped.
*
* @return a boolean indicating whether or not to skip execution of the task. * @return a boolean indicating whether or not to skip execution of the task.
*/ */
protected abstract boolean shouldSkipTask(); protected abstract boolean shouldSkipTask();
@ -70,7 +86,7 @@ public abstract class BaseColumnCalculatorTask extends BaseTableColumnTask {
try { try {
while(true) { while (true) {
MyRowCallbackHandler rch = new MyRowCallbackHandler(); MyRowCallbackHandler rch = new MyRowCallbackHandler();
getTxTemplate().execute(t -> { getTxTemplate().execute(t -> {
JdbcTemplate jdbcTemplate = newJdbcTemplate(); JdbcTemplate jdbcTemplate = newJdbcTemplate();

View File

@ -48,6 +48,13 @@ public class RemoteTerminologyServiceValidationSupport extends BaseValidationSup
@Override @Override
public CodeValidationResult validateCodeInValueSet(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, @Nonnull IBaseResource theValueSet) { public CodeValidationResult validateCodeInValueSet(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theOptions, String theCodeSystem, String theCode, String theDisplay, @Nonnull IBaseResource theValueSet) {
if (theOptions != null) {
if (theOptions.isInferSystem()) {
return null;
}
}
IBaseResource valueSet = theValueSet; IBaseResource valueSet = theValueSet;
String valueSetUrl = DefaultProfileValidationSupport.getConformanceResourceUrl(myCtx, valueSet); String valueSetUrl = DefaultProfileValidationSupport.getConformanceResourceUrl(myCtx, valueSet);
if (isNotBlank(valueSetUrl)) { if (isNotBlank(valueSetUrl)) {

View File

@ -1,6 +1,7 @@
package org.hl7.fhir.common.hapi.validation.support; package org.hl7.fhir.common.hapi.validation.support;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.support.ConceptValidationOptions;
import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.IValidationSupport;
import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Operation; import ca.uhn.fhir.rest.annotation.Operation;
@ -132,7 +133,7 @@ public class RemoteTerminologyServiceValidationSupportTest {
ValueSet valueSet = new ValueSet(); ValueSet valueSet = new ValueSet();
valueSet.setUrl(VALUE_SET_URL); valueSet.setUrl(VALUE_SET_URL);
IValidationSupport.CodeValidationResult outcome = mySvc.validateCodeInValueSet(null, null, CODE_SYSTEM, CODE, DISPLAY, valueSet); IValidationSupport.CodeValidationResult outcome = mySvc.validateCodeInValueSet(null, new ConceptValidationOptions(), CODE_SYSTEM, CODE, DISPLAY, valueSet);
assertEquals(CODE, outcome.getCode()); assertEquals(CODE, outcome.getCode());
assertEquals(DISPLAY, outcome.getDisplay()); assertEquals(DISPLAY, outcome.getDisplay());
assertEquals(null, outcome.getSeverity()); assertEquals(null, outcome.getSeverity());
@ -145,6 +146,20 @@ public class RemoteTerminologyServiceValidationSupportTest {
assertEquals(null, myValueSetProvider.myLastValueSet); assertEquals(null, myValueSetProvider.myLastValueSet);
} }
/**
* Remote terminology services shouldn't be used to validatre codes with an implied system
*/
@Test
public void testValidateCodeInValueSet_InferSystem() {
createNextValueSetReturnParameters(true, DISPLAY, null);
ValueSet valueSet = new ValueSet();
valueSet.setUrl(VALUE_SET_URL);
IValidationSupport.CodeValidationResult outcome = mySvc.validateCodeInValueSet(null, new ConceptValidationOptions().setInferSystem(true), null, CODE, DISPLAY, valueSet);
assertEquals(null, outcome);
}
@Test @Test
public void testIsValueSetSupported_False() { public void testIsValueSetSupported_False() {
myValueSetProvider.myNextReturnValueSets = new ArrayList<>(); myValueSetProvider.myNextReturnValueSets = new ArrayList<>();