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));
}
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));
}
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));
}
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));
}
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());
}
Aggregations