diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java index 9886a15e7..3d41ab92b 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java +++ b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java @@ -33,6 +33,8 @@ import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource; import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ResponseException; +import java.util.List; +import java.util.ArrayList; /** * Sub-resource for patient identifiers @@ -248,7 +250,13 @@ public void purge(PatientIdentifier delegate, RequestContext context) throws Res */ @Override public NeedsPaging doGetAll(Patient parent, RequestContext context) throws ResponseException { - return new NeedsPaging(parent.getActiveIdentifiers(), context); + List patientIdentifiers; + if (context.getIncludeAll()) { + patientIdentifiers = new ArrayList(parent.getIdentifiers()); + } else { + patientIdentifiers = parent.getActiveIdentifiers(); + } + return new NeedsPaging(patientIdentifiers, context); } /** diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierController1_9Test.java index 6312609e8..439d3ccdd 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierController1_9Test.java @@ -13,6 +13,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotEquals; import org.apache.commons.beanutils.PropertyUtils; import org.codehaus.jackson.map.ObjectMapper; @@ -124,6 +125,23 @@ public void shouldVoidAPatientIdentifier() throws Exception { assertEquals(reason, service.getPatientIdentifierByUuid(getUuid()).getVoidReason()); } + @Test + public void shouldListAllPatientIdentifiersWithVoidedIdentifiersForAPatient() throws Exception { + assertEquals(false, service.getPatientIdentifierByUuid(getUuid()).isVoided()); + MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); + final String reason = "none"; + req.addParameter("reason", reason); + handle(req); + assertEquals(true, service.getPatientIdentifierByUuid(getUuid()).isVoided()); + SimpleObject result = deserialize(handle(newGetRequest(getURI(), new Parameter( + RestConstants.REQUEST_PROPERTY_FOR_INCLUDE_ALL, "true")))); + assertNotEquals(getAllCount(), Util.getResultsSize(result)); + + SimpleObject nextResult = deserialize(handle(newGetRequest(getURI(), new Parameter( + RestConstants.REQUEST_PROPERTY_FOR_INCLUDE_ALL, "false")))); + assertEquals(getAllCount(), Util.getResultsSize(nextResult)); + } + @Test public void shouldPurgeAPatientIdentifier() throws Exception { long initialIdCount = getAllCount();