Search in sources :

Example 21 with SnomedDescriptionIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.

the class PreferredDescriptionPreCommitHookTest method indexConceptWithFsnAndSynonym.

@Test
public void indexConceptWithFsnAndSynonym() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    final SnomedDescriptionIndexEntry fsn = fsn(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    final SnomedDescriptionIndexEntry synonym = synonym(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    stageNew(concept);
    stageNew(fsn);
    stageNew(synonym);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).semanticTags(ImmutableSortedSet.of("semantic tag")).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn.getId(), fsn.getTypeId(), fsn.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK), new SnomedDescriptionFragment(synonym.getId(), synonym.getTypeId(), synonym.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).build();
    final Revision actual = Iterables.getOnlyElement(processor.getNewMappings().values());
    assertDocEquals(expected, actual);
    assertEquals(0, processor.getChangedMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedDescriptionFragment(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment) Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Example 22 with SnomedDescriptionIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.

the class PreferredDescriptionPreCommitHookTest method indexNewSynonymForExistingConcept.

@Test
public void indexNewSynonymForExistingConcept() throws Exception {
    final SnomedConceptDocument concept = concept().build();
    initRevisions(docWithDefaults(concept).build());
    final SnomedDescriptionIndexEntry synonym = synonym(concept.getId(), Collections.singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    stageNew(synonym);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(synonym.getId(), synonym.getTypeId(), synonym.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK))).build();
    final Revision actual = Iterables.getOnlyElement(processor.getChangedMappings().values()).getNewRevision();
    assertDocEquals(expected, actual);
    assertEquals(0, processor.getNewMappings().size());
    assertEquals(0, processor.getDeletions().size());
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedDescriptionFragment(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment) Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Example 23 with SnomedDescriptionIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.

the class SnomedDescriptionUpdateRequest method execute.

@Override
public Boolean execute(TransactionContext context) {
    final SnomedDescriptionIndexEntry description = context.lookup(componentId(), SnomedDescriptionIndexEntry.class);
    final SnomedDescriptionIndexEntry.Builder updatedDescription = SnomedDescriptionIndexEntry.builder(description);
    boolean changed = false;
    changed |= updateModuleId(context, description, updatedDescription);
    changed |= updateCaseSignificanceId(context, description, updatedDescription, caseSignificanceId);
    changed |= updateTypeId(context, description, updatedDescription);
    changed |= updateTerm(context, description, updatedDescription);
    changed |= updateLanguageCode(context, description, updatedDescription);
    changed |= updateEffectiveTime(description, updatedDescription);
    changed |= processInactivation(context, description, updatedDescription);
    // XXX: acceptability and association changes do not push the effective time forward on the description
    // XXX: this should be executed after processInactivation
    updateAcceptability(context, description);
    if (changed) {
        if (!isEffectiveTimeUpdate() && description.getEffectiveTime() != EffectiveTimes.UNSET_EFFECTIVE_TIME) {
            updatedDescription.effectiveTime(EffectiveTimes.UNSET_EFFECTIVE_TIME);
        }
        context.update(description, updatedDescription.build());
    }
    return changed;
}
Also used : SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry)

Example 24 with SnomedDescriptionIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.

the class ConceptIconIdUpdaterTest method indexTopLevelConceptWithKnownSemanticTag.

@Test
public void indexTopLevelConceptWithKnownSemanticTag() {
    final SnomedConceptDocument concept = concept().statedParents(IComponent.ROOT_IDL).parents(IComponent.ROOT_IDL).iconId(// intentionally unset icon ID before change processing
    null).build();
    final SnomedDescriptionIndexEntry fsn = description(concept.getId(), Concepts.FULLY_SPECIFIED_NAME, String.format(TEST_FSN, FINDING_SEMANTIC_TAG), singletonMap(Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED));
    stageNew(concept);
    stageNew(fsn);
    availableImages.add(FINDING_SEMANTIC_TAG);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expected = docWithDefaults(concept).semanticTags(ImmutableSortedSet.of(FINDING_SEMANTIC_TAG)).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn.getId(), fsn.getTypeId(), fsn.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_US))).iconId(// icon ID must be "finding"
    FINDING_SEMANTIC_TAG).build();
    final Revision actual = Iterables.getOnlyElement(processor.getNewMappings().values());
    assertDocEquals(expected, actual);
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedDescriptionFragment(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment) Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Example 25 with SnomedDescriptionIndexEntry

use of com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry in project snow-owl by b2ihealthcare.

the class ConceptIconIdUpdaterTest method indexChildConceptWithGBAndExtensionFsn.

