Search in sources :

Example 46 with PatientIdentifierType

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

the class PatientServiceTest method isIdentifierInUseByAnotherPatient_shouldReturnFalseWhenPatientIdentifierDoesNotContainAPatientAndNoPatientHasThisId.

/**
 * @see PatientService#isIdentifierInUseByAnotherPatient(PatientIdentifier)
 */
@Test
public void isIdentifierInUseByAnotherPatient_shouldReturnFalseWhenPatientIdentifierDoesNotContainAPatientAndNoPatientHasThisId() throws Exception {
    PatientIdentifierType pit = patientService.getPatientIdentifierType(1);
    PatientIdentifier patientIdentifier = new PatientIdentifier("Nobody could possibly have this identifier", pit, null);
    Assert.assertFalse(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 47 with PatientIdentifierType

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

the class PatientServiceTest method getPatientIdentifierType_shouldFetchPatientIdentifierWithGivenPatientIdentifierTypeId.

/**
 * @see PatientService#getPatientIdentifierType(Integer)
 */
@Test
public void getPatientIdentifierType_shouldFetchPatientIdentifierWithGivenPatientIdentifierTypeId() throws Exception {
    PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierType(1);
    Assert.assertNotNull(identifierType);
    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 48 with PatientIdentifierType

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

the class PatientServiceTest method savePatient_shouldNotThrowNonUniqueObjectExceptionWhenCalledWithPersonPromotedToPatient.

/**
 * https://tickets.openmrs.org/browse/TRUNK-3728
 *
 * @see PatientService#savePatient(Patient)
 */
@Test
public void savePatient_shouldNotThrowNonUniqueObjectExceptionWhenCalledWithPersonPromotedToPatient() throws Exception {
    Person person = personService.getPerson(1);
    Patient patient = patientService.getPatientOrPromotePerson(person.getPersonId());
    PatientIdentifier patientIdentifier = new PatientIdentifier("some identifier", new PatientIdentifierType(2), new Location(1));
    patientIdentifier.setPreferred(true);
    patient.addIdentifier(patientIdentifier);
    patientService.savePatient(patient);
}
Also used : Patient(org.openmrs.Patient) Person(org.openmrs.Person) PatientIdentifier(org.openmrs.PatientIdentifier) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 49 with PatientIdentifierType

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

the class PatientServiceTest method purgePatientIdentifierType_shouldThrowErrorWhenTryingToDeleteAPatientIdentifierTypeWhilePatientIdentifierTypesAreLocked.

@Test(expected = PatientIdentifierTypeLockedException.class)
public void purgePatientIdentifierType_shouldThrowErrorWhenTryingToDeleteAPatientIdentifierTypeWhilePatientIdentifierTypesAreLocked() throws Exception {
    PatientService ps = Context.getPatientService();
    createPatientIdentifierTypeLockedGPAndSetValue("true");
    PatientIdentifierType pit = ps.getPatientIdentifierType(1);
    ps.purgePatientIdentifierType(pit);
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 50 with PatientIdentifierType

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

the class PatientServiceTest method getPatientIdentifierTypeByUuid_shouldFindObjectGivenValidUuid.

/**
 * @see PatientService#getPatientIdentifierTypeByUuid(String)
 */
@Test
public void getPatientIdentifierTypeByUuid_shouldFindObjectGivenValidUuid() throws Exception {
    String uuid = "1a339fe9-38bc-4ab3-b180-320988c0b968";
    PatientIdentifierType patientIdentifierType = Context.getPatientService().getPatientIdentifierTypeByUuid(uuid);
    Assert.assertEquals(1, (int) patientIdentifierType.getPatientIdentifierTypeId());
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

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