Search in sources :

Example 1 with ConceptNameInUseException

use of org.openmrs.api.ConceptNameInUseException in project openmrs-core by openmrs.

the class ConceptServiceImpl method purgeConcept.

/**
 * @see org.openmrs.api.ConceptService#purgeConcept(Concept)
 */
@Override
public void purgeConcept(Concept concept) throws APIException {
    checkIfLocked();
    if (concept.getConceptId() != null) {
        for (ConceptName conceptName : concept.getNames()) {
            if (hasAnyObservation(conceptName)) {
                throw new ConceptNameInUseException("Can't delete concept with id : " + concept.getConceptId() + " because it has a name '" + conceptName.getName() + "' which is being used by some observation(s)");
            }
        }
    }
    dao.purgeConcept(concept);
}
Also used : ConceptName(org.openmrs.ConceptName) ConceptNameInUseException(org.openmrs.api.ConceptNameInUseException)

Aggregations

ConceptName (org.openmrs.ConceptName)1 ConceptNameInUseException (org.openmrs.api.ConceptNameInUseException)1