use of org.hl7.fhir.r4.model.HumanName in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorUserImplTest method shouldTranslateUserGenderToFhirPractitionerType.
@Test
public void shouldTranslateUserGenderToFhirPractitionerType() {
Person person = new Person();
PersonName name = new PersonName();
name.setGivenName(GIVEN_NAME);
name.setFamilyName(FAMILY_NAME);
person.addName(name);
user.setPerson(person);
HumanName humanName = new HumanName();
humanName.setFamily(FAMILY_NAME);
humanName.addGiven(GIVEN_NAME);
when(nameTranslator.toFhirResource(name)).thenReturn(humanName);
Practitioner practitioner = practitionerTranslatorUser.toFhirResource(user);
assertThat(practitioner, notNullValue());
assertThat(practitioner.getName(), notNullValue());
assertThat(practitioner.getName(), not(empty()));
assertThat(practitioner.getName().get(0).getGiven().get(0).getValue(), equalTo(GIVEN_NAME));
assertThat(practitioner.getName().get(0).getFamily(), equalTo(FAMILY_NAME));
}
use of org.hl7.fhir.r4.model.HumanName in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonTranslatorImplTest method shouldTranslateRelationshipPersonAToFhirRelatedPersonName.
@Test
public void shouldTranslateRelationshipPersonAToFhirRelatedPersonName() {
HumanName humanName = new HumanName();
humanName.addGiven(PERSON_GIVEN_NAME);
humanName.setFamily(PERSON_FAMILY_NAME);
when(nameTranslator.toFhirResource(argThat(allOf(hasProperty("givenName", equalTo(PERSON_GIVEN_NAME)), hasProperty("familyName", equalTo(PERSON_FAMILY_NAME)))))).thenReturn(humanName);
PersonName name = new PersonName();
name.setGivenName(PERSON_GIVEN_NAME);
name.setFamilyName(PERSON_FAMILY_NAME);
personA.addName(name);
relationship.setPersonA(personA);
org.hl7.fhir.r4.model.RelatedPerson result = relatedPersonTranslator.toFhirResource(relationship);
assertThat(result.getName(), not(empty()));
assertThat(result.getName().get(0), notNullValue());
assertThat(result.getName().get(0).getGivenAsSingleString(), equalTo(PERSON_GIVEN_NAME));
assertThat(result.getName().get(0).getFamily(), equalTo(PERSON_FAMILY_NAME));
}
use of org.hl7.fhir.r4.model.HumanName in project openmrs-module-fhir2 by openmrs.
the class PersonNameTranslatorImplTest method shouldConvertHumanNameToPersonName.
@Test
public void shouldConvertHumanNameToPersonName() {
HumanName name = new HumanName();
name.setId(PERSON_NAME_UUID);
PersonName result = personNameTranslator.toOpenmrsType(name);
assertThat(result, notNullValue());
assertThat(result.getUuid(), equalTo(PERSON_NAME_UUID));
}
use of org.hl7.fhir.r4.model.HumanName in project openmrs-module-fhir2 by openmrs.
the class PersonNameTranslatorImplTest method shouldConvertGivenNameToGivenName.
@Test
public void shouldConvertGivenNameToGivenName() {
PersonName name = new PersonName();
name.setGivenName(PERSON_GIVEN_NAME);
HumanName result = personNameTranslator.toFhirResource(name);
assertThat(result.getGiven(), notNullValue());
assertThat(result.getGiven(), not(empty()));
assertThat(result.getGiven().get(0).getValue(), equalTo(PERSON_GIVEN_NAME));
}
use of org.hl7.fhir.r4.model.HumanName in project openmrs-module-fhir2 by openmrs.
the class PersonNameTranslatorImplTest method shouldConvertExtensionToFamilyNameSuffix.
@Test
public void shouldConvertExtensionToFamilyNameSuffix() {
HumanName name = new HumanName();
Extension nameExtension = name.addExtension();
nameExtension.setUrl(FhirConstants.OPENMRS_FHIR_EXT_NAME);
nameExtension.addExtension(FhirConstants.OPENMRS_FHIR_EXT_NAME + "#familyNameSuffix", new StringType(PERSON_MIDDLE_NAME));
assertThat(personNameTranslator.toOpenmrsType(name).getFamilyNameSuffix(), equalTo(PERSON_MIDDLE_NAME));
}
Aggregations