/** * @see EncounterService#purgeEncounterType(EncounterType) */ @Test public void purgeEncounterType_shouldPurgeType() { EncounterService encounterService = Context.getEncounterService(); EncounterType encounterTypeToPurge = encounterService.getEncounterType(4); assertNotNull(encounterTypeToPurge); // check deletion encounterService.purgeEncounterType(encounterTypeToPurge); assertNull(encounterService.getEncounterType(4)); }
/** * @see EncounterService#purgeEncounterType(EncounterType) */ @Test(expected = EncounterTypeLockedException.class) public void purgeEncounterType_shouldThrowErrorWhenTryingToDeleteEncounterTypeWhenEncounterTypesAreLocked() { EncounterService encounterService = Context.getEncounterService(); EncounterType encounterType = Context.getEncounterService().getEncounterType(1); Assert.assertNotNull(encounterType); GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_ENCOUNTER_TYPES_LOCKED); gp.setPropertyValue("true"); Context.getAdministrationService().saveGlobalProperty(gp); encounterService.purgeEncounterType(encounterType); }
/** * @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(EncounterType encounterType, RequestContext context) throws ResponseException { if (encounterType == null) return; Context.getEncounterService().purgeEncounterType(encounterType); }