private LinkedHashSet<Concept> transformNamesToConcepts(List<ConceptName> names) { LinkedHashSet<Concept> concepts = new LinkedHashSet<>(); for (ConceptName name : names) { concepts.add(name.getConcept()); } return concepts; }
/** * @see ConceptDAO#getConcepts(String, List, boolean, List, List, List, List, Concept, Integer, * Integer) */ @Override public List<ConceptSearchResult> getConcepts(final String phrase, final List<Locale> locales, final boolean includeRetired, final List<ConceptClass> requireClasses, final List<ConceptClass> excludeClasses, final List<ConceptDatatype> requireDatatypes, final List<ConceptDatatype> excludeDatatypes, final Concept answersToConcept, final Integer start, final Integer size) throws DAOException { LuceneQuery<ConceptName> query = newConceptNameLuceneQuery(phrase, true, locales, false, includeRetired, requireClasses, excludeClasses, requireDatatypes, excludeDatatypes, answersToConcept); ListPart<ConceptName> names = query.listPart(start, size); List<ConceptSearchResult> results = new ArrayList<>(); for (ConceptName name : names.getList()) { results.add(new ConceptSearchResult(phrase, name.getConcept(), name)); } return results; }
return false; if (name.getConcept() != null) { if (name.getConcept().getRetired()) { return false; if (!name.equals(name.getConcept().getName(name.getLocale()))) { return false; if (candidateName.getConcept().getRetired()) { continue; if (candidateName.getConcept().equals(name.getConcept())) { continue; if (candidateName.getConcept().getName(candidateName.getLocale()).equals(candidateName)) { return true;
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object) */ @Override public Concept getParent(ConceptName instance) { return instance.getConcept(); }
@Test public void shouldChangeConceptNameReferenceToParentConcept() { Concept c = new Concept(123); c.addName(new ConceptName(1)); c.addName(new ConceptName(2)); ConceptNumeric cn = new ConceptNumeric(c); for (ConceptName cName : cn.getNames()) { Assert.assertSame(cn, cName.getConcept()); } }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public void purge(ConceptName cn, RequestContext context) throws ResponseException { cn.getConcept().removeName(cn); Context.getConceptService().saveConcept(cn.getConcept()); }
@Test public void validate_shouldPassIfTheDuplicateNameInTheLocaleForTheConceptBeingValidatedIsVoided() { ConceptName otherName = conceptService.getConceptName(1439); //sanity check since names should only be unique amongst preferred and fully specified names Assert.assertTrue(otherName.isFullySpecifiedName() || otherName.isPreferred()); Assert.assertFalse(otherName.getVoided()); Assert.assertFalse(otherName.getConcept().getRetired()); //change to a duplicate name in the same locale ConceptName duplicateName = conceptService.getConceptName(2477); duplicateName.setName(otherName.getName()); Concept concept = duplicateName.getConcept(); concept.setPreferredName(duplicateName); //ensure that the name has been marked as preferred in its locale Assert.assertEquals(duplicateName, concept.getPreferredName(duplicateName.getLocale())); Assert.assertTrue(duplicateName.isPreferred()); duplicateName.setVoided(true); Errors errors = new BindException(concept, "concept"); validator.validate(concept, errors); Assert.assertFalse(errors.hasErrors()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) */ @Override public ConceptName save(ConceptName newName) { // make sure that the name has actually been added to the concept boolean needToAdd = true; for (ConceptName cn : newName.getConcept().getNames()) { if (cn.equals(newName)) { needToAdd = false; break; } } if (needToAdd) newName.getConcept().addName(newName); Context.getConceptService().saveConcept(newName.getConcept()); return newName; }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public void delete(ConceptName cn, String reason, RequestContext context) throws ResponseException { cn.setVoided(true); cn.setVoidedBy(Context.getAuthenticatedUser()); cn.setVoidReason(reason); cn.setDateVoided(new Date()); Context.getConceptService().saveConcept(cn.getConcept()); }
} else if (value instanceof ConceptName) { obs.setValueCodedName((ConceptName) value); obs.setValueCoded(obs.getValueCodedName().getConcept()); } else if (value instanceof Concept) { obs.setValueCoded((Concept) value);