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));
}
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());
}
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;
}
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]));
}
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);
}
Aggregations