### Question:
PatientDataVoidHandler implements VoidHandler<Patient> { @Override public void handle(Patient patient, User voidingUser, Date voidedDate, String voidReason) { EncounterService es = Context.getEncounterService(); List<Encounter> encounters = es.getEncountersByPatient(patient); if (CollectionUtils.isNotEmpty(encounters)) { for (Encounter encounter : encounters) { if (!encounter.getVoided()) { encounter.setDateVoided(patient.getDateVoided()); es.voidEncounter(encounter, voidReason); } } } Context.addProxyPrivilege(PrivilegeConstants.EDIT_COHORTS); try { Context.getCohortService().notifyPatientVoided(patient); } finally { Context.removeProxyPrivilege(PrivilegeConstants.EDIT_COHORTS); } }  @Override void handle(Patient patient, User voidingUser, Date voidedDate, String voidReason);  }### Answer:
@Test public void handle_shouldVoidTheOrdersEncountersAndObservationsAssociatedWithThePatient() { Patient patient = Context.getPatientService().getPatient(7); Assert.assertFalse(patient.getVoided()); List<Encounter> encounters = Context.getEncounterService().getEncountersByPatient(patient); List<Obs> observations = Context.getObsService().getObservationsByPerson(patient); List<Order> orders = Context.getOrderService().getAllOrdersByPatient(patient); assertTrue(CollectionUtils.isNotEmpty(encounters)); assertTrue(CollectionUtils.isNotEmpty(observations)); assertTrue(CollectionUtils.isNotEmpty(orders)); for (Encounter encounter : encounters) { assertNull(encounter.getDateVoided()); assertNull(encounter.getVoidedBy()); assertNull(encounter.getVoidReason()); } for (Obs obs : observations) { assertNull(obs.getDateVoided()); assertNull(obs.getVoidedBy()); assertNull(obs.getVoidReason()); } for (Order order : orders) { assertNull(order.getDateVoided()); assertNull(order.getVoidedBy()); assertNull(order.getVoidReason()); } new PatientDataVoidHandler().handle(patient, new User(1), new Date(), "voidReason"); for (Encounter encounter : encounters) { assertTrue(encounter.getVoided()); assertNotNull(encounter.getDateVoided()); assertNotNull(encounter.getVoidedBy()); assertNotNull(encounter.getVoidReason()); } for (Obs obs : observations) { assertTrue(obs.getVoided()); assertNotNull(obs.getDateVoided()); assertNotNull(obs.getVoidedBy()); assertNotNull(obs.getVoidReason()); } for (Order order : orders) { assertTrue(order.getVoided()); assertNotNull(order.getDateVoided()); assertNotNull(order.getVoidedBy()); assertNotNull(order.getVoidReason()); } encounters = Context.getEncounterService().getEncountersByPatient(patient); observations = Context.getObsService().getObservationsByPerson(patient); assertTrue(CollectionUtils.isEmpty(encounters)); assertTrue(CollectionUtils.isEmpty(observations)); }