Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5395

PatientService getPatients(name, identifier, types, matchIdentifierExactly) does not restrict by identifierType

    XMLWordPrintable

Details

    Description

      If one or more identifier types are passed in to the "types" parameter of the getPatients search, the search result should only return matches on those identifier types.  Currently, the "types" parameter is ignored in the underlying call to the DAO:

      @Override
      @Transactional(readOnly = true)
      public List<Patient> getPatients(String name, String identifier, List<PatientIdentifierType> identifierTypes,
              boolean matchIdentifierExactly, Integer start, Integer length) throws APIException {
         
         return dao.getPatients(name != null ? name : identifier, start, length);
      }

      Example unit test to reproduce here:

      @Test
      @SkipBaseSetup
      public void shouldGetPatientsByIdentifierAndIdentifierType() throws Exception {
         initializeInMemoryDatabase();
         executeDataSet(FIND_PATIENTS_XML);
         authenticate();
         updateSearchIndex();
         
         List<PatientIdentifierType> types = new ArrayList<>();
         types.add(new PatientIdentifierType(1));
         // make sure we get back only one patient
         List<Patient> patients = patientService.getPatients("1234", null, types, false);
         assertEquals(1, patients.size());
         
         // make sure we get back only one patient
         patients = patientService.getPatients("1234", null, null, false);
         assertEquals(1, patients.size());
         
         // make sure we can search a padded identifier
         patients = patientService.getPatients("00000001234", null, null, false);
         assertEquals(1, patients.size());
         
         // change to use another identifier type
         // THESE TWO TESTS CURRENTLY FAIL
         types = new ArrayList<>();
         types.add(new PatientIdentifierType(2));
         patients = patientService.getPatients("1234", null, types, false);
         assertEquals(0, patients.size());
      
         patients = patientService.getPatients(null, "1234", types, false);
         assertEquals(0, patients.size());
      }
      

       

      Gliffy Diagrams

        Attachments

          Activity

            People

              fruether Fred Rue
              mogoodrich Mark Goodrich
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: