use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.
the class PersonAddressTranslatorImpl method toFhirResource.
@Override
public Address toFhirResource(@Nonnull PersonAddress address) {
if (address == null || address.getVoided()) {
return null;
}
Address fhirAddress = new Address();
fhirAddress.setId(address.getUuid());
fhirAddress.setCity(address.getCityVillage());
fhirAddress.setState(address.getStateProvince());
fhirAddress.setCountry(address.getCountry());
fhirAddress.setPostalCode(address.getPostalCode());
// TODO is this the right mapping?
if (address.getPreferred() != null) {
if (address.getPreferred()) {
fhirAddress.setUse(Address.AddressUse.HOME);
} else {
fhirAddress.setUse(Address.AddressUse.OLD);
}
}
addAddressExtensions(fhirAddress, address);
return fhirAddress;
}
use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.
the class PersonTranslatorImpl method toOpenmrsType.
@Override
public Person toOpenmrsType(@Nonnull Person openmrsPerson, @Nonnull org.hl7.fhir.r4.model.Person person) {
notNull(openmrsPerson, "The existing Openmrs Person object should not be null");
notNull(person, "The Person object should not be null");
openmrsPerson.setUuid(person.getId());
for (HumanName name : person.getName()) {
openmrsPerson.addName(nameTranslator.toOpenmrsType(name));
}
if (person.hasGender()) {
openmrsPerson.setGender(genderTranslator.toOpenmrsType(person.getGender()));
}
if (person.hasBirthDateElement()) {
birthDateTranslator.toOpenmrsType(openmrsPerson, person.getBirthDateElement());
}
for (Address address : person.getAddress()) {
openmrsPerson.addAddress(addressTranslator.toOpenmrsType(address));
}
person.getTelecom().stream().map(contactPoint -> (PersonAttribute) telecomTranslator.toOpenmrsType(new PersonAttribute(), contactPoint)).distinct().filter(Objects::nonNull).forEach(openmrsPerson::addAttribute);
return openmrsPerson;
}
use of com.adobe.target.delivery.v1.model.Address in project openmrs-module-fhir2 by openmrs.
the class PractitionerTranslatorProviderImpl method toOpenmrsType.
@Override
public Provider toOpenmrsType(@Nonnull Provider existingProvider, @Nonnull Practitioner practitioner) {
if (existingProvider == null) {
return null;
}
if (practitioner == null) {
return null;
}
existingProvider.setUuid(practitioner.getId());
existingProvider.setIdentifier(practitioner.getIdentifierFirstRep().getValue());
if (existingProvider.getPerson() == null) {
existingProvider.setPerson(new Person());
}
if (practitioner.hasBirthDateElement()) {
birthDateTranslator.toOpenmrsType(existingProvider.getPerson(), practitioner.getBirthDateElement());
}
for (HumanName name : practitioner.getName()) {
existingProvider.getPerson().addName(nameTranslator.toOpenmrsType(name));
}
if (practitioner.hasGender()) {
existingProvider.getPerson().setGender(genderTranslator.toOpenmrsType(practitioner.getGender()));
}
for (Address address : practitioner.getAddress()) {
existingProvider.getPerson().addAddress(addressTranslator.toOpenmrsType(address));
}
practitioner.getTelecom().stream().map(contactPoint -> (ProviderAttribute) telecomTranslator.toOpenmrsType(new ProviderAttribute(), contactPoint)).filter(Objects::nonNull).forEach(existingProvider::addAttribute);
return existingProvider;
}
use of com.adobe.target.delivery.v1.model.Address in project Gravity-SDOH-Exchange-RI by FHIR.
the class PatientToDtoConverter method convert.
@Override
public PatientDto convert(PatientInfo patientInfo) {
Patient patient = patientInfo.getPatient();
PatientDto patientDto = new PatientDto();
patientDto.setId(patient.getIdElement().getIdPart());
patientDto.setName(patient.getNameFirstRep().getNameAsSingleString());
// Get Date of Birth and Age
if (patient.hasBirthDate()) {
LocalDate dob = FhirUtil.toLocalDate(patient.getBirthDateElement());
patientDto.setDob(dob);
patientDto.setAge(Period.between(dob, LocalDate.now(ZoneOffset.UTC)).getYears());
}
// Get gender
patientDto.setGender(ObjectUtils.defaultIfNull(patient.getGender(), Enumerations.AdministrativeGender.UNKNOWN).getDisplay());
// Get communication language
patientDto.setLanguage(patient.getCommunication().stream().filter(Patient.PatientCommunicationComponent::getPreferred).map(c -> c.getLanguage().getCodingFirstRep()).map(c -> c.getDisplay() != null ? c.getDisplay() : c.getCode()).filter(Objects::nonNull).findFirst().orElse(null));
// Get Address full String. No need to compose it on UI side.
patientDto.setAddress(patient.getAddress().stream().filter(a -> (patient.getAddress().size() == 1 && a.getUse() == null) || Address.AddressUse.HOME.equals(a.getUse())).map(this::convertAddress).findFirst().orElse(null));
List<ContactPoint> telecom = patient.getTelecom();
// Get phone numbers
patientDto.getPhones().addAll(telecom.stream().filter(t -> ContactPoint.ContactPointSystem.PHONE.equals(t.getSystem())).map(cp -> {
String display = cp.getUse() == null ? null : cp.getUse().getDisplay();
return new PhoneDto(display, cp.getValue());
}).collect(Collectors.toList()));
// Get email addreses
patientDto.getEmails().addAll(telecom.stream().filter(t -> ContactPoint.ContactPointSystem.EMAIL.equals(t.getSystem())).map(cp -> {
String display = cp.getUse() == null ? null : cp.getUse().getDisplay();
return new EmailDto(display, cp.getValue());
}).collect(Collectors.toList()));
if (patientInfo.getEmployment() != null) {
String employmentStatus = patientInfo.getEmployment().getValueCodeableConcept().getCodingFirstRep().getDisplay();
patientDto.setEmploymentStatus(employmentStatus);
}
if (patientInfo.getEducation() != null) {
String education = patientInfo.getEducation().getValueCodeableConcept().getCodingFirstRep().getDisplay();
patientDto.setEducation(education);
}
// Get race
Extension race = patient.getExtensionByUrl(UsCorePatientExtensions.RACE);
patientDto.setRace(convertExtension(race));
// Get ethnicity
Extension ethnicity = patient.getExtensionByUrl(UsCorePatientExtensions.ETHNICITY);
patientDto.setEthnicity(convertExtension(ethnicity));
// Get marital status
Coding ms = patient.getMaritalStatus().getCodingFirstRep();
patientDto.setMaritalStatus(Optional.ofNullable(ms.getDisplay()).orElse(Optional.ofNullable(ms.getCode()).orElse(null)));
patientDto.getInsurances().addAll(convertPayors(patientInfo.getPayors()));
return patientDto;
}
use of com.adobe.target.delivery.v1.model.Address in project integration-adaptor-111 by nhsconnect.
the class AddressMapperTest method shouldMapAddressType.
@Test
public void shouldMapAddressType() {
when(itkAddress.getUse()).thenReturn(ADDRESS_TYPE_LIST);
Address address = addressMapper.mapAddress(itkAddress);
assertThat(address.getType()).isEqualTo(AddressType.PHYSICAL);
}
Aggregations