Search in sources :

Example 21 with HumanName

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));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) PersonName(org.openmrs.PersonName) Person(org.openmrs.Person) Test(org.junit.Test)

Example 22 with HumanName

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));
}
Also used : RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) HumanName(org.hl7.fhir.r4.model.HumanName) PersonName(org.openmrs.PersonName) Test(org.junit.Test)

Example 23 with HumanName

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));
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) PersonName(org.openmrs.PersonName) Test(org.junit.Test)

Example 24 with HumanName

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));
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) PersonName(org.openmrs.PersonName) Test(org.junit.Test)

Example 25 with HumanName

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));
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) HumanName(org.hl7.fhir.r4.model.HumanName) StringType(org.hl7.fhir.r4.model.StringType) Test(org.junit.Test)

Aggregations

HumanName (org.hl7.fhir.r4.model.HumanName)84 HumanName (org.hl7.fhir.dstu3.model.HumanName)37 Patient (org.hl7.fhir.r4.model.Patient)37 Test (org.junit.jupiter.api.Test)29 ArrayList (java.util.ArrayList)27 Patient (org.hl7.fhir.dstu3.model.Patient)27 Test (org.junit.Test)26 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)23 Address (org.hl7.fhir.r4.model.Address)20 Identifier (org.hl7.fhir.r4.model.Identifier)20 PersonName (org.openmrs.PersonName)17 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 GET (javax.ws.rs.GET)15 Path (javax.ws.rs.Path)15 Produces (javax.ws.rs.Produces)15 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 StringType (org.hl7.fhir.r4.model.StringType)14 Date (java.util.Date)13