Add equivalency flag to reverse lookup
This commit is contained in:
parent
98d794e30f
commit
acfe442cf9
|
@ -143,6 +143,10 @@ public class FhirResourceDaoConceptMapR4 extends FhirResourceDaoR4<ConceptMap> i
|
|||
|
||||
translationMatch.setSource(new UriType(element.getConceptMapUrl()));
|
||||
|
||||
if (element.getConceptMapGroupElementTargets().size() == 1) {
|
||||
translationMatch.setEquivalence(new CodeType(element.getConceptMapGroupElementTargets().get(0).getEquivalence().toCode()));
|
||||
}
|
||||
|
||||
retVal.addMatch(translationMatch);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1343,14 +1343,18 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
predicates = new ArrayList<>();
|
||||
|
||||
coding = translationQuery.getCoding();
|
||||
String targetCode = null;
|
||||
String targetCodeSystem = null;
|
||||
if (coding.hasCode()) {
|
||||
predicates.add(criteriaBuilder.equal(targetJoin.get("myCode"), coding.getCode()));
|
||||
targetCode = coding.getCode();
|
||||
} else {
|
||||
throw new InvalidRequestException("A code must be provided for translation to occur.");
|
||||
}
|
||||
|
||||
if (coding.hasSystem()) {
|
||||
predicates.add(criteriaBuilder.equal(groupJoin.get("myTarget"), coding.getSystem()));
|
||||
targetCodeSystem = coding.getSystem();
|
||||
}
|
||||
|
||||
if (coding.hasVersion()) {
|
||||
|
@ -1384,7 +1388,24 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
|
|||
Iterator<TermConceptMapGroupElement> scrollableResultsIterator = new ScrollableResultsIterator<>(scrollableResults);
|
||||
|
||||
while (scrollableResultsIterator.hasNext()) {
|
||||
elements.add(scrollableResultsIterator.next());
|
||||
TermConceptMapGroupElement nextElement = scrollableResultsIterator.next();
|
||||
nextElement.getConceptMapGroupElementTargets().size();
|
||||
myEntityManager.detach(nextElement);
|
||||
|
||||
if (isNotBlank(targetCode) && isNotBlank(targetCodeSystem)) {
|
||||
for (Iterator<TermConceptMapGroupElementTarget> iter = nextElement.getConceptMapGroupElementTargets().iterator(); iter.hasNext(); ) {
|
||||
TermConceptMapGroupElementTarget next = iter.next();
|
||||
if (targetCodeSystem.equals(next.getSystem())) {
|
||||
if (targetCode.equals(next.getCode())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
elements.add(nextElement);
|
||||
}
|
||||
|
||||
ourLastResultsFromTranslationWithReverseCache = false; // For testing.
|
||||
|
|
|
@ -395,6 +395,12 @@ public abstract class BaseJpaR4Test extends BaseJpaTest {
|
|||
target.setDisplay("Target Code 45678");
|
||||
target.setEquivalence(ConceptMapEquivalence.WIDER);
|
||||
|
||||
// Add a duplicate
|
||||
target = element.addTarget();
|
||||
target.setCode("45678");
|
||||
target.setDisplay("Target Code 45678");
|
||||
target.setEquivalence(ConceptMapEquivalence.WIDER);
|
||||
|
||||
group = conceptMap.addGroup();
|
||||
group.setSource(CS_URL);
|
||||
group.setSourceVersion("Version 3");
|
||||
|
|
|
@ -613,7 +613,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(1, translationResult.getMatches().size());
|
||||
|
||||
TranslationMatch translationMatch = translationResult.getMatches().get(0);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("narrower", translationMatch.getEquivalence().getCode());
|
||||
Coding concept = translationMatch.getConcept();
|
||||
assertEquals("78901", concept.getCode());
|
||||
assertEquals("Source Code 78901", concept.getDisplay());
|
||||
|
@ -625,6 +625,49 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateWithReverseHavingEquivalence() {
|
||||
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(TransactionStatus theStatus) {
|
||||
/*
|
||||
* Provided:
|
||||
* source code
|
||||
* source code system
|
||||
* target code system
|
||||
* reverse = true
|
||||
*/
|
||||
TranslationRequest translationRequest = new TranslationRequest();
|
||||
translationRequest.getCodeableConcept().addCoding()
|
||||
.setSystem(CS_URL_3)
|
||||
.setCode("67890");
|
||||
translationRequest.setTargetSystem(new UriType(CS_URL));
|
||||
translationRequest.setReverse(true);
|
||||
|
||||
TranslationResult translationResult = myConceptMapDao.translate(translationRequest, null);
|
||||
|
||||
assertTrue(translationResult.getResult().booleanValue());
|
||||
assertEquals("Matches found!", translationResult.getMessage().getValueAsString());
|
||||
|
||||
assertEquals(1, translationResult.getMatches().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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTranslateWithReverseByCodeSystemsAndSourceCodeUnmapped() {
|
||||
ConceptMap conceptMap = myConceptMapDao.read(myConceptMapId);
|
||||
|
@ -680,7 +723,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(2, translationResult.getMatches().size());
|
||||
|
||||
TranslationMatch translationMatch = translationResult.getMatches().get(0);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("equal", translationMatch.getEquivalence().getCode());
|
||||
Coding concept = translationMatch.getConcept();
|
||||
assertEquals("12345", concept.getCode());
|
||||
assertEquals("Source Code 12345", concept.getDisplay());
|
||||
|
@ -690,7 +733,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
|
||||
|
||||
translationMatch = translationResult.getMatches().get(1);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("narrower", translationMatch.getEquivalence().getCode());
|
||||
concept = translationMatch.getConcept();
|
||||
assertEquals("78901", concept.getCode());
|
||||
assertEquals("Source Code 78901", concept.getDisplay());
|
||||
|
@ -733,7 +776,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(1, translationResult.getMatches().size());
|
||||
|
||||
TranslationMatch translationMatch = translationResult.getMatches().get(0);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("equal", translationMatch.getEquivalence().getCode());
|
||||
Coding concept = translationMatch.getConcept();
|
||||
assertEquals("12345", concept.getCode());
|
||||
assertEquals("Source Code 12345", concept.getDisplay());
|
||||
|
@ -776,7 +819,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(1, translationResult.getMatches().size());
|
||||
|
||||
TranslationMatch translationMatch = translationResult.getMatches().get(0);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("narrower", translationMatch.getEquivalence().getCode());
|
||||
Coding concept = translationMatch.getConcept();
|
||||
assertEquals("78901", concept.getCode());
|
||||
assertEquals("Source Code 78901", concept.getDisplay());
|
||||
|
@ -817,7 +860,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(2, translationResult.getMatches().size());
|
||||
|
||||
TranslationMatch translationMatch = translationResult.getMatches().get(0);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("equal", translationMatch.getEquivalence().getCode());
|
||||
Coding concept = translationMatch.getConcept();
|
||||
assertEquals("12345", concept.getCode());
|
||||
assertEquals("Source Code 12345", concept.getDisplay());
|
||||
|
@ -827,7 +870,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
|
||||
|
||||
translationMatch = translationResult.getMatches().get(1);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("narrower", translationMatch.getEquivalence().getCode());
|
||||
concept = translationMatch.getConcept();
|
||||
assertEquals("78901", concept.getCode());
|
||||
assertEquals("Source Code 78901", concept.getDisplay());
|
||||
|
@ -870,7 +913,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(2, translationResult.getMatches().size());
|
||||
|
||||
TranslationMatch translationMatch = translationResult.getMatches().get(0);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("equal", translationMatch.getEquivalence().getCode());
|
||||
Coding concept = translationMatch.getConcept();
|
||||
assertEquals("12345", concept.getCode());
|
||||
assertEquals("Source Code 12345", concept.getDisplay());
|
||||
|
@ -880,7 +923,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
|
||||
|
||||
translationMatch = translationResult.getMatches().get(1);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("narrower", translationMatch.getEquivalence().getCode());
|
||||
concept = translationMatch.getConcept();
|
||||
assertEquals("78901", concept.getCode());
|
||||
assertEquals("Source Code 78901", concept.getDisplay());
|
||||
|
@ -921,7 +964,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(2, translationResult.getMatches().size());
|
||||
|
||||
TranslationMatch translationMatch = translationResult.getMatches().get(0);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("equal", translationMatch.getEquivalence().getCode());
|
||||
Coding concept = translationMatch.getConcept();
|
||||
assertEquals("12345", concept.getCode());
|
||||
assertEquals("Source Code 12345", concept.getDisplay());
|
||||
|
@ -931,7 +974,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
|
||||
|
||||
translationMatch = translationResult.getMatches().get(1);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("narrower", translationMatch.getEquivalence().getCode());
|
||||
concept = translationMatch.getConcept();
|
||||
assertEquals("78901", concept.getCode());
|
||||
assertEquals("Source Code 78901", concept.getDisplay());
|
||||
|
@ -972,7 +1015,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(2, translationResult.getMatches().size());
|
||||
|
||||
TranslationMatch translationMatch = translationResult.getMatches().get(0);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("equal", translationMatch.getEquivalence().getCode());
|
||||
Coding concept = translationMatch.getConcept();
|
||||
assertEquals("12345", concept.getCode());
|
||||
assertEquals("Source Code 12345", concept.getDisplay());
|
||||
|
@ -982,7 +1025,7 @@ public class FhirResourceDaoR4ConceptMapTest extends BaseJpaR4Test {
|
|||
assertEquals(CM_URL, translationMatch.getSource().getValueAsString());
|
||||
|
||||
translationMatch = translationResult.getMatches().get(1);
|
||||
assertNull(translationMatch.getEquivalence());
|
||||
assertEquals("narrower", translationMatch.getEquivalence().getCode());
|
||||
concept = translationMatch.getConcept();
|
||||
assertEquals("78901", concept.getCode());
|
||||
assertEquals("Source Code 78901", concept.getDisplay());
|
||||
|
|
|
@ -195,3 +195,38 @@ drop column SP_ID from table HFJ_RES_PARAM_PRESENT;
|
|||
drop index IDX_SEARCHPARM_RESTYPE_SPNAME;
|
||||
drop index IDX_RESPARMPRESENT_SPID_RESID;
|
||||
drop table HFJ_SEARCH_PARM;
|
||||
|
||||
|
||||
|
||||
# Delete everything
|
||||
update hfj_res_ver set forced_id_pid = null where res_id in (select res_id from hfj_resource);
|
||||
update hfj_resource set forced_id_pid = null where res_id in (select res_id from hfj_resource);
|
||||
delete from hfj_history_tag where res_id in (select res_id from hfj_resource);
|
||||
delete from hfj_res_ver where res_id in (select res_id from hfj_resource);
|
||||
delete from hfj_forced_id where resource_pid in (select res_id from hfj_resource);
|
||||
delete from hfj_res_link where src_resource_id in (select res_id from hfj_resource);
|
||||
delete from hfj_res_link where target_resource_id in (select res_id from hfj_resource);
|
||||
delete from hfj_spidx_coords;
|
||||
delete from hfj_spidx_date;
|
||||
delete from hfj_spidx_number;
|
||||
delete from hfj_spidx_quantity;
|
||||
delete from hfj_spidx_string;
|
||||
delete from hfj_spidx_token;
|
||||
delete from hfj_spidx_uri;
|
||||
delete from hfj_res_tag;
|
||||
delete from hfj_search_result;
|
||||
delete from hfj_res_param_present;
|
||||
delete from hfj_idx_cmp_string_uniq;
|
||||
delete from hfj_subscription_stats;
|
||||
DELETE FROM TRM_CONCEPT_MAP_GRP_ELM_TGT;
|
||||
DELETE FROM TRM_CONCEPT_MAP_GRP_ELEMENT;
|
||||
DELETE FROM TRM_CONCEPT_MAP_GROUP;
|
||||
DELETE FROM TRM_CONCEPT_MAP;
|
||||
DELETE FROM TRM_CONCEPT_DESIG;
|
||||
DELETE FROM TRM_CONCEPT_PC_LINK;
|
||||
DELETE FROM TRM_CONCEPT_PROPERTY;
|
||||
DELETE FROM TRM_CONCEPT;
|
||||
DELETE FROM TRM_CODESYSTEM_VER;
|
||||
DELETE FROM TRM_CODESYSTEM;
|
||||
delete from hfj_resource;
|
||||
|
||||
|
|
|
@ -249,6 +249,10 @@
|
|||
queue (only the ID), which should reduce the memory/disk footprint of the queue
|
||||
when it grows long.
|
||||
</action>
|
||||
<action type="add">
|
||||
When performing a ConceptMap/$translate operation with reverse="true" in the arguments,
|
||||
the equivalency flag is now set on the response just as it is for a non-reverse lookup.
|
||||
</action>
|
||||
</release>
|
||||
<release version="3.4.0" date="2018-05-28">
|
||||
<action type="add">
|
||||
|
|
Loading…
Reference in New Issue