@Test
public void indexChildConceptWithGBAndExtensionFsn() {
    final SnomedConceptDocument concept = concept().iconId(// intentionally unset icon ID before change processing
    null).build();
    final SnomedDescriptionIndexEntry fsn1 = description(concept.getId(), Concepts.FULLY_SPECIFIED_NAME, String.format(TEST_FSN, FINDING_SEMANTIC_TAG), singletonMap(Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED));
    indexRevision(MAIN, concept, fsn1);
    final SnomedConceptDocument childConcept = concept().iconId(// intentionally unset icon ID before change processing
    null).build();
    // the GB preferred FSN has priority over the other preferred FSNs (except the US one)
    final SnomedDescriptionIndexEntry fsn2 = description(childConcept.getId(), Concepts.FULLY_SPECIFIED_NAME, String.format(TEST_FSN, DISORDER_SEMANTIC_TAG), singletonMap(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.PREFERRED));
    final SnomedDescriptionIndexEntry fsn3 = description(childConcept.getId(), Concepts.FULLY_SPECIFIED_NAME, String.format(TEST_FSN, "trouble"), singletonMap(Concepts.REFSET_LANGUAGE_TYPE_SG, Acceptability.PREFERRED));
    final SnomedRefSetMemberIndexEntry member = createOwlAxiom(childConcept.getId(), String.format("SubClassOf(:%s :%s)", childConcept.getId(), concept.getId())).build();
    stageNew(childConcept);
    stageNew(fsn3);
    stageNew(fsn2);
    stageNew(member);
    statedChangedConceptIds.add(Long.parseLong(concept.getId()));
    statedChangedConceptIds.add(Long.parseLong(childConcept.getId()));
    availableImages.add(DISORDER_SEMANTIC_TAG);
    final ConceptChangeProcessor processor = process();
    final SnomedConceptDocument expectedChild = docWithDefaults(childConcept).semanticTags(// both semantic tags should be present
    ImmutableSortedSet.of(DISORDER_SEMANTIC_TAG, "trouble")).preferredDescriptions(ImmutableList.of(new SnomedDescriptionFragment(fsn2.getId(), fsn2.getTypeId(), fsn2.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_UK), new SnomedDescriptionFragment(fsn3.getId(), fsn3.getTypeId(), fsn3.getTerm(), Concepts.REFSET_LANGUAGE_TYPE_SG))).iconId(// icon ID must be "disorder"
    DISORDER_SEMANTIC_TAG).statedParents(Long.parseLong(concept.getId())).statedAncestors(IComponent.ROOT_IDL).activeMemberOf(singleton(Concepts.REFSET_OWL_AXIOM)).memberOf(singleton(Concepts.REFSET_OWL_AXIOM)).build();
    final Revision actualChild = Iterables.getOnlyElement(processor.getNewMappings().values());
    assertDocEquals(expectedChild, actualChild);
}
Also used : SnomedConceptDocument(com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument) SnomedRefSetMemberIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry) SnomedDescriptionFragment(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment) Revision(com.b2international.index.revision.Revision) SnomedDescriptionIndexEntry(com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry) Test(org.junit.Test)

Aggregations

SnomedDescriptionIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionIndexEntry)38 Test (org.junit.Test)33 Revision (com.b2international.index.revision.Revision)32 SnomedConceptDocument (com.b2international.snowowl.snomed.datastore.index.entry.SnomedConceptDocument)23 SnomedDescriptionFragment (com.b2international.snowowl.snomed.datastore.index.entry.SnomedDescriptionFragment)21 SnomedRefSetMemberIndexEntry (com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry)17 RevisionSearcher (com.b2international.index.revision.RevisionSearcher)3 StagingArea (com.b2international.index.revision.StagingArea)3 ChangeSetProcessorBase (com.b2international.snowowl.core.repository.ChangeSetProcessorBase)3 Acceptability (com.b2international.snowowl.snomed.core.domain.Acceptability)3 RefSetMemberChange (com.b2international.snowowl.snomed.datastore.index.refset.RefSetMemberChange)3 ReferenceSetMembershipUpdater (com.b2international.snowowl.snomed.datastore.index.update.ReferenceSetMembershipUpdater)3 com.google.common.collect (com.google.common.collect)3 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)3 IOException (java.io.IOException)3 Collectors (java.util.stream.Collectors)3 LongSets (com.b2international.commons.collect.LongSets)2 ObjectId (com.b2international.index.revision.ObjectId)2 RevisionDiff (com.b2international.index.revision.StagingArea.RevisionDiff)2 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)2