Search in sources :

Example 21 with PatientIdentifierType

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

the class PatientServiceTest method getPatientIdentifierTypeByUuid_shouldReturnNullWhenPatientIdentifierTypeWithGivenUuidDoesNotExist.

/**
 * @see PatientService#getPatientIdentifierTypeByUuid(String)
 */
@Test
public void getPatientIdentifierTypeByUuid_shouldReturnNullWhenPatientIdentifierTypeWithGivenUuidDoesNotExist() throws Exception {
    PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierTypeByUuid("thisuuiddoesnotexist");
    Assert.assertNull(identifierType);
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 22 with PatientIdentifierType

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

the class PatientServiceTest method getPatientIdentifierTypes_shouldFetchRequiredPatientIdentifierTypesWhenGivenRequiredIsTrue.

/**
 * @see PatientService#getPatientIdentifierTypes(String,String,Boolean,Boolean)
 */
@Test
public void getPatientIdentifierTypes_shouldFetchRequiredPatientIdentifierTypesWhenGivenRequiredIsTrue() throws Exception {
    executeDataSet("org/openmrs/api/include/PatientServiceTest-createPatientIdentifierType.xml");
    List<PatientIdentifierType> patientIdentifierTypes = Context.getPatientService().getPatientIdentifierTypes(null, null, true, null);
    Assert.assertTrue(!patientIdentifierTypes.isEmpty());
    Assert.assertEquals(1, patientIdentifierTypes.size());
    for (PatientIdentifierType patientIdentifierType : patientIdentifierTypes) {
        Assert.assertTrue(patientIdentifierType.getRequired());
    }
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 23 with PatientIdentifierType

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

the class PatientServiceTest method retirePatientIdentifierType_shouldRetireAndSetReasonAndRetiredByAndDate.

@Test
public void retirePatientIdentifierType_shouldRetireAndSetReasonAndRetiredByAndDate() {
    PatientService ps = Context.getPatientService();
    PatientIdentifierType pit = ps.getPatientIdentifierType(1);
    String reason = "moved away";
    PatientIdentifierType result = ps.retirePatientIdentifierType(pit, reason);
    assertTrue(result.getRetired());
    assertEquals(result.getRetireReason(), reason);
    assertEquals(result.getRetiredBy(), Context.getAuthenticatedUser());
    Date today = new Date();
    Date dateRetired = result.getDateRetired();
    assertEquals(dateRetired.getDay(), today.getDay());
    assertEquals(dateRetired.getMonth(), today.getMonth());
    assertEquals(dateRetired.getYear(), today.getYear());
}
Also used : PatientIdentifierType(org.openmrs.PatientIdentifierType) Date(java.util.Date) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 24 with PatientIdentifierType

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

the class PatientServiceTest method unretirePatientIdentifierType_shouldThrowErrorWhenTryingToUnretireAPatientIdentifierTypeWhilePatientIdentifierTypesAreLocked.

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

Example 25 with PatientIdentifierType

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

the class PatientServiceTest method unretirePatientIdentifierType_shouldUnretirePatientIdentifierType.

/**
 * @see PatientService#unretirePatientIdentifierType(PatientIdentifierType)
 */
@Test
public void unretirePatientIdentifierType_shouldUnretirePatientIdentifierType() throws Exception {
    PatientIdentifierType identifierType = Context.getPatientService().getPatientIdentifierType(4);
    Assert.assertTrue(identifierType.getRetired());
    Assert.assertNotNull(identifierType.getRetiredBy());
    Assert.assertNotNull(identifierType.getRetireReason());
    Assert.assertNotNull(identifierType.getDateRetired());
    PatientIdentifierType unretiredIdentifierType = Context.getPatientService().unretirePatientIdentifierType(identifierType);
    Assert.assertFalse(unretiredIdentifierType.getRetired());
    Assert.assertNull(unretiredIdentifierType.getRetiredBy());
    Assert.assertNull(unretiredIdentifierType.getRetireReason());
    Assert.assertNull(unretiredIdentifierType.getDateRetired());
}
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