Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c057f4e12e93
Choose a base ref
...
head repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4eb52bb36a5f
Choose a head ref
  • 2 commits
  • 18 files changed
  • 2 contributors

Commits on Jan 17, 2014

  1. Added automated tests for org.openmrs.api.db.hibernate.HibernatePatie…

    …ntDAO and org.openmrs.api.db.hibernate.PatientSearchCriteria
    
    Refactored org.openmrs.api.db.hibernate.PatientSearchCriteria
    Added and implemented org.openmrs.api.db.PatientDAO#getPatients(String,Integer,Integer)
    Added and implemented org.openmrs.api.db.PatientDAO#getCountOfPatients(String)
    Marked org.openmrs.api.db.PatientDAO#getPatients(String,String,List,boolean,Integer,Integer) as deprecated
    Marked org.openmrs.api.db.PatientDAO#getCountOfPatients(String,String,List,boolean,boolean) as deprecated
    Moved tests from org.openmrs.api.db.hibernate.HibernatePatientDAOTest to org.openmrs.api.db.PatientDAOTest
    WolfSchlegel committed Jan 17, 2014
    Copy the full SHA
    b7d00c6 View commit details

Commits on Jan 20, 2014

  1. Merge pull request #498 from WolfSchlegel/TRUNK-2472-B

    added automated tests for patient search
    dkayiwa committed Jan 20, 2014
    Copy the full SHA
    4eb52bb View commit details
Showing with 2,549 additions and 283 deletions.
  1. +4 −4 api/src/main/java/org/openmrs/api/PatientService.java
  2. +148 −1 api/src/main/java/org/openmrs/api/db/PatientDAO.java
  3. +83 −62 api/src/main/java/org/openmrs/api/db/hibernate/HibernatePatientDAO.java
  4. +17 −21 api/src/main/java/org/openmrs/api/db/hibernate/HibernatePersonDAO.java
  5. +261 −123 api/src/main/java/org/openmrs/api/db/hibernate/PatientSearchCriteria.java
  6. +18 −0 api/src/main/java/org/openmrs/api/db/hibernate/PatientSearchMode.java
  7. +43 −0 api/src/main/java/org/openmrs/api/db/hibernate/PersonSearchCriteria.java
  8. +5 −2 api/src/main/java/org/openmrs/api/impl/PatientServiceImpl.java
  9. +3 −1 api/src/main/java/org/openmrs/util/OpenmrsConstants.java
  10. +2 −3 api/src/test/java/org/openmrs/api/PatientServiceTest.java
  11. +1,319 −24 api/src/test/java/org/openmrs/api/db/PatientDAOTest.java
  12. +46 −0 api/src/test/java/org/openmrs/api/db/PatientSearchTestHelper.java
  13. +30 −21 api/src/test/java/org/openmrs/api/db/hibernate/HibernatePersonDAOTest.java
  14. +392 −0 api/src/test/java/org/openmrs/api/db/hibernate/PatientSearchCriteriaTest.java
  15. +16 −2 ...a/org/openmrs/api/db/hibernate/{HibernatePersonAttributeHelper.java → PersonAttributeHelper.java}
  16. +38 −14 ...enmrs/api/db/hibernate/{HibernatePersonAttributeHelperTest.java → PersonAttributeHelperTest.java}
  17. +119 −0 api/src/test/resources/org/openmrs/api/db/hibernate/include/HibernatePatientDAOTest-patients.xml
  18. +5 −5 api/src/test/resources/org/openmrs/api/db/hibernate/include/HibernatePersonDAOTest-people.xml
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
@@ -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
@@ -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
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
@@ -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
@@ -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)
@@ -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);

}
Loading