use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.
the class PersonAddressTranslatorImplTest method shouldConvertHomeAddressToPreferred.
@Test
public void shouldConvertHomeAddressToPreferred() {
Address address = new Address();
address.setUse(Address.AddressUse.HOME);
assertThat(addressTranslator.toOpenmrsType(address).getPreferred(), is(true));
}
use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.
the class PersonTranslatorImplTest method shouldTranslateFhirAddressToPersonAddress.
@Test
public void shouldTranslateFhirAddressToPersonAddress() {
PersonAddress personAddress = new PersonAddress();
personAddress.setUuid(ADDRESS_UUID);
personAddress.setCityVillage(ADDRESS_CITY);
org.hl7.fhir.r4.model.Person person = new org.hl7.fhir.r4.model.Person();
Address address = person.addAddress();
address.setId(ADDRESS_UUID);
address.setCity(ADDRESS_CITY);
when(addressTranslator.toOpenmrsType(address)).thenReturn(personAddress);
Person result = personTranslator.toOpenmrsType(person);
assertThat(result, notNullValue());
assertThat(result.getPersonAddress(), notNullValue());
assertThat(result.getPersonAddress().getUuid(), equalTo(ADDRESS_UUID));
assertThat(result.getPersonAddress().getCityVillage(), equalTo(ADDRESS_CITY));
}
use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.
the class PersonTranslatorImplTest method shouldTranslateOpenmrsAddressToFhirAddress.
@Test
public void shouldTranslateOpenmrsAddressToFhirAddress() {
Address address = new Address();
address.setId(ADDRESS_UUID);
address.setCity(ADDRESS_CITY);
when(addressTranslator.toFhirResource(argThat(allOf(hasProperty("uuid", equalTo(ADDRESS_UUID)), hasProperty("cityVillage", equalTo(ADDRESS_CITY)))))).thenReturn(address);
Person person = new Person();
PersonAddress personAddress = new PersonAddress();
personAddress.setUuid(ADDRESS_UUID);
personAddress.setCityVillage(ADDRESS_CITY);
person.addAddress(personAddress);
org.hl7.fhir.r4.model.Person result = personTranslator.toFhirResource(person);
assertThat(result.getAddress(), notNullValue());
assertThat(result.getAddress(), not(empty()));
assertThat(result.getAddress().get(0), equalTo(address));
}
use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.
the class LocationAddressTranslatorImpl method toFhirResource.
@Override
public Address toFhirResource(@Nonnull Location omrsLocation) {
Address address = null;
if (omrsLocation != null) {
address = new Address();
address.setId(null);
address.setCity(omrsLocation.getCityVillage());
address.setState(omrsLocation.getStateProvince());
address.setCountry(omrsLocation.getCountry());
address.setPostalCode(omrsLocation.getPostalCode());
addAddressExtensions(address, omrsLocation);
}
return address;
}
use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.
the class PatientTranslatorImpl method toOpenmrsType.
@Override
public org.openmrs.Patient toOpenmrsType(@Nonnull org.openmrs.Patient currentPatient, @Nonnull Patient patient) {
notNull(currentPatient, "The existing Openmrs Patient object should not be null");
notNull(patient, "The Patient object should not be null");
currentPatient.setUuid(patient.getId());
for (Identifier identifier : patient.getIdentifier()) {
PatientIdentifier omrsIdentifier = identifierTranslator.toOpenmrsType(identifier);
if (omrsIdentifier != null) {
currentPatient.addIdentifier(omrsIdentifier);
}
}
for (HumanName name : patient.getName()) {
currentPatient.addName(nameTranslator.toOpenmrsType(name));
}
if (patient.hasGender()) {
currentPatient.setGender(genderTranslator.toOpenmrsType(patient.getGender()));
}
if (patient.hasBirthDateElement()) {
birthDateTranslator.toOpenmrsType(currentPatient, patient.getBirthDateElement());
}
if (patient.hasDeceased()) {
try {
patient.getDeceasedBooleanType();
currentPatient.setDead(patient.getDeceasedBooleanType().booleanValue());
} catch (FHIRException ignored) {
}
try {
patient.getDeceasedDateTimeType();
currentPatient.setDead(true);
currentPatient.setDeathDate(patient.getDeceasedDateTimeType().getValue());
} catch (FHIRException ignored) {
}
}
for (Address address : patient.getAddress()) {
currentPatient.addAddress(addressTranslator.toOpenmrsType(address));
}
patient.getTelecom().stream().map(contactPoint -> (PersonAttribute) telecomTranslator.toOpenmrsType(new PersonAttribute(), contactPoint)).distinct().filter(Objects::nonNull).forEach(currentPatient::addAttribute);
return currentPatient;
}
Aggregations