/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#delete(org.openmrs.Encounter, * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) */ @Override public void delete(Visit visit, String reason, RequestContext context) throws ResponseException { if (visit.isVoided()) { // Makes no sense, so we return success here return; } Context.getVisitService().voidVisit(visit, reason); }
@Test public void shouldVoidAVisit() throws Exception { Visit visit = service.getVisitByUuid(RestTestConstants1_9.VISIT_UUID); Assert.assertFalse(visit.isVoided()); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("reason", "test reason"))); visit = service.getVisitByUuid(RestTestConstants1_9.VISIT_UUID); Assert.assertTrue(visit.isVoided()); Assert.assertEquals("test reason", visit.getVoidReason()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#validateDefaultRepresentation() */ @Override public void validateDefaultRepresentation() throws Exception { super.validateDefaultRepresentation(); assertPropPresent("patient"); assertPropPresent("visitType"); assertPropPresent("indication"); assertPropPresent("location"); assertPropPresent("encounters"); assertPropEquals("startDatetime", getObject().getStartDatetime()); assertPropEquals("stopDatetime", getObject().getStopDatetime()); assertPropPresent("attributes"); assertPropEquals("voided", getObject().isVoided()); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#validateFullRepresentation() */ @Override public void validateFullRepresentation() throws Exception { super.validateFullRepresentation(); assertPropPresent("patient"); assertPropPresent("visitType"); assertPropPresent("indication"); assertPropPresent("location"); assertPropPresent("encounters"); assertPropEquals("startDatetime", getObject().getStartDatetime()); assertPropEquals("stopDatetime", getObject().getStopDatetime()); assertPropPresent("attributes"); assertPropEquals("voided", getObject().isVoided()); assertPropPresent("auditInfo"); }