Search in sources :

Example 11 with PersonName

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

the class PersonServiceTest method getPersonNameByUuid_shouldFindObjectGivenValidUuid.

/**
 * @see PersonService#getPersonNameByUuid(String)
 */
@Test
public void getPersonNameByUuid_shouldFindObjectGivenValidUuid() throws Exception {
    String uuid = "399e3a7b-6482-487d-94ce-c07bb3ca3cc7";
    PersonName personName = Context.getPersonService().getPersonNameByUuid(uuid);
    Assert.assertEquals(2, (int) personName.getPersonNameId());
}
Also used : PersonName(org.openmrs.PersonName) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 12 with PersonName

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

the class PersonServiceTest method parsePersonName_shouldParseFourPersonName.

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

Example 13 with PersonName

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

the class PersonServiceTest method getPersonNameById_shouldNotFindAnyObjectGivenInvalidId.

@Test
public void getPersonNameById_shouldNotFindAnyObjectGivenInvalidId() throws Exception {
    PersonName personName = Context.getPersonService().getPersonName(-1);
    Assert.assertNull(personName);
}
Also used : PersonName(org.openmrs.PersonName) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 14 with PersonName

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

the class PersonServiceTest method savePerson_shouldNotSetThePreferredNameAndAddressIfTheyAlreadyExist.

/**
 * @see PersonService#savePerson(Person)
 */
@Test
public void savePerson_shouldNotSetThePreferredNameAndAddressIfTheyAlreadyExist() throws Exception {
    Person person = new Person();
    person.setGender("M");
    PersonName name = new PersonName("givenName", "middleName", "familyName");
    PersonName preferredName = new PersonName("givenName", "middleName", "familyName");
    preferredName.setPreferred(true);
    person.addName(name);
    person.addName(preferredName);
    PersonAddress address = new PersonAddress();
    address.setAddress1("some address");
    PersonAddress preferredAddress = new PersonAddress();
    preferredAddress.setAddress1("another address");
    preferredAddress.setPreferred(true);
    person.addAddress(address);
    person.addAddress(preferredAddress);
    personService.savePerson(person);
    assertTrue(preferredName.getPreferred());
    assertTrue(preferredAddress.getPreferred());
    Assert.assertFalse(name.getPreferred());
    Assert.assertFalse(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)

Example 15 with PersonName

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

the class UserServiceTest method userWithValidPerson.

private User userWithValidPerson() {
    Person person = new Person();
    person.addName(new PersonName("jane", "sue", "doe"));
    person.setGender("F");
    return new User(person);
}
Also used : PersonName(org.openmrs.PersonName) User(org.openmrs.User) Person(org.openmrs.Person)

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