Skip to content

Commit

Permalink
reverting backport for TRUNK-3822: Search for patient by identifier f…
Browse files Browse the repository at this point in the history
…ails when identifier is made of only letters
  • Loading branch information
mogoodrich committed May 15, 2013
1 parent 539307a commit 14914f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 42 deletions.
19 changes: 9 additions & 10 deletions web/src/main/java/org/openmrs/web/dwr/DWRPatientService.java
Expand Up @@ -13,15 +13,6 @@
*/
package org.openmrs.web.dwr;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -54,6 +45,15 @@
import org.openmrs.patient.UnallowedIdentifierException;
import org.openmrs.util.OpenmrsConstants;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;

/**
* DWR patient methods. The methods in here are used in the webapp to get data from the database via
* javascript calls.
Expand Down Expand Up @@ -176,7 +176,6 @@ else if (validCheckDigit)
* @should signal for a new search if the new search value has matches and is a first call
* @should not signal for a new search if it is not the first ajax call
* @should not signal for a new search if the new search value has no matches
* @should match patient with identifiers that contain no digit
*/
public Map<String, Object> findCountAndPatients(String searchValue, Integer start, Integer length, boolean getMatchCount)
throws APIException {
Expand Down
35 changes: 3 additions & 32 deletions web/src/test/java/org/openmrs/web/dwr/DWRPatientServiceTest.java
Expand Up @@ -13,20 +13,15 @@
*/
package org.openmrs.web.dwr;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.openmrs.Patient;
import org.openmrs.PatientIdentifier;
import org.openmrs.api.PatientService;
import org.openmrs.api.context.Context;
import org.openmrs.test.Verifies;
import org.openmrs.web.test.BaseWebContextSensitiveTest;

import java.util.Collection;
import java.util.Map;

/**
* Test the methods in {@link DWRPatientsServiceTest}
*/
Expand Down Expand Up @@ -100,28 +95,4 @@ public void findCountAndPatients_shouldSignalForANewSearchIfTheNewSearchValueHas
Assert.assertNotNull(resultObjects.get("notification"));
}

/**
* @see {@link DWRPatientService#findCountAndPatients(String,Integer,Integer,null)}
*/
@Test
@Verifies(value = "should match patient with identifiers that contain no digit", method = "findCountAndPatients(String,Integer,Integer,null)")
public void findCountAndPatients_shouldMatchPatientWithIdentifiersThatContainNoDigit() throws Exception {
PatientService ps = Context.getPatientService();
final String identifier = "XYZ";
//should have no patient with this identifiers
Assert.assertEquals(0, ps.getCountOfPatients(identifier).intValue());

Patient patient = ps.getPatient(2);
PatientIdentifier pId = new PatientIdentifier(identifier, ps.getPatientIdentifierType(2), Context
.getLocationService().getLocation(1));
patient.addIdentifier(pId);
ps.savePatient(patient);

//Let's do this in a case insensitive way
Map<String, Object> resultObjects = new DWRPatientService().findCountAndPatients(identifier.toLowerCase(), 0, null,
true);
Assert.assertEquals(1, resultObjects.get("count"));
Assert.assertEquals(1, ((List<?>) resultObjects.get("objectList")).size());
}

}

0 comments on commit 14914f9

Please sign in to comment.