/** * @see org.openmrs.api.ObsService#purgeObs(org.openmrs.Obs) */ @Override public void purgeObs(Obs obs) throws APIException { Context.getObsService().purgeObs(obs, false); }
/** * @see ObsService#purgeObs(Obs,boolean) */ @Test(expected = APIException.class) public void purgeObs_shouldThrowAPIExceptionIfGivenTrueCascade() { Context.getObsService().purgeObs(new Obs(1), true); }
/** * @see org.openmrs.api.EncounterService#purgeEncounter(Encounter, boolean) */ @Override public void purgeEncounter(Encounter encounter, boolean cascade) throws APIException { // if authenticated user is not supposed to edit encounter of certain type if (!canEditEncounter(encounter, null)) { throw new APIException("Encounter.error.privilege.required.purge", new Object[] { encounter.getEncounterType() .getEditPrivilege() }); } if (cascade) { ObsService obsService = Context.getObsService(); List<Encounter> justThisEncounter = new ArrayList<>(); justThisEncounter.add(encounter); List<Obs> observations = new ArrayList<>( obsService.getObservations(null, justThisEncounter, null, null, null, null, null, null, null, null, null, true)); for (Obs o : observations) { obsService.purgeObs(o); } Set<Order> orders = encounter.getOrders(); for (Order o : orders) { Context.getOrderService().purgeOrder(o); } } Context.getEncounterService().purgeEncounter(encounter); }
/** * @see ObsService#purgeObs(Obs) */ @Test public void purgeObs_shouldDeleteTheGivenObsFromTheDatabase() { ObsService obsService = Context.getObsService(); Obs obs = obsService.getObs(7); obsService.purgeObs(obs); Assert.assertNull(obsService.getObs(7)); executeDataSet(COMPLEX_OBS_XML); Obs complexObs = obsService.getComplexObs(44, ComplexObsHandler.RAW_VIEW); // obs #44 is coded by the concept complex #8473 pointing to ImageHandler // ImageHandler inherits AbstractHandler which handles complex data files on disk assertNotNull(complexObs.getComplexData()); AdministrationService as = Context.getAdministrationService(); File complexObsDir = OpenmrsUtil.getDirectoryInApplicationDataDirectory(as .getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_COMPLEX_OBS_DIR)); for (File file : complexObsDir.listFiles()) { file.delete(); } obsService.purgeObs(complexObs); assertNull(obsService.getObs(obs.getObsId())); }
/** * @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(Obs delegate, RequestContext context) throws ResponseException { Context.getObsService().purgeObs(delegate); }
/** * @see ObsService#purgeObs(Obs,boolean) */ @Test public void purgeObs_shouldNotDeleteReferencedOrdersWhenPurgingObs() { executeDataSet(INITIAL_OBS_XML); ObsService obsService = Context.getObsService(); final OrderService orderService = Context.getOrderService(); final int orderReferencingObsId = 4; final Obs obs = obsService.getObs(orderReferencingObsId); final Order order = obs.getOrder(); final Integer referencedOrderId = order.getOrderId(); Context.getObsService().purgeObs(obs, false); Assert.assertNull(obsService.getObs(orderReferencingObsId)); Assert.assertNotNull(orderService.getOrder(referencedOrderId)); }
os.purgeObs(oGGGPThatWasUpdated);
Assert.assertNotNull(obsService.getObs(conceptProposalObsId)); Context.getObsService().purgeObs(obs, false);