use of org.ihtsdo.drools.validator.rf2.domain.DroolsConcept 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.validator.rf2.domain.DroolsConcept in project snomed-drools by IHTSDO.
the class DroolsConceptService method findStatedAncestorsOfConcept.
@Override
public Set<String> findStatedAncestorsOfConcept(Concept concept) {
if (concept == null || concept.getId().equals(Constants.ROOT_CONCEPT)) {
return Collections.emptySet();
}
DroolsConcept droolsConcept = repository.getConcept(concept.getId());
Set<String> statedParents = new HashSet<>();
for (DroolsRelationship relationship : droolsConcept.getRelationships()) {
if (relationship.isActive() && !relationship.isAxiomGCI() && Constants.IS_A.equals(relationship.getTypeId()) && Constants.STATED_RELATIONSHIP.equals(relationship.getCharacteristicTypeId())) {
statedParents.add(relationship.getDestinationId());
}
}
Set<String> resultSet = new HashSet<>(statedParents);
for (String statedParent : statedParents) {
resultSet.addAll(findStatedAncestorsOfConcept(repository.getConcept(statedParent)));
}
return resultSet;
}
use of org.ihtsdo.drools.validator.rf2.domain.DroolsConcept in project snomed-drools by IHTSDO.
the class BaseServiceTest method loadConceptsIntoRepository.
protected void loadConceptsIntoRepository() throws FileNotFoundException {
repository.addConcept(FileLoaderTestUtils.fileToObject("data/138875005.json", DroolsConcept.class));
repository.addConcept(FileLoaderTestUtils.fileToObject("data/1263005.json", DroolsConcept.class));
repository.addConcept(FileLoaderTestUtils.fileToObject("data/91832008.json", DroolsConcept.class));
repository.addConcept(FileLoaderTestUtils.fileToObject("data/123037004.json", DroolsConcept.class));
repository.addConcept(FileLoaderTestUtils.fileToObject("data/4421005.json", DroolsConcept.class));
repository.addConcept(FileLoaderTestUtils.fileToObject("data/67185001.json", DroolsConcept.class));
repository.addConcept(FileLoaderTestUtils.fileToObject("data/91723000.json", DroolsConcept.class));
repository.addConcept(FileLoaderTestUtils.fileToObject("data/442083009.json", DroolsConcept.class));
repository.addConcept(new DroolsConcept("12345678", true, "900000000000207008", "900000000000073002", true, true));
}
use of org.ihtsdo.drools.validator.rf2.domain.DroolsConcept in project snomed-drools by IHTSDO.
the class DroolsDescriptionServiceTest method testFindMatchingDescriptionsInHierachy.
@Test
public void testFindMatchingDescriptionsInHierachy() throws FileNotFoundException {
// load a dummy concept which has duplicated description term with its parent
repository.addConcept(FileLoaderTestUtils.fileToObject("data/1234567890.json", DroolsConcept.class));
DroolsConcept testConcept = repository.getConcept("1234567890");
DroolsDescription testDescription = null;
for (DroolsDescription droolsDescription : testConcept.getDescriptions()) {
testDescription = droolsDescription;
}
Set<Description> results = droolsDescriptionService.findMatchingDescriptionInHierarchy(testConcept, testDescription);
Assert.assertEquals(1, results.size());
for (Description result : results) {
Assert.assertEquals("1204236014", result.getId());
}
}
use of org.ihtsdo.drools.validator.rf2.domain.DroolsConcept in project snomed-drools by IHTSDO.
the class DroolsRF2Validator method validateSnapshot.
public List<InvalidContent> validateSnapshot(InputStream snomedRf2EditionZip, Set<String> ruleSetNamesToRun) throws ReleaseImportException {
long start = new Date().getTime();
Assert.isTrue(ruleSetNamesToRun != null && !ruleSetNamesToRun.isEmpty(), "The name of at least one rule set must be specified.");
ReleaseImporter importer = new ReleaseImporter();
SnomedDroolsComponentRepository repository = new SnomedDroolsComponentRepository();
logger.info("Loading components from RF2");
LoadingProfile loadingProfile = LoadingProfile.complete;
loadingProfile.getIncludedReferenceSetFilenamePatterns().add(".*_cRefset_Language.*");
importer.loadSnapshotReleaseFiles(snomedRf2EditionZip, loadingProfile, new SnomedDroolsComponentFactory(repository));
logger.info("Components loaded");
DroolsConceptService conceptService = new DroolsConceptService(repository);
DroolsDescriptionService descriptionService = new DroolsDescriptionService(repository);
DroolsRelationshipService relationshipService = new DroolsRelationshipService(repository);
Collection<DroolsConcept> concepts = repository.getConcepts();
logger.info("Running tests");
List<InvalidContent> invalidContents = ruleExecutor.execute(ruleSetNamesToRun, concepts, conceptService, descriptionService, relationshipService, true, false);
logger.info("Tests complete. Total run time {} seconds", (new Date().getTime() - start) / 1000);
logger.info("invalidContent count {}", invalidContents.size());
return invalidContents;
}
Aggregations