use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember in project snow-owl by b2ihealthcare.
the class SnomedRf2ExportRequest method getLatestModuleEffectiveTime.
private Optional<LocalDate> getLatestModuleEffectiveTime(final RepositoryContext context, final Version version, String field) {
SnomedRefSetMemberSearchRequestBuilder requestBuilder = SnomedRequests.prepareSearchMember().filterByRefSet(Concepts.REFSET_MODULE_DEPENDENCY_TYPE).filterByActive(true).sortBy(Sort.fieldDesc(field)).setLimit(1);
// See the comment in setModules; a value of "null" means that all modules should be exported
if (modules != null) {
requestBuilder.filterByModules(modules);
}
final Optional<SnomedReferenceSetMember> moduleDependencyMember = requestBuilder.build(version.getVersionResourceURI()).execute(context.service(IEventBus.class)).getSync(1, TimeUnit.MINUTES).first();
return moduleDependencyMember.map(m -> {
return (LocalDate) m.getProperties().get(field);
});
}
use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember in project snow-owl by b2ihealthcare.
the class SnomedDescriptionApiTest method updateInactivationIndicatorOnActiveReleasedDescription.
@Test
public void updateInactivationIndicatorOnActiveReleasedDescription() throws Exception {
String descriptionToInactivate = createNewDescription(branchPath);
assertInactivation(branchPath, descriptionToInactivate, new InactivationProperties(Concepts.PENDING_MOVE, Collections.emptyList()));
// release component
createCodeSystemAndVersion(branchPath, "SNOMEDCT-RELDESC-INACTIVATIONINDICATOR", "v1", LocalDate.parse("2018-07-01"));
SnomedDescription description = assertInactivation(branchPath, descriptionToInactivate, new InactivationProperties(Concepts.CONCEPT_NON_CURRENT, Collections.emptyList())).extract().as(SnomedDescription.class);
List<SnomedReferenceSetMember> inactivationIndicators = description.getMembers().stream().filter(member -> Concepts.REFSET_DESCRIPTION_INACTIVITY_INDICATOR.equals(member.getRefsetId())).collect(Collectors.toList());
final SnomedReferenceSetMember inactivationIndicator = Iterables.getOnlyElement(inactivationIndicators);
assertEquals(Concepts.CONCEPT_NON_CURRENT, inactivationIndicator.getProperties().get(SnomedRf2Headers.FIELD_VALUE_ID));
assertNull(inactivationIndicator.getEffectiveTime());
}
use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember in project snow-owl by b2ihealthcare.
the class SnomedDescriptionApiTest method testDuplicateMemberCleanupEmptiesAcceptabilityMap.
@Test
public void testDuplicateMemberCleanupEmptiesAcceptabilityMap() throws Exception {
String descriptionId = createNewDescription(branchPath);
// Inject inactive language member with different acceptability (API won't allow it)
String memberIdToUpdate = UUID.randomUUID().toString();
SnomedRefSetMemberIndexEntry member = SnomedRefSetMemberIndexEntry.builder().id(memberIdToUpdate).active(false).released(false).moduleId(Concepts.MODULE_SCT_CORE).refsetId(Concepts.REFSET_LANGUAGE_TYPE_UK).referencedComponentId(descriptionId).referenceSetType(SnomedRefSetType.LANGUAGE).field(SnomedRf2Headers.FIELD_ACCEPTABILITY_ID, Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_PREFERRED).build();
new RepositoryRequest<>(SnomedTerminologyComponentConstants.TOOLING_ID, context -> {
ApplicationContext.getServiceForClass(RepositoryManager.class).get(SnomedTerminologyComponentConstants.TOOLING_ID).service(RevisionIndex.class).prepareCommit(branchPath.getPath()).stageNew(member).withContext(context.inject().bind(ModuleIdProvider.class, c -> c.getModuleId()).build()).commit(ApplicationContext.getServiceForClass(TimestampProvider.class).getTimestamp(), "test", "Added duplicate language reference set member to " + descriptionId);
return null;
}).execute(ApplicationContext.getServiceForClass(Environment.class));
// Check the acceptability map; the description should be acceptable in the UK reference set
SnomedDescription description = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).extract().as(SnomedDescription.class);
assertEquals(Acceptability.ACCEPTABLE, description.getAcceptabilityMap().get(Concepts.REFSET_LANGUAGE_TYPE_UK));
assertEquals(2, description.getMembers().getTotal());
String memberIdToDelete = null;
for (SnomedReferenceSetMember descriptionMember : description.getMembers()) {
if (Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_ACCEPTABLE.equals(descriptionMember.getProperties().get(SnomedRf2Headers.FIELD_ACCEPTABILITY_ID))) {
memberIdToDelete = descriptionMember.getId();
break;
}
}
assertNotNull(memberIdToDelete);
// Using bulk update, remove the currently active member and activate the inactive one, also changing its acceptability
Json bulkRequest = Json.object("requests", Json.array(Json.object("action", "delete", "memberId", memberIdToDelete), Json.object("action", "update", "memberId", memberIdToUpdate, "active", true, "acceptabilityId", Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_ACCEPTABLE)), "commitComment", "Consolidated language reference set members");
bulkUpdateMembers(branchPath, Concepts.REFSET_LANGUAGE_TYPE_UK, bulkRequest).statusCode(204);
// Verify that description acceptability is still acceptable, but only one member remains
SnomedDescription newDescription = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).extract().as(SnomedDescription.class);
assertEquals(Acceptability.ACCEPTABLE, newDescription.getAcceptabilityMap().get(Concepts.REFSET_LANGUAGE_TYPE_UK));
assertEquals(1, newDescription.getMembers().getTotal());
SnomedReferenceSetMember languageMember = Iterables.getOnlyElement(newDescription.getMembers());
assertEquals(memberIdToUpdate, languageMember.getId());
assertEquals(true, languageMember.isActive());
}
use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember in project snow-owl by b2ihealthcare.
the class SnomedDescriptionApiTest method updateAcceptabilityWithRemove.
@Test
public void updateAcceptabilityWithRemove() throws Exception {
changeToAcceptable(branchPath, Concepts.ROOT_CONCEPT, Concepts.REFSET_LANGUAGE_TYPE_US);
String descriptionId = createNewDescription(branchPath, Concepts.ROOT_CONCEPT, Concepts.SYNONYM, Map.<String, Acceptability>of(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.ACCEPTABLE, Concepts.REFSET_LANGUAGE_TYPE_US, Acceptability.PREFERRED));
Json requestBody = Json.object("acceptability", Json.object(Concepts.REFSET_LANGUAGE_TYPE_UK, Acceptability.ACCEPTABLE), "commitComment", "Removed US preferred acceptability from description");
updateComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, requestBody).statusCode(204);
SnomedReferenceSetMembers members = getComponent(branchPath, SnomedComponentType.DESCRIPTION, descriptionId, "members()").statusCode(200).extract().as(SnomedDescription.class).getMembers();
assertEquals(1, members.getTotal());
SnomedReferenceSetMember member = Iterables.getOnlyElement(members);
assertEquals(Concepts.REFSET_LANGUAGE_TYPE_UK, member.getRefsetId());
assertEquals(Concepts.REFSET_DESCRIPTION_ACCEPTABILITY_ACCEPTABLE, member.getProperties().get(SnomedRf2Headers.FIELD_ACCEPTABILITY_ID));
}
use of com.b2international.snowowl.snomed.core.domain.refset.SnomedReferenceSetMember in project snow-owl by b2ihealthcare.
the class SnomedConceptApiTest method addMemberViaConceptUpdate.
@Test
public void addMemberViaConceptUpdate() throws Exception {
final String refSetId = createNewRefSet(branchPath);
final String conceptId = createNewConcept(branchPath);
SnomedConcept concept = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "members()").statusCode(200).extract().as(SnomedConcept.class);
assertEquals(0, concept.getMembers().getTotal());
// Add a reference set member
SnomedReferenceSetMember newMember = new SnomedReferenceSetMember();
newMember.setId(UUID.randomUUID().toString());
newMember.setActive(true);
newMember.setRefsetId(refSetId);
newMember.setModuleId(Concepts.MODULE_SCT_CORE);
final List<SnomedReferenceSetMember> changedMembers = ImmutableList.<SnomedReferenceSetMember>builder().addAll(concept.getMembers()).add(newMember).build();
final Map<?, ?> updateRequestBody = Json.object("members", SnomedReferenceSetMembers.of(changedMembers), "commitComment", "Add new reference set member via concept update");
updateComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, updateRequestBody).statusCode(204);
final SnomedConcept updatedConcept = getComponent(branchPath, SnomedComponentType.CONCEPT, conceptId, "members()").statusCode(200).extract().as(SnomedConcept.class);
assertEquals(1, updatedConcept.getMembers().getTotal());
}
Aggregations