use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.
the class SnomedConcreteValueApiTest method updateConcreteValueWithSamePropertiesShouldNotCauseAnyChange.
@Test
public void updateConcreteValueWithSamePropertiesShouldNotCauseAnyChange() throws Exception {
final String relationshipId = createNewConcreteValue(branchPath);
final SnomedRelationship concreteValue = getRelationship(relationshipId);
// explicitly create a new Boolean object with same value to simulate deserialization "bug"
concreteValue.setActive(new Boolean(true));
// same value as set in createNewConcreteValue(String)
concreteValue.setValueAsObject(new RelationshipValue("Hello World!"));
Boolean updated = SnomedRequests.prepareCommit().setCommitComment("Update concrete value").setBody(concreteValue.toUpdateRequest()).build(branchPath.getPath()).execute(getBus()).getSync(1, TimeUnit.MINUTES).getResultAs(Boolean.class);
assertFalse(updated);
}
use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.
the class SnomedConcreteValueApiTest method createConcreteValueWithReservedId.
@Test
public void createConcreteValueWithReservedId() {
ISnomedIdentifierService identifierService = getServiceForClass(ISnomedIdentifierService.class);
String relationshipId = Iterables.getOnlyElement(identifierService.reserve(null, ComponentCategory.RELATIONSHIP, 1));
Json requestBody = createConcreteValueRequestBody(Concepts.ROOT_CONCEPT, Concepts.PART_OF, new RelationshipValue("string value")).with("id", relationshipId).with("commitComment", "Created new concrete value with reserved identifier");
createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(201).header("Location", endsWith("/" + relationshipId));
SctId concreteValueSctId = SnomedRequests.identifiers().prepareGet().setComponentId(relationshipId).buildAsync().execute(getBus()).getSync().first().get();
assertEquals(IdentifierStatus.ASSIGNED.getSerializedName(), concreteValueSctId.getStatus());
}
use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.
the class SnomedConcreteValueApiTest method deleteInactiveConcreteValue.
@Test
public void deleteInactiveConcreteValue() {
String sourceId = createNewConcept(branchPath);
String relationshipId = createNewConcreteValue(branchPath, sourceId, Concepts.PART_OF, new RelationshipValue("hello world!"));
Json requestBody = Json.object("active", false, "commitComment", "Inactivated concrete value");
updateComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, requestBody).statusCode(204);
deleteComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId, false).statusCode(204);
getComponent(branchPath, SnomedComponentType.RELATIONSHIP, relationshipId).statusCode(404);
/*
* Source concept should still exist at this point (the deletion plan should not
* consider removing it with the concrete value).
*/
getComponent(branchPath, SnomedComponentType.CONCEPT, sourceId).statusCode(200);
}
use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.
the class SnomedConcreteValueApiTest method createConcreteValueInvalidSource.
@Test
public void createConcreteValueInvalidSource() {
Json requestBody = createConcreteValueRequestBody("11110000", Concepts.PART_OF, new RelationshipValue(new BigDecimal("3.334"))).with("commitComment", "Created new concrete value with invalid sourceId");
createComponent(branchPath, SnomedComponentType.RELATIONSHIP, requestBody).statusCode(400);
}
use of com.b2international.snowowl.snomed.core.domain.RelationshipValue in project snow-owl by b2ihealthcare.
the class SnomedFhirCodeSystemLookupConverter method expandProperties.
@Override
public List<Property> expandProperties(ServiceProvider context, CodeSystem codeSystem, Concept concept, LookupRequest lookupRequest) {
SnomedConcept snomedConcept = concept.getInternalConceptAs();
List<Property> properties = new ArrayList<>();
// add basic SNOMED properties
if (lookupRequest.isPropertyRequested(CoreSnomedConceptProperties.INACTIVE)) {
properties.add(CoreSnomedConceptProperties.INACTIVE.propertyOf(!snomedConcept.isActive()));
}
if (lookupRequest.isPropertyRequested(CoreSnomedConceptProperties.MODULE_ID)) {
properties.add(CoreSnomedConceptProperties.MODULE_ID.propertyOf(snomedConcept.getModuleId()));
}
if (lookupRequest.isPropertyRequested(CoreSnomedConceptProperties.SUFFICIENTLY_DEFINED)) {
properties.add(CoreSnomedConceptProperties.SUFFICIENTLY_DEFINED.propertyOf(!snomedConcept.isPrimitive()));
}
if (lookupRequest.isPropertyRequested(CoreSnomedConceptProperties.EFFECTIVE_TIME)) {
properties.add(CoreSnomedConceptProperties.EFFECTIVE_TIME.propertyOf(EffectiveTimes.format(snomedConcept.getEffectiveTime(), DateFormats.SHORT)));
}
// Optionally requested properties
boolean requestedChild = lookupRequest.containsProperty(CommonConceptProperties.CHILD.getCode());
boolean requestedParent = lookupRequest.containsProperty(CommonConceptProperties.PARENT.getCode());
if (requestedChild && snomedConcept.getDescendants() != null) {
for (SnomedConcept child : snomedConcept.getDescendants()) {
properties.add(CommonConceptProperties.CHILD.propertyOf(child.getId(), SnomedDisplayTermType.PT.getLabel(child)));
}
}
if (requestedParent && snomedConcept.getAncestors() != null) {
for (SnomedConcept parent : snomedConcept.getAncestors()) {
properties.add(CommonConceptProperties.PARENT.propertyOf(parent.getId(), SnomedDisplayTermType.PT.getLabel(parent)));
}
}
// Relationship Properties
Set<String> relationshipTypeIds = lookupRequest.getPropertyCodes().stream().map(p -> {
if (p.startsWith(SnomedTerminologyComponentConstants.SNOMED_URI_BASE)) {
// URI prefixed properties
return p.substring(p.lastIndexOf('/') + 1, p.length());
} else {
// use as is, so users won't need to define full URI for each SNOMED CT property, ID is enough
return p;
}
}).filter(// only SNOMED CT Concept IDs
SnomedIdentifiers::isConceptIdentifier).collect(Collectors.toSet());
if (!relationshipTypeIds.isEmpty()) {
SnomedRequests.prepareSearchRelationship().all().filterByActive(true).filterByCharacteristicType(Concepts.INFERRED_RELATIONSHIP).filterBySource(concept.getId()).filterByTypes(relationshipTypeIds).build(codeSystem.getResourceURI()).getRequest().execute(context).forEach(r -> {
Property.Builder propertyBuilder = Property.builder().code(r.getTypeId());
if (r.hasValue()) {
RelationshipValue value = r.getValueAsObject();
value.map(i -> propertyBuilder.valueInteger(i), d -> propertyBuilder.valueDecimal(d.doubleValue()), s -> propertyBuilder.valueString(s));
} else {
propertyBuilder.valueCode(r.getDestinationId());
}
properties.add(propertyBuilder.build());
});
}
if (properties.isEmpty()) {
return null;
} else {
return properties;
}
}
Aggregations