Search in sources :

Example 86 with Address

use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.

the class PersonAddressTranslatorImplTest method shouldConvertAddressToPersonAddress.

@Test
public void shouldConvertAddressToPersonAddress() {
    Address address = new Address();
    address.setId(PERSON_ADDRESS_UUID);
    PersonAddress result = addressTranslator.toOpenmrsType(address);
    assertThat(result, notNullValue());
    assertThat(result.getUuid(), equalTo(PERSON_ADDRESS_UUID));
}
Also used : Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) PersonAddress(org.openmrs.PersonAddress) Test(org.junit.Test)

Example 87 with Address

use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.

the class PersonAddressTranslatorImplTest method shouldConvertStateToStateProvince.

@Test
public void shouldConvertStateToStateProvince() {
    Address address = new Address();
    address.setState(PROVINCE);
    assertThat(addressTranslator.toOpenmrsType(address).getStateProvince(), equalTo(PROVINCE));
}
Also used : Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) Test(org.junit.Test)

Example 88 with Address

use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.

the class PractitionerTranslatorProviderImplTest method shouldTranslateProviderAddressToFhirPractitionerAddressType.

@Test
public void shouldTranslateProviderAddressToFhirPractitionerAddressType() {
    Person person = new Person();
    PersonAddress personAddress = new PersonAddress();
    personAddress.setCityVillage(CITY_VILLAGE);
    personAddress.setCountry(COUNTRY);
    person.addAddress(personAddress);
    provider.setPerson(person);
    Address fhirAddress = new Address();
    fhirAddress.setCity(CITY_VILLAGE);
    fhirAddress.setCountry(COUNTRY);
    when(addressTranslator.toFhirResource(personAddress)).thenReturn(fhirAddress);
    Practitioner practitioner = practitionerTranslator.toFhirResource(provider);
    assertThat(practitioner, notNullValue());
    assertThat(practitioner.getAddress(), not(empty()));
    assertThat(practitioner.getAddress().get(0).getCountry(), equalTo(COUNTRY));
    assertThat(practitioner.getAddress().get(0).getCity(), equalTo(CITY_VILLAGE));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) PersonAddress(org.openmrs.PersonAddress) Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) Person(org.openmrs.Person) Test(org.junit.Test)

Example 89 with Address

use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.

the class PractitionerTranslatorProviderImplTest method shouldTranslateFhirAddressToPersonAddress.

@Test
public void shouldTranslateFhirAddressToPersonAddress() {
    PersonAddress personAddress = new PersonAddress();
    personAddress.setUuid(ADDRESS_UUID);
    personAddress.setCityVillage(ADDRESS_CITY);
    org.hl7.fhir.r4.model.Practitioner practitioner = new org.hl7.fhir.r4.model.Practitioner();
    practitioner.addIdentifier(new Identifier().setValue("349023n23b-t"));
    Address address = practitioner.addAddress();
    address.setId(ADDRESS_UUID);
    address.setCity(ADDRESS_CITY);
    when(addressTranslator.toOpenmrsType(address)).thenReturn(personAddress);
    Provider result = practitionerTranslator.toOpenmrsType(practitioner);
    assertThat(result, notNullValue());
    assertThat(result.getPerson().getPersonAddress(), notNullValue());
    assertThat(result.getPerson().getPersonAddress().getUuid(), equalTo(ADDRESS_UUID));
    assertThat(result.getPerson().getPersonAddress().getCityVillage(), equalTo(ADDRESS_CITY));
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) Identifier(org.hl7.fhir.r4.model.Identifier) PersonAddress(org.openmrs.PersonAddress) Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) Practitioner(org.hl7.fhir.r4.model.Practitioner) Provider(org.openmrs.Provider) Test(org.junit.Test)

Example 90 with Address

use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.

the class PatientTranslatorImplTest method shouldTranslateFhirAddressToOpenMRSAddress.

@Test
public void shouldTranslateFhirAddressToOpenMRSAddress() {
    PersonAddress personAddress = new PersonAddress();
    personAddress.setUuid(ADDRESS_UUID);
    personAddress.setCityVillage(ADDRESS_CITY);
    when(addressTranslator.toOpenmrsType(argThat(hasProperty("id", equalTo(ADDRESS_UUID))))).thenReturn(personAddress);
    Patient patient = new Patient();
    Address address = new Address();
    address.setId(ADDRESS_UUID);
    address.setCity(ADDRESS_CITY);
    patient.addAddress(address);
    org.openmrs.Patient result = patientTranslator.toOpenmrsType(patient);
    assertThat(result.getAddresses(), not(empty()));
    assertThat(result.getAddresses(), hasItem(hasProperty("uuid", equalTo(ADDRESS_UUID))));
    assertThat(result.getAddresses(), hasItem(hasProperty("cityVillage", equalTo(ADDRESS_CITY))));
}
Also used : PersonAddress(org.openmrs.PersonAddress) Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.Test)

Aggregations

Address (org.hl7.fhir.r4.model.Address)75 Test (org.junit.Test)35 Address (org.hl7.fhir.dstu3.model.Address)22 PersonAddress (org.openmrs.PersonAddress)21 HumanName (org.hl7.fhir.r4.model.HumanName)20 Patient (org.hl7.fhir.r4.model.Patient)18 ArrayList (java.util.ArrayList)17 Identifier (org.hl7.fhir.r4.model.Identifier)17 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)16 Test (org.junit.jupiter.api.Test)13 Organization (org.hl7.fhir.r4.model.Organization)12 Address (com.amazonaws.services.ec2.model.Address)7 HumanName (org.hl7.fhir.dstu3.model.HumanName)7 PatientCommunicationComponent (org.hl7.fhir.r4.model.Patient.PatientCommunicationComponent)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 DescribeAddressesResult (com.amazonaws.services.ec2.model.DescribeAddressesResult)5 HashSet (java.util.HashSet)5 Coding (org.hl7.fhir.r4.model.Coding)5 StringType (org.hl7.fhir.r4.model.StringType)5 Before (org.junit.Before)5