DroolsDescriptionService implements DescriptionService { @Override public Set<String> getFSNs(Set<String> conceptIds, String... languageRefsetIds) { Set<String> fsns = new HashSet<>(); for (String conceptId : conceptIds) { DroolsConcept concept = repository.getConcept(conceptId); if(concept != null) { Collection<DroolsDescription> descriptions = concept.getDescriptions(); for (DroolsDescription description : descriptions) { if (description.isActive() && description.getTypeId().equals(FULLY_SPECIFIED_NAME)) { if(languageRefsetIds != null && languageRefsetIds.length > 0) { for (String languageRefsetId : languageRefsetIds) { if (PREFERRED_ACCEPTABILITY.equals(description.getAcceptabilityMap().get(languageRefsetId))) { fsns.add(description.getTerm()); } } } else { fsns.add(description.getTerm()); } } } } } return fsns; } DroolsDescriptionService(SnomedDroolsComponentRepository repository, TestResourceProvider testResourceProvider); @Override Set<String> getFSNs(Set<String> conceptIds, String... languageRefsetIds); @Override Set<Description> findActiveDescriptionByExactTerm(String exactTerm); @Override Set<Description> findInactiveDescriptionByExactTerm(String exactTerm); @Override // FIXME: Currently only finds matching description in ancestors. // Should search all descendants of the second highest ancestor (the ancestor which is a direct child of root). Set<Description> findMatchingDescriptionInHierarchy(Concept concept, Description description); @Override String getCaseSensitiveWordsErrorMessage(Description description); @Override String getLanguageSpecificErrorMessage(Description description); @Override Set<String> findParentsNotContainingSemanticTag(Concept concept, String termSematicTag, String... languageRefsetIds); @Override boolean isRecognisedSemanticTag(String termSemanticTag); DroolsDescriptionIndex getDroolsDescriptionIndex();  }
@Test public void testFindFSNs() { repository.getConcept("1263005").getDescriptions().stream() .filter(d -> ConceptConstants.FSN.equals(d.getTypeId())) .forEach(d -> d.getAcceptabilityMap().put(ConceptConstants.US_EN_LANGUAGE_REFERENCE_SET, Constants.ACCEPTABILITY_PREFERRED)); Set<String> conceptsIds = new HashSet<>(); conceptsIds.add("1263005"); Set<String> results = droolsDescriptionService.getFSNs(conceptsIds, ConceptConstants.US_EN_LANGUAGE_REFERENCE_SET); Assert.assertEquals(1, results.size()); for (String result : results) { Assert.assertEquals("Distinctive arrangement of microtubules (cell structure)", result); } }