/** * @see java.lang.Object#toString() */ @Override public String toString() { //This should not be changed due to extensive usage in UI. return getFullName(); }
@Override public boolean matchesSafely(Set<PersonName> personNames) { for (PersonName personName : personNames) { if (personName.getFullName().equals(fullName)) { return true; } } return false; }
/** * @see org.openmrs.Attributable#getDisplayString() */ @Override public String getDisplayString() { String returnString = ""; if (getPersonName() != null) { returnString += getPersonName().getFullName() + " "; } returnString += "(" + getUsername() + ")"; return returnString; }
/** * @see org.openmrs.BaseOpenmrsMetadata#getName() * @should return person full name if person is not null or null otherwise */ @Override public String getName() { if (getPerson() != null && getPerson().getPersonName() != null) { return getPerson().getPersonName().getFullName(); } else { log.warn("We no longer support providers who are not linked to person. Set the name on the linked person"); return null; } } }
@Override public void execute() { Context.getAuthenticatedUser().getPersonName().getFullName(); } }
/** * @see PersonName#getFullName() */ @Test public void getFullName_shouldNotPutSpacesAroundAnEmptyMiddleName() { PersonName pn = new PersonName(); pn.setGivenName("Bob"); pn.setMiddleName(""); pn.setFamilyName("Jones"); Assert.assertEquals("Bob Jones", pn.getFullName()); }
preferred = patientService.getPatient(999); for (PersonName n : preferred.getNames()) { if (n.getFullName().equals(name.getFullName())) { addedNameUuid = n.getUuid();
/** * @see Provider#getName() */ @Test public void getName_shouldReturnPersonFullNameIfPersonIsNotNullOrNullOtherwise() { Provider provider = new Provider(); Person person = new Person(1); person.addName(new PersonName("givenName", "middleName", "familyName")); provider.setPerson(person); Assert.assertEquals(person.getPersonName().getFullName(), provider.getName()); }
errors.rejectValue("person.voided", "error.null"); if (person.getPersonName() == null || StringUtils.isEmpty(person.getPersonName().getFullName())) { errors.rejectValue("person", "Person.names.length");
public String getPatientPersonName() { return StringEscapeUtils.escapeHtml(patient.getPersonName().getFullName()); }
@Test public void getFullName_shouldNotReturnShortIfPersonNameFormatIsLong() { PersonName pn = new PersonName(); PersonName.setFormat(OpenmrsConstants.PERSON_NAME_FORMAT_LONG); pn.setPrefix("Sr."); pn.setGivenName("Taylor"); pn.setMiddleName("Bob"); pn.setFamilyNamePrefix("Wilson"); pn.setFamilyName("Mark"); pn.setFamilyName2("Jones"); pn.setFamilyNameSuffix("jr."); pn.setDegree("3"); Assert.assertEquals(pn.getFullName(), "Sr. Taylor Bob Wilson Mark Jones jr. 3"); }
@Test public void getFullName_shouldReturnShortIfPersonNameFormatIsNull() { PersonName pn = new PersonName(); PersonName.setFormat(OpenmrsConstants.PERSON_NAME_FORMAT_LONG); pn.setPrefix("Sr."); pn.setGivenName("Taylor"); pn.setMiddleName("Bob"); pn.setFamilyNamePrefix("Wilson"); pn.setFamilyName("Mark"); pn.setFamilyName2("Jones"); pn.setFamilyNameSuffix("jr."); pn.setDegree("3"); PersonName.setFormat(""); Assert.assertEquals(pn.getFullName(), "Sr. Taylor Bob Mark"); }
@Override public String getDisplayString(PersonName personName) { try { NameTemplate nameTemplate = NameSupport.getInstance().getDefaultLayoutTemplate(); if (nameTemplate != null) { // need to use reflection since the format method was not added until later versions of openmrs Method format = NameTemplate.class.getDeclaredMethod("format", PersonName.class); return (String) format.invoke(nameTemplate, personName); } } catch (Exception e) { // fall through to just returning full name if no format method found or format fails } // otherwise, just return full name return personName.getFullName(); } }
/** * @see PersonName#getFullName() */ @Test public void getFullName_shouldNotReturnLongIfPersonNameFormatIsShort() { PersonName pn = new PersonName(); PersonName.setFormat(OpenmrsConstants.PERSON_NAME_FORMAT_LONG); pn.setPrefix("Sr."); pn.setGivenName("Taylor"); pn.setMiddleName("Bob"); pn.setFamilyNamePrefix("Wilson"); pn.setFamilyName("Mark"); pn.setFamilyName2("Jones"); pn.setFamilyNameSuffix("jr."); pn.setDegree("3"); PersonName.setFormat(OpenmrsConstants.PERSON_NAME_FORMAT_SHORT); Assert.assertEquals(pn.getFullName(), "Sr. Taylor Bob Mark"); }
/** * Gets the display string for a person name. * * @param personName the person name object. * @return the display string. */ @PropertyGetter("display") public String getDisplayString(PersonName personName) { try { NameTemplate nameTemplate = NameSupport.getInstance().getDefaultLayoutTemplate(); if (nameTemplate != null) { // need to use reflection since the format method was not added until later versions of openmrs Method format = NameTemplate.class.getDeclaredMethod("format", PersonName.class); return (String) format.invoke(nameTemplate, personName); } } catch (Exception e) { // fall through to just returning full name if no format method found or format fails } // otherwise, just return full name return personName.getFullName(); } }
/** * @param person * @return fullname (for concise display purposes) */ @PropertyGetter("display") public String getDisplayString(Person person) { // TODO copy what is done in PatientResource to use configured name layout if (person.getPersonName() == null) return ""; return person.getPersonName().getFullName(); }
+ (provider == null ? "" : JavaScriptUtils.javaScriptEscape(provider.getPersonName().getFullName())) + "\");\n"); sb.append("$j('#" + widgetFieldName + "_hid" + "').val(\"" + (provider == null ? "" : JavaScriptUtils.javaScriptEscape(provider.getId().toString())) + "\");\n");
/** * @param patient * @return identifier + name (for concise display purposes) */ @PropertyGetter("display") public String getDisplayString(Patient patient) { if (patient.getPatientIdentifier() == null) return ""; return patient.getPatientIdentifier().getIdentifier() + " - " + patient.getPersonName().getFullName(); }
/** * @param member the patient * @return string that contains cohort member's identifier and full name */ @PropertyGetter("display") public String getDisplayString(CohortMember1_8 member) { if (member.getPatient().getPatientIdentifier() == null) return ""; return member.getPatient().getPatientIdentifier().getIdentifier() + " - " + member.getPatient().getPersonName().getFullName(); } }
@Test public void shouldCreateAPerson() throws Exception { long originalCount = service.getPeople("", false).size(); String json = "{ \"names\": [{ \"givenName\":\"Helen\", \"familyName\":\"of Troy\" }, " + "{\"givenName\":\"Leda\", \"familyName\":\"Nemesis\"} ], " + "\"birthdate\":\"2003-01-01\", \"gender\":\"F\" }"; SimpleObject newPerson = deserialize(handle(newPostRequest(getURI(), json))); String uuid = PropertyUtils.getProperty(newPerson, "uuid").toString(); Person person = Context.getPersonService().getPersonByUuid(uuid); assertEquals(2, person.getNames().size()); assertEquals("Helen of Troy", person.getPersonName().getFullName()); assertEquals(++originalCount, service.getPeople("", false).size()); }