Search in sources :

Example 1 with Concept

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());
}
Also used : Concept(org.ihtsdo.drools.domain.Concept) DroolsConcept(org.ihtsdo.drools.validator.rf2.domain.DroolsConcept) DroolsConcept(org.ihtsdo.drools.validator.rf2.domain.DroolsConcept) Test(org.junit.Test)

Example 2 with Concept

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);
}
Also used : Concept(org.ihtsdo.drools.domain.Concept) ConceptImpl(org.ihtsdo.drools.unittest.domain.ConceptImpl) DescriptionImpl(org.ihtsdo.drools.unittest.domain.DescriptionImpl) RelationshipImpl(org.ihtsdo.drools.unittest.domain.RelationshipImpl) Test(org.junit.Test)

Example 3 with Concept

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;
}
Also used : Concept(org.ihtsdo.drools.domain.Concept) Description(org.ihtsdo.drools.domain.Description) HashSet(java.util.HashSet)

Example 4 with Concept

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);
}
Also used : Concept(org.ihtsdo.drools.domain.Concept) TestDescriptionService(org.ihtsdo.drools.rulestestrig.service.TestDescriptionService) ResourceManager(org.ihtsdo.otf.resourcemanager.ResourceManager) RuleExecutorFactory(org.ihtsdo.drools.RuleExecutorFactory) ManualResourceConfiguration(org.ihtsdo.otf.resourcemanager.ManualResourceConfiguration) TestResourceProvider(org.ihtsdo.drools.service.TestResourceProvider) ResourceConfiguration(org.ihtsdo.otf.resourcemanager.ResourceConfiguration) ManualResourceConfiguration(org.ihtsdo.otf.resourcemanager.ManualResourceConfiguration) TestConceptService(org.ihtsdo.drools.rulestestrig.service.TestConceptService) TestRelationshipService(org.ihtsdo.drools.rulestestrig.service.TestRelationshipService) Before(org.junit.Before)

Example 5 with Concept

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;
}
Also used : Concept(org.ihtsdo.drools.domain.Concept) Description(org.ihtsdo.drools.domain.Description) HashSet(java.util.HashSet)

Aggregations

Concept (org.ihtsdo.drools.domain.Concept)15 Test (org.junit.Test)8 Description (org.ihtsdo.drools.domain.Description)6 ConceptImpl (org.ihtsdo.drools.unittest.domain.ConceptImpl)6 DescriptionImpl (org.ihtsdo.drools.unittest.domain.DescriptionImpl)6 HashSet (java.util.HashSet)5 RelationshipImpl (org.ihtsdo.drools.unittest.domain.RelationshipImpl)5 InvalidContent (org.ihtsdo.drools.response.InvalidContent)3 DroolsConcept (org.ihtsdo.drools.validator.rf2.domain.DroolsConcept)3 java.util (java.util)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 RuleExecutorFactory (org.ihtsdo.drools.RuleExecutorFactory)1 Constants (org.ihtsdo.drools.domain.Constants)1 TestConceptService (org.ihtsdo.drools.rulestestrig.service.TestConceptService)1 TestDescriptionService (org.ihtsdo.drools.rulestestrig.service.TestDescriptionService)1 TestRelationshipService (org.ihtsdo.drools.rulestestrig.service.TestRelationshipService)1 ConceptService (org.ihtsdo.drools.service.ConceptService)1 TestResourceProvider (org.ihtsdo.drools.service.TestResourceProvider)1