Search in sources :

Example 1 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class SnomedComponentInactivationApiTest method reuseConceptAndDescriptionInactivationIndicators.

@Test
public void reuseConceptAndDescriptionInactivationIndicators() throws Exception {
    // create a concept
    String conceptId = createNewConcept(branchPath);
    SnomedConcept concept = getConcept(conceptId, "descriptions()");
    // add pending move to concept and descriptions
    Map<?, ?> pendingMoveUpdate = ImmutableMap.of("inactivationProperties", new InactivationProperties(Concepts.PENDING_MOVE, null), "commitComment", "Set to Pending Move");
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, pendingMoveUpdate).statusCode(204);
    for (SnomedDescription description : concept.getDescriptions()) {
        updateComponent(branchPath, SnomedComponentType.DESCRIPTION, description.getId(), pendingMoveUpdate).statusCode(204);
    }
    // XXX intentionally using the members() expand here to check duplication
    SnomedConcept pendingMoveConcept = getConcept(conceptId, "members(),descriptions(expand(members()))");
    // verify and collect inactivation indicator members
    SnomedReferenceSetMember conceptInactivationIndicatorMember = getIndicatorMember(pendingMoveConcept, Concepts.REFSET_CONCEPT_INACTIVITY_INDICATOR);
    SnomedReferenceSetMember fsnInactivationIndicatorMember = null;
    SnomedReferenceSetMember ptInactivationIndicatorMember = null;
    for (SnomedDescription description : pendingMoveConcept.getDescriptions()) {
        if (Concepts.FULLY_SPECIFIED_NAME.equals(description.getTypeId())) {
            fsnInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
        } else if (Concepts.SYNONYM.equals(description.getTypeId())) {
            ptInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
        } else {
            throw new UnsupportedOperationException();
        }
    }
    Map<?, ?> inactivationConceptRequest = ImmutableMap.builder().put("active", false).put("inactivationProperties", new InactivationProperties(Concepts.DUPLICATE, null)).put("commitComment", "Inactivated concept").build();
    updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, inactivationConceptRequest).statusCode(204);
    // XXX intentionally using the members() expand here to check duplication/member issues
    SnomedConcept inactivatedConcept = getConcept(conceptId, "members(),descriptions(expand(members()))");
    SnomedReferenceSetMember afterInactivationConceptInactivationIndicatorMember = getIndicatorMember(inactivatedConcept, Concepts.REFSET_CONCEPT_INACTIVITY_INDICATOR);
    SnomedReferenceSetMember afterInactivationFsnInactivationIndicatorMember = null;
    SnomedReferenceSetMember afterInactivationPtInactivationIndicatorMember = null;
    for (SnomedDescription description : inactivatedConcept.getDescriptions()) {
        if (Concepts.FULLY_SPECIFIED_NAME.equals(description.getTypeId())) {
            afterInactivationFsnInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
        } else if (Concepts.SYNONYM.equals(description.getTypeId())) {
            afterInactivationPtInactivationIndicatorMember = getIndicatorMember(description, Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR);
        } else {
            throw new UnsupportedOperationException();
        }
    }
    assertEquals(conceptInactivationIndicatorMember.getId(), afterInactivationConceptInactivationIndicatorMember.getId());
    assertEquals(null, afterInactivationConceptInactivationIndicatorMember.getEffectiveTime());
    assertEquals(false, afterInactivationConceptInactivationIndicatorMember.isReleased());
    assertEquals(Concepts.DUPLICATE, afterInactivationConceptInactivationIndicatorMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
    assertEquals(fsnInactivationIndicatorMember.getId(), afterInactivationFsnInactivationIndicatorMember.getId());
    assertEquals(null, afterInactivationFsnInactivationIndicatorMember.getEffectiveTime());
    assertEquals(false, afterInactivationFsnInactivationIndicatorMember.isReleased());
    assertEquals(Concepts.CONCEPT_NON_CURRENT, afterInactivationFsnInactivationIndicatorMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
    assertEquals(ptInactivationIndicatorMember.getId(), afterInactivationPtInactivationIndicatorMember.getId());
    assertEquals(null, afterInactivationPtInactivationIndicatorMember.getEffectiveTime());
    assertEquals(false, afterInactivationPtInactivationIndicatorMember.isReleased());
    assertEquals(Concepts.CONCEPT_NON_CURRENT, afterInactivationPtInactivationIndicatorMember.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) InactivationProperties(com.b2international.snowowl.snomed.core.domain.InactivationProperties) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept) Test(org.junit.Test) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest)

Example 2 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class SnomedDescriptionApiTest method retireDescription.

@Test
public void retireDescription() {
    String descriptionId = createNewDescription(branchPath);
    Json requestBody = Json.object("active", false, "commitComment", "Inactivated description", "acceptability", Json.object());
    updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, requestBody).statusCode(204);
    SnomedDescription description = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "acceptabilities()").statusCode(200).extract().as(SnomedDescription.class);
    assertTrue(!description.isActive());
    assertTrue(description.getAcceptabilities().isEmpty());
}
Also used : SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) Json(com.b2international.commons.json.Json) AbstractSnomedApiTest(com.b2international.snowowl.snomed.core.rest.AbstractSnomedApiTest) Test(org.junit.Test)

Example 3 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class MapTypeRefSetDSVExporter method prepareLabelCache.

