use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method checkPatientIdentifiers_shouldThrowErrorGivenPatientIdentifierIsInvalid.
/**
* @see PatientService#checkPatientIdentifiers(Patient)
*/
@Test
public void checkPatientIdentifiers_shouldThrowErrorGivenPatientIdentifierIsInvalid() throws Exception {
// given
Patient patient = new Patient();
PatientIdentifier nonBlankIdentifierWithoutLocation = new PatientIdentifier();
nonBlankIdentifierWithoutLocation.setVoided(false);
nonBlankIdentifierWithoutLocation.setLocation(null);
nonBlankIdentifierWithoutLocation.setIdentifier("an identifier");
nonBlankIdentifierWithoutLocation.setIdentifierType(new PatientIdentifierType(21345));
nonBlankIdentifierWithoutLocation.setIdentifierType(Context.getPatientService().getAllPatientIdentifierTypes(false).get(0));
patient.addIdentifier(nonBlankIdentifierWithoutLocation);
assertEquals(1, patient.getIdentifiers().size());
try {
// when
Context.getPatientService().checkPatientIdentifiers(patient);
// then
fail("should throw PatientIdentifierException");
} catch (BlankIdentifierException e) {
fail("should not throw BlankIdentifierException");
} catch (PatientIdentifierException e) {
assertEquals(1, patient.getIdentifiers().size());
}
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method isIdentifierInUseByAnotherPatient_shouldReturnTrueWhenPatientIdentifierContainsAPatientAndAnotherPatientHasThisId.
/**
* @see PatientService#isIdentifierInUseByAnotherPatient(PatientIdentifier)
*/
@Test
public void isIdentifierInUseByAnotherPatient_shouldReturnTrueWhenPatientIdentifierContainsAPatientAndAnotherPatientHasThisId() throws Exception {
PatientIdentifierType pit = patientService.getPatientIdentifierType(1);
PatientIdentifier patientIdentifier = new PatientIdentifier("7TU-8", pit, null);
patientIdentifier.setPatient(patientService.getPatient(2));
Assert.assertTrue(patientService.isIdentifierInUseByAnotherPatient(patientIdentifier));
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientServiceTest method retirePatientIdentifierType_shouldThrowErrorWhenTryingToRetireAPatientIdentifierTypeWhilePatientIdentifierTypesAreLocked.
@Test(expected = PatientIdentifierTypeLockedException.class)
public void retirePatientIdentifierType_shouldThrowErrorWhenTryingToRetireAPatientIdentifierTypeWhilePatientIdentifierTypesAreLocked() throws Exception {
PatientService ps = Context.getPatientService();
createPatientIdentifierTypeLockedGPAndSetValue("true");
PatientIdentifierType pit = ps.getPatientIdentifierType(1);
ps.retirePatientIdentifierType(pit, "Retire test");
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientDAOTest method getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypes_OrderedByRequiredAndName.
/**
* @see PatientDAO#getPatientIdentifierTypes(String, String, Boolean, Boolean)
*/
@Test
public void getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypes_OrderedByRequiredAndName() {
PatientIdentifierType openMRSIdNumber = dao.getPatientIdentifierType(1);
PatientIdentifierType oldIdNumber = dao.getPatientIdentifierType(2);
oldIdNumber.setRequired(true);
dao.savePatientIdentifierType(oldIdNumber);
PatientIdentifierType nationalIdNo = dao.getPatientIdentifierType(5);
oldIdNumber.setRequired(true);
dao.savePatientIdentifierType(nationalIdNo);
PatientIdentifierType socialSecNumber = dao.getPatientIdentifierType(4);
socialSecNumber.setName("ASecurityNumber");
socialSecNumber.setRequired(true);
socialSecNumber.setRetired(false);
dao.savePatientIdentifierType(socialSecNumber);
List<PatientIdentifierType> patientIdentifierTypes = dao.getPatientIdentifierTypes(null, null, null, null);
Assert.assertArrayEquals(new Object[] { socialSecNumber, oldIdNumber, openMRSIdNumber, nationalIdNo }, patientIdentifierTypes.toArray());
}
use of org.openmrs.PatientIdentifierType in project openmrs-core by openmrs.
the class PatientDAOTest method getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypes_OrderedByRequiredNameAndTypeId.
/**
* @see PatientDAO#getPatientIdentifierTypes(String, String, Boolean, Boolean)
*/
@Test
public void getPatientIdentifierTypes_shouldReturnNonRetiredPatientIdentifierTypes_OrderedByRequiredNameAndTypeId() {
PatientIdentifierType openMRSIdNumber = dao.getPatientIdentifierType(1);
openMRSIdNumber.setName("IdNumber");
openMRSIdNumber.setRequired(true);
dao.savePatientIdentifierType(openMRSIdNumber);
PatientIdentifierType oldIdNumber = dao.getPatientIdentifierType(2);
oldIdNumber.setName("IdNumber");
oldIdNumber.setRequired(true);
dao.savePatientIdentifierType(oldIdNumber);
PatientIdentifierType socialSecNumber = dao.getPatientIdentifierType(4);
socialSecNumber.setRequired(true);
socialSecNumber.setRetired(false);
dao.savePatientIdentifierType(socialSecNumber);
PatientIdentifierType nationalIdNo = dao.getPatientIdentifierType(5);
oldIdNumber.setName("IdNumber");
oldIdNumber.setRequired(true);
dao.savePatientIdentifierType(nationalIdNo);
List<PatientIdentifierType> patientIdentifierTypes = dao.getPatientIdentifierTypes(null, null, null, null);
Assert.assertArrayEquals(new Object[] { openMRSIdNumber, oldIdNumber, socialSecNumber, nationalIdNo }, patientIdentifierTypes.toArray());
}
Aggregations