|
|
|
@ -18,8 +18,6 @@ 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.IdType;
|
|
|
|
|
import org.hl7.fhir.r4.model.StringType;
|
|
|
|
|
import org.hl7.fhir.r4.model.UriType;
|
|
|
|
|
import org.hl7.fhir.r4.model.codesystems.HttpVerb;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
import org.mockito.ArgumentCaptor;
|
|
|
|
@ -27,11 +25,7 @@ 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 jakarta.annotation.Nonnull;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
@ -73,13 +67,11 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
@Test
|
|
|
|
|
public void testByCodeSystemsAndSourceCodeOneToMany() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
TranslationRequest translationRequest = new TranslationRequest();
|
|
|
|
|
translationRequest.getCodeableConcept().addCoding()
|
|
|
|
|
.setSystem(CS_URL)
|
|
|
|
@ -120,20 +112,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(2, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testByCodeSystemsAndSourceCodeOneToOne() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
TranslationRequest translationRequest = new TranslationRequest();
|
|
|
|
|
translationRequest.getCodeableConcept().addCoding()
|
|
|
|
|
.setSystem(CS_URL)
|
|
|
|
@ -162,20 +151,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(1, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testByCodeSystemsAndSourceCodeUnmapped() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
TranslationRequest translationRequest = new TranslationRequest();
|
|
|
|
|
translationRequest.getCodeableConcept().addCoding()
|
|
|
|
|
.setSystem(CS_URL)
|
|
|
|
@ -185,7 +171,26 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertTrue(targets.isEmpty());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testByCodeSystemsAndSourceCodeMatchedWithoutCode() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
TranslationRequest translationRequest = new TranslationRequest();
|
|
|
|
|
translationRequest.getCodeableConcept().addCoding()
|
|
|
|
|
.setSystem(CS_URL_4)
|
|
|
|
|
.setCode("89012");
|
|
|
|
|
translationRequest.setTargetSystem(CS_URL_3);
|
|
|
|
|
|
|
|
|
|
List<TranslateConceptResult> targets = myConceptMappingSvc.translate(translationRequest).getResults();
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertTrue(targets.isEmpty());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -208,7 +213,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
.addTarget()
|
|
|
|
|
.setCode("999");
|
|
|
|
|
|
|
|
|
|
myConceptMapDao.create(conceptMap);
|
|
|
|
|
myConceptMapDao.create(conceptMap, mySrd);
|
|
|
|
|
|
|
|
|
|
TranslationRequest translationRequest = new TranslationRequest()
|
|
|
|
|
.addCode(CS_URL, "12345")
|
|
|
|
@ -222,13 +227,11 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
@Test
|
|
|
|
|
public void testUsingPredicatesWithCodeOnly() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -283,20 +286,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(3, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUsingPredicatesWithSourceAndTargetSystem2() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -331,20 +331,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(1, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUsingPredicatesWithSourceAndTargetSystem3() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -391,20 +388,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(2, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUsingPredicatesWithSourceSystem() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -461,20 +455,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(3, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUsingPredicatesWithSourceSystemAndVersion1() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -509,20 +500,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(1, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUsingPredicatesWithSourceSystemAndVersion3() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -569,20 +557,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(2, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUsingPredicatesWithSourceValueSet() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -639,20 +624,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(3, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUsingPredicatesWithTargetValueSet() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -709,20 +691,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(targets);
|
|
|
|
|
assertEquals(3, targets.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWithReverse() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -758,20 +737,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(elements);
|
|
|
|
|
assertEquals(1, elements.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWithReverseByCodeSystemsAndSourceCodeUnmapped() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
TranslationRequest translationRequest = new TranslationRequest();
|
|
|
|
|
translationRequest.getCodeableConcept().addCoding()
|
|
|
|
|
.setSystem(CS_URL_3)
|
|
|
|
@ -781,20 +757,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
TranslateConceptResults elements = myConceptMappingSvc.translateWithReverse(translationRequest);
|
|
|
|
|
assertNotNull(elements);
|
|
|
|
|
assertTrue(elements.isEmpty());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWithReverseUsingPredicatesWithCodeOnly() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -837,20 +810,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(elements);
|
|
|
|
|
assertEquals(2, elements.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWithReverseUsingPredicatesWithSourceAndTargetSystem1() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -886,20 +856,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(elements);
|
|
|
|
|
assertEquals(1, elements.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWithReverseUsingPredicatesWithSourceAndTargetSystem4() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -935,20 +902,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(elements);
|
|
|
|
|
assertEquals(1, elements.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWithReverseUsingPredicatesWithSourceSystem() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -993,20 +957,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(elements);
|
|
|
|
|
assertEquals(2, elements.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWithReverseUsingPredicatesWithSourceSystemAndVersion() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -1053,20 +1014,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(elements);
|
|
|
|
|
assertEquals(2, elements.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWithReverseUsingPredicatesWithSourceValueSet() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -1111,20 +1069,17 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(elements);
|
|
|
|
|
assertEquals(2, elements.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testWithReverseUsingPredicatesWithTargetValueSet() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
/*
|
|
|
|
|
* Provided:
|
|
|
|
|
* source code
|
|
|
|
@ -1169,7 +1124,6 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertNotNull(elements);
|
|
|
|
|
assertEquals(2, elements.size());
|
|
|
|
|
assertTrue(TermConceptMappingSvcImpl.isOurLastResultsFromTranslationWithReverseCache());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1203,13 +1157,11 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
@Test
|
|
|
|
|
public void testStoreTermConceptMapAndChildren() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap originalConceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(originalConceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
Pageable page = PageRequest.of(0, 1);
|
|
|
|
|
List<TermConceptMap> optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL);
|
|
|
|
|
assertEquals(1, optionalConceptMap.size());
|
|
|
|
@ -1221,174 +1173,199 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertEquals(VS_URL, conceptMap.getSource());
|
|
|
|
|
assertEquals(VS_URL_2, conceptMap.getTarget());
|
|
|
|
|
assertEquals(CM_URL, conceptMap.getUrl());
|
|
|
|
|
assertEquals(3, conceptMap.getConceptMapGroups().size());
|
|
|
|
|
assertEquals(4, 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());
|
|
|
|
|
assertGroupHasValues(
|
|
|
|
|
CS_URL,"Version 1", CS_URL_2, "Version 2", group);
|
|
|
|
|
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());
|
|
|
|
|
assertElementHasValues(
|
|
|
|
|
"12345", "Source Code 12345", CS_URL, "Version 1", element);
|
|
|
|
|
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());
|
|
|
|
|
assertTargetHasValues(
|
|
|
|
|
"34567", "Target Code 34567", CS_URL_2, "Version 2", Enumerations.ConceptMapEquivalence.EQUAL, target);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertElementHasValues(
|
|
|
|
|
"23456", "Source Code 23456", CS_URL, "Version 1", element);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertTargetHasValues(
|
|
|
|
|
"45678", "Target Code 45678", CS_URL_2, "Version 2", Enumerations.ConceptMapEquivalence.WIDER, target);
|
|
|
|
|
|
|
|
|
|
// 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());
|
|
|
|
|
assertTargetHasValues(
|
|
|
|
|
"45678", "Target Code 45678", CS_URL_2, "Version 2", Enumerations.ConceptMapEquivalence.WIDER, target);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertGroupHasValues(
|
|
|
|
|
CS_URL, "Version 3", CS_URL_3, "Version 4", group);
|
|
|
|
|
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());
|
|
|
|
|
assertElementHasValues(
|
|
|
|
|
"12345", "Source Code 12345", CS_URL, "Version 3", element);
|
|
|
|
|
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());
|
|
|
|
|
assertTargetHasValues(
|
|
|
|
|
"56789", "Target Code 56789", CS_URL_3, "Version 4", Enumerations.ConceptMapEquivalence.EQUAL, target);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertTargetHasValues(
|
|
|
|
|
"67890", "Target Code 67890", CS_URL_3, "Version 4", Enumerations.ConceptMapEquivalence.WIDER, target);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertGroupHasValues(
|
|
|
|
|
CS_URL_4, "Version 5", CS_URL_2, "Version 2", group);
|
|
|
|
|
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());
|
|
|
|
|
assertElementHasValues(
|
|
|
|
|
"78901", "Source Code 78901", CS_URL_4, "Version 5", element);
|
|
|
|
|
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());
|
|
|
|
|
@Test
|
|
|
|
|
public void testStoreTermConceptMapAndChildren_handleUnmappedElements() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap originalConceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(originalConceptMap));
|
|
|
|
|
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
Pageable page = PageRequest.of(0, 1);
|
|
|
|
|
List<TermConceptMap> optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL);
|
|
|
|
|
assertEquals(1, optionalConceptMap.size());
|
|
|
|
|
|
|
|
|
|
TermConceptMap conceptMap = optionalConceptMap.get(0);
|
|
|
|
|
TermConceptMapGroup group = conceptMap.getConceptMapGroups().get(3);
|
|
|
|
|
|
|
|
|
|
ourLog.info("ConceptMap.group(3):\n" + group.toString());
|
|
|
|
|
|
|
|
|
|
assertGroupHasValues(
|
|
|
|
|
CS_URL_4, "Version 1", CS_URL_3, "Version 1", group);
|
|
|
|
|
assertEquals(2, group.getConceptMapGroupElements().size());
|
|
|
|
|
|
|
|
|
|
TermConceptMapGroupElement element = group.getConceptMapGroupElements().get(0);
|
|
|
|
|
|
|
|
|
|
ourLog.info("ConceptMap.group(3).element(0):\n" + element.toString());
|
|
|
|
|
|
|
|
|
|
assertElementHasValues(
|
|
|
|
|
"89012", "Source Code 89012", CS_URL_4, "Version 1", element);
|
|
|
|
|
assertEquals(0, element.getConceptMapGroupElementTargets().size());
|
|
|
|
|
|
|
|
|
|
element = group.getConceptMapGroupElements().get(1);
|
|
|
|
|
|
|
|
|
|
ourLog.info("ConceptMap.group(3).element(1):\n" + element.toString());
|
|
|
|
|
|
|
|
|
|
assertElementHasValues(
|
|
|
|
|
"89123", "Source Code 89123", CS_URL_4, "Version 1", element);
|
|
|
|
|
assertEquals(1, element.getConceptMapGroupElementTargets().size());
|
|
|
|
|
|
|
|
|
|
TermConceptMapGroupElementTarget target = element.getConceptMapGroupElementTargets().get(0);
|
|
|
|
|
|
|
|
|
|
ourLog.info("ConceptMap.group(3).element(1).target(0):\n" + target.toString());
|
|
|
|
|
|
|
|
|
|
assertTargetHasValues(
|
|
|
|
|
null, null, CS_URL_3, "Version 1", Enumerations.ConceptMapEquivalence.UNMATCHED, target);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void assertGroupHasValues(String theExpectedSourceCodeSystem,
|
|
|
|
|
String theExpectedSourceCodeSystemVersion,
|
|
|
|
|
String theExpectedTargetCodeSystem,
|
|
|
|
|
String theExpectedTargetCodeSystemVersion,
|
|
|
|
|
TermConceptMapGroup group) {
|
|
|
|
|
assertEquals(theExpectedSourceCodeSystem, group.getSource());
|
|
|
|
|
assertEquals(theExpectedSourceCodeSystemVersion, group.getSourceVersion());
|
|
|
|
|
assertEquals(theExpectedTargetCodeSystem, group.getTarget());
|
|
|
|
|
assertEquals(theExpectedTargetCodeSystemVersion, group.getTargetVersion());
|
|
|
|
|
assertEquals(CM_URL, group.getConceptMapUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void assertElementHasValues(String theExpectedCode,
|
|
|
|
|
String theExpectedDisplayText,
|
|
|
|
|
String theExpectedCodeSystem,
|
|
|
|
|
String theExpectedCodeSystemVersion,
|
|
|
|
|
TermConceptMapGroupElement element) {
|
|
|
|
|
assertEquals(theExpectedCode, element.getCode());
|
|
|
|
|
assertEquals(theExpectedDisplayText, element.getDisplay());
|
|
|
|
|
assertEquals(theExpectedCodeSystem, element.getSystem());
|
|
|
|
|
assertEquals(theExpectedCodeSystemVersion, element.getSystemVersion());
|
|
|
|
|
assertEquals(VS_URL, element.getValueSet());
|
|
|
|
|
assertEquals(CM_URL, element.getConceptMapUrl());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void assertTargetHasValues(String theExpectedCode,
|
|
|
|
|
String theExpectedDisplayText,
|
|
|
|
|
String theExpectedCodeSystem,
|
|
|
|
|
String theExpectedCodeSystemVersion,
|
|
|
|
|
Enumerations.ConceptMapEquivalence theExpectedEquivalence,
|
|
|
|
|
TermConceptMapGroupElementTarget target) {
|
|
|
|
|
assertEquals(theExpectedCode, target.getCode());
|
|
|
|
|
assertEquals(theExpectedDisplayText, target.getDisplay());
|
|
|
|
|
assertEquals(theExpectedCodeSystem, target.getSystem());
|
|
|
|
|
assertEquals(theExpectedCodeSystemVersion, target.getSystemVersion());
|
|
|
|
|
assertEquals(theExpectedEquivalence, target.getEquivalence());
|
|
|
|
|
assertEquals(VS_URL_2, target.getValueSet());
|
|
|
|
|
assertEquals(CM_URL, target.getConceptMapUrl());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testStoreTermConceptMapAndChildrenWithClientAssignedId() {
|
|
|
|
|
createAndPersistConceptMap();
|
|
|
|
|
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
|
|
|
|
ConceptMap originalConceptMap = myConceptMapDao.read(myConceptMapId, mySrd);
|
|
|
|
|
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(conceptMap));
|
|
|
|
|
ourLog.debug("ConceptMap:\n" + myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(originalConceptMap));
|
|
|
|
|
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
Pageable page = PageRequest.of(0, 1);
|
|
|
|
|
List<TermConceptMap> optionalConceptMap = myTermConceptMapDao.getTermConceptMapEntitiesByUrlOrderByMostRecentUpdate(page, CM_URL);
|
|
|
|
|
assertEquals(1, optionalConceptMap.size());
|
|
|
|
@ -1400,7 +1377,7 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
assertEquals(VS_URL, conceptMap.getSource());
|
|
|
|
|
assertEquals(VS_URL_2, conceptMap.getTarget());
|
|
|
|
|
assertEquals(CM_URL, conceptMap.getUrl());
|
|
|
|
|
assertEquals(3, conceptMap.getConceptMapGroups().size());
|
|
|
|
|
assertEquals(4, conceptMap.getConceptMapGroups().size());
|
|
|
|
|
|
|
|
|
|
TermConceptMapGroup group = conceptMap.getConceptMapGroups().get(0);
|
|
|
|
|
|
|
|
|
@ -1419,142 +1396,77 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertElementHasValues("12345", "Source Code 12345", CS_URL, "Version 1", element);
|
|
|
|
|
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());
|
|
|
|
|
assertTargetHasValues("34567", "Target Code 34567", CS_URL_2, "Version 2", Enumerations.ConceptMapEquivalence.EQUAL, target);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertElementHasValues("23456", "Source Code 23456", CS_URL, "Version 1", element);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertTargetHasValues("45678", "Target Code 45678", CS_URL_2, "Version 2", Enumerations.ConceptMapEquivalence.WIDER, target);
|
|
|
|
|
|
|
|
|
|
// 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());
|
|
|
|
|
assertTargetHasValues("45678", "Target Code 45678", CS_URL_2, "Version 2", Enumerations.ConceptMapEquivalence.WIDER, target);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertGroupHasValues(CS_URL, "Version 3", CS_URL_3, "Version 4", group);
|
|
|
|
|
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());
|
|
|
|
|
assertElementHasValues("12345", "Source Code 12345", CS_URL, "Version 3", element);
|
|
|
|
|
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());
|
|
|
|
|
assertTargetHasValues("56789", "Target Code 56789", CS_URL_3, "Version 4", Enumerations.ConceptMapEquivalence.EQUAL, target);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertTargetHasValues("67890", "Target Code 67890", CS_URL_3, "Version 4", Enumerations.ConceptMapEquivalence.WIDER, target);
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
assertGroupHasValues(CS_URL_4, "Version 5", CS_URL_2, "Version 2", group);
|
|
|
|
|
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());
|
|
|
|
|
assertElementHasValues("78901", "Source Code 78901", CS_URL_4, "Version 5", element);
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
assertTargetHasValues("34567", "Target Code 34567", CS_URL_2, "Version 2", Enumerations.ConceptMapEquivalence.NARROWER, target);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1670,19 +1582,13 @@ public class TermConceptMappingSvcImplTest extends BaseTermR4Test {
|
|
|
|
|
private void persistConceptMap(ConceptMap theConceptMap, HttpVerb theVerb) {
|
|
|
|
|
switch (theVerb) {
|
|
|
|
|
case POST:
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
myConceptMapId = myConceptMapDao.create(theConceptMap, mySrd).getId().toUnqualifiedVersionless();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case PUT:
|
|
|
|
|
new TransactionTemplate(myTxManager).execute(new TransactionCallbackWithoutResult() {
|
|
|
|
|
@Override
|
|
|
|
|
protected void doInTransactionWithoutResult(@Nonnull TransactionStatus theStatus) {
|
|
|
|
|
runInTransaction(() -> {
|
|
|
|
|
myConceptMapId = myConceptMapDao.update(theConceptMap, mySrd).getId().toUnqualifiedVersionless();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|