Skip to content

Commit

Permalink
Merge pull request #498 from WolfSchlegel/TRUNK-2472-B
Browse files Browse the repository at this point in the history
added automated tests for patient search
  • Loading branch information
dkayiwa committed Jan 20, 2014
2 parents c057f4e + b7d00c6 commit 4eb52bb
Show file tree
Hide file tree
Showing 18 changed files with 2,549 additions and 283 deletions.
8 changes: 4 additions & 4 deletions api/src/main/java/org/openmrs/api/PatientService.java
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ public PatientIdentifierType unretirePatientIdentifierType(PatientIdentifierType
/**
* Generic search on patients based on the given string and returns a specific number of them
* from the specified starting position. Implementations can use this string to search on name,
* identifier, etc Voided patients are not returned in search results If start is 0 and length
* is not specified, then all matches are returned
* identifier, searchable person attributes etc. Voided patients are not returned in search results.
* If start is 0 and length is not specified, then all matches are returned
*
* @param query the string to search on
* @param start the starting index
Expand Down Expand Up @@ -965,8 +965,8 @@ public void saveCauseOfDeathObs(Patient patient, Date dateDied, Concept causeOfD
public void voidAllergy(Allergy allergy, String reason) throws APIException;

/**
* Return the number of unvoided patients with names or patient identifiers starting with or
* equal to the specified text
* Return the number of unvoided patients with names or patient identifiers or searchable person attributes
* starting with or equal to the specified text
*
* @param query the string to search on
* @return the number of patients matching the given search phrase
Expand Down
149 changes: 148 additions & 1 deletion api/src/main/java/org/openmrs/api/db/PatientDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public interface PatientDAO {
* name or identifier otherwise find patients that match both the name and identifier
* @see org.openmrs.api.PatientService#getPatients(String, String, List, boolean, Integer,
* Integer)
*
* @deprecated replaced by {@link org.openmrs.api.db.PatientDAO#getPatients(String, Integer, Integer)}
*
* @should escape percentage character in name phrase
* @should escape underscore character in name phrase
* @should escape an asterix character in name phrase
Expand All @@ -67,11 +70,123 @@ public interface PatientDAO {
* @should escape an asterix character in identifier phrase
* @should get patients with a matching identifier and type
* @should not search on voided patients
*
* @should not match voided patients _ signature no 1
* @should not match voided patient names _ signature no 1
*
* @should get patient by given name _ signature no 1
* @should get patient by middle name _ signature no 1
* @should get patient by family name _ signature no 1
* @should get patient by family2 name _ signature no 1
* @should get patient by whole name _ signature no 1
*
* @should not get patient by non-existing single name _ signature no 1
* @should not get patient by non-existing name parts _ signature no 1
* @should not get patient by mix of existing and non-existing name parts _ signature no 1
* @should not get patient by voided name _ signature no 1
*
* @should not get patients by empty name _ signature no 1
* @should not get patients by null name _ signature no 1
*
* @should get patient by short given name _ signature no 1
* @should get patient by short middle name _ signature no 1
* @should get patient by short family name _ signature no 1
* @should get patient by short family2 name _ signature no 1
* @should get patient by whole name made up of short names _ signature no 1
* @should get patients by multiple short name parts _ signature no 1
*
* @should not get patient by non-existing single short name _ signature no 1
* @should not get patient by non-existing short name parts _ signature no 1
* @should not get patient by mix of existing and non-existing short name parts _ signature no 1
* @should not get patient by voided short name _ signature no 1
*
* @should get patients with match mode start _ signature no 1
* @should get patients with match mode anywhere _ signature no 1
* @should not get patients with match mode start _ signature no 1
* @should not get patients with match mode anywhere _ signature no 1
*
* @should get patient by identifier _ signature no 1
* @should not get patient by non-existing identifier _ signature no 1
* @should not get patient by voided identifier _ signature no 1
*
* @should not get patient by empty identifier _ signature no 1
* @should not get patient by null identifier _ signature no 1
*
* @should get patient by searching on names or identifiers and using name value as identifier parameter _ signature no 1
* @should get patient by searching on names or identifiers and using identifier value as name parameter _ signature no 1
*
* @should get one patient by multiple name parts _ signature no 1
*
*/
public List<Patient> getPatients(String name, String identifier, List<PatientIdentifierType> identifierTypes,
boolean matchIdentifierExactly, Integer start, Integer length, boolean searchOnNamesOrIdentifiers)
throws DAOException;

/**
* @see org.openmrs.api.PatientService#getPatients(String, Integer, Integer)
*
* @should not get patients by empty query _ signature no 2
* @should not get patients by null query _ signature no 2
*
* @should get patient by given name _ signature no 2
* @should get patient by middle name _ signature no 2
* @should get patient by family name _ signature no 2
* @should get patient by family2 name _ signature no 2
* @should get patient by whole name _ signature no 2
*
* @should not get patient by non-existing single name _ signature no 2
* @should not get patient by non-existing name parts _ signature no 2
* @should not get patient by mix of existing and non-existing name parts _ signature no 2
* @should not get patient by voided name _ signature no 2
*
* @should get patient by short given name _ signature no 2
* @should get patient by short middle name _ signature no 2
* @should get patient by short family name _ signature no 2
* @should get patient by short family2 name _ signature no 2
* @should get patient by whole name made up of short names _ signature no 2
* @should get patients by multiple short name parts _ signature no 2
*
* @should not get patient by non-existing single short name _ signature no 2
* @should not get patient by non-existing short name parts _ signature no 2
* @should not get patient by mix of existing and non-existing short name parts _ signature no 2
* @should not get patient by voided short name _ signature no 2
*
* @should get patient by identifier _ signature no 2
* @should not get patient by non-existing identifier _ signature no 2
* @should not get patient by voided identifier _ signature no 2
*
* @should get no patient by non-existing attribute _ signature no 2
* @should get no patient by non-searchable attribute _ signature no 2
* @should get no patient by voided attribute _ signature no 2
* @should get one patient by attribute _ signature no 2
* @should get one patient by random case attribute _ signature no 2
* @should not get patients by searching for non-voided and voided attribute _ signature no 2
* @should get multiple patients by single attribute _ signature no 2
* @should not get patients by multiple attributes _ signature no 2
*
* @should find eleven out of eleven patients _ signature no 2
* @should find the first four out of eleven patients _ signature no 2
* @should find the next four out of eleven patients _ signature no 2
* @should find the remaining three out of eleven patients _ signature no 2
* @should find patients with null as start _ signature no 2
* @should find patients with negative start _ signature no 2
* @should find patients with null as length _ signature no 2
* @should not get patients by zero length _ signature no 2
* @should not get patients by negative length _ signature no 2
* @should find patients with excessive length _ signature no 2
*
* @should return distinct patient list _ signature no 2
* @should not match voided patients _ signature no 2
*
* @should get patients with match mode start _ signature no 2
* @should get patients with match mode anywhere _ signature no 2
* @should not get patients with match mode start _ signature no 2
* @should not get patients with match mode anywhere _ signature no 2
*
*/
public List<Patient> getPatients(String query, Integer start, Integer length) throws DAOException;

/**
* @see org.openmrs.api.PatientService#getPatientIdentifiers(java.lang.String, java.util.List,
* java.util.List, java.util.List, java.lang.Boolean)
Expand Down Expand Up @@ -167,7 +282,39 @@ public List<PatientIdentifierType> getPatientIdentifierTypes(String name, String
* @param searchOnNamesOrIdentifiers specifies if the logic should find patients that match the
* name or identifier otherwise find patients that match both the name and identifier
* @see PatientService#getCountOfPatients(String)
*/
*
* @deprecated replaced by {@link org.openmrs.api.db.PatientDAO#getCountOfPatients(String)}
*
* @should count zero patients when name and identifier and list of identifier types are empty _ signature no 1
* @should count zero patients when name and identifier and list of identifier types are null _ signature no 1
*
* @should count zero patients for non-matching query _ signature no 1
*
* @should not count voided patients _ signature no 1
* @should count single patient _ signature no 1
* @should count multiple patients _ signature no 1
*
* @should count patients by name _ signature no 1
* @should count patients by identifier _ signature no 1
*/
public Long getCountOfPatients(String name, String identifier, List<PatientIdentifierType> identifierTypes,
boolean matchIdentifierExactly, boolean searchOnNamesOrIdentifiers);

/**
* @see org.openmrs.api.PatientService#getCountOfPatients(String)
*
* @should count zero patients when query is empty _ signature no 2
* @should count zero patients when query is null _ signature no 2
* @should count zero patients for non-matching query _ signature no 2
* @should not count voided patients _ signature no 2
* @should count single patient _ signature no 2
* @should count multiple patients _ signature no 2
*
* @should count patients by name _ signature no 2
* @should count patients by identifier _ signature no 2
* @should count patients by searchable attribute _ signature no 2
*/
public Long getCountOfPatients(String query);

}

0 comments on commit 4eb52bb

Please sign in to comment.