ourValueSetDao;
+ @Autowired
+ protected ITermConceptMappingSvc myConceptMappingSvc;
@Autowired
protected IPartitionLookupSvc myPartitionConfigSvc;
@Autowired
@@ -510,8 +514,8 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil
public void afterClearTerminologyCaches() {
BaseTermReadSvcImpl baseHapiTerminologySvc = AopTestUtils.getTargetObject(myTermSvc);
baseHapiTerminologySvc.clearCaches();
- BaseTermReadSvcImpl.clearOurLastResultsFromTranslationCache();
- BaseTermReadSvcImpl.clearOurLastResultsFromTranslationWithReverseCache();
+ TermConceptMappingSvcImpl.clearOurLastResultsFromTranslationCache();
+ TermConceptMappingSvcImpl.clearOurLastResultsFromTranslationWithReverseCache();
TermDeferredStorageSvcImpl termDeferredStorageSvc = AopTestUtils.getTargetObject(myTerminologyDeferredStorageSvc);
termDeferredStorageSvc.clearDeferred();
}
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 da8fab09060..9c2a5d6e8ee 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
@@ -1,18 +1,13 @@
package ca.uhn.fhir.jpa.dao.r4;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.Optional;
-
+import ca.uhn.fhir.context.support.IValidationSupport;
+import ca.uhn.fhir.context.support.TranslateConceptResult;
+import ca.uhn.fhir.context.support.TranslateConceptResults;
+import ca.uhn.fhir.jpa.api.model.TranslationRequest;
+import ca.uhn.fhir.jpa.entity.TermConceptMap;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.CanonicalType;
import org.hl7.fhir.r4.model.CodeableConcept;
-import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.ConceptMap;
import org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence;
import org.hl7.fhir.r4.model.Enumerations.PublicationStatus;
@@ -28,10 +23,18 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
-import ca.uhn.fhir.jpa.api.model.TranslationMatch;
-import ca.uhn.fhir.jpa.api.model.TranslationRequest;
-import ca.uhn.fhir.jpa.api.model.TranslationResult;
-import ca.uhn.fhir.jpa.entity.TermConceptMap;
+import javax.annotation.Nonnull;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Optional;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItem;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
private static final Logger ourLog = LoggerFactory.getLogger(FhirResourceDaoR4ConceptMapTest.class);
@@ -50,16 +53,16 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding()
.setSystem(CS_URL)
.setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3));
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertFalse(translationResult.getResult().booleanValue());
+ assertFalse(translationResult.getResult());
}
});
@@ -73,7 +76,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
//
TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding()
@@ -81,32 +84,29 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3));
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(2, translationResult.getMatches().size());
+ assertEquals(2, translationResult.getResults().size());
+ assertEquals(translationResult.size(), new HashSet<>(translationResult.getResults()).size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("56789", concept.getCode());
- assertEquals("Target Code 56789", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("56789", translationMatch.getCode());
+ assertEquals("Target Code 56789", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("67890", concept.getCode());
- assertEquals("Target Code 67890", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence());
+ assertEquals("67890", translationMatch.getCode());
+ assertEquals("Target Code 67890", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
//
}
});
@@ -120,7 +120,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
//
TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding()
@@ -128,22 +128,20 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_2));
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(1, translationResult.getMatches().size());
+ assertEquals(1, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("34567", concept.getCode());
- assertEquals("Target Code 34567", concept.getDisplay());
- assertEquals(CS_URL_2, concept.getSystem());
- assertEquals("Version 2", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("34567", translationMatch.getCode());
+ assertEquals("Target Code 34567", translationMatch.getDisplay());
+ assertEquals(CS_URL_2, translationMatch.getSystem());
+ assertEquals("Version 2", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
//
}
});
@@ -157,7 +155,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
//
TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding()
@@ -165,12 +163,12 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("BOGUS");
translationRequest.setTargetSystem(new UriType(CS_URL_3));
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertFalse(translationResult.getResult().booleanValue());
- assertEquals("No matches found!", translationResult.getMessage().getValueAsString());
+ assertFalse(translationResult.getResult());
+ assertEquals("No Matches found", translationResult.getMessage());
- assertEquals(0, translationResult.getMatches().size());
+ assertEquals(0, translationResult.getResults().size());
//
}
});
@@ -184,7 +182,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -193,42 +191,36 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.getCodeableConcept().addCoding()
.setCode("12345");
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(3, translationResult.getMatches().size());
+ assertEquals(3, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("34567", concept.getCode());
- assertEquals("Target Code 34567", concept.getDisplay());
- assertEquals(CS_URL_2, concept.getSystem());
- assertEquals("Version 2", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("34567", translationMatch.getCode());
+ assertEquals("Target Code 34567", translationMatch.getDisplay());
+ assertEquals(CS_URL_2, translationMatch.getSystem());
+ assertEquals("Version 2", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("56789", concept.getCode());
- assertEquals("Target Code 56789", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("56789", translationMatch.getCode());
+ assertEquals("Target Code 56789", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(2);
- assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("67890", concept.getCode());
- assertEquals("Target Code 67890", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(2);
+ assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence());
+ assertEquals("67890", translationMatch.getCode());
+ assertEquals("Target Code 67890", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -241,7 +233,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -254,22 +246,20 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_2));
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(1, translationResult.getMatches().size());
+ assertEquals(1, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("34567", concept.getCode());
- assertEquals("Target Code 34567", concept.getDisplay());
- assertEquals(CS_URL_2, concept.getSystem());
- assertEquals("Version 2", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("34567", translationMatch.getCode());
+ assertEquals("Target Code 34567", translationMatch.getDisplay());
+ assertEquals(CS_URL_2, translationMatch.getSystem());
+ assertEquals("Version 2", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -282,7 +272,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -295,32 +285,28 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("12345");
translationRequest.setTargetSystem(new UriType(CS_URL_3));
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(2, translationResult.getMatches().size());
+ assertEquals(2, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("56789", concept.getCode());
- assertEquals("Target Code 56789", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("56789", translationMatch.getCode());
+ assertEquals("Target Code 56789", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("67890", concept.getCode());
- assertEquals("Target Code 67890", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence());
+ assertEquals("67890", translationMatch.getCode());
+ assertEquals("Target Code 67890", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -333,7 +319,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -344,42 +330,36 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setSystem(CS_URL)
.setCode("12345");
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(3, translationResult.getMatches().size());
+ assertEquals(3, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("34567", concept.getCode());
- assertEquals("Target Code 34567", concept.getDisplay());
- assertEquals(CS_URL_2, concept.getSystem());
- assertEquals("Version 2", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("34567", translationMatch.getCode());
+ assertEquals("Target Code 34567", translationMatch.getDisplay());
+ assertEquals(CS_URL_2, translationMatch.getSystem());
+ assertEquals("Version 2", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("56789", concept.getCode());
- assertEquals("Target Code 56789", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("56789", translationMatch.getCode());
+ assertEquals("Target Code 56789", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(2);
- assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("67890", concept.getCode());
- assertEquals("Target Code 67890", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(2);
+ assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence());
+ assertEquals("67890", translationMatch.getCode());
+ assertEquals("Target Code 67890", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -392,7 +372,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -405,22 +385,20 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("12345")
.setVersion("Version 1");
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(1, translationResult.getMatches().size());
+ assertEquals(1, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("34567", concept.getCode());
- assertEquals("Target Code 34567", concept.getDisplay());
- assertEquals(CS_URL_2, concept.getSystem());
- assertEquals("Version 2", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("34567", translationMatch.getCode());
+ assertEquals("Target Code 34567", translationMatch.getDisplay());
+ assertEquals(CS_URL_2, translationMatch.getSystem());
+ assertEquals("Version 2", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -433,7 +411,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -446,32 +424,28 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("12345")
.setVersion("Version 3");
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(2, translationResult.getMatches().size());
+ assertEquals(2, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("56789", concept.getCode());
- assertEquals("Target Code 56789", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("56789", translationMatch.getCode());
+ assertEquals("Target Code 56789", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("67890", concept.getCode());
- assertEquals("Target Code 67890", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence());
+ assertEquals("67890", translationMatch.getCode());
+ assertEquals("Target Code 67890", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -484,7 +458,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -495,42 +469,36 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("12345");
translationRequest.setSource(new UriType(VS_URL));
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(3, translationResult.getMatches().size());
+ assertEquals(3, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("34567", concept.getCode());
- assertEquals("Target Code 34567", concept.getDisplay());
- assertEquals(CS_URL_2, concept.getSystem());
- assertEquals("Version 2", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("34567", translationMatch.getCode());
+ assertEquals("Target Code 34567", translationMatch.getDisplay());
+ assertEquals(CS_URL_2, translationMatch.getSystem());
+ assertEquals("Version 2", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("56789", concept.getCode());
- assertEquals("Target Code 56789", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("56789", translationMatch.getCode());
+ assertEquals("Target Code 56789", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(2);
- assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("67890", concept.getCode());
- assertEquals("Target Code 67890", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(2);
+ assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence());
+ assertEquals("67890", translationMatch.getCode());
+ assertEquals("Target Code 67890", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -543,7 +511,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -554,42 +522,36 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("12345");
translationRequest.setTarget(new UriType(VS_URL_2));
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(3, translationResult.getMatches().size());
+ assertEquals(3, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("34567", concept.getCode());
- assertEquals("Target Code 34567", concept.getDisplay());
- assertEquals(CS_URL_2, concept.getSystem());
- assertEquals("Version 2", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("34567", translationMatch.getCode());
+ assertEquals("Target Code 34567", translationMatch.getDisplay());
+ assertEquals(CS_URL_2, translationMatch.getSystem());
+ assertEquals("Version 2", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("56789", concept.getCode());
- assertEquals("Target Code 56789", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("56789", translationMatch.getCode());
+ assertEquals("Target Code 56789", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(2);
- assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("67890", concept.getCode());
- assertEquals("Target Code 67890", concept.getDisplay());
- assertEquals(CS_URL_3, concept.getSystem());
- assertEquals("Version 4", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(2);
+ assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence());
+ assertEquals("67890", translationMatch.getCode());
+ assertEquals("Target Code 67890", translationMatch.getDisplay());
+ assertEquals(CS_URL_3, translationMatch.getSystem());
+ assertEquals("Version 4", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -602,7 +564,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -617,22 +579,20 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.setTargetSystem(new UriType(CS_URL_4));
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(1, translationResult.getMatches().size());
+ assertEquals(1, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("narrower", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("78901", concept.getCode());
- assertEquals("Source Code 78901", concept.getDisplay());
- assertEquals(CS_URL_4, concept.getSystem());
- assertEquals("Version 5", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.NARROWER.toCode(), translationMatch.getEquivalence());
+ assertEquals("78901", translationMatch.getCode());
+ assertEquals("Source Code 78901", translationMatch.getDisplay());
+ assertEquals(CS_URL_4, translationMatch.getSystem());
+ assertEquals("Version 5", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -645,7 +605,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -660,22 +620,20 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.setTargetSystem(new UriType(CS_URL));
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(1, translationResult.getMatches().size());
+ assertEquals(1, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- Coding concept = translationMatch.getConcept();
- assertEquals("12345", concept.getCode());
- assertEquals("Source Code 12345", concept.getDisplay());
- assertEquals(CS_URL, concept.getSystem());
- assertEquals("Version 3", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
- assertEquals("wider", translationMatch.getEquivalence().getCode());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals("12345", translationMatch.getCode());
+ assertEquals("Source Code 12345", translationMatch.getDisplay());
+ assertEquals(CS_URL, translationMatch.getSystem());
+ assertEquals("Version 3", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
+ assertEquals(ConceptMapEquivalence.WIDER.toCode(), translationMatch.getEquivalence());
}
});
}
@@ -688,7 +646,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
//
TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding()
@@ -697,12 +655,12 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.setTargetSystem(new UriType(CS_URL));
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertFalse(translationResult.getResult().booleanValue());
- assertEquals("No matches found!", translationResult.getMessage().getValueAsString());
+ assertFalse(translationResult.getResult());
+ assertEquals("No Matches found", translationResult.getMessage());
- assertEquals(0, translationResult.getMatches().size());
+ assertEquals(0, translationResult.getResults().size());
//
}
});
@@ -716,7 +674,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -727,32 +685,28 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("34567");
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(2, translationResult.getMatches().size());
+ assertEquals(2, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("equal", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("12345", concept.getCode());
- assertEquals("Source Code 12345", concept.getDisplay());
- assertEquals(CS_URL, concept.getSystem());
- assertEquals("Version 1", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("12345", translationMatch.getCode());
+ assertEquals("Source Code 12345", translationMatch.getDisplay());
+ assertEquals(CS_URL, translationMatch.getSystem());
+ assertEquals("Version 1", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals("narrower", translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("78901", concept.getCode());
- assertEquals("Source Code 78901", concept.getDisplay());
- assertEquals(CS_URL_4, concept.getSystem());
- assertEquals("Version 5", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.NARROWER.toCode(), translationMatch.getEquivalence());
+ assertEquals("78901", translationMatch.getCode());
+ assertEquals("Source Code 78901", translationMatch.getDisplay());
+ assertEquals(CS_URL_4, translationMatch.getSystem());
+ assertEquals("Version 5", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -765,7 +719,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -780,22 +734,20 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.setTargetSystem(new UriType(CS_URL));
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(1, translationResult.getMatches().size());
+ assertEquals(1, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("equal", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("12345", concept.getCode());
- assertEquals("Source Code 12345", concept.getDisplay());
- assertEquals(CS_URL, concept.getSystem());
- assertEquals("Version 1", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("12345", translationMatch.getCode());
+ assertEquals("Source Code 12345", translationMatch.getDisplay());
+ assertEquals(CS_URL, translationMatch.getSystem());
+ assertEquals("Version 1", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -808,7 +760,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -823,22 +775,20 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.setTargetSystem(new UriType(CS_URL_4));
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(1, translationResult.getMatches().size());
+ assertEquals(1, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("narrower", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("78901", concept.getCode());
- assertEquals("Source Code 78901", concept.getDisplay());
- assertEquals(CS_URL_4, concept.getSystem());
- assertEquals("Version 5", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.NARROWER.toCode(), translationMatch.getEquivalence());
+ assertEquals("78901", translationMatch.getCode());
+ assertEquals("Source Code 78901", translationMatch.getDisplay());
+ assertEquals(CS_URL_4, translationMatch.getSystem());
+ assertEquals("Version 5", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -851,7 +801,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -864,32 +814,28 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setCode("34567");
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(2, translationResult.getMatches().size());
+ assertEquals(2, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("equal", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("12345", concept.getCode());
- assertEquals("Source Code 12345", concept.getDisplay());
- assertEquals(CS_URL, concept.getSystem());
- assertEquals("Version 1", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("12345", translationMatch.getCode());
+ assertEquals("Source Code 12345", translationMatch.getDisplay());
+ assertEquals(CS_URL, translationMatch.getSystem());
+ assertEquals("Version 1", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals("narrower", translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("78901", concept.getCode());
- assertEquals("Source Code 78901", concept.getDisplay());
- assertEquals(CS_URL_4, concept.getSystem());
- assertEquals("Version 5", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.NARROWER.toCode(), translationMatch.getEquivalence());
+ assertEquals("78901", translationMatch.getCode());
+ assertEquals("Source Code 78901", translationMatch.getDisplay());
+ assertEquals(CS_URL_4, translationMatch.getSystem());
+ assertEquals("Version 5", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -902,7 +848,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -917,32 +863,28 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
.setVersion("Version 2");
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(2, translationResult.getMatches().size());
+ assertEquals(2, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("equal", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("12345", concept.getCode());
- assertEquals("Source Code 12345", concept.getDisplay());
- assertEquals(CS_URL, concept.getSystem());
- assertEquals("Version 1", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("12345", translationMatch.getCode());
+ assertEquals("Source Code 12345", translationMatch.getDisplay());
+ assertEquals(CS_URL, translationMatch.getSystem());
+ assertEquals("Version 1", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals("narrower", translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("78901", concept.getCode());
- assertEquals("Source Code 78901", concept.getDisplay());
- assertEquals(CS_URL_4, concept.getSystem());
- assertEquals("Version 5", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.NARROWER.toCode(), translationMatch.getEquivalence());
+ assertEquals("78901", translationMatch.getCode());
+ assertEquals("Source Code 78901", translationMatch.getDisplay());
+ assertEquals(CS_URL_4, translationMatch.getSystem());
+ assertEquals("Version 5", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -955,7 +897,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -968,32 +910,28 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.setSource(new UriType(VS_URL_2));
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(2, translationResult.getMatches().size());
+ assertEquals(2, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("equal", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("12345", concept.getCode());
- assertEquals("Source Code 12345", concept.getDisplay());
- assertEquals(CS_URL, concept.getSystem());
- assertEquals("Version 1", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("12345", translationMatch.getCode());
+ assertEquals("Source Code 12345", translationMatch.getDisplay());
+ assertEquals(CS_URL, translationMatch.getSystem());
+ assertEquals("Version 1", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals("narrower", translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("78901", concept.getCode());
- assertEquals("Source Code 78901", concept.getDisplay());
- assertEquals(CS_URL_4, concept.getSystem());
- assertEquals("Version 5", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.NARROWER.toCode(), translationMatch.getEquivalence());
+ assertEquals("78901", translationMatch.getCode());
+ assertEquals("Source Code 78901", translationMatch.getDisplay());
+ assertEquals(CS_URL_4, translationMatch.getSystem());
+ assertEquals("Version 5", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
@@ -1006,7 +944,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
@Override
- protected void doInTransactionWithoutResult(TransactionStatus theStatus) {
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
/*
* Provided:
* source code
@@ -1019,39 +957,35 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.setTarget(new UriType(VS_URL));
translationRequest.setReverse(true);
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(2, translationResult.getMatches().size());
+ assertEquals(2, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("equal", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("12345", concept.getCode());
- assertEquals("Source Code 12345", concept.getDisplay());
- assertEquals(CS_URL, concept.getSystem());
- assertEquals("Version 1", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("12345", translationMatch.getCode());
+ assertEquals("Source Code 12345", translationMatch.getDisplay());
+ assertEquals(CS_URL, translationMatch.getSystem());
+ assertEquals("Version 1", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
- translationMatch = translationResult.getMatches().get(1);
- assertEquals("narrower", translationMatch.getEquivalence().getCode());
- concept = translationMatch.getConcept();
- assertEquals("78901", concept.getCode());
- assertEquals("Source Code 78901", concept.getDisplay());
- assertEquals(CS_URL_4, concept.getSystem());
- assertEquals("Version 5", concept.getVersion());
- assertFalse(concept.getUserSelected());
- assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
+ translationMatch = translationResult.getResults().get(1);
+ assertEquals(ConceptMapEquivalence.NARROWER.toCode(), translationMatch.getEquivalence());
+ assertEquals("78901", translationMatch.getCode());
+ assertEquals("Source Code 78901", translationMatch.getDisplay());
+ assertEquals(CS_URL_4, translationMatch.getSystem());
+ assertEquals("Version 5", translationMatch.getSystemVersion());
+ assertEquals(CM_URL, translationMatch.getConceptMapUrl());
}
});
}
/**
* Some US core ConceptMaps use this style, e.g:
- *
+ *
* http://hl7.org/fhir/us/core/ConceptMap/ndc-cvx
*/
@Test
@@ -1064,7 +998,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
cm.addGroup().addElement().setCode("source1").addTarget().setCode("target1").setEquivalence(ConceptMapEquivalence.EQUAL);
myConceptMapDao.create(cm);
- runInTransaction(()->{
+ runInTransaction(() -> {
TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding()
.setSystem("http://source")
@@ -1072,29 +1006,37 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.setTarget(new UriType("http://target"));
ourLog.info("*** About to translate");
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
ourLog.info("*** Done translating");
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(1, translationResult.getMatches().size());
+ assertEquals(1, translationResult.getResults().size());
+
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("target1", translationMatch.getCode());
+ assertNull(translationMatch.getDisplay());
+ assertEquals("http://target", translationMatch.getSystem());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("equal", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("target1", concept.getCode());
- assertEquals(null, concept.getDisplay());
- assertEquals("http://target", concept.getSystem());
});
-
+ List translationResults = myValidationSupport.translateConcept(new IValidationSupport.TranslateCodeRequest("http://source", "source1", "http://target")).getResults();
+ assertThat(translationResults.toString(), translationResults, hasItem(
+ new TranslateConceptResult()
+ .setSystem("http://target")
+ .setCode("target1")
+ .setEquivalence("equal")
+ .setConceptMapUrl("http://foo")
+ .setValueSet("http://target"))
+ );
+ assertEquals(translationResults.size(), new HashSet<>(translationResults).size());
}
-
/**
* Handle ConceptMaps where targets are missing, such as this one:
- *
+ *
* https://www.hl7.org/fhir/conceptmap-example-specimen-type.html
*/
@Test
@@ -1109,7 +1051,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
cm.addGroup().addElement().setCode("source3").addTarget().setComment("No target code"); // no target code
myConceptMapDao.create(cm);
- runInTransaction(()->{
+ runInTransaction(() -> {
TranslationRequest translationRequest = new TranslationRequest();
translationRequest.getCodeableConcept().addCoding()
.setSystem("http://source")
@@ -1117,27 +1059,25 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
translationRequest.setTarget(new UriType("http://target"));
ourLog.info("*** About to translate");
- TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
+ TranslateConceptResults translationResult = myConceptMapDao.translate(translationRequest, null);
ourLog.info("*** Done translating");
- assertTrue(translationResult.getResult().booleanValue());
- assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
+ assertTrue(translationResult.getResult());
+ assertEquals("Matches found", translationResult.getMessage());
- assertEquals(1, translationResult.getMatches().size());
+ assertEquals(1, translationResult.getResults().size());
- TranslationMatch translationMatch = translationResult.getMatches().get(0);
- assertEquals("equal", translationMatch.getEquivalence().getCode());
- Coding concept = translationMatch.getConcept();
- assertEquals("target1", concept.getCode());
- assertEquals(null, concept.getDisplay());
- assertEquals("http://target", concept.getSystem());
+ TranslateConceptResult translationMatch = translationResult.getResults().get(0);
+ assertEquals(ConceptMapEquivalence.EQUAL.toCode(), translationMatch.getEquivalence());
+ assertEquals("target1", translationMatch.getCode());
+ assertNull(translationMatch.getDisplay());
+ assertEquals("http://target", translationMatch.getSystem());
});
}
-
@Test
public void testUploadAndApplyR4DemoConceptMap() throws IOException {
upload("/r4/ConceptMap-icd-sct.xml");
@@ -1149,41 +1089,41 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
TranslationRequest request = new TranslationRequest();
request.setCodeableConcept(sourceCode);
request.setTargetSystem(new UriType("http://hl7.org/fhir/sid/icd-10-us"));
- TranslationResult outcome = myConceptMapDao.translate(request, mySrd);
+ TranslateConceptResults outcome = myConceptMapDao.translate(request, mySrd);
- assertEquals("S52.209A", outcome.getMatches().get(0).getConcept().getCode());
+ assertEquals("S52.209A", outcome.getResults().get(0).getCode());
}
@Test
public void testConceptMapFindTermConceptMapByUrl() {
-
+
Pageable page = PageRequest.of(0, 1);
List theExpConceptMapList = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL);
assertEquals(1, theExpConceptMapList.size());
assertEquals(CM_URL, theExpConceptMapList.get(0).getUrl());
-
+
}
@Test
public void testConceptMapTwoConceptMapWithSameUrlDifferentVersion() {
-
+
String theUrl = "http://loinc.org/property/analyte-suffix";
ConceptMap theConceptMap1 = new ConceptMap();
ConceptMap theConceptMap2 = new ConceptMap();
-
+
theConceptMap1.setUrl(theUrl).setStatus(PublicationStatus.ACTIVE).setName("name1").setVersion("v1");
theConceptMap2.setUrl(theUrl).setStatus(PublicationStatus.ACTIVE).setName("name2").setVersion("v2");
-
+
myConceptMapDao.create(theConceptMap1);
myConceptMapDao.create(theConceptMap2);
-
+
Optional theExpConceptMapV1 = myTermConceptMapDao.findTermConceptMapByUrlAndVersion(theUrl, "v1");
Optional theExpConceptMapV2 = myTermConceptMapDao.findTermConceptMapByUrlAndVersion(theUrl, "v2");
-
+
assertTrue(theExpConceptMapV1.isPresent());
assertEquals(theUrl, theExpConceptMapV1.get().getUrl());
assertEquals("v1", theExpConceptMapV1.get().getVersion());
-
+
assertTrue(theExpConceptMapV2.isPresent());
assertEquals(theUrl, theExpConceptMapV2.get().getUrl());
assertEquals("v2", theExpConceptMapV2.get().getVersion());
@@ -1191,7 +1131,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
// should return the latest one which is v2
Pageable page = PageRequest.of(0, 1);
List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, theUrl);
-
+
assertEquals(1, theExpSecondOne.size());
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
assertEquals("v2", theExpSecondOne.get(0).getVersion());
@@ -1199,27 +1139,27 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
@Test
public void testConceptMapTwoConceptMapWithSameUrlOneWithoutVersion() {
-
+
String theUrl = "http://loinc.org/property/analyte-suffix";
ConceptMap theConceptMap1 = new ConceptMap();
ConceptMap theConceptMap2 = new ConceptMap();
-
+
theConceptMap1.setUrl(theUrl).setStatus(PublicationStatus.ACTIVE).setName("name1").setVersion("v1");
theConceptMap2.setUrl(theUrl).setStatus(PublicationStatus.ACTIVE).setName("name2");
-
+
myConceptMapDao.create(theConceptMap1);
myConceptMapDao.create(theConceptMap2);
-
+
Optional theExpConceptMapV1 = myTermConceptMapDao.findTermConceptMapByUrlAndVersion(theUrl, "v1");
-
+
assertTrue(theExpConceptMapV1.isPresent());
assertEquals(theUrl, theExpConceptMapV1.get().getUrl());
assertEquals("v1", theExpConceptMapV1.get().getVersion());
-
+
// should return the latest one which is v2
Pageable page = PageRequest.of(0, 1);
List theExpSecondOne = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, theUrl);
-
+
assertEquals(1, theExpSecondOne.size());
assertEquals(theUrl, theExpSecondOne.get(0).getUrl());
assertNull(theExpSecondOne.get(0).getVersion());
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java
index 517c4915c11..9f1a8677c14 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r5/BaseJpaR5Test.java
@@ -59,6 +59,7 @@ import ca.uhn.fhir.jpa.search.warm.ICacheWarmingSvc;
import ca.uhn.fhir.jpa.searchparam.registry.SearchParamRegistryImpl;
import ca.uhn.fhir.jpa.subscription.match.registry.SubscriptionRegistry;
import ca.uhn.fhir.jpa.term.BaseTermReadSvcImpl;
+import ca.uhn.fhir.jpa.term.TermConceptMappingSvcImpl;
import ca.uhn.fhir.jpa.term.TermDeferredStorageSvcImpl;
import ca.uhn.fhir.jpa.term.ValueSetExpansionR4Test;
import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc;
@@ -437,8 +438,8 @@ public abstract class BaseJpaR5Test extends BaseJpaTest {
public void afterClearTerminologyCaches() {
BaseTermReadSvcImpl baseHapiTerminologySvc = AopTestUtils.getTargetObject(myTermSvc);
baseHapiTerminologySvc.clearCaches();
- BaseTermReadSvcImpl.clearOurLastResultsFromTranslationCache();
- BaseTermReadSvcImpl.clearOurLastResultsFromTranslationWithReverseCache();
+ TermConceptMappingSvcImpl.clearOurLastResultsFromTranslationCache();
+ TermConceptMappingSvcImpl.clearOurLastResultsFromTranslationWithReverseCache();
TermDeferredStorageSvcImpl deferredStorageSvc = AopTestUtils.getTargetObject(myTermDeferredStorageSvc);
deferredStorageSvc.clearDeferred();
}
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/ResponseTerminologyTranslationInterceptorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/ResponseTerminologyTranslationInterceptorTest.java
new file mode 100644
index 00000000000..b6b6926b40a
--- /dev/null
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/interceptor/ResponseTerminologyTranslationInterceptorTest.java
@@ -0,0 +1,133 @@
+package ca.uhn.fhir.jpa.interceptor;
+
+import ca.uhn.fhir.interceptor.api.IInterceptorService;
+import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
+import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test;
+import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationInterceptor;
+import org.hamcrest.Matchers;
+import org.hl7.fhir.instance.model.api.IIdType;
+import org.hl7.fhir.r4.model.Coding;
+import org.hl7.fhir.r4.model.Observation;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import javax.annotation.Nonnull;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class ResponseTerminologyTranslationInterceptorTest extends BaseResourceProviderR4Test {
+
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResponseTerminologyTranslationInterceptorTest.class);
+
+ @Autowired
+ private DaoRegistry myDaoRegistry;
+ @Autowired
+ private IInterceptorService myInterceptorBroadcaster;
+ @Autowired
+ private ResponseTerminologyTranslationInterceptor myResponseTerminologyTranslationInterceptor;
+
+ @BeforeEach
+ public void beforeEach() {
+ myConceptMapDao.create(createConceptMap());
+ ourRestServer.registerInterceptor(myResponseTerminologyTranslationInterceptor);
+ }
+
+ @AfterEach
+ public void afterEach() {
+ myResponseTerminologyTranslationInterceptor.clearMappingSpecifications();
+ ourRestServer.unregisterInterceptor(myResponseTerminologyTranslationInterceptor);
+ }
+
+ @Test
+ public void testMapConcept_MappingFound() {
+ myResponseTerminologyTranslationInterceptor.addMappingSpecification(CS_URL, CS_URL_2);
+
+ Observation observation = new Observation();
+ observation.setStatus(Observation.ObservationStatus.AMENDED);
+ observation .getCode()
+ .addCoding(new Coding(CS_URL, "12345", null));
+ IIdType id = myObservationDao.create(observation).getId();
+
+ // Read it back
+ observation = myClient.read().resource(Observation.class).withId(id).execute();
+
+ assertThat(toCodeStrings(observation).toString(), toCodeStrings(observation), Matchers.contains(
+ "[system=http://example.com/my_code_system, code=12345, display=null]",
+ "[system=http://example.com/my_code_system2, code=34567, display=Target Code 34567]"
+ ));
+ }
+
+ @Test
+ public void testMapConcept_MultipleMappingsFound() {
+ myResponseTerminologyTranslationInterceptor.addMappingSpecification(CS_URL, CS_URL_3);
+
+ Observation observation = new Observation();
+ observation.setStatus(Observation.ObservationStatus.AMENDED);
+ observation .getCode()
+ .addCoding(new Coding(CS_URL, "12345", null));
+ IIdType id = myObservationDao.create(observation).getId();
+
+ // Read it back
+ observation = myClient.read().resource(Observation.class).withId(id).execute();
+
+ assertThat(toCodeStrings(observation).toString(), toCodeStrings(observation), Matchers.contains(
+ "[system=http://example.com/my_code_system, code=12345, display=null]",
+ "[system=http://example.com/my_code_system3, code=56789, display=Target Code 56789]",
+ "[system=http://example.com/my_code_system3, code=67890, display=Target Code 67890]"
+ ));
+ }
+
+ /**
+ * Don't map if we already have a code in the desired target
+ */
+ @Test
+ public void testMapConcept_MappingNotNeeded() {
+ myResponseTerminologyTranslationInterceptor.addMappingSpecification(CS_URL, CS_URL_2);
+
+ Observation observation = new Observation();
+ observation.setStatus(Observation.ObservationStatus.AMENDED);
+ observation .getCode()
+ .addCoding(new Coding(CS_URL, "12345", null))
+ .addCoding(new Coding(CS_URL_2, "9999", "Display 9999"));
+ IIdType id = myObservationDao.create(observation).getId();
+
+ // Read it back
+ observation = myClient.read().resource(Observation.class).withId(id).execute();
+
+ assertThat(toCodeStrings(observation).toString(), toCodeStrings(observation), Matchers.contains(
+ "[system=http://example.com/my_code_system, code=12345, display=null]",
+ "[system=http://example.com/my_code_system2, code=9999, display=Display 9999]"
+ ));
+ }
+
+ @Test
+ public void testMapConcept_NoMappingExists() {
+ myResponseTerminologyTranslationInterceptor.addMappingSpecification(CS_URL, CS_URL_2);
+
+ Observation observation = new Observation();
+ observation.setStatus(Observation.ObservationStatus.AMENDED);
+ observation .getCode()
+ .addCoding(new Coding(CS_URL, "FOO", null));
+ IIdType id = myObservationDao.create(observation).getId();
+
+ // Read it back
+ observation = myClient.read().resource(Observation.class).withId(id).execute();
+
+ assertThat(toCodeStrings(observation).toString(), toCodeStrings(observation), Matchers.contains(
+ "[system=http://example.com/my_code_system, code=FOO, display=null]"
+ ));
+ }
+
+ @Nonnull
+ private List toCodeStrings(Observation observation) {
+ return observation.getCode().getCoding().stream().map(t -> "[system=" + t.getSystem() + ", code=" + t.getCode() + ", display=" + t.getDisplay() + "]").collect(Collectors.toList());
+ }
+
+
+}
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ConceptMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ConceptMapTest.java
index 9d196fde0c0..0f1cd25e2c5 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ConceptMapTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/dstu3/ResourceProviderDstu3ConceptMapTest.java
@@ -95,7 +95,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -156,7 +156,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -205,7 +205,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -255,7 +255,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -304,7 +304,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -352,7 +352,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -400,7 +400,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -446,7 +446,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertFalse(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("No matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("No Matches found", ((StringType) param.getValue()).getValueAsString());
}
@@ -480,7 +480,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -525,7 +525,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -570,7 +570,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -615,7 +615,7 @@ public class ResourceProviderDstu3ConceptMapTest extends BaseResourceProviderDst
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java
index 916bb3ffc70..d0144436f0e 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java
@@ -567,11 +567,6 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid
assertEquals(1, response.getEntry().size());
assertNull(response.getTotalElement().getValue());
- // Load next page
- response = myClient.loadPage().next(response).execute();
- assertEquals(1, response.getEntry().size());
- assertNull(response.getTotalElement().getValue());
-
StopWatch sw = new StopWatch();
while(true) {
SearchStatusEnum status = runInTransaction(() -> {
@@ -586,6 +581,11 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid
}
}
+ // Load next page
+ response = myClient.loadPage().next(response).execute();
+ assertEquals(1, response.getEntry().size());
+ assertNull(response.getTotalElement().getValue());
+
runInTransaction(() -> {
Search search = mySearchEntityDao.findByUuidAndFetchIncludes(searchId).orElseThrow(() -> new IllegalStateException());
assertEquals(3, search.getNumFound());
@@ -594,7 +594,12 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid
});
// The paging should have ended now - but the last redacted female result is an empty existing page which should never have been there.
- assertNull(BundleUtil.getLinkUrlOfType(myFhirCtx, response, "next"));
+ String next = BundleUtil.getLinkUrlOfType(myFhirCtx, response, "next");
+ if (next != null) {
+ response = myClient.loadPage().next(response).execute();
+ fail(myFhirCtx.newJsonParser().encodeResourceToString(response));
+ }
+
}
/**
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ConceptMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ConceptMapTest.java
index 9236a043090..77f2315c5de 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ConceptMapTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4ConceptMapTest.java
@@ -94,7 +94,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -152,7 +152,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
@@ -197,7 +197,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertFalse(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("No matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("No Matches found", ((StringType) param.getValue()).getValueAsString());
assertFalse(hasParameterByName(respParams, "match"));
}
@@ -230,7 +230,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(3, getNumberOfParametersByName(respParams, "match"));
@@ -308,7 +308,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
@@ -361,7 +361,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(4, getNumberOfParametersByName(respParams, "match"));
@@ -452,7 +452,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(3, getNumberOfParametersByName(respParams, "match"));
@@ -531,7 +531,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
@@ -582,7 +582,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
@@ -647,7 +647,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
@@ -698,7 +698,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
@@ -761,7 +761,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(3, getNumberOfParametersByName(respParams, "match"));
@@ -838,7 +838,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(3, getNumberOfParametersByName(respParams, "match"));
@@ -949,7 +949,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -993,7 +993,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(3, getNumberOfParametersByName(respParams, "match"));
@@ -1074,7 +1074,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
@@ -1120,7 +1120,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertFalse(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("No matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("No Matches found", ((StringType) param.getValue()).getValueAsString());
assertFalse(hasParameterByName(respParams, "match"));
}
@@ -1155,7 +1155,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
@@ -1221,7 +1221,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
@@ -1291,7 +1291,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(4, getNumberOfParametersByName(respParams, "match"));
@@ -1324,9 +1324,9 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertEquals(CM_URL, ((UriType) part.getValue()).getValueAsString());
param = getParametersByName(respParams, "match").get(2);
- assertEquals(2, param.getPart().size());
+ assertEquals(3, param.getPart().size());
part = getPartByName(param, "equivalence");
- assertFalse(part.hasValue());
+ assertEquals("wider", ((CodeType)part.getValue()).getCode());
part = getPartByName(param, "concept");
coding = (Coding) part.getValue();
assertEquals("23456", coding.getCode());
@@ -1384,7 +1384,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
@@ -1451,7 +1451,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
@@ -1518,7 +1518,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
@@ -1571,7 +1571,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
@@ -1622,7 +1622,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
@@ -1687,7 +1687,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
@@ -1783,7 +1783,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -1828,7 +1828,7 @@ public class ResourceProviderR4ConceptMapTest extends BaseResourceProviderR4Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(2, getNumberOfParametersByName(respParams, "match"));
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ConceptMapTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ConceptMapTest.java
index a2cb18581f0..7acdbc38b35 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ConceptMapTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r5/ResourceProviderR5ConceptMapTest.java
@@ -88,7 +88,7 @@ public class ResourceProviderR5ConceptMapTest extends BaseResourceProviderR5Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
@@ -170,7 +170,7 @@ public class ResourceProviderR5ConceptMapTest extends BaseResourceProviderR5Test
assertTrue(((BooleanType) param.getValue()).booleanValue());
param = getParameterByName(respParams, "message");
- assertEquals("Matches found!", ((StringType) param.getValue()).getValueAsString());
+ assertEquals("Matches found", ((StringType) param.getValue()).getValueAsString());
assertEquals(1, getNumberOfParametersByName(respParams, "match"));
param = getParametersByName(respParams, "match").get(0);
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImplTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImplTest.java
new file mode 100644
index 00000000000..ecfe133f24e
--- /dev/null
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermConceptMappingSvcImplTest.java
@@ -0,0 +1,1587 @@
+package ca.uhn.fhir.jpa.term;
+
+import ca.uhn.fhir.context.support.TranslateConceptResult;
+import ca.uhn.fhir.jpa.api.model.TranslationRequest;
+import ca.uhn.fhir.context.support.TranslateConceptResults;
+import ca.uhn.fhir.jpa.entity.TermConceptMap;
+import ca.uhn.fhir.jpa.entity.TermConceptMapGroup;
+import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElement;
+import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElementTarget;
+import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
+import org.hl7.fhir.instance.model.api.IIdType;
+import org.hl7.fhir.r4.model.CanonicalType;
+import org.hl7.fhir.r4.model.ConceptMap;
+import org.hl7.fhir.r4.model.Enumerations;
+import org.hl7.fhir.r4.model.UriType;
+import org.hl7.fhir.r4.model.codesystems.HttpVerb;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.TransactionCallbackWithoutResult;
+import org.springframework.transaction.support.TransactionTemplate;
+
+import javax.annotation.Nonnull;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
+ private static final Logger ourLog = LoggerFactory.getLogger(TermConceptMappingSvcImplTest.class);
+
+ private IIdType myConceptMapId;
+
+ @Test
+ public void testCreateConceptMapWithVirtualSourceSystem() {
+ ConceptMap conceptMap = createConceptMap();
+ conceptMap.getGroup().forEach(t -> t.setSource(null));
+ conceptMap.setSource(new CanonicalType("http://hl7.org/fhir/uv/livd/StructureDefinition/loinc-livd"));
+
+ persistConceptMap(conceptMap, HttpVerb.POST);
+
+ }
+
+ @Test
+ public void testCreateConceptMapWithVirtualSourceSystemWithClientAssignedId() {
+ ConceptMap conceptMap = createConceptMap();
+ conceptMap.getGroup().forEach(t -> t.setSource(null));
+ conceptMap.setSource(new CanonicalType("http://hl7.org/fhir/uv/livd/StructureDefinition/loinc-livd"));
+ conceptMap.setId("ConceptMap/cm");
+
+ persistConceptMap(conceptMap, HttpVerb.PUT);
+
+ }
+
+ @Test
+ public void testByCodeSystemsAndSourceCodeOneToMany() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL)
+ .setCode("12345");
+ translationRequest.setTargetSystem(new UriType(CS_URL_3));
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(2, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("target(0):\n" + target.toString());
+
+ assertEquals("56789", target.getCode());
+ assertEquals("Target Code 56789", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(1);
+
+ ourLog.info("target(1):\n" + target.toString());
+
+ assertEquals("67890", target.getCode());
+ assertEquals("Target Code 67890", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(2, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testByCodeSystemsAndSourceCodeOneToOne() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL)
+ .setCode("12345");
+ translationRequest.setTargetSystem(new UriType(CS_URL_2));
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(1, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("ConceptMap.group.element.target:\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(1, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testByCodeSystemsAndSourceCodeUnmapped() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL)
+ .setCode("BOGUS");
+ translationRequest.setTargetSystem(new UriType(CS_URL_3));
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertTrue(targets.isEmpty());
+ }
+ });
+ }
+
+ @Test
+ public void testConceptMapWithNoSourceAndTargetValueSet() {
+
+ ConceptMap conceptMap = new ConceptMap();
+ conceptMap.setUrl(CM_URL);
+ conceptMap.setSource(null);
+ conceptMap.setTarget(null);
+ ConceptMap.ConceptMapGroupComponent group = conceptMap.addGroup()
+ .setSource(CS_URL)
+ .setTarget(CS_URL_2);
+ group.addElement()
+ .setCode("12345")
+ .addTarget()
+ .setCode("34567");
+ group.addElement()
+ .setCode("888")
+ .addTarget()
+ .setCode("999");
+
+ myConceptMapDao.create(conceptMap);
+
+ TranslationRequest translationRequest = new TranslationRequest()
+ .addCode(CS_URL, "12345")
+ .setTargetSystem(new UriType(CS_URL_2));
+
+ TranslateConceptResults resp = myConceptMappingSvc.translate(translationRequest);
+ assertEquals(1, resp.size());
+ assertEquals("34567", resp.getResults().get(0).getCode());
+ }
+
+ @Test
+ public void testUsingPredicatesWithCodeOnly() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setCode("12345");
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(3, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("target(0):\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(1);
+
+ ourLog.info("target(1):\n" + target.toString());
+
+ assertEquals("56789", target.getCode());
+ assertEquals("Target Code 56789", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(2);
+
+ ourLog.info("target(2):\n" + target.toString());
+
+ assertEquals("67890", target.getCode());
+ assertEquals("Target Code 67890", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(3, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testUsingPredicatesWithSourceAndTargetSystem2() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ * target code system #2
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL)
+ .setCode("12345");
+ translationRequest.setTargetSystem(new UriType(CS_URL_2));
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(1, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("target:\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(1, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testUsingPredicatesWithSourceAndTargetSystem3() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ * target code system #3
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL)
+ .setCode("12345");
+ translationRequest.setTargetSystem(new UriType(CS_URL_3));
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(2, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("target(0):\n" + target.toString());
+
+ assertEquals("56789", target.getCode());
+ assertEquals("Target Code 56789", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(1);
+
+ ourLog.info("target(1):\n" + target.toString());
+
+ assertEquals("67890", target.getCode());
+ assertEquals("Target Code 67890", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(2, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testUsingPredicatesWithSourceSystem() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL)
+ .setCode("12345");
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(3, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("target(0):\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(1);
+
+ ourLog.info("target(1):\n" + target.toString());
+
+ assertEquals("56789", target.getCode());
+ assertEquals("Target Code 56789", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(2);
+
+ ourLog.info("target(2):\n" + target.toString());
+
+ assertEquals("67890", target.getCode());
+ assertEquals("Target Code 67890", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(3, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testUsingPredicatesWithSourceSystemAndVersion1() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ * source code system version #1
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL)
+ .setCode("12345")
+ .setVersion("Version 1");
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(1, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("target:\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(1, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testUsingPredicatesWithSourceSystemAndVersion3() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ * source code system version #3
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL)
+ .setCode("12345")
+ .setVersion("Version 3");
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(2, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("target(0):\n" + target.toString());
+
+ assertEquals("56789", target.getCode());
+ assertEquals("Target Code 56789", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(1);
+
+ ourLog.info("target(1):\n" + target.toString());
+
+ assertEquals("67890", target.getCode());
+ assertEquals("Target Code 67890", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(2, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testUsingPredicatesWithSourceValueSet() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source value set
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setCode("12345");
+ translationRequest.setSource(new UriType(VS_URL));
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(3, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("target(0):\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(1);
+
+ ourLog.info("target(1):\n" + target.toString());
+
+ assertEquals("56789", target.getCode());
+ assertEquals("Target Code 56789", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(2);
+
+ ourLog.info("target(2):\n" + target.toString());
+
+ assertEquals("67890", target.getCode());
+ assertEquals("Target Code 67890", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(3, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testUsingPredicatesWithTargetValueSet() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * target value set
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setCode("12345");
+ translationRequest.setTarget(new UriType(VS_URL_2));
+
+ List targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(3, targets.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+
+ TranslateConceptResult target = targets.get(0);
+
+ ourLog.info("target(0):\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(1);
+
+ ourLog.info("target(1):\n" + target.toString());
+
+ assertEquals("56789", target.getCode());
+ assertEquals("Target Code 56789", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = targets.get(2);
+
+ ourLog.info("target(2):\n" + target.toString());
+
+ assertEquals("67890", target.getCode());
+ assertEquals("Target Code 67890", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER.toCode(), target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // Test caching.
+ targets = myConceptMappingSvc.translate(translationRequest).getResults();
+ assertNotNull(targets);
+ assertEquals(3, targets.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
+ }
+ });
+ }
+
+ @Test
+ public void testWithReverse() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ * target code system
+ * reverse = true
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL_2)
+ .setCode("34567");
+ translationRequest.setTargetSystem(new UriType(CS_URL_4));
+ translationRequest.setReverse(true);
+
+ TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(1, elements.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+
+ TranslateConceptResult element = elements.getResults().get(0);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("78901", element.getCode());
+ assertEquals("Source Code 78901", element.getDisplay());
+ assertEquals(CS_URL_4, element.getSystem());
+ assertEquals("Version 5", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ // Test caching.
+ elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(1, elements.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+ }
+ });
+ }
+
+ @Test
+ public void testWithReverseByCodeSystemsAndSourceCodeUnmapped() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL_3)
+ .setCode("BOGUS");
+ translationRequest.setTargetSystem(new UriType(CS_URL));
+
+ TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertTrue(elements.isEmpty());
+ }
+ });
+ }
+
+ @Test
+ public void testWithReverseUsingPredicatesWithCodeOnly() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * reverse = true
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setCode("34567");
+ translationRequest.setReverse(true);
+
+ TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+
+ TranslateConceptResult element = elements.getResults().get(0);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ element = elements.getResults().get(1);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("78901", element.getCode());
+ assertEquals("Source Code 78901", element.getDisplay());
+ assertEquals(CS_URL_4, element.getSystem());
+ assertEquals("Version 5", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ // Test caching.
+ elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+ }
+ });
+ }
+
+ @Test
+ public void testWithReverseUsingPredicatesWithSourceAndTargetSystem1() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ * target code system #1
+ * reverse = true
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL_2)
+ .setCode("34567");
+ translationRequest.setTargetSystem(new UriType(CS_URL));
+ translationRequest.setReverse(true);
+
+ TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(1, elements.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+
+ TranslateConceptResult element = elements.getResults().get(0);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ // Test caching.
+ elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(1, elements.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+ }
+ });
+ }
+
+ @Test
+ public void testWithReverseUsingPredicatesWithSourceAndTargetSystem4() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ * target code system #4
+ * reverse = true
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL_2)
+ .setCode("34567");
+ translationRequest.setTargetSystem(new UriType(CS_URL_4));
+ translationRequest.setReverse(true);
+
+ TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(1, elements.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+
+ TranslateConceptResult element = elements.getResults().get(0);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("78901", element.getCode());
+ assertEquals("Source Code 78901", element.getDisplay());
+ assertEquals(CS_URL_4, element.getSystem());
+ assertEquals("Version 5", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ // Test caching.
+ elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(1, elements.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+ }
+ });
+ }
+
+ @Test
+ public void testWithReverseUsingPredicatesWithSourceSystem() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ * reverse = true
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL_2)
+ .setCode("34567");
+ translationRequest.setReverse(true);
+
+ TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+
+ TranslateConceptResult element = elements.getResults().get(0);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ element = elements.getResults().get(1);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("78901", element.getCode());
+ assertEquals("Source Code 78901", element.getDisplay());
+ assertEquals(CS_URL_4, element.getSystem());
+ assertEquals("Version 5", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ // Test caching.
+ elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+ }
+ });
+ }
+
+ @Test
+ public void testWithReverseUsingPredicatesWithSourceSystemAndVersion() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source code system
+ * source code system version
+ * reverse = true
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setSystem(CS_URL_2)
+ .setCode("34567")
+ .setVersion("Version 2");
+ translationRequest.setReverse(true);
+
+ TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+
+ TranslateConceptResult element = elements.getResults().get(0);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ element = elements.getResults().get(1);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("78901", element.getCode());
+ assertEquals("Source Code 78901", element.getDisplay());
+ assertEquals(CS_URL_4, element.getSystem());
+ assertEquals("Version 5", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ // Test caching.
+ elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+ }
+ });
+ }
+
+ @Test
+ public void testWithReverseUsingPredicatesWithSourceValueSet() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * source value set
+ * reverse = true
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setCode("34567");
+ translationRequest.setSource(new UriType(VS_URL_2));
+ translationRequest.setReverse(true);
+
+ TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+
+ TranslateConceptResult element = elements.getResults().get(0);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ element = elements.getResults().get(1);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("78901", element.getCode());
+ assertEquals("Source Code 78901", element.getDisplay());
+ assertEquals(CS_URL_4, element.getSystem());
+ assertEquals("Version 5", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ // Test caching.
+ elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+ }
+ });
+ }
+
+ @Test
+ public void testWithReverseUsingPredicatesWithTargetValueSet() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ /*
+ * Provided:
+ * source code
+ * target value set
+ * reverse = true
+ */
+ TranslationRequest translationRequest = new TranslationRequest();
+ translationRequest.getCodeableConcept().addCoding()
+ .setCode("34567");
+ translationRequest.setTarget(new UriType(VS_URL));
+ translationRequest.setReverse(true);
+
+ TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertFalse(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+
+ TranslateConceptResult element = elements.getResults().get(0);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ element = elements.getResults().get(1);
+
+ ourLog.info("element:\n" + element.toString());
+
+ assertEquals("78901", element.getCode());
+ assertEquals("Source Code 78901", element.getDisplay());
+ assertEquals(CS_URL_4, element.getSystem());
+ assertEquals("Version 5", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ // Test caching.
+ elements = myConceptMappingSvc.translateWithReverse(translationRequest);
+ assertNotNull(elements);
+ assertEquals(2, elements.size());
+ assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
+ }
+ });
+ }
+
+ @Test
+ public void testDuplicateConceptMapUrls() {
+ createAndPersistConceptMap();
+
+ try {
+ createAndPersistConceptMap();
+ fail();
+ } catch (UnprocessableEntityException e) {
+ assertEquals("Can not create multiple ConceptMap resources with ConceptMap.url \"http://example.com/my_concept_map\", already have one with resource ID: ConceptMap/" + myConceptMapId.getIdPart(), e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void testDuplicateConceptMapUrlsAndVersions() {
+ createAndPersistConceptMap("v1");
+
+ try {
+ createAndPersistConceptMap("v1");
+ fail();
+ } catch (UnprocessableEntityException e) {
+ assertEquals("Can not create multiple ConceptMap resources with ConceptMap.url \"http://example.com/my_concept_map\" and ConceptMap.version \"v1\", already have one with resource ID: ConceptMap/" + myConceptMapId.getIdPart(), e.getMessage());
+ }
+
+ }
+
+
+ @Test
+ public void testStoreTermConceptMapAndChildren() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ Pageable page = PageRequest.of(0, 1);
+ List optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL);
+ assertEquals(1, optionalConceptMap.size());
+
+ TermConceptMap conceptMap = optionalConceptMap.get(0);
+
+ ourLog.info("ConceptMap:\n" + conceptMap.toString());
+
+ assertEquals(VS_URL, conceptMap.getSource());
+ assertEquals(VS_URL_2, conceptMap.getTarget());
+ assertEquals(CM_URL, conceptMap.getUrl());
+ assertEquals(3, conceptMap.getConceptMapGroups().size());
+
+ TermConceptMapGroup group = conceptMap.getConceptMapGroups().get(0);
+
+ ourLog.info("ConceptMap.group(0):\n" + group.toString());
+
+ assertEquals(CS_URL, group.getSource());
+ assertEquals("Version 1", group.getSourceVersion());
+ assertEquals(VS_URL, group.getSourceValueSet());
+ assertEquals(CS_URL_2, group.getTarget());
+ assertEquals("Version 2", group.getTargetVersion());
+ assertEquals(VS_URL_2, group.getTargetValueSet());
+ assertEquals(CM_URL, group.getConceptMapUrl());
+ assertEquals(2, group.getConceptMapGroupElements().size());
+
+ TermConceptMapGroupElement element = group.getConceptMapGroupElements().get(0);
+
+ ourLog.info("ConceptMap.group(0).element(0):\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+ assertEquals(1, element.getConceptMapGroupElementTargets().size());
+
+ TermConceptMapGroupElementTarget target = element.getConceptMapGroupElementTargets().get(0);
+
+ ourLog.info("ConceptMap.group(0).element(0).target(0):\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ element = group.getConceptMapGroupElements().get(1);
+
+ ourLog.info("ConceptMap.group(0).element(1):\n" + element.toString());
+
+ assertEquals("23456", element.getCode());
+ assertEquals("Source Code 23456", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ assertEquals(2, element.getConceptMapGroupElementTargets().size());
+
+ target = element.getConceptMapGroupElementTargets().get(0);
+ ourLog.info("ConceptMap.group(0).element(1).target(0):\n" + target.toString());
+ assertEquals("45678", target.getCode());
+ assertEquals("Target Code 45678", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // We had deliberately added a duplicate, and here it is...
+ target = element.getConceptMapGroupElementTargets().get(1);
+ ourLog.info("ConceptMap.group(0).element(1).target(1):\n" + target.toString());
+ assertEquals("45678", target.getCode());
+ assertEquals("Target Code 45678", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ group = conceptMap.getConceptMapGroups().get(1);
+
+ ourLog.info("ConceptMap.group(1):\n" + group.toString());
+
+ assertEquals(CS_URL, group.getSource());
+ assertEquals("Version 3", group.getSourceVersion());
+ assertEquals(CS_URL_3, group.getTarget());
+ assertEquals("Version 4", group.getTargetVersion());
+ assertEquals(CM_URL, group.getConceptMapUrl());
+ assertEquals(1, group.getConceptMapGroupElements().size());
+
+ element = group.getConceptMapGroupElements().get(0);
+
+ ourLog.info("ConceptMap.group(1).element(0):\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 3", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+ assertEquals(2, element.getConceptMapGroupElementTargets().size());
+
+ target = element.getConceptMapGroupElementTargets().get(0);
+
+ ourLog.info("ConceptMap.group(1).element(0).target(0):\n" + target.toString());
+
+ assertEquals("56789", target.getCode());
+ assertEquals("Target Code 56789", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = element.getConceptMapGroupElementTargets().get(1);
+
+ ourLog.info("ConceptMap.group(1).element(0).target(1):\n" + target.toString());
+
+ assertEquals("67890", target.getCode());
+ assertEquals("Target Code 67890", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ group = conceptMap.getConceptMapGroups().get(2);
+
+ ourLog.info("ConceptMap.group(2):\n" + group.toString());
+
+ assertEquals(CS_URL_4, group.getSource());
+ assertEquals("Version 5", group.getSourceVersion());
+ assertEquals(CS_URL_2, group.getTarget());
+ assertEquals("Version 2", group.getTargetVersion());
+ assertEquals(CM_URL, group.getConceptMapUrl());
+ assertEquals(1, group.getConceptMapGroupElements().size());
+
+ element = group.getConceptMapGroupElements().get(0);
+
+ ourLog.info("ConceptMap.group(2).element(0):\n" + element.toString());
+
+ assertEquals("78901", element.getCode());
+ assertEquals("Source Code 78901", element.getDisplay());
+ assertEquals(CS_URL_4, element.getSystem());
+ assertEquals("Version 5", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+ assertEquals(1, element.getConceptMapGroupElementTargets().size());
+
+ target = element.getConceptMapGroupElementTargets().get(0);
+
+ ourLog.info("ConceptMap.group(2).element(0).target(0):\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.NARROWER, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+ }
+ });
+ }
+
+ @Test
+ public void testStoreTermConceptMapAndChildrenWithClientAssignedId() {
+ createAndPersistConceptMap();
+ ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
+
+ ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
+
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ Pageable page = PageRequest.of(0, 1);
+ List optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL);
+ assertEquals(1, optionalConceptMap.size());
+
+ TermConceptMap conceptMap = optionalConceptMap.get(0);
+
+ ourLog.info("ConceptMap:\n" + conceptMap.toString());
+
+ assertEquals(VS_URL, conceptMap.getSource());
+ assertEquals(VS_URL_2, conceptMap.getTarget());
+ assertEquals(CM_URL, conceptMap.getUrl());
+ assertEquals(3, conceptMap.getConceptMapGroups().size());
+
+ TermConceptMapGroup group = conceptMap.getConceptMapGroups().get(0);
+
+ ourLog.info("ConceptMap.group(0):\n" + group.toString());
+
+ assertEquals(CS_URL, group.getSource());
+ assertEquals("Version 1", group.getSourceVersion());
+ assertEquals(VS_URL, group.getSourceValueSet());
+ assertEquals(CS_URL_2, group.getTarget());
+ assertEquals("Version 2", group.getTargetVersion());
+ assertEquals(VS_URL_2, group.getTargetValueSet());
+ assertEquals(CM_URL, group.getConceptMapUrl());
+ assertEquals(2, group.getConceptMapGroupElements().size());
+
+ TermConceptMapGroupElement element = group.getConceptMapGroupElements().get(0);
+
+ ourLog.info("ConceptMap.group(0).element(0):\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+ assertEquals(1, element.getConceptMapGroupElementTargets().size());
+
+ TermConceptMapGroupElementTarget target = element.getConceptMapGroupElementTargets().get(0);
+
+ ourLog.info("ConceptMap.group(0).element(0).target(0):\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ element = group.getConceptMapGroupElements().get(1);
+
+ ourLog.info("ConceptMap.group(0).element(1):\n" + element.toString());
+
+ assertEquals("23456", element.getCode());
+ assertEquals("Source Code 23456", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 1", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+
+ assertEquals(2, element.getConceptMapGroupElementTargets().size());
+
+ target = element.getConceptMapGroupElementTargets().get(0);
+ ourLog.info("ConceptMap.group(0).element(1).target(0):\n" + target.toString());
+ assertEquals("45678", target.getCode());
+ assertEquals("Target Code 45678", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ // We had deliberately added a duplicate, and here it is...
+ target = element.getConceptMapGroupElementTargets().get(1);
+ ourLog.info("ConceptMap.group(0).element(1).target(1):\n" + target.toString());
+ assertEquals("45678", target.getCode());
+ assertEquals("Target Code 45678", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ group = conceptMap.getConceptMapGroups().get(1);
+
+ ourLog.info("ConceptMap.group(1):\n" + group.toString());
+
+ assertEquals(CS_URL, group.getSource());
+ assertEquals("Version 3", group.getSourceVersion());
+ assertEquals(CS_URL_3, group.getTarget());
+ assertEquals("Version 4", group.getTargetVersion());
+ assertEquals(CM_URL, group.getConceptMapUrl());
+ assertEquals(1, group.getConceptMapGroupElements().size());
+
+ element = group.getConceptMapGroupElements().get(0);
+
+ ourLog.info("ConceptMap.group(1).element(0):\n" + element.toString());
+
+ assertEquals("12345", element.getCode());
+ assertEquals("Source Code 12345", element.getDisplay());
+ assertEquals(CS_URL, element.getSystem());
+ assertEquals("Version 3", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+ assertEquals(2, element.getConceptMapGroupElementTargets().size());
+
+ target = element.getConceptMapGroupElementTargets().get(0);
+
+ ourLog.info("ConceptMap.group(1).element(0).target(0):\n" + target.toString());
+
+ assertEquals("56789", target.getCode());
+ assertEquals("Target Code 56789", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.EQUAL, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ target = element.getConceptMapGroupElementTargets().get(1);
+
+ ourLog.info("ConceptMap.group(1).element(0).target(1):\n" + target.toString());
+
+ assertEquals("67890", target.getCode());
+ assertEquals("Target Code 67890", target.getDisplay());
+ assertEquals(CS_URL_3, target.getSystem());
+ assertEquals("Version 4", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+
+ group = conceptMap.getConceptMapGroups().get(2);
+
+ ourLog.info("ConceptMap.group(2):\n" + group.toString());
+
+ assertEquals(CS_URL_4, group.getSource());
+ assertEquals("Version 5", group.getSourceVersion());
+ assertEquals(CS_URL_2, group.getTarget());
+ assertEquals("Version 2", group.getTargetVersion());
+ assertEquals(CM_URL, group.getConceptMapUrl());
+ assertEquals(1, group.getConceptMapGroupElements().size());
+
+ element = group.getConceptMapGroupElements().get(0);
+
+ ourLog.info("ConceptMap.group(2).element(0):\n" + element.toString());
+
+ assertEquals("78901", element.getCode());
+ assertEquals("Source Code 78901", element.getDisplay());
+ assertEquals(CS_URL_4, element.getSystem());
+ assertEquals("Version 5", element.getSystemVersion());
+ assertEquals(VS_URL, element.getValueSet());
+ assertEquals(CM_URL, element.getConceptMapUrl());
+ assertEquals(1, element.getConceptMapGroupElementTargets().size());
+
+ target = element.getConceptMapGroupElementTargets().get(0);
+
+ ourLog.info("ConceptMap.group(2).element(0).target(0):\n" + target.toString());
+
+ assertEquals("34567", target.getCode());
+ assertEquals("Target Code 34567", target.getDisplay());
+ assertEquals(CS_URL_2, target.getSystem());
+ assertEquals("Version 2", target.getSystemVersion());
+ assertEquals(Enumerations.ConceptMapEquivalence.NARROWER, target.getEquivalence());
+ assertEquals(VS_URL_2, target.getValueSet());
+ assertEquals(CM_URL, target.getConceptMapUrl());
+ }
+ });
+ }
+
+
+ private void createAndPersistConceptMap() {
+ ConceptMap conceptMap = createConceptMap();
+ conceptMap.setId("ConceptMap/cm");
+ persistConceptMap(conceptMap, HttpVerb.POST);
+ }
+
+ private void createAndPersistConceptMap(String version) {
+ ConceptMap conceptMap = createConceptMap();
+ conceptMap.setId("ConceptMap/cm");
+ conceptMap.setVersion(version);
+ persistConceptMap(conceptMap, HttpVerb.POST);
+ }
+
+ @SuppressWarnings("EnumSwitchStatementWhichMissesCases")
+ private void persistConceptMap(ConceptMap theConceptMap, HttpVerb theVerb) {
+ switch (theVerb) {
+ case POST:
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ myConceptMapId = myConceptMapDao.create(theConceptMap, mySrd).getId().toUnqualifiedVersionless();
+ }
+ });
+ break;
+ case PUT:
+ new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
+ @Override
+ protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
+ myConceptMapId = myConceptMapDao.update(theConceptMap, mySrd).getId().toUnqualifiedVersionless();
+ }
+ });
+ break;
+ default:
+ throw new IllegalArgumentException("HTTP verb is not supported: " + theVerb);
+ }
+ }
+
+}
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 507b397ed7a..40aae7b0c75 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
@@ -3,32 +3,21 @@ package ca.uhn.fhir.jpa.term;
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.jpa.api.model.TranslationRequest;
import ca.uhn.fhir.jpa.entity.TermCodeSystem;
import ca.uhn.fhir.jpa.entity.TermCodeSystemVersion;
import ca.uhn.fhir.jpa.entity.TermConcept;
-import ca.uhn.fhir.jpa.entity.TermConceptMap;
-import ca.uhn.fhir.jpa.entity.TermConceptMapGroup;
-import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElement;
-import ca.uhn.fhir.jpa.entity.TermConceptMapGroupElementTarget;
import ca.uhn.fhir.jpa.entity.TermValueSet;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import org.hl7.fhir.instance.model.api.IIdType;
-import org.hl7.fhir.r4.model.CanonicalType;
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.ConceptMap;
-import org.hl7.fhir.r4.model.Enumerations;
-import org.hl7.fhir.r4.model.Enumerations.ConceptMapEquivalence;
-import org.hl7.fhir.r4.model.UriType;
import org.hl7.fhir.r4.model.ValueSet;
import org.hl7.fhir.r4.model.codesystems.HttpVerb;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.data.domain.PageRequest;
-import org.springframework.data.domain.Pageable;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;
@@ -44,7 +33,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -53,44 +41,6 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test {
private static final Logger ourLog = LoggerFactory.getLogger(TerminologySvcImplR4Test.class);
ConceptValidationOptions optsNoGuess = new ConceptValidationOptions();
ConceptValidationOptions optsGuess = new ConceptValidationOptions().setInferSystem(true);
- private IIdType myConceptMapId;
-
- private void createAndPersistConceptMap() {
- ConceptMap conceptMap = createConceptMap();
- conceptMap.setId("ConceptMap/cm");
- persistConceptMap(conceptMap, HttpVerb.POST);
- }
-
- private void createAndPersistConceptMap(String version) {
- ConceptMap conceptMap = createConceptMap();
- conceptMap.setId("ConceptMap/cm");
- conceptMap.setVersion(version);
- persistConceptMap(conceptMap, HttpVerb.POST);
- }
-
- @SuppressWarnings("EnumSwitchStatementWhichMissesCases")
- private void persistConceptMap(ConceptMap theConceptMap, HttpVerb theVerb) {
- switch (theVerb) {
- case POST:
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- myConceptMapId = myConceptMapDao.create(theConceptMap, mySrd).getId().toUnqualifiedVersionless();
- }
- });
- break;
- case PUT:
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- myConceptMapId = myConceptMapDao.update(theConceptMap, mySrd).getId().toUnqualifiedVersionless();
- }
- });
- break;
- default:
- throw new IllegalArgumentException("HTTP verb is not supported: " + theVerb);
- }
- }
@Test
public void testCreateConceptMapWithMissingSourceSystem() {
@@ -114,26 +64,6 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test {
}
- @Test
- public void testCreateConceptMapWithVirtualSourceSystem() {
- ConceptMap conceptMap = createConceptMap();
- conceptMap.getGroup().forEach(t -> t.setSource(null));
- conceptMap.setSource(new CanonicalType("http://hl7.org/fhir/uv/livd/StructureDefinition/loinc-livd"));
-
- persistConceptMap(conceptMap, HttpVerb.POST);
-
- }
-
- @Test
- public void testCreateConceptMapWithVirtualSourceSystemWithClientAssignedId() {
- ConceptMap conceptMap = createConceptMap();
- conceptMap.getGroup().forEach(t -> t.setSource(null));
- conceptMap.setSource(new CanonicalType("http://hl7.org/fhir/uv/livd/StructureDefinition/loinc-livd"));
- conceptMap.setId("ConceptMap/cm");
-
- persistConceptMap(conceptMap, HttpVerb.PUT);
-
- }
@Test
public void testCreateConceptMapWithMissingTargetSystems() {
@@ -269,32 +199,7 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test {
}
}
- @Test
- public void testDuplicateConceptMapUrls() {
- createAndPersistConceptMap();
- try {
- createAndPersistConceptMap();
- fail();
- } catch (UnprocessableEntityException e) {
- assertEquals("Can not create multiple ConceptMap resources with ConceptMap.url \"http://example.com/my_concept_map\", already have one with resource ID: ConceptMap/" + myConceptMapId.getIdPart(), e.getMessage());
- }
-
- }
-
- @Test
- public void testDuplicateConceptMapUrlsAndVersions() {
- createAndPersistConceptMap("v1");
-
- try {
- createAndPersistConceptMap("v1");
- fail();
- } catch (UnprocessableEntityException e) {
- assertEquals("Can not create multiple ConceptMap resources with ConceptMap.url \"http://example.com/my_concept_map\" and ConceptMap.version \"v1\", already have one with resource ID: ConceptMap/" + myConceptMapId.getIdPart(), e.getMessage());
- }
-
- }
-
@Test
public void testDuplicateValueSetUrls() throws Exception {
myDaoConfig.setPreExpandValueSets(true);
@@ -311,1498 +216,6 @@ public class TerminologySvcImplR4Test extends BaseTermR4Test {
}
- @Test
- public void testStoreTermConceptMapAndChildren() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- Pageable page = PageRequest.of(0, 1);
- List optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL);
- assertEquals(1, optionalConceptMap.size());
-
- TermConceptMap conceptMap = optionalConceptMap.get(0);
-
- ourLog.info("ConceptMap:\n" + conceptMap.toString());
-
- assertEquals(VS_URL, conceptMap.getSource());
- assertEquals(VS_URL_2, conceptMap.getTarget());
- assertEquals(CM_URL, conceptMap.getUrl());
- assertEquals(3, conceptMap.getConceptMapGroups().size());
-
- TermConceptMapGroup group = conceptMap.getConceptMapGroups().get(0);
-
- ourLog.info("ConceptMap.group(0):\n" + group.toString());
-
- assertEquals(CS_URL, group.getSource());
- assertEquals("Version 1", group.getSourceVersion());
- assertEquals(VS_URL, group.getSourceValueSet());
- assertEquals(CS_URL_2, group.getTarget());
- assertEquals("Version 2", group.getTargetVersion());
- assertEquals(VS_URL_2, group.getTargetValueSet());
- assertEquals(CM_URL, group.getConceptMapUrl());
- assertEquals(2, group.getConceptMapGroupElements().size());
-
- TermConceptMapGroupElement element = group.getConceptMapGroupElements().get(0);
-
- ourLog.info("ConceptMap.group(0).element(0):\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
- assertEquals(1, element.getConceptMapGroupElementTargets().size());
-
- TermConceptMapGroupElementTarget target = element.getConceptMapGroupElementTargets().get(0);
-
- ourLog.info("ConceptMap.group(0).element(0).target(0):\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- element = group.getConceptMapGroupElements().get(1);
-
- ourLog.info("ConceptMap.group(0).element(1):\n" + element.toString());
-
- assertEquals("23456", element.getCode());
- assertEquals("Source Code 23456", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- assertEquals(2, element.getConceptMapGroupElementTargets().size());
-
- target = element.getConceptMapGroupElementTargets().get(0);
- ourLog.info("ConceptMap.group(0).element(1).target(0):\n" + target.toString());
- assertEquals("45678", target.getCode());
- assertEquals("Target Code 45678", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // We had deliberately added a duplicate, and here it is...
- target = element.getConceptMapGroupElementTargets().get(1);
- ourLog.info("ConceptMap.group(0).element(1).target(1):\n" + target.toString());
- assertEquals("45678", target.getCode());
- assertEquals("Target Code 45678", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- group = conceptMap.getConceptMapGroups().get(1);
-
- ourLog.info("ConceptMap.group(1):\n" + group.toString());
-
- assertEquals(CS_URL, group.getSource());
- assertEquals("Version 3", group.getSourceVersion());
- assertEquals(CS_URL_3, group.getTarget());
- assertEquals("Version 4", group.getTargetVersion());
- assertEquals(CM_URL, group.getConceptMapUrl());
- assertEquals(1, group.getConceptMapGroupElements().size());
-
- element = group.getConceptMapGroupElements().get(0);
-
- ourLog.info("ConceptMap.group(1).element(0):\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 3", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
- assertEquals(2, element.getConceptMapGroupElementTargets().size());
-
- target = element.getConceptMapGroupElementTargets().get(0);
-
- ourLog.info("ConceptMap.group(1).element(0).target(0):\n" + target.toString());
-
- assertEquals("56789", target.getCode());
- assertEquals("Target Code 56789", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = element.getConceptMapGroupElementTargets().get(1);
-
- ourLog.info("ConceptMap.group(1).element(0).target(1):\n" + target.toString());
-
- assertEquals("67890", target.getCode());
- assertEquals("Target Code 67890", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- group = conceptMap.getConceptMapGroups().get(2);
-
- ourLog.info("ConceptMap.group(2):\n" + group.toString());
-
- assertEquals(CS_URL_4, group.getSource());
- assertEquals("Version 5", group.getSourceVersion());
- assertEquals(CS_URL_2, group.getTarget());
- assertEquals("Version 2", group.getTargetVersion());
- assertEquals(CM_URL, group.getConceptMapUrl());
- assertEquals(1, group.getConceptMapGroupElements().size());
-
- element = group.getConceptMapGroupElements().get(0);
-
- ourLog.info("ConceptMap.group(2).element(0):\n" + element.toString());
-
- assertEquals("78901", element.getCode());
- assertEquals("Source Code 78901", element.getDisplay());
- assertEquals(CS_URL_4, element.getSystem());
- assertEquals("Version 5", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
- assertEquals(1, element.getConceptMapGroupElementTargets().size());
-
- target = element.getConceptMapGroupElementTargets().get(0);
-
- ourLog.info("ConceptMap.group(2).element(0).target(0):\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.NARROWER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
- }
- });
- }
-
- @Test
- public void testStoreTermConceptMapAndChildrenWithClientAssignedId() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- Pageable page = PageRequest.of(0, 1);
- List optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL);
- assertEquals(1, optionalConceptMap.size());
-
- TermConceptMap conceptMap = optionalConceptMap.get(0);
-
- ourLog.info("ConceptMap:\n" + conceptMap.toString());
-
- assertEquals(VS_URL, conceptMap.getSource());
- assertEquals(VS_URL_2, conceptMap.getTarget());
- assertEquals(CM_URL, conceptMap.getUrl());
- assertEquals(3, conceptMap.getConceptMapGroups().size());
-
- TermConceptMapGroup group = conceptMap.getConceptMapGroups().get(0);
-
- ourLog.info("ConceptMap.group(0):\n" + group.toString());
-
- assertEquals(CS_URL, group.getSource());
- assertEquals("Version 1", group.getSourceVersion());
- assertEquals(VS_URL, group.getSourceValueSet());
- assertEquals(CS_URL_2, group.getTarget());
- assertEquals("Version 2", group.getTargetVersion());
- assertEquals(VS_URL_2, group.getTargetValueSet());
- assertEquals(CM_URL, group.getConceptMapUrl());
- assertEquals(2, group.getConceptMapGroupElements().size());
-
- TermConceptMapGroupElement element = group.getConceptMapGroupElements().get(0);
-
- ourLog.info("ConceptMap.group(0).element(0):\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
- assertEquals(1, element.getConceptMapGroupElementTargets().size());
-
- TermConceptMapGroupElementTarget target = element.getConceptMapGroupElementTargets().get(0);
-
- ourLog.info("ConceptMap.group(0).element(0).target(0):\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- element = group.getConceptMapGroupElements().get(1);
-
- ourLog.info("ConceptMap.group(0).element(1):\n" + element.toString());
-
- assertEquals("23456", element.getCode());
- assertEquals("Source Code 23456", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- assertEquals(2, element.getConceptMapGroupElementTargets().size());
-
- target = element.getConceptMapGroupElementTargets().get(0);
- ourLog.info("ConceptMap.group(0).element(1).target(0):\n" + target.toString());
- assertEquals("45678", target.getCode());
- assertEquals("Target Code 45678", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // We had deliberately added a duplicate, and here it is...
- target = element.getConceptMapGroupElementTargets().get(1);
- ourLog.info("ConceptMap.group(0).element(1).target(1):\n" + target.toString());
- assertEquals("45678", target.getCode());
- assertEquals("Target Code 45678", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- group = conceptMap.getConceptMapGroups().get(1);
-
- ourLog.info("ConceptMap.group(1):\n" + group.toString());
-
- assertEquals(CS_URL, group.getSource());
- assertEquals("Version 3", group.getSourceVersion());
- assertEquals(CS_URL_3, group.getTarget());
- assertEquals("Version 4", group.getTargetVersion());
- assertEquals(CM_URL, group.getConceptMapUrl());
- assertEquals(1, group.getConceptMapGroupElements().size());
-
- element = group.getConceptMapGroupElements().get(0);
-
- ourLog.info("ConceptMap.group(1).element(0):\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 3", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
- assertEquals(2, element.getConceptMapGroupElementTargets().size());
-
- target = element.getConceptMapGroupElementTargets().get(0);
-
- ourLog.info("ConceptMap.group(1).element(0).target(0):\n" + target.toString());
-
- assertEquals("56789", target.getCode());
- assertEquals("Target Code 56789", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = element.getConceptMapGroupElementTargets().get(1);
-
- ourLog.info("ConceptMap.group(1).element(0).target(1):\n" + target.toString());
-
- assertEquals("67890", target.getCode());
- assertEquals("Target Code 67890", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- group = conceptMap.getConceptMapGroups().get(2);
-
- ourLog.info("ConceptMap.group(2):\n" + group.toString());
-
- assertEquals(CS_URL_4, group.getSource());
- assertEquals("Version 5", group.getSourceVersion());
- assertEquals(CS_URL_2, group.getTarget());
- assertEquals("Version 2", group.getTargetVersion());
- assertEquals(CM_URL, group.getConceptMapUrl());
- assertEquals(1, group.getConceptMapGroupElements().size());
-
- element = group.getConceptMapGroupElements().get(0);
-
- ourLog.info("ConceptMap.group(2).element(0):\n" + element.toString());
-
- assertEquals("78901", element.getCode());
- assertEquals("Source Code 78901", element.getDisplay());
- assertEquals(CS_URL_4, element.getSystem());
- assertEquals("Version 5", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
- assertEquals(1, element.getConceptMapGroupElementTargets().size());
-
- target = element.getConceptMapGroupElementTargets().get(0);
-
- ourLog.info("ConceptMap.group(2).element(0).target(0):\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(Enumerations.ConceptMapEquivalence.NARROWER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
- }
- });
- }
-
- @Test
- public void testTranslateByCodeSystemsAndSourceCodeOneToMany() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL)
- .setCode("12345");
- translationRequest.setTargetSystem(new UriType(CS_URL_3));
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(2, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("target(0):\n" + target.toString());
-
- assertEquals("56789", target.getCode());
- assertEquals("Target Code 56789", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(1);
-
- ourLog.info("target(1):\n" + target.toString());
-
- assertEquals("67890", target.getCode());
- assertEquals("Target Code 67890", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(2, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateByCodeSystemsAndSourceCodeOneToOne() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL)
- .setCode("12345");
- translationRequest.setTargetSystem(new UriType(CS_URL_2));
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(1, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("ConceptMap.group.element.target:\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- TermConceptMapGroupElement element = target.getConceptMapGroupElement();
-
- ourLog.info("ConceptMap.group.element:\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- TermConceptMapGroup group = element.getConceptMapGroup();
-
- ourLog.info("ConceptMap.group:\n" + group.toString());
-
- assertEquals(CS_URL, group.getSource());
- assertEquals("Version 1", group.getSourceVersion());
- assertEquals(VS_URL, group.getSourceValueSet());
- assertEquals(CS_URL_2, group.getTarget());
- assertEquals("Version 2", group.getTargetVersion());
- assertEquals(VS_URL_2, group.getTargetValueSet());
- assertEquals(CM_URL, group.getConceptMapUrl());
-
- TermConceptMap conceptMap = group.getConceptMap();
-
- ourLog.info("ConceptMap:\n" + conceptMap.toString());
-
- assertNotNull(conceptMap);
- assertEquals(VS_URL, conceptMap.getSource());
- assertEquals(VS_URL_2, conceptMap.getTarget());
- assertEquals(CM_URL, conceptMap.getUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(1, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateByCodeSystemsAndSourceCodeUnmapped() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL)
- .setCode("BOGUS");
- translationRequest.setTargetSystem(new UriType(CS_URL_3));
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertTrue(targets.isEmpty());
- }
- });
- }
-
- @Test
- public void testTranslateConceptMapWithNoSourceAndTargetValueSet() {
-
- ConceptMap conceptMap = new ConceptMap();
- conceptMap.setUrl(CM_URL);
- conceptMap.setSource(null);
- conceptMap.setTarget(null);
- ConceptMap.ConceptMapGroupComponent group = conceptMap.addGroup()
- .setSource(CS_URL)
- .setTarget(CS_URL_2);
- group.addElement()
- .setCode("12345")
- .addTarget()
- .setCode("34567");
- group.addElement()
- .setCode("888")
- .addTarget()
- .setCode("999");
-
- myConceptMapDao.create(conceptMap);
-
- TranslationRequest translationRequest = new TranslationRequest()
- .addCode(CS_URL, "12345")
- .setTargetSystem(new UriType(CS_URL_2));
-
- List resp = myTermSvc.translate(translationRequest);
- assertEquals(1, resp.size());
- assertEquals("34567", resp.get(0).getCode());
- }
-
- @Test
- public void testTranslateUsingPredicatesWithCodeOnly() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setCode("12345");
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(3, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("target(0):\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(1);
-
- ourLog.info("target(1):\n" + target.toString());
-
- assertEquals("56789", target.getCode());
- assertEquals("Target Code 56789", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(2);
-
- ourLog.info("target(2):\n" + target.toString());
-
- assertEquals("67890", target.getCode());
- assertEquals("Target Code 67890", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(3, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateUsingPredicatesWithSourceAndTargetSystem2() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- * target code system #2
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL)
- .setCode("12345");
- translationRequest.setTargetSystem(new UriType(CS_URL_2));
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(1, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("target:\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(1, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateUsingPredicatesWithSourceAndTargetSystem3() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- * target code system #3
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL)
- .setCode("12345");
- translationRequest.setTargetSystem(new UriType(CS_URL_3));
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(2, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("target(0):\n" + target.toString());
-
- assertEquals("56789", target.getCode());
- assertEquals("Target Code 56789", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(1);
-
- ourLog.info("target(1):\n" + target.toString());
-
- assertEquals("67890", target.getCode());
- assertEquals("Target Code 67890", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(2, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateUsingPredicatesWithSourceSystem() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL)
- .setCode("12345");
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(3, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("target(0):\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(1);
-
- ourLog.info("target(1):\n" + target.toString());
-
- assertEquals("56789", target.getCode());
- assertEquals("Target Code 56789", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(2);
-
- ourLog.info("target(2):\n" + target.toString());
-
- assertEquals("67890", target.getCode());
- assertEquals("Target Code 67890", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(3, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateUsingPredicatesWithSourceSystemAndVersion1() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- * source code system version #1
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL)
- .setCode("12345")
- .setVersion("Version 1");
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(1, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("target:\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(1, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateUsingPredicatesWithSourceSystemAndVersion3() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- * source code system version #3
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL)
- .setCode("12345")
- .setVersion("Version 3");
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(2, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("target(0):\n" + target.toString());
-
- assertEquals("56789", target.getCode());
- assertEquals("Target Code 56789", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(1);
-
- ourLog.info("target(1):\n" + target.toString());
-
- assertEquals("67890", target.getCode());
- assertEquals("Target Code 67890", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(2, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateUsingPredicatesWithSourceValueSet() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source value set
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setCode("12345");
- translationRequest.setSource(new UriType(VS_URL));
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(3, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("target(0):\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(1);
-
- ourLog.info("target(1):\n" + target.toString());
-
- assertEquals("56789", target.getCode());
- assertEquals("Target Code 56789", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(2);
-
- ourLog.info("target(2):\n" + target.toString());
-
- assertEquals("67890", target.getCode());
- assertEquals("Target Code 67890", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(3, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateUsingPredicatesWithTargetValueSet() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * target value set
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setCode("12345");
- translationRequest.setTarget(new UriType(VS_URL_2));
-
- List targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(3, targets.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
-
- TermConceptMapGroupElementTarget target = targets.get(0);
-
- ourLog.info("target(0):\n" + target.toString());
-
- assertEquals("34567", target.getCode());
- assertEquals("Target Code 34567", target.getDisplay());
- assertEquals(CS_URL_2, target.getSystem());
- assertEquals("Version 2", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(1);
-
- ourLog.info("target(1):\n" + target.toString());
-
- assertEquals("56789", target.getCode());
- assertEquals("Target Code 56789", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.EQUAL, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- target = targets.get(2);
-
- ourLog.info("target(2):\n" + target.toString());
-
- assertEquals("67890", target.getCode());
- assertEquals("Target Code 67890", target.getDisplay());
- assertEquals(CS_URL_3, target.getSystem());
- assertEquals("Version 4", target.getSystemVersion());
- assertEquals(ConceptMapEquivalence.WIDER, target.getEquivalence());
- assertEquals(VS_URL_2, target.getValueSet());
- assertEquals(CM_URL, target.getConceptMapUrl());
-
- // Test caching.
- targets = myTermSvc.translate(translationRequest);
- assertNotNull(targets);
- assertEquals(3, targets.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationCache());
- }
- });
- }
-
- @Test
- public void testTranslateWithReverse() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- * target code system
- * reverse = true
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL_2)
- .setCode("34567");
- translationRequest.setTargetSystem(new UriType(CS_URL_4));
- translationRequest.setReverse(true);
-
- List elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(1, elements.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
-
- TermConceptMapGroupElement element = elements.get(0);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("78901", element.getCode());
- assertEquals("Source Code 78901", element.getDisplay());
- assertEquals(CS_URL_4, element.getSystem());
- assertEquals("Version 5", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- // Test caching.
- elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(1, elements.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
- }
- });
- }
-
- @Test
- public void testTranslateWithReverseByCodeSystemsAndSourceCodeUnmapped() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL_3)
- .setCode("BOGUS");
- translationRequest.setTargetSystem(new UriType(CS_URL));
-
- List elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertTrue(elements.isEmpty());
- }
- });
- }
-
- @Test
- public void testTranslateWithReverseUsingPredicatesWithCodeOnly() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * reverse = true
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setCode("34567");
- translationRequest.setReverse(true);
-
- List elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
-
- TermConceptMapGroupElement element = elements.get(0);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- element = elements.get(1);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("78901", element.getCode());
- assertEquals("Source Code 78901", element.getDisplay());
- assertEquals(CS_URL_4, element.getSystem());
- assertEquals("Version 5", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- // Test caching.
- elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
- }
- });
- }
-
- @Test
- public void testTranslateWithReverseUsingPredicatesWithSourceAndTargetSystem1() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- * target code system #1
- * reverse = true
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL_2)
- .setCode("34567");
- translationRequest.setTargetSystem(new UriType(CS_URL));
- translationRequest.setReverse(true);
-
- List elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(1, elements.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
-
- TermConceptMapGroupElement element = elements.get(0);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- // Test caching.
- elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(1, elements.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
- }
- });
- }
-
- @Test
- public void testTranslateWithReverseUsingPredicatesWithSourceAndTargetSystem4() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- * target code system #4
- * reverse = true
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL_2)
- .setCode("34567");
- translationRequest.setTargetSystem(new UriType(CS_URL_4));
- translationRequest.setReverse(true);
-
- List elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(1, elements.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
-
- TermConceptMapGroupElement element = elements.get(0);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("78901", element.getCode());
- assertEquals("Source Code 78901", element.getDisplay());
- assertEquals(CS_URL_4, element.getSystem());
- assertEquals("Version 5", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- // Test caching.
- elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(1, elements.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
- }
- });
- }
-
- @Test
- public void testTranslateWithReverseUsingPredicatesWithSourceSystem() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- * reverse = true
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL_2)
- .setCode("34567");
- translationRequest.setReverse(true);
-
- List elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
-
- TermConceptMapGroupElement element = elements.get(0);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- element = elements.get(1);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("78901", element.getCode());
- assertEquals("Source Code 78901", element.getDisplay());
- assertEquals(CS_URL_4, element.getSystem());
- assertEquals("Version 5", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- // Test caching.
- elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
- }
- });
- }
-
- @Test
- public void testTranslateWithReverseUsingPredicatesWithSourceSystemAndVersion() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source code system
- * source code system version
- * reverse = true
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setSystem(CS_URL_2)
- .setCode("34567")
- .setVersion("Version 2");
- translationRequest.setReverse(true);
-
- List elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
-
- TermConceptMapGroupElement element = elements.get(0);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- element = elements.get(1);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("78901", element.getCode());
- assertEquals("Source Code 78901", element.getDisplay());
- assertEquals(CS_URL_4, element.getSystem());
- assertEquals("Version 5", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- // Test caching.
- elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
- }
- });
- }
-
- @Test
- public void testTranslateWithReverseUsingPredicatesWithSourceValueSet() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * source value set
- * reverse = true
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setCode("34567");
- translationRequest.setSource(new UriType(VS_URL_2));
- translationRequest.setReverse(true);
-
- List elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
-
- TermConceptMapGroupElement element = elements.get(0);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- element = elements.get(1);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("78901", element.getCode());
- assertEquals("Source Code 78901", element.getDisplay());
- assertEquals(CS_URL_4, element.getSystem());
- assertEquals("Version 5", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- // Test caching.
- elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
- }
- });
- }
-
- @Test
- public void testTranslateWithReverseUsingPredicatesWithTargetValueSet() {
- createAndPersistConceptMap();
- ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
-
- ourLog.info("ConceptMap:\n" + myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
-
- new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
- @Override
- protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
- /*
- * Provided:
- * source code
- * target value set
- * reverse = true
- */
- TranslationRequest translationRequest = new TranslationRequest();
- translationRequest.getCodeableConcept().addCoding()
- .setCode("34567");
- translationRequest.setTarget(new UriType(VS_URL));
- translationRequest.setReverse(true);
-
- List elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertFalse(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
-
- TermConceptMapGroupElement element = elements.get(0);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("12345", element.getCode());
- assertEquals("Source Code 12345", element.getDisplay());
- assertEquals(CS_URL, element.getSystem());
- assertEquals("Version 1", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- element = elements.get(1);
-
- ourLog.info("element:\n" + element.toString());
-
- assertEquals("78901", element.getCode());
- assertEquals("Source Code 78901", element.getDisplay());
- assertEquals(CS_URL_4, element.getSystem());
- assertEquals("Version 5", element.getSystemVersion());
- assertEquals(VS_URL, element.getValueSet());
- assertEquals(CM_URL, element.getConceptMapUrl());
-
- // Test caching.
- elements = myTermSvc.translateWithReverse(translationRequest);
- assertNotNull(elements);
- assertEquals(2, elements.size());
- assertTrue(BaseTermReadSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
- }
- });
- }
@Test
public void testValidateCode() {
diff --git a/hapi-fhir-jpaserver-batch/pom.xml b/hapi-fhir-jpaserver-batch/pom.xml
index c461ab9bbf1..95d1bee3105 100644
--- a/hapi-fhir-jpaserver-batch/pom.xml
+++ b/hapi-fhir-jpaserver-batch/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-cql/pom.xml b/hapi-fhir-jpaserver-cql/pom.xml
index 1bf1bb9a827..c7ec753f71c 100644
--- a/hapi-fhir-jpaserver-cql/pom.xml
+++ b/hapi-fhir-jpaserver-cql/pom.xml
@@ -7,7 +7,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
@@ -144,13 +144,13 @@
ca.uhn.hapi.fhir
hapi-fhir-test-utilities
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
test
ca.uhn.hapi.fhir
hapi-fhir-jpaserver-test-utilities
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
test
diff --git a/hapi-fhir-jpaserver-mdm/pom.xml b/hapi-fhir-jpaserver-mdm/pom.xml
index 568806407a2..f6362d545f7 100644
--- a/hapi-fhir-jpaserver-mdm/pom.xml
+++ b/hapi-fhir-jpaserver-mdm/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
@@ -55,13 +55,13 @@
ca.uhn.hapi.fhir
hapi-fhir-test-utilities
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
test
ca.uhn.hapi.fhir
hapi-fhir-jpaserver-test-utilities
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
test
diff --git a/hapi-fhir-jpaserver-migrate/pom.xml b/hapi-fhir-jpaserver-migrate/pom.xml
index 5e61a7c54e0..2d44f20af89 100644
--- a/hapi-fhir-jpaserver-migrate/pom.xml
+++ b/hapi-fhir-jpaserver-migrate/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java
index a53a5a1f6da..de5042f9a43 100644
--- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java
+++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java
@@ -71,53 +71,54 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
init501(); // 20200514 - 20200515
init510(); // 20200516 - 20201028
init520(); // 20201029 -
- init530();
+ init530();
init540(); // 20210218 -
}
private void init540() {
-
+
Builder version = forVersion(VersionEnum.V5_4_0);
-
+
//-- add index on HFJ_SPIDX_DATE
- version.onTable("HFJ_SPIDX_DATE").addIndex("20210309.1", "IDX_SP_DATE_HASH_HIGH")
- .unique(false).withColumns("HASH_IDENTITY", "SP_VALUE_HIGH");
-
+ version.onTable("HFJ_SPIDX_DATE").addIndex("20210309.1", "IDX_SP_DATE_HASH_HIGH")
+ .unique(false).withColumns("HASH_IDENTITY", "SP_VALUE_HIGH");
+
//-- add index on HFJ_FORCED_ID
- version.onTable("HFJ_FORCED_ID").addIndex("20210309.2", "IDX_FORCEID_FID")
- .unique(false).withColumns("FORCED_ID");
+ version.onTable("HFJ_FORCED_ID").addIndex("20210309.2", "IDX_FORCEID_FID")
+ .unique(false).withColumns("FORCED_ID");
+
}
-
+
private void init530() {
Builder version = forVersion(VersionEnum.V5_3_0);
-
+
//-- TRM
version
.onTable("TRM_VALUESET_CONCEPT")
.dropIndex("20210104.1", "IDX_VS_CONCEPT_CS_CODE");
-
- version
- .onTable("TRM_VALUESET_CONCEPT")
- .addIndex("20210104.2", "IDX_VS_CONCEPT_CSCD").unique(true).withColumns("VALUESET_PID", "SYSTEM_URL", "CODEVAL");
-
+
+ version
+ .onTable("TRM_VALUESET_CONCEPT")
+ .addIndex("20210104.2", "IDX_VS_CONCEPT_CSCD").unique(true).withColumns("VALUESET_PID", "SYSTEM_URL", "CODEVAL");
+
//-- Add new Table, HFJ_SPIDX_QUANTITY_NRML
version.addIdGenerator("20210109.1", "SEQ_SPIDX_QUANTITY_NRML");
Builder.BuilderAddTableByColumns pkg = version.addTableByColumns("20210109.2", "HFJ_SPIDX_QUANTITY_NRML", "SP_ID");
- pkg.addColumn("RES_ID").nonNullable().type(ColumnTypeEnum.LONG);
- pkg.addColumn("RES_TYPE").nonNullable().type(ColumnTypeEnum.STRING, 100);
- pkg.addColumn("SP_UPDATED").nullable().type(ColumnTypeEnum.DATE_TIMESTAMP);
- pkg.addColumn("SP_MISSING").nonNullable().type(ColumnTypeEnum.BOOLEAN);
+ pkg.addColumn("RES_ID").nonNullable().type(ColumnTypeEnum.LONG);
+ pkg.addColumn("RES_TYPE").nonNullable().type(ColumnTypeEnum.STRING, 100);
+ pkg.addColumn("SP_UPDATED").nullable().type(ColumnTypeEnum.DATE_TIMESTAMP);
+ pkg.addColumn("SP_MISSING").nonNullable().type(ColumnTypeEnum.BOOLEAN);
pkg.addColumn("SP_NAME").nonNullable().type(ColumnTypeEnum.STRING, 100);
- pkg.addColumn("SP_ID").nonNullable().type(ColumnTypeEnum.LONG);
+ pkg.addColumn("SP_ID").nonNullable().type(ColumnTypeEnum.LONG);
pkg.addColumn("SP_SYSTEM").nullable().type(ColumnTypeEnum.STRING, 200);
pkg.addColumn("SP_UNITS").nullable().type(ColumnTypeEnum.STRING, 200);
pkg.addColumn("HASH_IDENTITY_AND_UNITS").nullable().type(ColumnTypeEnum.LONG);
pkg.addColumn("HASH_IDENTITY_SYS_UNITS").nullable().type(ColumnTypeEnum.LONG);
pkg.addColumn("HASH_IDENTITY").nullable().type(ColumnTypeEnum.LONG);
pkg.addColumn("SP_VALUE").nullable().type(ColumnTypeEnum.FLOAT);
- pkg.addIndex("20210109.3", "IDX_SP_QNTY_NRML_HASH").unique(false).withColumns("HASH_IDENTITY","SP_VALUE");
- pkg.addIndex("20210109.4", "IDX_SP_QNTY_NRML_HASH_UN").unique(false).withColumns("HASH_IDENTITY_AND_UNITS","SP_VALUE");
- pkg.addIndex("20210109.5", "IDX_SP_QNTY_NRML_HASH_SYSUN").unique(false).withColumns("HASH_IDENTITY_SYS_UNITS","SP_VALUE");
+ pkg.addIndex("20210109.3", "IDX_SP_QNTY_NRML_HASH").unique(false).withColumns("HASH_IDENTITY", "SP_VALUE");
+ pkg.addIndex("20210109.4", "IDX_SP_QNTY_NRML_HASH_UN").unique(false).withColumns("HASH_IDENTITY_AND_UNITS", "SP_VALUE");
+ pkg.addIndex("20210109.5", "IDX_SP_QNTY_NRML_HASH_SYSUN").unique(false).withColumns("HASH_IDENTITY_SYS_UNITS", "SP_VALUE");
pkg.addIndex("20210109.6", "IDX_SP_QNTY_NRML_UPDATED").unique(false).withColumns("SP_UPDATED");
pkg.addIndex("20210109.7", "IDX_SP_QNTY_NRML_RESID").unique(false).withColumns("RES_ID");
@@ -154,7 +155,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
.toColumn("GOLDEN_RESOURCE_PID")
.references("HFJ_RESOURCE", "RES_ID");
}
-
+
protected void init510() {
Builder version = forVersion(VersionEnum.V5_1_0);
@@ -224,7 +225,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
init510_20200725();
//EMPI Target Type
- empiLink.addColumn("20200727.1","TARGET_TYPE").nullable().type(ColumnTypeEnum.STRING, 40);
+ empiLink.addColumn("20200727.1", "TARGET_TYPE").nullable().type(ColumnTypeEnum.STRING, 40);
//ConceptMap add version for search
Builder.BuilderWithTableName trmConceptMap = version.onTable("TRM_CONCEPT_MAP");
@@ -1022,8 +1023,8 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
spidxUri
.addTask(new CalculateHashesTask(VersionEnum.V3_5_0, "20180903.44")
.setColumnName("HASH_IDENTITY")
- .addCalculator("HASH_IDENTITY", t -> BaseResourceIndexedSearchParam.calculateHashIdentity(new PartitionSettings(), (RequestPartitionId)null, t.getResourceType(), t.getString("SP_NAME")))
- .addCalculator("HASH_URI", t -> ResourceIndexedSearchParamUri.calculateHashUri(new PartitionSettings(), (RequestPartitionId)null, t.getResourceType(), t.getString("SP_NAME"), t.getString("SP_URI")))
+ .addCalculator("HASH_IDENTITY", t -> BaseResourceIndexedSearchParam.calculateHashIdentity(new PartitionSettings(), (RequestPartitionId) null, t.getResourceType(), t.getString("SP_NAME")))
+ .addCalculator("HASH_URI", t -> ResourceIndexedSearchParamUri.calculateHashUri(new PartitionSettings(), (RequestPartitionId) null, t.getResourceType(), t.getString("SP_NAME"), t.getString("SP_URI")))
);
}
@@ -1056,7 +1057,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks {
Boolean present = columnToBoolean(t.get("SP_PRESENT"));
String resType = (String) t.get("RES_TYPE");
String paramName = (String) t.get("PARAM_NAME");
- Long hash = SearchParamPresent.calculateHashPresence(new PartitionSettings(), (RequestPartitionId)null, resType, paramName, present);
+ Long hash = SearchParamPresent.calculateHashPresence(new PartitionSettings(), (RequestPartitionId) null, resType, paramName, present);
consolidateSearchParamPresenceIndexesTask.executeSql("HFJ_RES_PARAM_PRESENT", "update HFJ_RES_PARAM_PRESENT set HASH_PRESENCE = ? where PID = ?", hash, pid);
});
version.addTask(consolidateSearchParamPresenceIndexesTask);
diff --git a/hapi-fhir-jpaserver-model/pom.xml b/hapi-fhir-jpaserver-model/pom.xml
index 2866ec6e866..68a9fc35de9 100644
--- a/hapi-fhir-jpaserver-model/pom.xml
+++ b/hapi-fhir-jpaserver-model/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-searchparam/pom.xml b/hapi-fhir-jpaserver-searchparam/pom.xml
index d9f61c0b2ae..724615d932a 100755
--- a/hapi-fhir-jpaserver-searchparam/pom.xml
+++ b/hapi-fhir-jpaserver-searchparam/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-subscription/pom.xml b/hapi-fhir-jpaserver-subscription/pom.xml
index 16fd9cb909a..41834647cbb 100644
--- a/hapi-fhir-jpaserver-subscription/pom.xml
+++ b/hapi-fhir-jpaserver-subscription/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-test-utilities/pom.xml b/hapi-fhir-jpaserver-test-utilities/pom.xml
index 5b0ac9b0a5f..de592655080 100644
--- a/hapi-fhir-jpaserver-test-utilities/pom.xml
+++ b/hapi-fhir-jpaserver-test-utilities/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml
index b9cb7f1f31f..944d39c11e5 100644
--- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml
+++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../pom.xml
@@ -169,7 +169,7 @@
ca.uhn.hapi.fhir
hapi-fhir-converter
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml
index 9dea7e84e8d..2817fc5ccd2 100644
--- a/hapi-fhir-server-mdm/pom.xml
+++ b/hapi-fhir-server-mdm/pom.xml
@@ -7,7 +7,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml
index 0e0893ae8d5..2407e313e9b 100644
--- a/hapi-fhir-server/pom.xml
+++ b/hapi-fhir-server/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/BaseResponseTerminologyInterceptor.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/BaseResponseTerminologyInterceptor.java
new file mode 100644
index 00000000000..fdb50da4597
--- /dev/null
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/BaseResponseTerminologyInterceptor.java
@@ -0,0 +1,99 @@
+package ca.uhn.fhir.rest.server.interceptor;
+
+/*-
+ * #%L
+ * HAPI FHIR - Server Framework
+ * %%
+ * Copyright (C) 2014 - 2021 Smile CDR, Inc.
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.context.support.IValidationSupport;
+import ca.uhn.fhir.rest.api.server.RequestDetails;
+import ca.uhn.fhir.util.BundleUtil;
+import org.apache.commons.lang3.Validate;
+import org.hl7.fhir.instance.model.api.IBaseBundle;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+
+import javax.annotation.Nonnull;
+import java.util.Collections;
+import java.util.List;
+
+public class BaseResponseTerminologyInterceptor {
+ protected final IValidationSupport myValidationSupport;
+ protected final FhirContext myContext;
+
+ /**
+ * Constructor
+ *
+ * @param theValidationSupport The validation support module
+ */
+ public BaseResponseTerminologyInterceptor(@Nonnull IValidationSupport theValidationSupport) {
+ myValidationSupport = theValidationSupport;
+ Validate.notNull(theValidationSupport, "The validation support must not be null");
+
+ myContext = theValidationSupport.getFhirContext();
+ Validate.notNull(myContext, "The validation support must not return a null context");
+ }
+
+
+ @Nonnull
+ protected List toListForProcessing(RequestDetails theRequestDetails, IBaseResource theResource) {
+
+ switch (theRequestDetails.getRestOperationType()) {
+ // Don't apply to these operations
+ case ADD_TAGS:
+ case DELETE_TAGS:
+ case GET_TAGS:
+ case GET_PAGE:
+ case GRAPHQL_REQUEST:
+ case EXTENDED_OPERATION_SERVER:
+ case EXTENDED_OPERATION_TYPE:
+ case EXTENDED_OPERATION_INSTANCE:
+ case CREATE:
+ case DELETE:
+ case TRANSACTION:
+ case UPDATE:
+ case VALIDATE:
+ case METADATA:
+ case META_ADD:
+ case META:
+ case META_DELETE:
+ case PATCH:
+ default:
+ return Collections.emptyList();
+
+ // Do apply to these operations
+ case HISTORY_INSTANCE:
+ case HISTORY_SYSTEM:
+ case HISTORY_TYPE:
+ case SEARCH_SYSTEM:
+ case SEARCH_TYPE:
+ case READ:
+ case VREAD:
+ break;
+ }
+
+ List resources;
+ if (theResource instanceof IBaseBundle) {
+ resources = BundleUtil.toListOfResources(myContext, (IBaseBundle) theResource);
+ } else {
+ resources = Collections.singletonList(theResource);
+ }
+ return resources;
+ }
+
+}
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/InterceptorOrders.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/InterceptorOrders.java
index 9c49270bd87..cf1895e1f4a 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/InterceptorOrders.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/InterceptorOrders.java
@@ -26,6 +26,9 @@ public class InterceptorOrders {
public static final int RESPONSE_HIGHLIGHTER_INTERCEPTOR = 10000;
public static final int RESPONSE_SIZE_CAPTURING_INTERCEPTOR_COMPLETED = -1;
+ public static final int RESPONSE_TERMINOLOGY_TRANSLATION_INTERCEPTOR = 100;
+ public static final int RESPONSE_TERMINOLOGY_DISPLAY_POPULATION_INTERCEPTOR = 110;
+
/**
* Non instantiable
*/
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptor.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptor.java
new file mode 100644
index 00000000000..bcc22a8cb82
--- /dev/null
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptor.java
@@ -0,0 +1,120 @@
+package ca.uhn.fhir.rest.server.interceptor;
+
+/*-
+ * #%L
+ * HAPI FHIR - Server Framework
+ * %%
+ * Copyright (C) 2014 - 2021 Smile CDR, Inc.
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
+import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
+import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
+import ca.uhn.fhir.context.RuntimePrimitiveDatatypeDefinition;
+import ca.uhn.fhir.context.support.IValidationSupport;
+import ca.uhn.fhir.context.support.ValidationSupportContext;
+import ca.uhn.fhir.interceptor.api.Hook;
+import ca.uhn.fhir.interceptor.api.Pointcut;
+import ca.uhn.fhir.rest.api.server.RequestDetails;
+import ca.uhn.fhir.util.FhirTerser;
+import ca.uhn.fhir.util.IModelVisitor;
+import org.hl7.fhir.instance.model.api.IBase;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+import org.hl7.fhir.instance.model.api.IPrimitiveType;
+
+import java.util.List;
+import java.util.Objects;
+
+import static ca.uhn.fhir.rest.server.interceptor.InterceptorOrders.RESPONSE_TERMINOLOGY_DISPLAY_POPULATION_INTERCEPTOR;
+import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
+
+/**
+ * This interceptor looks for coded data (
+ *
+ * @since 5.4.0
+ */
+public class ResponseTerminologyDisplayPopulationInterceptor extends BaseResponseTerminologyInterceptor {
+
+ private final BaseRuntimeChildDefinition myCodingSystemChild;
+ private final BaseRuntimeChildDefinition myCodingCodeChild;
+ private final Class extends IBase> myCodingType;
+ private final BaseRuntimeElementCompositeDefinition> myCodingDefinitition;
+ private final BaseRuntimeChildDefinition myCodingDisplayChild;
+ private final RuntimePrimitiveDatatypeDefinition myStringDefinition;
+
+ /**
+ * Constructor
+ *
+ * @param theValidationSupport The validation support module
+ */
+ public ResponseTerminologyDisplayPopulationInterceptor(IValidationSupport theValidationSupport) {
+ super(theValidationSupport);
+
+ myCodingDefinitition = (BaseRuntimeElementCompositeDefinition>) Objects.requireNonNull(myContext.getElementDefinition("Coding"));
+ myCodingType = myCodingDefinitition.getImplementingClass();
+ myCodingSystemChild = myCodingDefinitition.getChildByName("system");
+ myCodingCodeChild = myCodingDefinitition.getChildByName("code");
+ myCodingDisplayChild = myCodingDefinitition.getChildByName("display");
+
+ myStringDefinition = (RuntimePrimitiveDatatypeDefinition) myContext.getElementDefinition("string");
+ }
+
+ @Hook(value = Pointcut.SERVER_OUTGOING_RESPONSE, order = RESPONSE_TERMINOLOGY_DISPLAY_POPULATION_INTERCEPTOR)
+ public void handleResource(RequestDetails theRequestDetails, IBaseResource theResource) {
+ List resources = toListForProcessing(theRequestDetails, theResource);
+
+ FhirTerser terser = myContext.newTerser();
+ for (IBaseResource nextResource : resources) {
+ terser.visit(nextResource, new MappingVisitor());
+ }
+
+ }
+
+ private class MappingVisitor implements IModelVisitor {
+
+ @Override
+ public void acceptElement(IBaseResource theResource, IBase theElement, List thePathToElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition> theDefinition) {
+ if (myCodingType.isAssignableFrom(theElement.getClass())) {
+ String system = myCodingSystemChild.getAccessor().getFirstValueOrNull(theElement).map(t -> (IPrimitiveType>) t).map(t -> t.getValueAsString()).orElse(null);
+ String code = myCodingCodeChild.getAccessor().getFirstValueOrNull(theElement).map(t -> (IPrimitiveType>) t).map(t -> t.getValueAsString()).orElse(null);
+ if (isBlank(system) || isBlank(code)) {
+ return;
+ }
+
+ String display = myCodingDisplayChild.getAccessor().getFirstValueOrNull(theElement).map(t -> (IPrimitiveType>) t).map(t -> t.getValueAsString()).orElse(null);
+ if (isNotBlank(display)) {
+ return;
+ }
+
+ ValidationSupportContext validationSupportContext = new ValidationSupportContext(myValidationSupport);
+ if (myValidationSupport.isCodeSystemSupported(validationSupportContext, system)) {
+
+ IValidationSupport.LookupCodeResult lookupCodeResult = myValidationSupport.lookupCode(validationSupportContext, system, code);
+ if (lookupCodeResult.isFound()) {
+ String newDisplay = lookupCodeResult.getCodeDisplay();
+ IPrimitiveType> newString = myStringDefinition.newInstance(newDisplay);
+ myCodingDisplayChild.getMutator().addValue(theElement, newString);
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+}
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyTranslationInterceptor.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyTranslationInterceptor.java
new file mode 100644
index 00000000000..cdf0926cd61
--- /dev/null
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyTranslationInterceptor.java
@@ -0,0 +1,191 @@
+package ca.uhn.fhir.rest.server.interceptor;
+
+/*-
+ * #%L
+ * HAPI FHIR - Server Framework
+ * %%
+ * Copyright (C) 2014 - 2021 Smile CDR, Inc.
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
+import ca.uhn.fhir.context.BaseRuntimeElementCompositeDefinition;
+import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
+import ca.uhn.fhir.context.RuntimePrimitiveDatatypeDefinition;
+import ca.uhn.fhir.context.support.IValidationSupport;
+import ca.uhn.fhir.context.support.TranslateConceptResult;
+import ca.uhn.fhir.context.support.TranslateConceptResults;
+import ca.uhn.fhir.interceptor.api.Hook;
+import ca.uhn.fhir.interceptor.api.Pointcut;
+import ca.uhn.fhir.rest.api.server.RequestDetails;
+import ca.uhn.fhir.util.FhirTerser;
+import ca.uhn.fhir.util.IModelVisitor;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+import org.apache.commons.lang3.Validate;
+import org.hl7.fhir.instance.model.api.IBase;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+import org.hl7.fhir.instance.model.api.IPrimitiveType;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+import static ca.uhn.fhir.rest.server.interceptor.InterceptorOrders.RESPONSE_TERMINOLOGY_TRANSLATION_INTERCEPTOR;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
+
+/**
+ * This interceptor leverages ConceptMap resources stored in the repository to automatically map
+ * terminology from one CodeSystem to another at runtime, in resources that are being
+ * returned by the server.
+ *
+ * Mappings are applied only if they are explicitly configured in the interceptor via
+ * the {@link #addMappingSpecification(String, String)} method.
+ *
+ *
+ * @since 5.4.0
+ */
+public class ResponseTerminologyTranslationInterceptor extends BaseResponseTerminologyInterceptor {
+
+ private final BaseRuntimeChildDefinition myCodingSystemChild;
+ private final BaseRuntimeChildDefinition myCodingCodeChild;
+ private final BaseRuntimeElementDefinition> myUriDefinition;
+ private final BaseRuntimeElementDefinition> myCodeDefinition;
+ private final Class extends IBase> myCodeableConceptType;
+ private final Class extends IBase> myCodingType;
+ private final BaseRuntimeChildDefinition myCodeableConceptCodingChild;
+ private final BaseRuntimeElementCompositeDefinition> myCodingDefinitition;
+ private final RuntimePrimitiveDatatypeDefinition myStringDefinition;
+ private final BaseRuntimeChildDefinition myCodingDisplayChild;
+ private Map myMappingSpecifications = new HashMap<>();
+
+ /**
+ * Constructor
+ *
+ * @param theValidationSupport The validation support module
+ */
+ public ResponseTerminologyTranslationInterceptor(IValidationSupport theValidationSupport) {
+ super(theValidationSupport);
+
+ BaseRuntimeElementCompositeDefinition> codeableConceptDef = (BaseRuntimeElementCompositeDefinition>) Objects.requireNonNull(myContext.getElementDefinition("CodeableConcept"));
+ myCodeableConceptType = codeableConceptDef.getImplementingClass();
+ myCodeableConceptCodingChild = codeableConceptDef.getChildByName("coding");
+
+ myCodingDefinitition = (BaseRuntimeElementCompositeDefinition>) Objects.requireNonNull(myContext.getElementDefinition("Coding"));
+ myCodingType = myCodingDefinitition.getImplementingClass();
+ myCodingSystemChild = myCodingDefinitition.getChildByName("system");
+ myCodingCodeChild = myCodingDefinitition.getChildByName("code");
+ myCodingDisplayChild = myCodingDefinitition.getChildByName("display");
+
+ myUriDefinition = (RuntimePrimitiveDatatypeDefinition) myContext.getElementDefinition("uri");
+ myCodeDefinition = (RuntimePrimitiveDatatypeDefinition) myContext.getElementDefinition("code");
+ myStringDefinition = (RuntimePrimitiveDatatypeDefinition) myContext.getElementDefinition("string");
+ }
+
+ /**
+ * Adds a mapping specification using only a source and target CodeSystem URL. Any mappings specified using
+ * this URL
+ *
+ * @param theSourceCodeSystemUrl The source CodeSystem URL
+ * @param theTargetCodeSystemUrl The target CodeSystem URL
+ */
+ public void addMappingSpecification(String theSourceCodeSystemUrl, String theTargetCodeSystemUrl) {
+ Validate.notBlank(theSourceCodeSystemUrl, "theSourceCodeSystemUrl must not be null or blank");
+ Validate.notBlank(theTargetCodeSystemUrl, "theTargetCodeSystemUrl must not be null or blank");
+
+ myMappingSpecifications.put(theSourceCodeSystemUrl, theTargetCodeSystemUrl);
+ }
+
+ /**
+ * Clear all mapping specifications
+ */
+ public void clearMappingSpecifications() {
+ myMappingSpecifications.clear();
+ }
+
+
+ @Hook(value = Pointcut.SERVER_OUTGOING_RESPONSE, order = RESPONSE_TERMINOLOGY_TRANSLATION_INTERCEPTOR)
+ public void handleResource(RequestDetails theRequestDetails, IBaseResource theResource) {
+ List resources = toListForProcessing(theRequestDetails, theResource);
+
+ FhirTerser terser = myContext.newTerser();
+ for (IBaseResource nextResource : resources) {
+ terser.visit(nextResource, new MappingVisitor());
+ }
+
+ }
+
+
+ private class MappingVisitor implements IModelVisitor {
+
+ @Override
+ public void acceptElement(IBaseResource theResource, IBase theElement, List thePathToElement, BaseRuntimeChildDefinition theChildDefinition, BaseRuntimeElementDefinition> theDefinition) {
+ if (myCodeableConceptType.isAssignableFrom(theElement.getClass())) {
+
+ // Find all existing Codings
+ Multimap foundSystemsToCodes = ArrayListMultimap.create();
+ List nextCodeableConceptCodings = myCodeableConceptCodingChild.getAccessor().getValues(theElement);
+ for (IBase nextCodeableConceptCoding : nextCodeableConceptCodings) {
+ String system = myCodingSystemChild.getAccessor().getFirstValueOrNull(nextCodeableConceptCoding).map(t -> (IPrimitiveType>) t).map(t -> t.getValueAsString()).orElse(null);
+ String code = myCodingCodeChild.getAccessor().getFirstValueOrNull(nextCodeableConceptCoding).map(t -> (IPrimitiveType>) t).map(t -> t.getValueAsString()).orElse(null);
+ if (isNotBlank(system) && isNotBlank(code) && !foundSystemsToCodes.containsKey(system)) {
+ foundSystemsToCodes.put(system, code);
+ }
+ }
+
+ // Look for mappings
+ for (String nextSourceSystem : foundSystemsToCodes.keySet()) {
+ String wantTargetSystem = myMappingSpecifications.get(nextSourceSystem);
+ if (wantTargetSystem != null) {
+ if (!foundSystemsToCodes.containsKey(wantTargetSystem)) {
+
+ for (String code : foundSystemsToCodes.get(nextSourceSystem)) {
+ TranslateConceptResults translateConceptResults = myValidationSupport.translateConcept(new IValidationSupport.TranslateCodeRequest(nextSourceSystem, code, wantTargetSystem));
+ if (translateConceptResults != null) {
+ List mappings = translateConceptResults.getResults();
+ for (TranslateConceptResult nextMapping : mappings) {
+
+ IBase newCoding = createCodingFromMappingTarget(nextMapping);
+
+ // Add coding to existing CodeableConcept
+ myCodeableConceptCodingChild.getMutator().addValue(theElement, newCoding);
+
+ }
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ }
+
+ private IBase createCodingFromMappingTarget(TranslateConceptResult nextMapping) {
+ IBase newCoding = myCodingDefinitition.newInstance();
+ IPrimitiveType> newSystem = myUriDefinition.newInstance(nextMapping.getSystem());
+ myCodingSystemChild.getMutator().addValue(newCoding, newSystem);
+ IPrimitiveType> newCode = myCodeDefinition.newInstance(nextMapping.getCode());
+ myCodingCodeChild.getMutator().addValue(newCoding, newCode);
+ if (isNotBlank(nextMapping.getDisplay())) {
+ IPrimitiveType> newDisplay = myStringDefinition.newInstance(nextMapping.getDisplay());
+ myCodingDisplayChild.getMutator().addValue(newCoding, newDisplay);
+ }
+ return newCoding;
+ }
+
+ }
+}
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml
index 801015702e3..c92df1fa279 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml
index 2a544a47fe5..95cd4751b8b 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot-samples
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
hapi-fhir-spring-boot-sample-client-apache
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml
index d2bb1653411..e6066b3326a 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot-samples
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
hapi-fhir-spring-boot-sample-client-okhttp
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml
index c43b89ca9fb..fb7ddb09c3a 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot-samples
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
hapi-fhir-spring-boot-sample-server-jersey
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml
index d49c9df752c..d6ebc5a399b 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
hapi-fhir-spring-boot-samples
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml
index ee1ef7400ce..a93a5fdf968 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-spring-boot/pom.xml b/hapi-fhir-spring-boot/pom.xml
index dd416146a40..b90b5a0d590 100644
--- a/hapi-fhir-spring-boot/pom.xml
+++ b/hapi-fhir-spring-boot/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-structures-dstu2.1/pom.xml b/hapi-fhir-structures-dstu2.1/pom.xml
index 5ccb224816b..2990c9922c1 100644
--- a/hapi-fhir-structures-dstu2.1/pom.xml
+++ b/hapi-fhir-structures-dstu2.1/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml
index 657730dcab6..a3e48873406 100644
--- a/hapi-fhir-structures-dstu2/pom.xml
+++ b/hapi-fhir-structures-dstu2/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-structures-dstu3/pom.xml b/hapi-fhir-structures-dstu3/pom.xml
index 02c218e82d2..9a03f490acc 100644
--- a/hapi-fhir-structures-dstu3/pom.xml
+++ b/hapi-fhir-structures-dstu3/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-structures-hl7org-dstu2/pom.xml b/hapi-fhir-structures-hl7org-dstu2/pom.xml
index 33be95ed04d..f94b37ea096 100644
--- a/hapi-fhir-structures-hl7org-dstu2/pom.xml
+++ b/hapi-fhir-structures-hl7org-dstu2/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-structures-r4/pom.xml b/hapi-fhir-structures-r4/pom.xml
index 674daa483de..3a46d64b894 100644
--- a/hapi-fhir-structures-r4/pom.xml
+++ b/hapi-fhir-structures-r4/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-structures-r5/pom.xml b/hapi-fhir-structures-r5/pom.xml
index d04b1a5fe44..911d81a7d0b 100644
--- a/hapi-fhir-structures-r5/pom.xml
+++ b/hapi-fhir-structures-r5/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-test-utilities/pom.xml b/hapi-fhir-test-utilities/pom.xml
index 9ce3bc3bc62..5d92d6d774a 100644
--- a/hapi-fhir-test-utilities/pom.xml
+++ b/hapi-fhir-test-utilities/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-testpage-overlay/pom.xml b/hapi-fhir-testpage-overlay/pom.xml
index b418de07bfb..55407e74af8 100644
--- a/hapi-fhir-testpage-overlay/pom.xml
+++ b/hapi-fhir-testpage-overlay/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-validation-resources-dstu2.1/pom.xml b/hapi-fhir-validation-resources-dstu2.1/pom.xml
index 95f312078d3..a7c89b00189 100644
--- a/hapi-fhir-validation-resources-dstu2.1/pom.xml
+++ b/hapi-fhir-validation-resources-dstu2.1/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-validation-resources-dstu2/pom.xml b/hapi-fhir-validation-resources-dstu2/pom.xml
index 27ac1bc796b..4d10b5868a7 100644
--- a/hapi-fhir-validation-resources-dstu2/pom.xml
+++ b/hapi-fhir-validation-resources-dstu2/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-validation-resources-dstu3/pom.xml b/hapi-fhir-validation-resources-dstu3/pom.xml
index 325e4736caf..caa4236810b 100644
--- a/hapi-fhir-validation-resources-dstu3/pom.xml
+++ b/hapi-fhir-validation-resources-dstu3/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-validation-resources-r4/pom.xml b/hapi-fhir-validation-resources-r4/pom.xml
index 5185712e048..90bc4b01919 100644
--- a/hapi-fhir-validation-resources-r4/pom.xml
+++ b/hapi-fhir-validation-resources-r4/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-validation-resources-r5/pom.xml b/hapi-fhir-validation-resources-r5/pom.xml
index 98885fe44c0..23233a961e1 100644
--- a/hapi-fhir-validation-resources-r5/pom.xml
+++ b/hapi-fhir-validation-resources-r5/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-validation/pom.xml b/hapi-fhir-validation/pom.xml
index e2ef2cb4ad1..a04398bb661 100644
--- a/hapi-fhir-validation/pom.xml
+++ b/hapi-fhir-validation/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/BaseValidationSupportWrapper.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/BaseValidationSupportWrapper.java
index cc04a447d10..3bec90fd887 100644
--- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/BaseValidationSupportWrapper.java
+++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/BaseValidationSupportWrapper.java
@@ -3,6 +3,7 @@ package org.hl7.fhir.common.hapi.validation.support;
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.TranslateConceptResults;
import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.context.support.ValueSetExpansionOptions;
import org.apache.commons.lang3.Validate;
@@ -69,7 +70,7 @@ public class BaseValidationSupportWrapper extends BaseValidationSupport {
}
@Override
- public IValidationSupport.ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, ValueSetExpansionOptions theExpansionOptions, IBaseResource theValueSetToExpand) {
+ public IValidationSupport.ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, ValueSetExpansionOptions theExpansionOptions, @Nonnull IBaseResource theValueSetToExpand) {
return myWrap.expandValueSet(theValidationSupportContext, theExpansionOptions, theValueSetToExpand);
}
@@ -99,5 +100,8 @@ public class BaseValidationSupportWrapper extends BaseValidationSupport {
return myWrap.validateCodeInValueSet(theValidationSupportContext, theValidationOptions, theCodeSystem, theCode, theDisplay, theValueSet);
}
-
+ @Override
+ public TranslateConceptResults translateConcept(TranslateCodeRequest theRequest) {
+ return myWrap.translateConcept(theRequest);
+ }
}
diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java
index b6515f00d64..43fbfff5c6c 100644
--- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java
+++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/CachingValidationSupport.java
@@ -3,9 +3,11 @@ package org.hl7.fhir.common.hapi.validation.support;
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
import ca.uhn.fhir.context.support.ConceptValidationOptions;
import ca.uhn.fhir.context.support.IValidationSupport;
+import ca.uhn.fhir.context.support.TranslateConceptResults;
import ca.uhn.fhir.context.support.ValidationSupportContext;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
+import org.apache.commons.lang3.time.DateUtils;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.slf4j.Logger;
@@ -28,24 +30,44 @@ public class CachingValidationSupport extends BaseValidationSupportWrapper imple
private static final Logger ourLog = LoggerFactory.getLogger(CachingValidationSupport.class);
private final Cache myCache;
private final Cache myValidateCodeCache;
+ private final Cache myTranslateCodeCache;
private final Cache myLookupCodeCache;
-
+ /**
+ * Constuctor with default timeouts
+ *
+ * @param theWrap The validation support module to wrap
+ */
public CachingValidationSupport(IValidationSupport theWrap) {
+ this(theWrap, CacheTimeouts.defaultValues());
+ }
+
+ /**
+ * Constructor with configurable timeouts
+ *
+ * @param theWrap The validation support module to wrap
+ * @param theCacheTimeouts The timeouts to use
+ */
+ public CachingValidationSupport(IValidationSupport theWrap, CacheTimeouts theCacheTimeouts) {
super(theWrap.getFhirContext(), theWrap);
myValidateCodeCache = Caffeine
.newBuilder()
- .expireAfterWrite(10, TimeUnit.MINUTES)
+ .expireAfterWrite(theCacheTimeouts.getValidateCodeMillis(), TimeUnit.MILLISECONDS)
.maximumSize(5000)
.build();
myLookupCodeCache = Caffeine
.newBuilder()
- .expireAfterWrite(10, TimeUnit.MINUTES)
+ .expireAfterWrite(theCacheTimeouts.getLookupCodeMillis(), TimeUnit.MILLISECONDS)
+ .maximumSize(5000)
+ .build();
+ myTranslateCodeCache = Caffeine
+ .newBuilder()
+ .expireAfterWrite(theCacheTimeouts.getTranslateCodeMillis(), TimeUnit.MILLISECONDS)
.maximumSize(5000)
.build();
myCache = Caffeine
.newBuilder()
- .expireAfterWrite(10, TimeUnit.MINUTES)
+ .expireAfterWrite(theCacheTimeouts.getMiscMillis(), TimeUnit.MILLISECONDS)
.maximumSize(5000)
.build();
}
@@ -88,12 +110,30 @@ public class CachingValidationSupport extends BaseValidationSupportWrapper imple
return loadFromCache(myLookupCodeCache, key, t -> super.lookupCode(theValidationSupportContext, theSystem, theCode));
}
+ @Override
+ public IValidationSupport.CodeValidationResult validateCodeInValueSet(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theValidationOptions, String theCodeSystem, String theCode, String theDisplay, @Nonnull IBaseResource theValueSet) {
+
+ BaseRuntimeChildDefinition urlChild = myCtx.getResourceDefinition(theValueSet).getChildByName("url");
+ Optional valueSetUrl = urlChild.getAccessor().getValues(theValueSet).stream().map(t -> ((IPrimitiveType>) t).getValueAsString()).filter(t -> isNotBlank(t)).findFirst();
+ if (valueSetUrl.isPresent()) {
+ String key = "validateCodeInValueSet " + theValidationOptions.toString() + " " + defaultString(theCodeSystem, "(null)") + " " + defaultString(theCode, "(null)") + " " + defaultString(theDisplay, "(null)") + " " + valueSetUrl.get();
+ return loadFromCache(myValidateCodeCache, key, t -> super.validateCodeInValueSet(theValidationSupportContext, theValidationOptions, theCodeSystem, theCode, theDisplay, theValueSet));
+ }
+
+ return super.validateCodeInValueSet(theValidationSupportContext, theValidationOptions, theCodeSystem, theCode, theDisplay, theValueSet);
+ }
+
+ @Override
+ public TranslateConceptResults translateConcept(TranslateCodeRequest theRequest) {
+ return loadFromCache(myTranslateCodeCache, theRequest, k -> super.translateConcept(theRequest));
+ }
+
@SuppressWarnings("OptionalAssignedToNull")
@Nullable
- private T loadFromCache(Cache theCache, String theKey, Function theLoader) {
+ private T loadFromCache(Cache theCache, S theKey, Function theLoader) {
ourLog.trace("Fetching from cache: {}", theKey);
- Function> loaderWrapper = key -> Optional.ofNullable(theLoader.apply(theKey));
+ Function> loaderWrapper = key -> Optional.ofNullable(theLoader.apply(theKey));
Optional result = (Optional) theCache.get(theKey, loaderWrapper);
assert result != null;
@@ -101,23 +141,65 @@ public class CachingValidationSupport extends BaseValidationSupportWrapper imple
}
- @Override
- public IValidationSupport.CodeValidationResult validateCodeInValueSet(ValidationSupportContext theValidationSupportContext, ConceptValidationOptions theValidationOptions, String theCodeSystem, String theCode, String theDisplay, @Nonnull IBaseResource theValueSet) {
-
- BaseRuntimeChildDefinition urlChild = myCtx.getResourceDefinition(theValueSet).getChildByName("url");
- Optional valueSetUrl = urlChild.getAccessor().getValues(theValueSet).stream().map(t -> ((IPrimitiveType>) t).getValueAsString()).filter(t->isNotBlank(t)).findFirst();
- if (valueSetUrl.isPresent()) {
- String key = "validateCodeInValueSet " + theValidationOptions.toString() + " " + defaultString(theCodeSystem, "(null)") + " " + defaultString(theCode, "(null)") + " " + defaultString(theDisplay, "(null)") + " " + valueSetUrl.get();
- return loadFromCache(myValidateCodeCache, key, t-> super.validateCodeInValueSet(theValidationSupportContext, theValidationOptions, theCodeSystem, theCode, theDisplay, theValueSet));
- }
-
- return super.validateCodeInValueSet(theValidationSupportContext, theValidationOptions, theCodeSystem, theCode, theDisplay, theValueSet);
- }
-
@Override
public void invalidateCaches() {
myLookupCodeCache.invalidateAll();
myCache.invalidateAll();
myValidateCodeCache.invalidateAll();
}
+
+ /**
+ * @since 5.4.0
+ */
+ public static class CacheTimeouts {
+
+ private long myTranslateCodeMillis;
+ private long myLookupCodeMillis;
+ private long myValidateCodeMillis;
+ private long myMiscMillis;
+
+ public long getTranslateCodeMillis() {
+ return myTranslateCodeMillis;
+ }
+
+ public CacheTimeouts setTranslateCodeMillis(long theTranslateCodeMillis) {
+ myTranslateCodeMillis = theTranslateCodeMillis;
+ return this;
+ }
+
+ public long getLookupCodeMillis() {
+ return myLookupCodeMillis;
+ }
+
+ public CacheTimeouts setLookupCodeMillis(long theLookupCodeMillis) {
+ myLookupCodeMillis = theLookupCodeMillis;
+ return this;
+ }
+
+ public long getValidateCodeMillis() {
+ return myValidateCodeMillis;
+ }
+
+ public CacheTimeouts setValidateCodeMillis(long theValidateCodeMillis) {
+ myValidateCodeMillis = theValidateCodeMillis;
+ return this;
+ }
+
+ public long getMiscMillis() {
+ return myMiscMillis;
+ }
+
+ public CacheTimeouts setMiscMillis(long theMiscMillis) {
+ myMiscMillis = theMiscMillis;
+ return this;
+ }
+
+ public static CacheTimeouts defaultValues() {
+ return new CacheTimeouts()
+ .setLookupCodeMillis(10 * DateUtils.MILLIS_PER_MINUTE)
+ .setTranslateCodeMillis(10 * DateUtils.MILLIS_PER_MINUTE)
+ .setValidateCodeMillis(10 * DateUtils.MILLIS_PER_MINUTE)
+ .setMiscMillis(10 * DateUtils.MILLIS_PER_MINUTE);
+ }
+ }
}
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 f9d134ffe39..28d2407fb33 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
@@ -57,7 +57,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu
}
@Override
- public ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, ValueSetExpansionOptions theExpansionOptions, IBaseResource theValueSetToExpand) {
+ public ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, ValueSetExpansionOptions theExpansionOptions, @Nonnull IBaseResource theValueSetToExpand) {
org.hl7.fhir.r5.model.ValueSet expansionR5 = expandValueSetToCanonical(theValidationSupportContext, theValueSetToExpand, null, null);
if (expansionR5 == null) {
diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportChain.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportChain.java
index 841038fd4b7..10ce6294421 100644
--- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportChain.java
+++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/ValidationSupportChain.java
@@ -5,6 +5,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.support.ConceptValidationOptions;
import ca.uhn.fhir.context.support.IValidationSupport;
+import ca.uhn.fhir.context.support.TranslateConceptResults;
import ca.uhn.fhir.context.support.ValidationSupportContext;
import ca.uhn.fhir.context.support.ValueSetExpansionOptions;
import org.apache.commons.lang3.Validate;
@@ -42,6 +43,31 @@ public class ValidationSupportChain implements IValidationSupport {
}
}
+ @Override
+ public TranslateConceptResults translateConcept(TranslateCodeRequest theRequest) {
+ TranslateConceptResults retVal = null;
+ for (IValidationSupport next : myChain) {
+ TranslateConceptResults translations = next.translateConcept(theRequest);
+ if (translations != null) {
+ if (retVal == null) {
+ retVal = new TranslateConceptResults();
+ }
+
+ if (retVal.getMessage() == null) {
+ retVal.setMessage(translations.getMessage());
+ }
+
+ if (translations.getResult() && !retVal.getResult()) {
+ retVal.setResult(translations.getResult());
+ retVal.setMessage(translations.getMessage());
+ }
+
+ retVal.getResults().addAll(translations.getResults());
+ }
+ }
+ return retVal;
+ }
+
@Override
public void invalidateCaches() {
for (IValidationSupport next : myChain) {
@@ -131,7 +157,7 @@ public class ValidationSupportChain implements IValidationSupport {
}
@Override
- public ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, ValueSetExpansionOptions theExpansionOptions, IBaseResource theValueSetToExpand) {
+ public ValueSetExpansionOutcome expandValueSet(ValidationSupportContext theValidationSupportContext, ValueSetExpansionOptions theExpansionOptions, @Nonnull IBaseResource theValueSetToExpand) {
for (IValidationSupport next : myChain) {
// TODO: test if code system is supported?
ValueSetExpansionOutcome expanded = next.expandValueSet(theValidationSupportContext, theExpansionOptions, theValueSetToExpand);
diff --git a/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java b/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java
new file mode 100644
index 00000000000..1a07ac3875e
--- /dev/null
+++ b/hapi-fhir-validation/src/test/java/ca/uhn/fhir/rest/server/interceptor/ResponseTerminologyDisplayPopulationInterceptorTest.java
@@ -0,0 +1,94 @@
+package ca.uhn.fhir.rest.server.interceptor;
+
+import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.context.FhirVersionEnum;
+import ca.uhn.fhir.rest.client.api.IGenericClient;
+import ca.uhn.fhir.test.utilities.server.HashMapResourceProviderExtension;
+import ca.uhn.fhir.test.utilities.server.RestfulServerExtension;
+import org.hl7.fhir.instance.model.api.IIdType;
+import org.hl7.fhir.r4.model.Bundle;
+import org.hl7.fhir.r4.model.Patient;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ResponseTerminologyDisplayPopulationInterceptorTest {
+
+ private final FhirContext myCtx = FhirContext.forCached(FhirVersionEnum.R4);
+ @Order(0)
+ @RegisterExtension
+ protected RestfulServerExtension myServerExtension = new RestfulServerExtension(myCtx);
+ @Order(1)
+ @RegisterExtension
+ protected HashMapResourceProviderExtension myProviderPatientExtension = new HashMapResourceProviderExtension<>(myServerExtension, Patient.class);
+ private IGenericClient myClient;
+
+ @BeforeEach
+ public void beforeEach() {
+ myClient = myServerExtension.getFhirClient();
+ }
+
+ @AfterEach
+ public void afterEach() {
+ myServerExtension.getRestfulServer().getInterceptorService().unregisterAllInterceptors();
+ }
+
+ @Test
+ public void testPopulateCoding_Read() {
+ myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(myCtx.getValidationSupport()));
+
+ Patient p = new Patient();
+ p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("A");
+ IIdType id = myClient.create().resource(p).execute().getId();
+
+ p = myClient.read().resource(Patient.class).withId(id).execute();
+ assertEquals(1, p.getMaritalStatus().getCoding().size());
+ assertEquals("Annulled", p.getMaritalStatus().getCoding().get(0).getDisplay());
+ }
+
+ @Test
+ public void testPopulateCoding_Search() {
+ myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(myCtx.getValidationSupport()));
+
+ Patient p = new Patient();
+ p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("A");
+ IIdType id = myClient.create().resource(p).execute().getId();
+
+ Bundle bundle = myClient.search().forResource(Patient.class).returnBundle(Bundle.class).execute();
+ assertEquals(1, bundle.getEntry().size());
+ p = (Patient) bundle.getEntry().get(0).getResource();
+ assertEquals(1, p.getMaritalStatus().getCoding().size());
+ assertEquals("Annulled", p.getMaritalStatus().getCoding().get(0).getDisplay());
+ }
+
+ @Test
+ public void testDontPopulateCodingIfAlreadyPopulated() {
+ myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(myCtx.getValidationSupport()));
+
+ Patient p = new Patient();
+ p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("A").setDisplay("FOO");
+ IIdType id = myClient.create().resource(p).execute().getId();
+
+ p = myClient.read().resource(Patient.class).withId(id).execute();
+ assertEquals(1, p.getMaritalStatus().getCoding().size());
+ assertEquals("FOO", p.getMaritalStatus().getCoding().get(0).getDisplay());
+ }
+
+ @Test
+ public void testDontPopulateCodingIfNoneFound() {
+ myServerExtension.getRestfulServer().registerInterceptor(new ResponseTerminologyDisplayPopulationInterceptor(myCtx.getValidationSupport()));
+
+ Patient p = new Patient();
+ p.getMaritalStatus().addCoding().setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus").setCode("ZZZZZZ");
+ IIdType id = myClient.create().resource(p).execute().getId();
+
+ p = myClient.read().resource(Patient.class).withId(id).execute();
+ assertEquals(1, p.getMaritalStatus().getCoding().size());
+ assertEquals(null, p.getMaritalStatus().getCoding().get(0).getDisplay());
+ }
+
+}
diff --git a/hapi-tinder-plugin/pom.xml b/hapi-tinder-plugin/pom.xml
index d1b246dc1b4..5f3f25b6514 100644
--- a/hapi-tinder-plugin/pom.xml
+++ b/hapi-tinder-plugin/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../pom.xml
@@ -58,37 +58,37 @@
ca.uhn.hapi.fhir
hapi-fhir-structures-dstu3
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
ca.uhn.hapi.fhir
hapi-fhir-structures-hl7org-dstu2
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
ca.uhn.hapi.fhir
hapi-fhir-structures-r4
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
ca.uhn.hapi.fhir
hapi-fhir-structures-r5
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
ca.uhn.hapi.fhir
hapi-fhir-validation-resources-dstu2
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
ca.uhn.hapi.fhir
hapi-fhir-validation-resources-dstu3
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
ca.uhn.hapi.fhir
hapi-fhir-validation-resources-r4
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
org.apache.velocity
diff --git a/hapi-tinder-test/pom.xml b/hapi-tinder-test/pom.xml
index fa9fc869023..87cdd749b64 100644
--- a/hapi-tinder-test/pom.xml
+++ b/hapi-tinder-test/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../pom.xml
diff --git a/pom.xml b/pom.xml
index c1c6c82099e..37e6ec00032 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-fhir
pom
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
HAPI-FHIR
An open-source implementation of the FHIR specification in Java.
https://hapifhir.io
diff --git a/restful-server-example/pom.xml b/restful-server-example/pom.xml
index f88c2bac86b..0b83454925b 100644
--- a/restful-server-example/pom.xml
+++ b/restful-server-example/pom.xml
@@ -8,7 +8,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../pom.xml
diff --git a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml
index 7020e739997..a9bfd82091e 100644
--- a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml
+++ b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml
@@ -6,7 +6,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../../pom.xml
diff --git a/tests/hapi-fhir-base-test-mindeps-client/pom.xml b/tests/hapi-fhir-base-test-mindeps-client/pom.xml
index 4da73724308..1bbe808dd62 100644
--- a/tests/hapi-fhir-base-test-mindeps-client/pom.xml
+++ b/tests/hapi-fhir-base-test-mindeps-client/pom.xml
@@ -4,7 +4,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../../pom.xml
diff --git a/tests/hapi-fhir-base-test-mindeps-server/pom.xml b/tests/hapi-fhir-base-test-mindeps-server/pom.xml
index 5436174b35d..4a1c0978be1 100644
--- a/tests/hapi-fhir-base-test-mindeps-server/pom.xml
+++ b/tests/hapi-fhir-base-test-mindeps-server/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.4.0-PRE1-SNAPSHOT
+ 5.4.0-PRE2-SNAPSHOT
../../pom.xml