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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations