From dc3443665cebadb957d29caa0a7c8ea9a26bc9f3 Mon Sep 17 00:00:00 2001 From: ianmarshall Date: Tue, 29 Sep 2020 21:12:27 -0400 Subject: [PATCH] Changes per code review. --- .../2081-multiple-version-code-systems.yaml | 3 +- .../fhir/jpa/api/model/TranslationQuery.java | 2 - .../fhir/jpa/dao/data/ITermConceptMapDao.java | 5 +- .../fhir/jpa/dao/data/ITermValueSetDao.java | 1 + .../dao/predicate/PredicateBuilderToken.java | 22 +++--- .../ca/uhn/fhir/jpa/entity/TermConcept.java | 1 - .../fhir/jpa/term/BaseTermReadSvcImpl.java | 76 +++++++++---------- .../uhn/fhir/jpa/term/TermReadSvcDstu2.java | 25 +++--- .../uhn/fhir/jpa/term/TermReadSvcDstu3.java | 9 --- .../uhn/fhir/jpa/term/api/ITermReadSvc.java | 15 ++-- .../java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java | 6 +- .../FhirResourceDaoDstu3ConceptMapTest.java | 6 +- .../r4/FhirResourceDaoR4ConceptMapTest.java | 6 +- .../jpa/term/TerminologySvcImplDstu3Test.java | 6 +- .../jpa/term/TerminologySvcImplR4Test.java | 4 +- ...oryTerminologyServerValidationSupport.java | 44 +++++------ 16 files changed, 108 insertions(+), 123 deletions(-) diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_2_0/2081-multiple-version-code-systems.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_2_0/2081-multiple-version-code-systems.yaml index d2b2f92e3b7..0c5f644c8a1 100644 --- a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_2_0/2081-multiple-version-code-systems.yaml +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_2_0/2081-multiple-version-code-systems.yaml @@ -1,5 +1,4 @@ --- type: add issue: 2081 -title: "Terminology loader for LOINC and operations for CodeSystem, ValueSet and ConcepMap will now support - multiple CodeSystem versions." +title: "Operations for CodeSystem, ValueSet and ConcepMap will now support multiple CodeSystem versions." diff --git a/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/model/TranslationQuery.java b/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/model/TranslationQuery.java index 06bfd9cd07a..04e51dd9039 100644 --- a/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/model/TranslationQuery.java +++ b/hapi-fhir-jpaserver-api/src/main/java/ca/uhn/fhir/jpa/api/model/TranslationQuery.java @@ -61,7 +61,6 @@ public class TranslationQuery { myResourceId = theResourceId; } - //-- url public boolean hasUrl() { return myUrl != null && myUrl.hasValue(); } @@ -74,7 +73,6 @@ public class TranslationQuery { myUrl = theUrl; } - //-- ConceptMapVersion public boolean hasConceptMapVersion() { return myConceptMapVersion != null && myConceptMapVersion.hasValue(); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermConceptMapDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermConceptMapDao.java index a7716ebafe0..f4109f94e96 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermConceptMapDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermConceptMapDao.java @@ -46,9 +46,10 @@ public interface ITermConceptMapDao extends JpaRepository @Query("SELECT cm FROM TermConceptMap cm WHERE cm.myUrl = :url and cm.myVersion is null") Optional findTermConceptMapByUrlAndNullVersion(@Param("url") String theUrl); - + + // Note that last updated version is considered current version. @Query(value="SELECT cm FROM TermConceptMap cm INNER JOIN ResourceTable r ON r.myId = cm.myResourcePid WHERE cm.myUrl = :url ORDER BY r.myUpdated DESC") - List getTermConceptMapEntitiesByUrlOrderByVersion(Pageable thePage, @Param("url") String theUrl); + List getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(Pageable thePage, @Param("url") String theUrl); @Query("SELECT cm FROM TermConceptMap cm WHERE cm.myUrl = :url AND cm.myVersion = :version") Optional findTermConceptMapByUrlAndVersion(@Param("url") String theUrl, @Param("version") String theVersion); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermValueSetDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermValueSetDao.java index bc698dc8b3b..3046ac6a244 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermValueSetDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermValueSetDao.java @@ -36,6 +36,7 @@ public interface ITermValueSetDao extends JpaRepository { @Query("SELECT vs FROM TermValueSet vs WHERE vs.myResourcePid = :resource_pid") Optional findByResourcePid(@Param("resource_pid") Long theResourcePid); + // Keeping for backwards compatibility but recommend using findTermValueSetByUrlAndNullVersion instead. @Deprecated @Query("SELECT vs FROM TermValueSet vs WHERE vs.myUrl = :url") Optional findByUrl(@Param("url") String theUrl); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderToken.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderToken.java index a58f739e1fa..9606694f68d 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderToken.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/predicate/PredicateBuilderToken.java @@ -39,7 +39,7 @@ import ca.uhn.fhir.rest.param.TokenParam; import ca.uhn.fhir.rest.param.TokenParamModifier; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException; -import ca.uhn.fhir.util.VersionIndependentConcept; +import ca.uhn.fhir.util.FhirVersionIndependentConcept; import com.google.common.collect.Sets; import org.hibernate.query.criteria.internal.CriteriaBuilderImpl; import org.hibernate.query.criteria.internal.predicate.BooleanStaticAssertionPredicate; @@ -160,7 +160,7 @@ class PredicateBuilderToken extends BasePredicateBuilder implements IPredicateBu From theFrom, SearchFilterParser.CompareOperation operation, RequestPartitionId theRequestPartitionId) { - final List codes = new ArrayList<>(); + final List codes = new ArrayList<>(); String paramName = theSearchParam.getName(); TokenParamModifier modifier = null; @@ -214,12 +214,12 @@ class PredicateBuilderToken extends BasePredicateBuilder implements IPredicateBu validateHaveSystemAndCodeForToken(paramName, code, system); codes.addAll(myTerminologySvc.findCodesBelow(system, code)); } else { - codes.add(new VersionIndependentConcept(system, code)); + codes.add(new FhirVersionIndependentConcept(system, code)); } } - List sortedCodesList = codes + List sortedCodesList = codes .stream() .filter(t -> t.getCode() != null || t.getSystem() != null) .sorted() @@ -234,19 +234,19 @@ class PredicateBuilderToken extends BasePredicateBuilder implements IPredicateBu List retVal = new ArrayList<>(); // System only - List systemOnlyCodes = sortedCodesList.stream().filter(t -> isBlank(t.getCode())).collect(Collectors.toList()); + List systemOnlyCodes = sortedCodesList.stream().filter(t -> isBlank(t.getCode())).collect(Collectors.toList()); if (!systemOnlyCodes.isEmpty()) { retVal.add(addPredicate(theResourceName, paramName, theBuilder, theFrom, systemOnlyCodes, modifier, SearchBuilderTokenModeEnum.SYSTEM_ONLY, theRequestPartitionId)); } // Code only - List codeOnlyCodes = sortedCodesList.stream().filter(t -> t.getSystem() == null).collect(Collectors.toList()); + List codeOnlyCodes = sortedCodesList.stream().filter(t -> t.getSystem() == null).collect(Collectors.toList()); if (!codeOnlyCodes.isEmpty()) { retVal.add(addPredicate(theResourceName, paramName, theBuilder, theFrom, codeOnlyCodes, modifier, SearchBuilderTokenModeEnum.VALUE_ONLY, theRequestPartitionId)); } // System and code - List systemAndCodeCodes = sortedCodesList.stream().filter(t -> isNotBlank(t.getCode()) && t.getSystem() != null).collect(Collectors.toList()); + List systemAndCodeCodes = sortedCodesList.stream().filter(t -> isNotBlank(t.getCode()) && t.getSystem() != null).collect(Collectors.toList()); if (!systemAndCodeCodes.isEmpty()) { retVal.add(addPredicate(theResourceName, paramName, theBuilder, theFrom, systemAndCodeCodes, modifier, SearchBuilderTokenModeEnum.SYSTEM_AND_VALUE, theRequestPartitionId)); } @@ -272,8 +272,8 @@ class PredicateBuilderToken extends BasePredicateBuilder implements IPredicateBu String valueSet = valueSetUris.iterator().next(); ValueSetExpansionOptions options = new ValueSetExpansionOptions() .setFailOnMissingCodeSystem(false); - List candidateCodes = myTerminologySvc.expandValueSet(options, valueSet); - for (VersionIndependentConcept nextCandidate : candidateCodes) { + List candidateCodes = myTerminologySvc.expandValueSet(options, valueSet); + for (FhirVersionIndependentConcept nextCandidate : candidateCodes) { if (nextCandidate.getCode().equals(code)) { retVal = nextCandidate.getSystem(); break; @@ -298,7 +298,7 @@ class PredicateBuilderToken extends BasePredicateBuilder implements IPredicateBu } } - private Predicate addPredicate(String theResourceName, String theParamName, CriteriaBuilder theBuilder, From theFrom, List theTokens, TokenParamModifier theModifier, SearchBuilderTokenModeEnum theTokenMode, RequestPartitionId theRequestPartitionId) { + private Predicate addPredicate(String theResourceName, String theParamName, CriteriaBuilder theBuilder, From theFrom, List theTokens, TokenParamModifier theModifier, SearchBuilderTokenModeEnum theTokenMode, RequestPartitionId theRequestPartitionId) { if (myDontUseHashesForSearch) { final Path systemExpression = theFrom.get("mySystem"); final Path valueExpression = theFrom.get("myValue"); @@ -317,7 +317,7 @@ class PredicateBuilderToken extends BasePredicateBuilder implements IPredicateBu orPredicates.add(orPredicate); break; case SYSTEM_AND_VALUE: - for (VersionIndependentConcept next : theTokens) { + for (FhirVersionIndependentConcept next : theTokens) { orPredicates.add(theBuilder.and( toEqualOrIsNullPredicate(systemExpression, next.getSystem()), toEqualOrIsNullPredicate(valueExpression, next.getCode()) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermConcept.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermConcept.java index 753b56b9b4f..176f77a2740 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermConcept.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermConcept.java @@ -23,7 +23,6 @@ package ca.uhn.fhir.jpa.entity; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.jpa.entity.TermConceptParentChildLink.RelationshipTypeEnum; import ca.uhn.fhir.jpa.search.DeferConceptIndexingInterceptor; -import ca.uhn.fhir.util.VersionIndependentConcept; import ca.uhn.fhir.util.ValidateUtil; import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.builder.EqualsBuilder; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java index 85e9afc540c..30553cb86a2 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/BaseTermReadSvcImpl.java @@ -84,7 +84,7 @@ import ca.uhn.fhir.util.CoverageIgnore; import ca.uhn.fhir.util.StopWatch; import ca.uhn.fhir.util.UrlUtil; import ca.uhn.fhir.util.ValidateUtil; -import ca.uhn.fhir.util.VersionIndependentConcept; +import ca.uhn.fhir.util.FhirVersionIndependentConcept; import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; import com.google.common.annotations.VisibleForTesting; @@ -301,7 +301,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { } } - private void addConceptsToList(IValueSetConceptAccumulator theValueSetCodeAccumulator, Set theAddedCodes, String theSystem, List theConcept, boolean theAdd, VersionIndependentConcept theWantConceptOrNull) { + private void addConceptsToList(IValueSetConceptAccumulator theValueSetCodeAccumulator, Set theAddedCodes, String theSystem, List theConcept, boolean theAdd, FhirVersionIndependentConcept theWantConceptOrNull) { for (CodeSystem.ConceptDefinitionComponent next : theConcept) { if (isNoneBlank(theSystem, next.getCode())) { if (theWantConceptOrNull == null || theWantConceptOrNull.getCode().equals(next.getCode())) { @@ -388,7 +388,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { deleteValueSetForResource(theResourceTable); } - private ValueSet expandValueSetInMemory(ValueSetExpansionOptions theExpansionOptions, ValueSet theValueSetToExpand, VersionIndependentConcept theWantConceptOrNull) { + private ValueSet expandValueSetInMemory(ValueSetExpansionOptions theExpansionOptions, ValueSet theValueSetToExpand, FhirVersionIndependentConcept theWantConceptOrNull) { int maxCapacity = myDaoConfig.getMaximumExpansionSize(); ValueSetExpansionComponentWithConceptAccumulator expansionComponent = new ValueSetExpansionComponentWithConceptAccumulator(myContext, maxCapacity); @@ -409,7 +409,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { } @Override - public List expandValueSet(ValueSetExpansionOptions theExpansionOptions, String theValueSet) { + public List expandValueSet(ValueSetExpansionOptions theExpansionOptions, String theValueSet) { // TODO: DM 2019-09-10 - This is problematic because an incorrect URL that matches ValueSet.id will not be found in the terminology tables but will yield a ValueSet here. Depending on the ValueSet, the expansion may time-out. ValueSet valueSet = fetchCanonicalValueSetFromCompleteContext(theValueSet); @@ -554,7 +554,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { } @SuppressWarnings("ConstantConditions") - private void expandValueSet(ValueSetExpansionOptions theExpansionOptions, ValueSet theValueSetToExpand, IValueSetConceptAccumulator theValueSetCodeAccumulator, AtomicInteger theCodeCounter, VersionIndependentConcept theWantConceptOrNull) { + private void expandValueSet(ValueSetExpansionOptions theExpansionOptions, ValueSet theValueSetToExpand, IValueSetConceptAccumulator theValueSetCodeAccumulator, AtomicInteger theCodeCounter, FhirVersionIndependentConcept theWantConceptOrNull) { Set addedCodes = new HashSet<>(); StopWatch sw = new StopWatch(); @@ -640,12 +640,12 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { return sb.toString(); } - protected List expandValueSetAndReturnVersionIndependentConcepts(ValueSetExpansionOptions theExpansionOptions, ValueSet theValueSetToExpandR4, VersionIndependentConcept theWantConceptOrNull) { + protected List expandValueSetAndReturnVersionIndependentConcepts(ValueSetExpansionOptions theExpansionOptions, ValueSet theValueSetToExpandR4, FhirVersionIndependentConcept theWantConceptOrNull) { org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent expandedR4 = expandValueSetInMemory(theExpansionOptions, theValueSetToExpandR4, theWantConceptOrNull).getExpansion(); - ArrayList retVal = new ArrayList<>(); + ArrayList retVal = new ArrayList<>(); for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent nextContains : expandedR4.getContains()) { - retVal.add(new VersionIndependentConcept(nextContains.getSystem(), nextContains.getCode(), nextContains.getDisplay(), nextContains.getVersion())); + retVal.add(new FhirVersionIndependentConcept(nextContains.getSystem(), nextContains.getCode(), nextContains.getDisplay(), nextContains.getVersion())); } return retVal; } @@ -653,7 +653,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { /** * @return Returns true if there are potentially more results to process. */ - private Boolean expandValueSetHandleIncludeOrExclude(@Nullable ValueSetExpansionOptions theExpansionOptions, IValueSetConceptAccumulator theValueSetCodeAccumulator, Set theAddedCodes, ValueSet.ConceptSetComponent theIncludeOrExclude, boolean theAdd, AtomicInteger theCodeCounter, int theQueryIndex, VersionIndependentConcept theWantConceptOrNull) { + private Boolean expandValueSetHandleIncludeOrExclude(@Nullable ValueSetExpansionOptions theExpansionOptions, IValueSetConceptAccumulator theValueSetCodeAccumulator, Set theAddedCodes, ValueSet.ConceptSetComponent theIncludeOrExclude, boolean theAdd, AtomicInteger theCodeCounter, int theQueryIndex, FhirVersionIndependentConcept theWantConceptOrNull) { String system = theIncludeOrExclude.getSystem(); boolean hasSystem = isNotBlank(system); @@ -691,7 +691,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { // just in case there is a registered service that knows how to handle this. This can happen, for example, // if someone creates a valueset that includes UCUM codes, since we don't have a CodeSystem resource for those // but CommonCodeSystemsTerminologyService can validate individual codes. - List includedConcepts = null; + List includedConcepts = null; if (theWantConceptOrNull != null) { includedConcepts = new ArrayList<>(); includedConcepts.add(theWantConceptOrNull); @@ -699,13 +699,13 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { includedConcepts = theIncludeOrExclude .getConcept() .stream() - .map(t -> new VersionIndependentConcept(theIncludeOrExclude.getSystem(), t.getCode())) + .map(t -> new FhirVersionIndependentConcept(theIncludeOrExclude.getSystem(), t.getCode())) .collect(Collectors.toList()); } if (includedConcepts != null) { int foundCount = 0; - for (VersionIndependentConcept next : includedConcepts) { + for (FhirVersionIndependentConcept next : includedConcepts) { String nextSystem = next.getSystem(); if (nextSystem == null) { nextSystem = system; @@ -763,10 +763,10 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { for (CanonicalType nextValueSet : theIncludeOrExclude.getValueSet()) { ourLog.debug("Starting {} expansion around ValueSet: {}", (theAdd ? "inclusion" : "exclusion"), nextValueSet.getValueAsString()); - List expanded = expandValueSet(theExpansionOptions, nextValueSet.getValueAsString()); + List expanded = expandValueSet(theExpansionOptions, nextValueSet.getValueAsString()); Map uriToCodeSystem = new HashMap<>(); - for (VersionIndependentConcept nextConcept : expanded) { + for (FhirVersionIndependentConcept nextConcept : expanded) { if (theAdd) { if (!uriToCodeSystem.containsKey(nextConcept.getSystem())) { @@ -811,7 +811,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { } @Nonnull - private Boolean expandValueSetHandleIncludeOrExcludeUsingDatabase(IValueSetConceptAccumulator theValueSetCodeAccumulator, Set theAddedCodes, ValueSet.ConceptSetComponent theIncludeOrExclude, boolean theAdd, AtomicInteger theCodeCounter, int theQueryIndex, VersionIndependentConcept theWantConceptOrNull, String theSystem, TermCodeSystem theCs) { + private Boolean expandValueSetHandleIncludeOrExcludeUsingDatabase(IValueSetConceptAccumulator theValueSetCodeAccumulator, Set theAddedCodes, ValueSet.ConceptSetComponent theIncludeOrExclude, boolean theAdd, AtomicInteger theCodeCounter, int theQueryIndex, FhirVersionIndependentConcept theWantConceptOrNull, String theSystem, TermCodeSystem theCs) { String codeSystemVersion = theIncludeOrExclude.getVersion(); TermCodeSystemVersion csv; if (isEmpty(codeSystemVersion)) { @@ -1507,7 +1507,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { @Transactional @Override - public List findCodesAbove(String theSystem, String theCode) { + public List findCodesAbove(String theSystem, String theCode) { TermCodeSystem cs = getCodeSystem(theSystem); if (cs == null) { return findCodesAboveUsingBuiltInSystems(theSystem, theCode); @@ -1539,7 +1539,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { @Transactional @Override - public List findCodesBelow(String theSystem, String theCode) { + public List findCodesBelow(String theSystem, String theCode) { TermCodeSystem cs = getCodeSystem(theSystem); if (cs == null) { return findCodesBelowUsingBuiltInSystems(theSystem, theCode); @@ -1939,8 +1939,8 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { @Transactional public IFhirResourceDaoCodeSystem.SubsumesResult subsumes(IPrimitiveType theCodeA, IPrimitiveType theCodeB, IPrimitiveType theSystem, IBaseCoding theCodingA, IBaseCoding theCodingB) { - VersionIndependentConcept conceptA = toConcept(theCodeA, theSystem, theCodingA); - VersionIndependentConcept conceptB = toConcept(theCodeB, theSystem, theCodingB); + FhirVersionIndependentConcept conceptA = toConcept(theCodeA, theSystem, theCodingA); + FhirVersionIndependentConcept conceptB = toConcept(theCodeB, theSystem, theCodingB); if (!StringUtils.equals(conceptA.getSystem(), conceptB.getSystem())) { throw new InvalidRequestException("Unable to test subsumption across different code systems"); @@ -2044,10 +2044,10 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { return null; } - private ArrayList toVersionIndependentConcepts(String theSystem, Set codes) { - ArrayList retVal = new ArrayList<>(codes.size()); + private ArrayList toVersionIndependentConcepts(String theSystem, Set codes) { + ArrayList retVal = new ArrayList<>(codes.size()); for (TermConcept next : codes) { - retVal.add(new VersionIndependentConcept(theSystem, next.getCode())); + retVal.add(new FhirVersionIndependentConcept(theSystem, next.getCode())); } return retVal; } @@ -2291,7 +2291,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { private String getLatestConceptMapVersion(TranslationRequest theTranslationRequest) { Pageable page = PageRequest.of(0, 1); - List theConceptMapList = myConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, + List theConceptMapList = myConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, theTranslationRequest.getUrl().asStringValue()); if (!theConceptMapList.isEmpty()) { return theConceptMapList.get(0).getVersion(); @@ -2324,10 +2324,10 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { TransactionTemplate txTemplate = new TransactionTemplate(myTransactionManager); txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); - Optional codeOpt = txTemplate.execute(t -> findCode(theCodeSystem, theCode).map(c -> new VersionIndependentConcept(theCodeSystem, c.getCode()))); + Optional codeOpt = txTemplate.execute(t -> findCode(theCodeSystem, theCode).map(c -> new FhirVersionIndependentConcept(theCodeSystem, c.getCode()))); if (codeOpt != null && codeOpt.isPresent()) { - VersionIndependentConcept code = codeOpt.get(); + FhirVersionIndependentConcept code = codeOpt.get(); if (!theOptions.isValidateDisplay() || (isNotBlank(code.getDisplay()) && isNotBlank(theDisplay) && code.getDisplay().equals(theDisplay))) { return new CodeValidationResult() .setCode(code.getCode()) @@ -2429,7 +2429,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { return myContext; } - private void findCodesAbove(CodeSystem theSystem, String theSystemString, String theCode, List theListToPopulate) { + private void findCodesAbove(CodeSystem theSystem, String theSystemString, String theCode, List theListToPopulate) { List conceptList = theSystem.getConcept(); for (CodeSystem.ConceptDefinitionComponent next : conceptList) { addTreeIfItContainsCode(theSystemString, next, theCode, theListToPopulate); @@ -2437,8 +2437,8 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { } @Override - public List findCodesAboveUsingBuiltInSystems(String theSystem, String theCode) { - ArrayList retVal = new ArrayList<>(); + public List findCodesAboveUsingBuiltInSystems(String theSystem, String theCode) { + ArrayList retVal = new ArrayList<>(); CodeSystem system = fetchCanonicalCodeSystemFromCompleteContext(theSystem); if (system != null) { findCodesAbove(system, theSystem, theCode, retVal); @@ -2446,12 +2446,12 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { return retVal; } - private void findCodesBelow(CodeSystem theSystem, String theSystemString, String theCode, List theListToPopulate) { + private void findCodesBelow(CodeSystem theSystem, String theSystemString, String theCode, List theListToPopulate) { List conceptList = theSystem.getConcept(); findCodesBelow(theSystemString, theCode, theListToPopulate, conceptList); } - private void findCodesBelow(String theSystemString, String theCode, List theListToPopulate, List conceptList) { + private void findCodesBelow(String theSystemString, String theCode, List theListToPopulate, List conceptList) { for (CodeSystem.ConceptDefinitionComponent next : conceptList) { if (theCode.equals(next.getCode())) { addAllChildren(theSystemString, next, theListToPopulate); @@ -2462,8 +2462,8 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { } @Override - public List findCodesBelowUsingBuiltInSystems(String theSystem, String theCode) { - ArrayList retVal = new ArrayList<>(); + public List findCodesBelowUsingBuiltInSystems(String theSystem, String theCode) { + ArrayList retVal = new ArrayList<>(); CodeSystem system = fetchCanonicalCodeSystemFromCompleteContext(theSystem); if (system != null) { findCodesBelow(system, theSystem, theCode, retVal); @@ -2471,23 +2471,23 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { return retVal; } - private void addAllChildren(String theSystemString, CodeSystem.ConceptDefinitionComponent theCode, List theListToPopulate) { + private void addAllChildren(String theSystemString, CodeSystem.ConceptDefinitionComponent theCode, List theListToPopulate) { if (isNotBlank(theCode.getCode())) { - theListToPopulate.add(new VersionIndependentConcept(theSystemString, theCode.getCode())); + theListToPopulate.add(new FhirVersionIndependentConcept(theSystemString, theCode.getCode())); } for (CodeSystem.ConceptDefinitionComponent nextChild : theCode.getConcept()) { addAllChildren(theSystemString, nextChild, theListToPopulate); } } - private boolean addTreeIfItContainsCode(String theSystemString, CodeSystem.ConceptDefinitionComponent theNext, String theCode, List theListToPopulate) { + private boolean addTreeIfItContainsCode(String theSystemString, CodeSystem.ConceptDefinitionComponent theNext, String theCode, List theListToPopulate) { boolean foundCodeInChild = false; for (CodeSystem.ConceptDefinitionComponent nextChild : theNext.getConcept()) { foundCodeInChild |= addTreeIfItContainsCode(theSystemString, nextChild, theCode, theListToPopulate); } if (theCode.equals(theNext.getCode()) || foundCodeInChild) { - theListToPopulate.add(new VersionIndependentConcept(theSystemString, theNext.getCode())); + theListToPopulate.add(new FhirVersionIndependentConcept(theSystemString, theNext.getCode())); return true; } @@ -2591,7 +2591,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { } @NotNull - private VersionIndependentConcept toConcept(IPrimitiveType theCodeType, IPrimitiveType theCodeSystemIdentifierType, IBaseCoding theCodingType) { + private FhirVersionIndependentConcept toConcept(IPrimitiveType theCodeType, IPrimitiveType theCodeSystemIdentifierType, IBaseCoding theCodingType) { String code = theCodeType != null ? theCodeType.getValueAsString() : null; String system = theCodeSystemIdentifierType != null ? getUrlFromIdentifier(theCodeSystemIdentifierType.getValueAsString()): null; String systemVersion = theCodeSystemIdentifierType != null ? getVersionFromIdentifier(theCodeSystemIdentifierType.getValueAsString()): null; @@ -2601,7 +2601,7 @@ public abstract class BaseTermReadSvcImpl implements ITermReadSvc { system = canonicalizedCoding.getSystem(); systemVersion = canonicalizedCoding.getVersion(); } - return new VersionIndependentConcept(system, code, null, systemVersion); + return new FhirVersionIndependentConcept(system, code, null, systemVersion); } /** diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu2.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu2.java index e0f0ef269b5..8cc707f8b22 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu2.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu2.java @@ -26,7 +26,7 @@ import ca.uhn.fhir.context.support.ValueSetExpansionOptions; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt; import ca.uhn.fhir.model.dstu2.composite.CodingDt; -import ca.uhn.fhir.util.VersionIndependentConcept; +import ca.uhn.fhir.util.FhirVersionIndependentConcept; import org.hl7.fhir.instance.model.api.IBaseCoding; import org.hl7.fhir.instance.model.api.IBaseDatatype; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -34,7 +34,6 @@ import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.Coding; import org.hl7.fhir.r4.model.ValueSet; -import org.hl7.fhir.utilities.validation.ValidationOptions; import org.springframework.beans.factory.annotation.Autowired; import javax.annotation.Nullable; @@ -48,23 +47,23 @@ public class TermReadSvcDstu2 extends BaseTermReadSvcImpl { @Autowired private IValidationSupport myValidationSupport; - private void addAllChildren(String theSystemString, org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent theCode, List theListToPopulate) { + private void addAllChildren(String theSystemString, org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent theCode, List theListToPopulate) { if (isNotBlank(theCode.getCode())) { - theListToPopulate.add(new VersionIndependentConcept(theSystemString, theCode.getCode())); + theListToPopulate.add(new FhirVersionIndependentConcept(theSystemString, theCode.getCode())); } for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent nextChild : theCode.getConcept()) { addAllChildren(theSystemString, nextChild, theListToPopulate); } } - private boolean addTreeIfItContainsCode(String theSystemString, org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent theNext, String theCode, List theListToPopulate) { + private boolean addTreeIfItContainsCode(String theSystemString, org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent theNext, String theCode, List theListToPopulate) { boolean foundCodeInChild = false; for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent nextChild : theNext.getConcept()) { foundCodeInChild |= addTreeIfItContainsCode(theSystemString, nextChild, theCode, theListToPopulate); } if (theCode.equals(theNext.getCode()) || foundCodeInChild) { - theListToPopulate.add(new VersionIndependentConcept(theSystemString, theNext.getCode())); + theListToPopulate.add(new FhirVersionIndependentConcept(theSystemString, theNext.getCode())); return true; } @@ -96,7 +95,7 @@ public class TermReadSvcDstu2 extends BaseTermReadSvcImpl { throw new UnsupportedOperationException(); } - private void findCodesAbove(org.hl7.fhir.dstu2.model.ValueSet theSystem, String theSystemString, String theCode, List theListToPopulate) { + private void findCodesAbove(org.hl7.fhir.dstu2.model.ValueSet theSystem, String theSystemString, String theCode, List theListToPopulate) { List conceptList = theSystem.getCodeSystem().getConcept(); for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent next : conceptList) { addTreeIfItContainsCode(theSystemString, next, theCode, theListToPopulate); @@ -104,8 +103,8 @@ public class TermReadSvcDstu2 extends BaseTermReadSvcImpl { } @Override - public List findCodesAboveUsingBuiltInSystems(String theSystem, String theCode) { - ArrayList retVal = new ArrayList<>(); + public List findCodesAboveUsingBuiltInSystems(String theSystem, String theCode) { + ArrayList retVal = new ArrayList<>(); org.hl7.fhir.dstu2.model.ValueSet system = (org.hl7.fhir.dstu2.model.ValueSet) myValidationSupport.fetchCodeSystem(theSystem); if (system != null) { findCodesAbove(system, theSystem, theCode, retVal); @@ -113,12 +112,12 @@ public class TermReadSvcDstu2 extends BaseTermReadSvcImpl { return retVal; } - private void findCodesBelow(org.hl7.fhir.dstu2.model.ValueSet theSystem, String theSystemString, String theCode, List theListToPopulate) { + private void findCodesBelow(org.hl7.fhir.dstu2.model.ValueSet theSystem, String theSystemString, String theCode, List theListToPopulate) { List conceptList = theSystem.getCodeSystem().getConcept(); findCodesBelow(theSystemString, theCode, theListToPopulate, conceptList); } - private void findCodesBelow(String theSystemString, String theCode, List theListToPopulate, List conceptList) { + private void findCodesBelow(String theSystemString, String theCode, List theListToPopulate, List conceptList) { for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent next : conceptList) { if (theCode.equals(next.getCode())) { addAllChildren(theSystemString, next, theListToPopulate); @@ -129,8 +128,8 @@ public class TermReadSvcDstu2 extends BaseTermReadSvcImpl { } @Override - public List findCodesBelowUsingBuiltInSystems(String theSystem, String theCode) { - ArrayList retVal = new ArrayList<>(); + public List findCodesBelowUsingBuiltInSystems(String theSystem, String theCode) { + ArrayList retVal = new ArrayList<>(); org.hl7.fhir.dstu2.model.ValueSet system = (org.hl7.fhir.dstu2.model.ValueSet) myValidationSupport.fetchCodeSystem(theSystem); if (system != null) { findCodesBelow(system, theSystem, theCode, retVal); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu3.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu3.java index 4ab16d142d9..33d7355b441 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu3.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReadSvcDstu3.java @@ -5,15 +5,11 @@ import ca.uhn.fhir.context.support.ConceptValidationOptions; import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.context.support.ValueSetExpansionOptions; -import ca.uhn.fhir.jpa.api.dao.IFhirResourceDaoValueSet; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.api.ITermReadSvcDstu3; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; -import ca.uhn.fhir.util.CoverageIgnore; import ca.uhn.fhir.util.ValidateUtil; -import ca.uhn.fhir.util.VersionIndependentConcept; import org.hl7.fhir.convertors.VersionConvertor_30_40; -import org.hl7.fhir.convertors.VersionConvertor_40_50; import org.hl7.fhir.convertors.conv30_40.CodeSystem30_40; import org.hl7.fhir.dstu3.model.CodeSystem; import org.hl7.fhir.dstu3.model.CodeableConcept; @@ -23,16 +19,11 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IBaseCoding; import org.hl7.fhir.instance.model.api.IBaseDatatype; import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.utilities.validation.ValidationOptions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.support.TransactionTemplate; import javax.annotation.Nullable; -import java.util.Optional; -import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.hl7.fhir.convertors.conv30_40.ValueSet30_40.convertValueSet; /* diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/api/ITermReadSvc.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/api/ITermReadSvc.java index b945f337a63..465e7f562b5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/api/ITermReadSvc.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/api/ITermReadSvc.java @@ -10,9 +10,7 @@ import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElement; import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElementTarget; import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.term.IValueSetConceptAccumulator; -import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt; -import ca.uhn.fhir.model.dstu2.composite.CodingDt; -import ca.uhn.fhir.util.VersionIndependentConcept; +import ca.uhn.fhir.util.FhirVersionIndependentConcept; import org.hl7.fhir.instance.model.api.IBaseCoding; import org.hl7.fhir.instance.model.api.IBaseDatatype; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -21,7 +19,6 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.ConceptMap; import org.hl7.fhir.r4.model.ValueSet; -import org.hl7.fhir.utilities.validation.ValidationOptions; import javax.annotation.Nullable; import java.util.List; @@ -71,21 +68,21 @@ public interface ITermReadSvc extends IValidationSupport { void expandValueSet(@Nullable ValueSetExpansionOptions theExpansionOptions, IBaseResource theValueSetToExpand, IValueSetConceptAccumulator theValueSetCodeAccumulator); - List expandValueSet(ValueSetExpansionOptions theExpansionOptions, String theValueSet); + List expandValueSet(ValueSetExpansionOptions theExpansionOptions, String theValueSet); Optional findCode(String theCodeSystem, String theCode); Set findCodesAbove(Long theCodeSystemResourcePid, Long theCodeSystemResourceVersionPid, String theCode); - List findCodesAbove(String theSystem, String theCode); + List findCodesAbove(String theSystem, String theCode); - List findCodesAboveUsingBuiltInSystems(String theSystem, String theCode); + List findCodesAboveUsingBuiltInSystems(String theSystem, String theCode); Set findCodesBelow(Long theCodeSystemResourcePid, Long theCodeSystemResourceVersionPid, String theCode); - List findCodesBelow(String theSystem, String theCode); + List findCodesBelow(String theSystem, String theCode); - List findCodesBelowUsingBuiltInSystems(String theSystem, String theCode); + List findCodesBelowUsingBuiltInSystems(String theSystem, String theCode); CodeSystem fetchCanonicalCodeSystemFromCompleteContext(String theSystem); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java index b08b4c9ebc6..03d79468ca9 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java @@ -40,7 +40,7 @@ import ca.uhn.fhir.test.utilities.UnregisterScheduledProcessor; import ca.uhn.fhir.util.BundleUtil; import ca.uhn.fhir.util.StopWatch; import ca.uhn.fhir.util.TestUtil; -import ca.uhn.fhir.util.VersionIndependentConcept; +import ca.uhn.fhir.util.FhirVersionIndependentConcept; import org.apache.commons.io.IOUtils; import org.hibernate.HibernateException; import org.hibernate.Session; @@ -507,9 +507,9 @@ public abstract class BaseJpaTest extends BaseTest { return retVal; } - protected static Set toCodes(List theConcepts) { + protected static Set toCodes(List theConcepts) { HashSet retVal = new HashSet<>(); - for (VersionIndependentConcept next : theConcepts) { + for (FhirVersionIndependentConcept next : theConcepts) { retVal.add(next.getCode()); } return retVal; diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ConceptMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ConceptMapTest.java index 7202a38c741..32cee6db0c2 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ConceptMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/dstu3/FhirResourceDaoDstu3ConceptMapTest.java @@ -111,7 +111,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test { public void testConceptMapFindTermConceptMapByUrl() { Pageable page = PageRequest.of(0, 1); - List theExpConceptMapList = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, CM_URL); + List theExpConceptMapList = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL); assertEquals(1, theExpConceptMapList.size()); assertEquals(CM_URL, theExpConceptMapList.get(0).getUrl()); @@ -143,7 +143,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test { // should return the latest one which is v2 Pageable page = PageRequest.of(0, 1); - List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, theUrl); + List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, theUrl); assertEquals(1, theExpSecondOne.size()); assertEquals(theUrl, theExpSecondOne.get(0).getUrl()); @@ -171,7 +171,7 @@ public class FhirResourceDaoDstu3ConceptMapTest extends BaseJpaDstu3Test { // should return the latest one which in this case is not versioned Pageable page = PageRequest.of(0, 1); - List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, theUrl); + List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, theUrl); assertEquals(1, theExpSecondOne.size()); assertEquals(theUrl, theExpSecondOne.get(0).getUrl()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConceptMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConceptMapTest.java index e98ba97bd71..da8fab09060 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConceptMapTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ConceptMapTest.java @@ -1158,7 +1158,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { public void testConceptMapFindTermConceptMapByUrl() { Pageable page = PageRequest.of(0, 1); - List theExpConceptMapList = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, CM_URL); + List theExpConceptMapList = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL); assertEquals(1, theExpConceptMapList.size()); assertEquals(CM_URL, theExpConceptMapList.get(0).getUrl()); @@ -1190,7 +1190,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { // should return the latest one which is v2 Pageable page = PageRequest.of(0, 1); - List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, theUrl); + List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, theUrl); assertEquals(1, theExpSecondOne.size()); assertEquals(theUrl, theExpSecondOne.get(0).getUrl()); @@ -1218,7 +1218,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test { // should return the latest one which is v2 Pageable page = PageRequest.of(0, 1); - List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, theUrl); + List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, theUrl); assertEquals(1, theExpSecondOne.size()); assertEquals(theUrl, theExpSecondOne.get(0).getUrl()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java index ba515681dc3..332d7e42f2f 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplDstu3Test.java @@ -15,7 +15,7 @@ import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.api.server.storage.TransactionDetails; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; -import ca.uhn.fhir.util.VersionIndependentConcept; +import ca.uhn.fhir.util.FhirVersionIndependentConcept; import com.google.common.collect.Lists; import org.apache.commons.lang3.Validate; import org.hl7.fhir.dstu3.model.CodeSystem; @@ -1719,7 +1719,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test { @Test public void testFindCodesAboveBuiltInCodeSystem() { - List concepts; + List concepts; Set codes; concepts = myTermSvc.findCodesAbove("http://hl7.org/fhir/allergy-clinical-status", "active"); @@ -1765,7 +1765,7 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test { @Test public void testFindCodesBelowBuiltInCodeSystem() { - List concepts; + List concepts; Set codes; concepts = myTermSvc.findCodesBelow("http://hl7.org/fhir/allergy-clinical-status", "inactive"); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java index 48f4f4465ff..5fe2a780584 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TerminologySvcImplR4Test.java @@ -322,7 +322,7 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test { @Override protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) { Pageable page = PageRequest.of(0, 1); - List optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, CM_URL); + List optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL); assertEquals(1, optionalConceptMap.size()); TermConceptMap conceptMap = optionalConceptMap.get(0); @@ -501,7 +501,7 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test { @Override protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) { Pageable page = PageRequest.of(0, 1); - List optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByVersion(page, CM_URL); + List optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL); assertEquals(1, optionalConceptMap.size()); TermConceptMap conceptMap = optionalConceptMap.get(0); diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java index d6bad82267d..037e88ffa4c 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java @@ -7,7 +7,7 @@ import ca.uhn.fhir.context.support.IValidationSupport; import ca.uhn.fhir.context.support.ValidationSupportContext; import ca.uhn.fhir.context.support.ValueSetExpansionOptions; import ca.uhn.fhir.parser.IParser; -import ca.uhn.fhir.util.VersionIndependentConcept; +import ca.uhn.fhir.util.FhirVersionIndependentConcept; import org.apache.commons.lang3.Validate; import org.hl7.fhir.convertors.conv10_50.ValueSet10_50; import org.hl7.fhir.convertors.conv30_50.CodeSystem30_50; @@ -217,7 +217,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu codeSystemToValidateResource = theValidationSupportContext.getRootValidationSupport().fetchCodeSystem(theCodeSystemIdentifierToValidate); } - List codesInValueSetExpansion = new ArrayList<>(); + List codes = new ArrayList<>(); switch (theExpansion.getStructureFhirVersionEnum()) { case DSTU2_HL7ORG: { ValueSet expansionVs = (ValueSet) theExpansion; @@ -300,7 +300,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu codeSystemUrlToValidate = theCodeSystemIdentifierToValidate; } } - for (VersionIndependentConcept nextExpansionCode : codesInValueSetExpansion) { + for (FhirVersionIndependentConcept nextExpansionCode : codes) { boolean codeMatches; if (caseSensitive) { @@ -480,7 +480,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu @Nullable private org.hl7.fhir.r5.model.ValueSet expandValueSetR5(ValidationSupportContext theValidationSupportContext, org.hl7.fhir.r5.model.ValueSet theInput, Function theCodeSystemLoader, Function theValueSetLoader, @Nullable String theWantSystemIdentifier, @Nullable String theWantCode) { - Set concepts = new HashSet<>(); + Set concepts = new HashSet<>(); try { expandValueSetR5IncludeOrExclude(theValidationSupportContext, concepts, theCodeSystemLoader, theValueSetLoader, theInput.getCompose().getInclude(), true, theWantSystemIdentifier, theWantCode); @@ -490,7 +490,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu } org.hl7.fhir.r5.model.ValueSet retVal = new org.hl7.fhir.r5.model.ValueSet(); - for (VersionIndependentConcept next : concepts) { + for (FhirVersionIndependentConcept next : concepts) { org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent contains = retVal.getExpansion().addContains(); contains.setSystem(next.getSystem()); contains.setCode(next.getCode()); @@ -501,7 +501,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu return retVal; } - private void expandValueSetR5IncludeOrExclude(ValidationSupportContext theValidationSupportContext, Set theConcepts, Function theCodeSystemLoader, Function theValueSetLoader, List theComposeList, boolean theComposeListIsInclude, @Nullable String theWantSystemIdentifier, @Nullable String theWantCode) throws ExpansionCouldNotBeCompletedInternallyException { + private void expandValueSetR5IncludeOrExclude(ValidationSupportContext theValidationSupportContext, Set theConcepts, Function theCodeSystemLoader, Function theValueSetLoader, List theComposeList, boolean theComposeListIsInclude, @Nullable String theWantSystemIdentifier, @Nullable String theWantCode) throws ExpansionCouldNotBeCompletedInternallyException { String wantSystemUrl = null; String wantSystemVersion = null; if (theWantSystemIdentifier != null) { @@ -516,7 +516,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu for (org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent nextInclude : theComposeList) { - List nextCodeList = new ArrayList<>(); + List nextCodeList = new ArrayList<>(); String includeOrExcludeConceptSystemUrl = nextInclude.getSystem(); String includeOrExcludeConceptSystemVersion = nextInclude.getVersion(); if (isNotBlank(includeOrExcludeConceptSystemUrl)) { @@ -612,7 +612,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu throw new ExpansionCouldNotBeCompletedInternallyException(); } for (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent next : subExpansion.getExpansion().getContains()) { - nextCodeList.add(new VersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay(), next.getVersion())); + nextCodeList.add(new FhirVersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay(), next.getVersion())); } } } @@ -627,11 +627,11 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu } - private void addCodes(String theCodeSystemUrl, String theCodeSystemVersion, List theSource, List theTarget, Set theCodeFilter) { + private void addCodes(String theCodeSystemUrl, String theCodeSystemVersion, List theSource, List theTarget, Set theCodeFilter) { for (CodeSystem.ConceptDefinitionComponent next : theSource) { if (isNotBlank(next.getCode())) { if (theCodeFilter == null || theCodeFilter.contains(next.getCode())) { - theTarget.add(new VersionIndependentConcept(theCodeSystemUrl, next.getCode(), next.getDisplay(), theCodeSystemVersion)); + theTarget.add(new FhirVersionIndependentConcept(theCodeSystemUrl, next.getCode(), next.getDisplay(), theCodeSystemVersion)); } } addCodes(theCodeSystemUrl, theCodeSystemVersion, next.getConcept(), theTarget, theCodeFilter); @@ -642,31 +642,31 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu } - private static void flattenAndConvertCodesDstu2(List theInput, List theVersionIndependentConcepts) { + private static void flattenAndConvertCodesDstu2(List theInput, List theFhirVersionIndependentConcepts) { for (org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent next : theInput) { - theVersionIndependentConcepts.add(new VersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay())); - flattenAndConvertCodesDstu2(next.getContains(), theVersionIndependentConcepts); + theFhirVersionIndependentConcepts.add(new FhirVersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay())); + flattenAndConvertCodesDstu2(next.getContains(), theFhirVersionIndependentConcepts); } } - private static void flattenAndConvertCodesDstu3(List theInput, List theVersionIndependentConcepts) { + private static void flattenAndConvertCodesDstu3(List theInput, List theFhirVersionIndependentConcepts) { for (org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent next : theInput) { - theVersionIndependentConcepts.add(new VersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay(), next.getVersion())); - flattenAndConvertCodesDstu3(next.getContains(), theVersionIndependentConcepts); + theFhirVersionIndependentConcepts.add(new FhirVersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay(), next.getVersion())); + flattenAndConvertCodesDstu3(next.getContains(), theFhirVersionIndependentConcepts); } } - private static void flattenAndConvertCodesR4(List theInput, List theVersionIndependentConcepts) { + private static void flattenAndConvertCodesR4(List theInput, List theFhirVersionIndependentConcepts) { for (org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent next : theInput) { - theVersionIndependentConcepts.add(new VersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay(), next.getVersion())); - flattenAndConvertCodesR4(next.getContains(), theVersionIndependentConcepts); + theFhirVersionIndependentConcepts.add(new FhirVersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay(), next.getVersion())); + flattenAndConvertCodesR4(next.getContains(), theFhirVersionIndependentConcepts); } } - private static void flattenAndConvertCodesR5(List theInput, List theVersionIndependentConcepts) { + private static void flattenAndConvertCodesR5(List theInput, List theFhirVersionIndependentConcepts) { for (org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent next : theInput) { - theVersionIndependentConcepts.add(new VersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay(), next.getVersion())); - flattenAndConvertCodesR5(next.getContains(), theVersionIndependentConcepts); + theFhirVersionIndependentConcepts.add(new FhirVersionIndependentConcept(next.getSystem(), next.getCode(), next.getDisplay(), next.getVersion())); + flattenAndConvertCodesR5(next.getContains(), theFhirVersionIndependentConcepts); } }