use of org.ihtsdo.drools.domain.Concept in project snomed-drools by IHTSDO.
the class DroolsConceptServiceTest method testFindStatedAncestorsOfConcept.
@Test
public void testFindStatedAncestorsOfConcept() {
Concept concept = new DroolsConcept("1263005", true, "900000000000207008", "900000000000073002", true, true);
Set<String> results = droolsConceptService.findStatedAncestorsOfConcept(concept);
Assert.assertEquals(7, results.size());
concept = new DroolsConcept("91832008", true, "900000000000207008", "900000000000073002", true, true);
results = droolsConceptService.findStatedAncestorsOfConcept(concept);
Assert.assertEquals(2, results.size());
}
use of org.ihtsdo.drools.domain.Concept in project snomed-drools by IHTSDO.
the class RuleExecutorTest method testExecuteNullRelationshipId.
@Test(expected = BadRequestRuleExecutorException.class)
public void testExecuteNullRelationshipId() throws Exception {
final Concept concept = new ConceptImpl("1").addDescription(new DescriptionImpl("2", "a ")).addRelationship(new RelationshipImpl("r1", "3")).addRelationship(new RelationshipImpl(null, "4"));
ruleExecutor.execute(RULE_SET_NAMES, Collections.singleton(concept), conceptService, descriptionService, relationshipService, true, false);
}
use of org.ihtsdo.drools.domain.Concept in project snomed-drools by IHTSDO.
the class TestDescriptionService method findMatchingDescriptionInHierarchy.
@Override
public /*
* This primitive implementation just uses the direct parents to group given concepts into a 'hierarchy'.
*/
Set<Description> findMatchingDescriptionInHierarchy(Concept concept, Description description) {
checkMinSearchLength(description.getTerm());
Set<Description> matchingDescription = new HashSet<>();
Set<String> parents = getParents(concept);
for (Concept otherConcept : concepts.values()) {
for (String otherConceptParent : getParents(otherConcept)) {
if (parents.contains(otherConceptParent)) {
for (Description otherDescription : otherConcept.getDescriptions()) {
if (description.getTerm().equals(otherDescription.getTerm())) {
matchingDescription.add(otherDescription);
}
}
}
}
}
return matchingDescription;
}
use of org.ihtsdo.drools.domain.Concept in project snomed-drools by IHTSDO.
the class RuleExecutorTest method setup.
@Before
public void setup() {
ruleExecutor = new RuleExecutorFactory().createRuleExecutor("src/test/resources/rules");
ManualResourceConfiguration resourceConfiguration = new ManualResourceConfiguration(true, false, new ResourceConfiguration.Local("src/test/resources/dummy-test-resources"), null);
TestResourceProvider testResourceProvider = ruleExecutor.newTestResourceProvider(new ResourceManager(resourceConfiguration, null));
final Map<String, Concept> concepts = new HashMap<>();
conceptService = new TestConceptService(concepts);
descriptionService = new TestDescriptionService(concepts, testResourceProvider);
relationshipService = new TestRelationshipService(concepts);
}
use of org.ihtsdo.drools.domain.Concept in project snomed-drools by IHTSDO.
the class TestDescriptionService method getFSNs.
@Override
public Set<String> getFSNs(Set<String> conceptIds, String... languageRefsetIds) {
Set<String> fsns = new HashSet<>();
for (String conceptId : conceptIds) {
final Concept concept = concepts.get(conceptId);
for (Description description : concept.getDescriptions()) {
if (description.isActive() && Constants.FSN.equals(description.getTypeId())) {
for (String languageRefsetId : languageRefsetIds) {
Constants.ACCEPTABILITY_PREFERRED.equals(description.getAcceptabilityMap().get(languageRefsetId));
fsns.add(description.getTerm());
}
}
}
}
return fsns;
}
Aggregations