Search in sources :

Example 6 with PersonName

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

the class PersonServiceTest method parsePersonName_shouldParseTwoPersonNameWithoutComma.

/**
 * @see PersonService#parsePersonName(String)
 */
@Test
public void parsePersonName_shouldParseTwoPersonNameWithoutComma() throws Exception {
    PersonName pname2 = Context.getPersonService().parsePersonName("John Doe");
    assertEquals("Doe", pname2.getFamilyName());
    assertEquals("John", pname2.getGivenName());
}
Also used : PersonName(org.openmrs.PersonName) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 7 with PersonName

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

the class PersonServiceTest method voidPersonName_shouldVoidPersonNameWithTheGivenReason.

/**
 * @see PersonService#voidPersonName(org.openmrs.PersonName, String)
 */
@Test
public void voidPersonName_shouldVoidPersonNameWithTheGivenReason() throws Exception {
    executeDataSet("org/openmrs/api/include/PersionServiceTest-voidUnvoidPersonName.xml");
    PersonName personName = Context.getPersonService().getPersonNameByUuid("5e6571cc-c7f2-41de-b289-f55f8fe79c6f");
    Assert.assertFalse(personName.getVoided());
    PersonName voidedPersonName = Context.getPersonService().voidPersonName(personName, "Test Voiding PersonName");
    assertTrue(voidedPersonName.getVoided());
    Assert.assertNotNull(voidedPersonName.getVoidedBy());
    Assert.assertNotNull(voidedPersonName.getDateVoided());
    Assert.assertEquals(voidedPersonName.getVoidReason(), "Test Voiding PersonName");
}
Also used : PersonName(org.openmrs.PersonName) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 8 with PersonName

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

the class PersonServiceTest method getPersonNameById_shouldFindObjectGivenValidId.

@Test
public void getPersonNameById_shouldFindObjectGivenValidId() throws Exception {
    PersonName personName = Context.getPersonService().getPersonName(2);
    Assert.assertEquals(2, (int) personName.getId());
}
Also used : PersonName(org.openmrs.PersonName) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 9 with PersonName

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

the class PersonServiceTest method parsePersonName_shouldNotFailWhenEndingWithWhitespace.

/**
 * @see PersonService#parsePersonName(String)
 */
@Test
public void parsePersonName_shouldNotFailWhenEndingWithWhitespace() throws Exception {
    PersonName pname = Context.getPersonService().parsePersonName("John ");
    assertEquals("John", pname.getGivenName());
}
Also used : PersonName(org.openmrs.PersonName) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 10 with PersonName

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

the class PersonServiceTest method savePerson_shouldSetThePreferredNameAndAddressIfNoneIsSpecified.

/**
 * @see PersonService#savePerson(Person)
 */
@Test
public void savePerson_shouldSetThePreferredNameAndAddressIfNoneIsSpecified() throws Exception {
    Person person = new Person();
    person.setGender("M");
    PersonName name = new PersonName("givenName", "middleName", "familyName");
    person.addName(name);
    PersonAddress address = new PersonAddress();
    address.setAddress1("some address");
    person.addAddress(address);
    personService.savePerson(person);
    assertTrue(name.getPreferred());
    assertTrue(address.getPreferred());
}
Also used : PersonName(org.openmrs.PersonName) PersonAddress(org.openmrs.PersonAddress) Person(org.openmrs.Person) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

PersonName (org.openmrs.PersonName)115 Test (org.junit.Test)86 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)57 Patient (org.openmrs.Patient)46 Person (org.openmrs.Person)41 Date (java.util.Date)29 PatientIdentifier (org.openmrs.PatientIdentifier)24 PersonAddress (org.openmrs.PersonAddress)20 User (org.openmrs.User)19 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)17 Location (org.openmrs.Location)13 PatientIdentifierType (org.openmrs.PatientIdentifierType)13 ArrayList (java.util.ArrayList)9 PihCoreContextSensitiveTest (org.openmrs.module.pihcore.PihCoreContextSensitiveTest)8 PersonMergeLog (org.openmrs.person.PersonMergeLog)8 PersonAttribute (org.openmrs.PersonAttribute)7 PatientAndMatchQuality (org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality)7 BindException (org.springframework.validation.BindException)7 Provider (org.openmrs.Provider)6 Errors (org.springframework.validation.Errors)6