private Map<String, String> prepareLabelCache(SnomedReferenceSetMembers membersToExport) {
    final SnomedConcepts modelComponents = SnomedRequests.prepareSearchConcept().all().filterByActive(true).filterByEcl(String.format("< (%s OR %s) ", Concepts.MODULE_ROOT, Concepts.REFSET_ATTRIBUTE)).setExpand("fsn()").setLocales(exportSetting.getLocales()).build().execute(context);
    final Map<String, String> labels = newHashMapWithExpectedSize(membersToExport.getTotal() + modelComponents.getTotal());
    modelComponents.forEach(modelComponent -> {
        labels.put(modelComponent.getId(), getFsnOrId(modelComponent));
    });
    for (SnomedReferenceSetMember snomedReferenceSetMember : membersToExport) {
        SnomedCoreComponent referencedComponent = snomedReferenceSetMember.getReferencedComponent();
        String id = referencedComponent.getId();
        if (referencedComponent instanceof SnomedConcept) {
            labels.put(id, getFsnOrId((SnomedConcept) referencedComponent));
        } else if (referencedComponent instanceof SnomedDescription) {
            labels.put(id, ((SnomedDescription) referencedComponent).getTerm());
        } else if (referencedComponent instanceof SnomedRelationship) {
            SnomedRelationship relationship = (SnomedRelationship) referencedComponent;
            if (relationship.hasValue()) {
                labels.put(id, String.format("%s - %s - %s", relationship.getSourceId(), relationship.getTypeId(), relationship.getValue()));
            } else {
                labels.put(id, String.format("%s - %s - %s", relationship.getSourceId(), relationship.getTypeId(), relationship.getDestinationId()));
            }
        }
    }
    return labels;
}
Also used : SnomedReferenceSetMember(com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember) SnomedCoreComponent(com.b2international.snowowl.snomed.core.domain.SnomedCoreComponent) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedRelationship(com.b2international.snowowl.snomed.core.domain.SnomedRelationship) SnomedConcepts(com.b2international.snowowl.snomed.core.domain.SnomedConcepts) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Example 4 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class Rf2LanguageRefSetContentType method resolve.

@Override
public void resolve(SnomedReferenceSetMember component, String[] values) {
    component.setType(SnomedRefSetType.LANGUAGE);
    component.setRefsetId(values[4]);
    component.setReferencedComponent(new SnomedDescription(values[5]));
    component.setProperties(ImmutableMap.of(SnomedRf2Headers.FIELD_ACCEPTABILITY_ID, values[6]));
}
Also used : SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription)

Example 5 with SnomedDescription

use of com.b2international.snowowl.snomed.core.domain.SnomedDescription in project snow-owl by b2ihealthcare.

the class SnomedValueSetMemberSearchRequestEvaluator method toMember.

private ValueSetMember toMember(SnomedReferenceSetMember member, ResourceURI codeSystemURI) {
    final String term;
    final String iconId = member.getReferencedComponent().getIconId();
    String terminologyComponentId = member.getReferencedComponent().getComponentType();
    switch(terminologyComponentId) {
        case SnomedConcept.TYPE:
            SnomedConcept concept = (SnomedConcept) member.getReferencedComponent();
            term = concept.getFsn().getTerm();
            break;
        case SnomedDescription.TYPE:
            SnomedDescription description = (SnomedDescription) member.getReferencedComponent();
            term = description.getTerm();
            break;
        default:
            term = member.getReferencedComponentId();
    }
    return new ValueSetMember(ComponentURI.of(codeSystemURI, terminologyComponentId, member.getReferencedComponentId()), term, iconId);
}
Also used : ValueSetMember(com.b2international.snowowl.core.domain.ValueSetMember) SnomedDescription(com.b2international.snowowl.snomed.core.domain.SnomedDescription) SnomedConcept(com.b2international.snowowl.snomed.core.domain.SnomedConcept)

Aggregations

SnomedDescription (com.b2international.snowowl.snomed.core.domain.SnomedDescription)25 SnomedConcept (com.b2international.snowowl.snomed.core.domain.SnomedConcept)14 Test (org.junit.Test)8 Json (com.b2international.commons.json.Json)7 SnomedReferenceSetMember (com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember)6 LocalDate (java.time.LocalDate)6 ExtendedLocale (com.b2international.commons.http.ExtendedLocale)5 Options (com.b2international.commons.options.Options)4 CodeSystem (com.b2international.snowowl.core.codesystem.CodeSystem)4 Concepts (com.b2international.snowowl.snomed.common.SnomedConstants.Concepts)4 SnomedRelationship (com.b2international.snowowl.snomed.core.domain.SnomedRelationship)4 SnomedRequests (com.b2international.snowowl.snomed.datastore.request.SnomedRequests)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 IBranchPath (com.b2international.snowowl.core.api.IBranchPath)3 BranchContext (com.b2international.snowowl.core.domain.BranchContext)3 SnomedRf2Headers (com.b2international.snowowl.snomed.common.SnomedRf2Headers)3 InactivationProperties (com.b2international.snowowl.snomed.core.domain.InactivationProperties)3 SnomedRefSetType (com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType)3 SnomedConceptRequestCache (com.b2international.snowowl.snomed.datastore.request.SnomedConceptRequestCache)3