/** * @see org.openmrs.api.PersonService#getAllPersonAttributeTypes() */ @Override @Transactional(readOnly = true) public List<PersonAttributeType> getAllPersonAttributeTypes() throws APIException { return Context.getPersonService().getAllPersonAttributeTypes(true); }
/** * @see org.openmrs.api.PersonService#getPersonAttributeTypes(org.openmrs.util.OpenmrsConstants.PERSON_TYPE, * org.openmrs.api.PersonService.ATTR_VIEW_TYPE) */ @Override @Transactional(readOnly = true) public List<PersonAttributeType> getPersonAttributeTypes(PERSON_TYPE personType, ATTR_VIEW_TYPE viewType) throws APIException { if (viewType == null) { return Context.getPersonService().getAllPersonAttributeTypes(); } List<String> attrNames = getAttributeTypesFromGlobalProperties(viewType, personType); List<PersonAttributeType> result = new ArrayList<>(); for (String nameOrId : attrNames) { if (nameOrId.matches("\\d")) { result.add(getPersonAttributeType(Integer.valueOf(nameOrId))); } else { result.add(getPersonAttributeTypeByName(nameOrId)); } } return result; }
@Test public void getPersonAttributeTypes_shouldReturnAllPersonAttributeTypesWithViewTypeNull() { List<PersonAttributeType> expected = personService.getAllPersonAttributeTypes(); List<PersonAttributeType> result = personService.getPersonAttributeTypes(null, null); assertThat(result, containsInAnyOrder(expected.toArray())); }
List<PersonAttributeType> allTypes = Context.getPersonService().getAllPersonAttributeTypes(); if (!allTypes.isEmpty()) { type.setSortWeight(allTypes.get(allTypes.size() - 1).getSortWeight() + 1);
private List<PersonAttributeType> getAllPersonAttributeTypes() { return personService.getAllPersonAttributeTypes(false); }
/** * @see PersonService#getAllPersonAttributeTypes() */ @Test public void getAllPersonAttributeTypes_shouldReturnAllPersonAttributeTypesIncludingRetired() throws Exception { executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredPersonAttributeType.xml"); List<PersonAttributeType> attributeTypes = Context.getPersonService().getAllPersonAttributeTypes(); assertTrue("At least one element, otherwise no checking for retired will take place", attributeTypes.size() > 0); boolean foundRetired = false; for (PersonAttributeType personAttributeType : attributeTypes) { if (personAttributeType.getRetired()) { foundRetired = true; break; } } assertTrue("There should be at least one retired person attribute type found in the list", foundRetired); }
/** * @see PersonService#getAllPersonAttributeTypes(null) */ @Test public void getAllPersonAttributeTypes_shouldReturnAllPersonAttributeTypesExcludingRetiredWhenIncludeRetiredIsFalse() throws Exception { executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredPersonAttributeType.xml"); List<PersonAttributeType> attributeTypes = Context.getPersonService().getAllPersonAttributeTypes(false); assertTrue("At least one element, otherwise no checking for retired will take place", attributeTypes.size() > 0); boolean foundRetired = false; for (PersonAttributeType personAttributeType : attributeTypes) { if (personAttributeType.getRetired()) { foundRetired = true; break; } } Assert.assertFalse("There should be no retired person attribute type found in the list", foundRetired); }
coremetadatas.put("person_attribute_type", Context.getPersonService().getAllPersonAttributeTypes(true)); coremetadatas.put("encounter_type", Context.getEncounterService().getAllEncounterTypes(true)); coremetadatas.put("concept_datatype", Context.getConceptService().getAllConceptDatatypes(true));
/** * @see PersonService#getAllPersonAttributeTypes(null) */ @Test public void getAllPersonAttributeTypes_shouldReturnAllPersonAttributeTypesIncludingRetiredWhenIncludeRetiredIsTrue() throws Exception { executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredPersonAttributeType.xml"); //TODO: is this the correct way? or should we loop to find a retired type and then perform the following? List<PersonAttributeType> attributeTypes = Context.getPersonService().getAllPersonAttributeTypes(true); assertTrue("At least one element, otherwise no checking for retired will take place", attributeTypes.size() > 0); boolean foundRetired = false; for (PersonAttributeType personAttributeType : attributeTypes) { if (personAttributeType.getRetired()) { foundRetired = true; break; } } assertTrue("There should be at least one retired person attribute type found in the list", foundRetired); }
/** * Return all PersonAttributeTypes regardless of retired status * * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getAllCount() */ @Override public long getAllCount() { return service.getAllPersonAttributeTypes(false).size(); } }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<PersonAttributeType> doGetAll(RequestContext context) throws ResponseException { return new NeedsPaging<PersonAttributeType>(service().getAllPersonAttributeTypes(context.getIncludeAll()), context); }
velocityContext.put("htmlForm", form); velocityContext.put("identifierTypes", Context.getPatientService().getAllPatientIdentifierTypes(false)); velocityContext.put("personAttributeTypes", Context.getPersonService().getAllPersonAttributeTypes(false));
@Override public OpenMRSPerson addPerson(MRSPerson person) { if (!findByPersonId(person.getPersonId()).isEmpty()) { return updatePerson(person); } else { Person savedPerson = personService.savePerson(PersonHelper.createPerson(person, personService.getAllPersonAttributeTypes(false))); OpenMRSPerson returnedPerson = PersonHelper.openMRSToMRSPerson(savedPerson); eventRelay.sendEventMessage(new MotechEvent(EventKeys.CREATED_NEW_PERSON_SUBJECT, EventHelper.personParameters(returnedPerson))); return returnedPerson; } }
for (PersonAttributeType type : Context.getPersonService().getAllPersonAttributeTypes()) { if (type.getFormat() != null && type.getFormat().equals("java.lang.String")) { demo.addAttribute(new PersonAttribute(type, "Test " + type.getName() + " Attribute"));
@Override public OpenMRSPerson addPerson(String personId, String firstName, String lastName, DateTime dateOfBirth, String gender, String address, List<MRSAttribute> attributes) { OpenMRSPerson person = new OpenMRSPerson(); person.setFirstName(firstName); person.setLastName(lastName); person.setDateOfBirth(dateOfBirth); person.setGender(gender); person.setAddress(address); person.setAttributes(attributes); person.setPersonId(personId); if (!findByPersonId(person.getPersonId()).isEmpty()) { return updatePerson(person); } else { Person openMrsPerson = personService.savePerson(PersonHelper.createPerson(person, personService.getAllPersonAttributeTypes(false))); OpenMRSPerson returnedPerson = PersonHelper.openMRSToMRSPerson(openMrsPerson); eventRelay.sendEventMessage(new MotechEvent(EventKeys.CREATED_NEW_PERSON_SUBJECT, EventHelper.personParameters(returnedPerson))); return returnedPerson; } }