Search in sources :

Example 1 with PersonAttributeType

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

the class PersonServiceTest method getPersonAttributeTypes_shouldReturnUserAndPatientAttributesWhenViewTypeListiningAndPerson.

@Test
public void getPersonAttributeTypes_shouldReturnUserAndPatientAttributesWhenViewTypeListiningAndPerson() {
    adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_LISTING_ATTRIBUTES, "1");
    adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_USER_LISTING_ATTRIBUTES, "2");
    PersonAttributeType race = personService.getPersonAttributeType(1);
    PersonAttributeType birthplace = personService.getPersonAttributeType(2);
    List<PersonAttributeType> result = personService.getPersonAttributeTypes(OpenmrsConstants.PERSON_TYPE.PERSON, PersonService.ATTR_VIEW_TYPE.LISTING);
    assertThat(result, contains(race, birthplace));
    assertEquals(result.size(), 2);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 2 with PersonAttributeType

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

the class PersonServiceTest method savePersonAttributeType_shouldUpdateAnyGlobalPropertyWhichReferenceThisType.

/**
 * @see PersonService#savePersonAttributeType(PersonAttributeType)
 */
@Test
public void savePersonAttributeType_shouldUpdateAnyGlobalPropertyWhichReferenceThisType() throws Exception {
    executeDataSet("org/openmrs/api/include/PersonServiceTest-updatePersonAttributeType.xml");
    PersonService service = Context.getPersonService();
    AdministrationService as = Context.getAdministrationService();
    // get the type and change its name
    PersonAttributeType pat = service.getPersonAttributeType(1);
    assertEquals("Race", pat.getName());
    String patientHeader = as.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_HEADER_ATTRIBUTES);
    assertEquals("Race,Birthpalce", patientHeader);
    String patientListing = as.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_LISTING_ATTRIBUTES);
    assertEquals("Race,Birthpalce", patientListing);
    String patientViewing = as.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_VIEWING_ATTRIBUTES);
    assertEquals("Birthpalce", patientViewing);
    pat.setName("Race Updated");
    pat = service.savePersonAttributeType(pat);
    assertEquals("Race Updated", pat.getName());
    patientHeader = as.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_HEADER_ATTRIBUTES);
    assertEquals("Race Updated,Birthpalce", patientHeader);
    patientListing = as.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_LISTING_ATTRIBUTES);
    assertEquals("Race Updated,Birthpalce", patientListing);
    patientViewing = as.getGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_VIEWING_ATTRIBUTES);
    assertEquals("Birthpalce", patientViewing);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 3 with PersonAttributeType

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

the class PersonServiceTest method getPersonAttributeTypeByName_shouldReturnNullWhenNoPersonAttributeTypeMatchGivenTypeName.

/**
 * @see PersonService#getPersonAttributeTypeByName(String)
 */
@Test
public void getPersonAttributeTypeByName_shouldReturnNullWhenNoPersonAttributeTypeMatchGivenTypeName() throws Exception {
    PersonAttributeType attributeType = Context.getPersonService().getPersonAttributeTypeByName("Credit Card");
    Assert.assertNull(attributeType);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 4 with PersonAttributeType

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

the class PersonServiceTest method getPersonAttributeTypes_shouldReturnPatientAttributesWhenGivenViewTypeListing.

@Test
public void getPersonAttributeTypes_shouldReturnPatientAttributesWhenGivenViewTypeListing() {
    adminService.setGlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_PATIENT_LISTING_ATTRIBUTES, "1");
    PersonAttributeType race = personService.getPersonAttributeType(1);
    List<PersonAttributeType> result = personService.getPersonAttributeTypes(null, PersonService.ATTR_VIEW_TYPE.LISTING);
    assertThat(result, contains(race));
    assertEquals(result.size(), 1);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 5 with PersonAttributeType

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

the class PersonServiceTest method getPersonAttributeTypeByName_shouldReturnPersonAttributeTypeWhenNameMatchesGivenTypeName.

/**
 * @see PersonService#getPersonAttributeTypeByName(String)
 */
@Test
public void getPersonAttributeTypeByName_shouldReturnPersonAttributeTypeWhenNameMatchesGivenTypeName() throws Exception {
    PersonAttributeType attributeType = Context.getPersonService().getPersonAttributeTypeByName("Birthplace");
    Assert.assertNotNull(attributeType);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

PersonAttributeType (org.openmrs.PersonAttributeType)38 Test (org.junit.Test)33 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)33 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 PersonAttribute (org.openmrs.PersonAttribute)3 ArrayList (java.util.ArrayList)2 Location (org.openmrs.Location)2 Patient (org.openmrs.Patient)2 PatientIdentifierType (org.openmrs.PatientIdentifierType)2 DLD (ca.uhn.hl7v2.model.v25.datatype.DLD)1 IS (ca.uhn.hl7v2.model.v25.datatype.IS)1 File (java.io.File)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 Random (java.util.Random)1 Ignore (org.junit.Ignore)1 GlobalProperty (org.openmrs.GlobalProperty)1 PatientIdentifier (org.openmrs.PatientIdentifier)1 PersonName (org.openmrs.PersonName)1