本文整理汇总了Java中org.openmrs.Person.getNames方法的典型用法代码示例。如果您正苦于以下问题:Java Person.getNames方法的具体用法?Java Person.getNames怎么用?Java Person.getNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openmrs.Person
的用法示例。
在下文中一共展示了Person.getNames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PersonListItem
import org.openmrs.Person; //导入方法依赖的package包/类
/**
* Convenience constructor that creates a PersonListItem from the given Person. All relevant
* attributes are pulled off of the Person object and copied to this PersonListItem. And
* set the best match name based on the search criteria.
*
* @param person the Person to turn into a PersonListItem
* @param searchName Search query string of the name
* @should identify best matching name for the family name
* @should identify best matching name as preferred name even if other names match
* @should identify best matching name as other name for the middle name
* @should identify best matching name as other name for the given name
* @should identify best matching name in multiple search names
*/
public PersonListItem(Person person, String searchName) {
this(person);
if (person != null && !StringUtils.isBlank(searchName)) {
String[] searchNames = searchName.split(" ");
String fullName;
boolean foundABestMatch = false;
for (PersonName personName : person.getNames()) {
fullName = personName.getFullName();
if (!foundABestMatch && containsAll(fullName, searchNames)) {
familyName = personName.getFamilyName();
givenName = personName.getGivenName();
middleName = personName.getMiddleName();
foundABestMatch = true;
continue; // process the next name
}
if (!StringUtils.isBlank(otherNames)) {
otherNames += ",";
}
otherNames += " " + fullName;
}
}
}