Search in sources :

Example 51 with PatientIdentifierType

use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.

the class PatientServiceTest method isIdentifierInUseByAnotherPatient_shouldReturnTrueWhenPatientIdentifierDoesNotContainAPatientAndAPatientHasThisId.

/**
 * @see PatientService#isIdentifierInUseByAnotherPatient(PatientIdentifier)
 */
@Test
public void isIdentifierInUseByAnotherPatient_shouldReturnTrueWhenPatientIdentifierDoesNotContainAPatientAndAPatientHasThisId() throws Exception {
    PatientIdentifierType pit = patientService.getPatientIdentifierType(1);
    PatientIdentifier patientIdentifier = new PatientIdentifier("7TU-8", pit, null);
    Assert.assertTrue(patientService.isIdentifierInUseByAnotherPatient(patientIdentifier));
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) PatientIdentifier(org.openmrs.PatientIdentifier) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 52 with PatientIdentifierType

use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.

the class PatientServiceTest method getPatientIdentifierTypeByName_shouldFetchPatientIdentifierTypeThatExactlyMatchesGivenName.

/**
 * @see PatientService#getPatientIdentifierTypeByName(String)
 */
@Test
public void getPatientIdentifierTypeByName_shouldFetchPatientIdentifierTypeThatExactlyMatchesGivenName() throws Exception {
    String identifierTypeName = "OpenMRS Identification Number";
    PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierTypeByName(identifierTypeName);
    Assert.assertNotNull(identifierType);
    Assert.assertEquals(identifierType.getName(), identifierTypeName);
    Assert.assertTrue(identifierType.getClass().isAssignableFrom(PatientIdentifierType.class));
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 53 with PatientIdentifierType

use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.

the class PatientDAOTest method getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypesWithGivenFormat.

/**
 * @see PatientDAO#getPatientIdentifierTypes(String, String, Boolean, Boolean)
 */
@Test
public void getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypesWithGivenFormat() {
    PatientIdentifierType formatOneNonRetired = dao.getPatientIdentifierType(1);
    formatOneNonRetired.setFormat("1");
    dao.savePatientIdentifierType(formatOneNonRetired);
    List<PatientIdentifierType> patientIdentifierTypes = dao.getPatientIdentifierTypes(null, "1", null, null);
    Assert.assertEquals(patientIdentifierTypes.size(), 1);
    Assert.assertEquals(formatOneNonRetired, patientIdentifierTypes.get(0));
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 54 with PatientIdentifierType

use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.

the class PatientDAOTest method getPatientIdentifierTypes_shouldReturnOnlyNonRetiredPatientIdentifierTypes.

/**
 * @see PatientDAO#getPatientIdentifierTypes(String, String, Boolean, Boolean)
 */
@Test
public void getPatientIdentifierTypes_shouldReturnOnlyNonRetiredPatientIdentifierTypes() {
    PatientIdentifierType nonRetiredType1 = dao.getPatientIdentifierType(1);
    Assert.assertEquals(nonRetiredType1.getRetired(), false);
    PatientIdentifierType nonRetiredType2 = dao.getPatientIdentifierType(2);
    Assert.assertEquals(nonRetiredType2.getRetired(), false);
    PatientIdentifierType nonRetiredType3 = dao.getPatientIdentifierType(5);
    Assert.assertEquals(nonRetiredType3.getRetired(), false);
    PatientIdentifierType retiredType = dao.getPatientIdentifierType(4);
    Assert.assertEquals(retiredType.getRetired(), true);
    List<PatientIdentifierType> patientIdentifierTypes = dao.getPatientIdentifierTypes(null, null, null, null);
    Assert.assertEquals(patientIdentifierTypes.size(), 3);
    Assert.assertTrue(patientIdentifierTypes.contains(nonRetiredType1));
    Assert.assertTrue(patientIdentifierTypes.contains(nonRetiredType2));
    Assert.assertTrue(patientIdentifierTypes.contains(nonRetiredType3));
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 55 with PatientIdentifierType

use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.

the class PatientDAOTest method getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypes_OrderedByRequiredFirst.

/**
 * @see PatientDAO#getPatientIdentifierTypes(String, String, Boolean, Boolean)
 */
@Test
public void getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypes_OrderedByRequiredFirst() {
    PatientIdentifierType nonRetiredNonRequiredType1 = dao.getPatientIdentifierType(1);
    PatientIdentifierType nonRetiredNonRequiredType2 = dao.getPatientIdentifierType(5);
    PatientIdentifierType nonRetiredRequiredType = dao.getPatientIdentifierType(2);
    nonRetiredRequiredType.setRequired(true);
    dao.savePatientIdentifierType(nonRetiredRequiredType);
    List<PatientIdentifierType> patientIdentifierTypes = dao.getPatientIdentifierTypes(null, null, null, null);
    Assert.assertArrayEquals(new Object[] { nonRetiredRequiredType, nonRetiredNonRequiredType1, nonRetiredNonRequiredType2 }, patientIdentifierTypes.toArray());
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

PatientIdentifierType (org.openmrs.PatientIdentifierType)131 Test (org.junit.Test)99 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)88 PatientIdentifier (org.openmrs.PatientIdentifier)56 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)53 Patient (org.openmrs.Patient)37 Location (org.openmrs.Location)29 ArrayList (java.util.ArrayList)20 BindException (org.springframework.validation.BindException)17 Errors (org.springframework.validation.Errors)14 Date (java.util.Date)13 PersonName (org.openmrs.PersonName)13 User (org.openmrs.User)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 Concept (org.openmrs.Concept)6 Person (org.openmrs.Person)5 HashMap (java.util.HashMap)4 PersonAddress (org.openmrs.PersonAddress)4 PatientServiceTest (org.openmrs.api.PatientServiceTest)4 HL7Exception (ca.uhn.hl7v2.HL7Exception)3