Details
-
Bug
-
Status: Closed
-
Should
-
Resolution: Fixed
-
OpenMRS 1.7.3, OpenMRS 1.8.2, OpenMRS 1.9.0
-
None
-
Low
Description
While doing STAND-36 we discovered that when you call ConceptValidator.validate on a retired concept, it applies excessive validation to concept names.
For example, imagine that we have concepts 1 and 999, that both have the fully-specified name of "measles", but 999 is retired. Ideally doing validate(1) and validate(999) would both pass. The validation logic correctly handles the case where the other concept is retired, but it does not handle the case where the concept that you are validating is itself retired. So with the current code, doing validate(999) will fail. An example unit test is below.
The correct approach would be for validating retired concepts to validate the concept's names for internal consistency (e.g. can't have two fully-specified names) but not to do any checks against other concepts.
Example unit test:
@Test public void validate_shouldPassIfAnotherConceptHasADuplicateNameButThisConceptIsRetired() throws Exception { Context.setLocale(new Locale("en")); Concept concept = Context.getConceptService().getConcept(5497); String duplicateName = concept.getFullySpecifiedName(Context.getLocale()).getName(); Concept anotherConcept = Context.getConceptService().getConcept(5089); anotherConcept.getFullySpecifiedName(Context.getLocale()).setName(duplicateName); anotherConcept.setRetired(true); Errors errors = new BindException(anotherConcept, "concept"); new ConceptValidator().validate(anotherConcept, errors); Assert.assertEquals(false, errors.hasErrors()); }