/** * @see ConceptServiceImpl#purgeConcept(Concept) */ @Test public void purgeConcept_shouldPurgeTheConceptIfNotBeingUsedByAnObs() { int conceptId = 88; conceptService.purgeConcept(conceptService.getConcept(conceptId)); assertNull(conceptService.getConcept(conceptId)); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public void purge(Concept concept, RequestContext context) throws ResponseException { if (concept == null) return; Context.getConceptService().purgeConcept(concept); }
/** * @see ConceptService#purgeConcept(Concept) */ @Test(expected = ConceptNameInUseException.class) public void purgeConcept_shouldFailIfAnyOfTheConceptNamesOfTheConceptIsBeingUsedByAnObs() { Obs o = new Obs(); o.setConcept(Context.getConceptService().getConcept(3)); o.setPerson(new Patient(2)); o.setEncounter(new Encounter(3)); o.setObsDatetime(new Date()); o.setLocation(new Location(1)); ConceptName conceptName = new ConceptName(1847); o.setValueCodedName(conceptName); Context.getObsService().saveObs(o, null); //ensure that the association between the conceptName and the obs has been established Assert.assertEquals(true, conceptService.hasAnyObservation(conceptName)); Concept concept = conceptService.getConceptByName("cd4 count"); //make sure the name concept name exists Assert.assertNotNull(concept); conceptService.purgeConcept(concept); }
@Override public void deleteConcept(String conceptId) { Concept existingOpenMrsConcept = conceptService.getConcept(Integer.parseInt(conceptId)); if (existingOpenMrsConcept != null) { conceptService.purgeConcept(existingOpenMrsConcept); eventRelay.sendEventMessage(new MotechEvent(EventKeys.DELETED_CONCEPT_SUBJECT, EventHelper.conceptParameters(new OpenMRSConcept(new OpenMRSConceptName(existingOpenMrsConcept.getName().getName()))))); } }