Search in sources :

Example 31 with Address

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;
}
Also used : Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress)

Example 32 with Address

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;
}
Also used : Person(org.openmrs.Person) Setter(lombok.Setter) ProvenanceTranslator(org.openmrs.module.fhir2.api.translators.ProvenanceTranslator) PersonAttribute(org.openmrs.PersonAttribute) BirthDateTranslator(org.openmrs.module.fhir2.api.translators.BirthDateTranslator) Autowired(org.springframework.beans.factory.annotation.Autowired) PersonNameTranslator(org.openmrs.module.fhir2.api.translators.PersonNameTranslator) Objects(java.util.Objects) TelecomTranslator(org.openmrs.module.fhir2.api.translators.TelecomTranslator) Address(org.hl7.fhir.r4.model.Address) BaseOpenmrsData(org.openmrs.BaseOpenmrsData) FhirPatientDao(org.openmrs.module.fhir2.api.dao.FhirPatientDao) Component(org.springframework.stereotype.Component) AccessLevel(lombok.AccessLevel) GenderTranslator(org.openmrs.module.fhir2.api.translators.GenderTranslator) HumanName(org.hl7.fhir.r4.model.HumanName) PatientReferenceTranslator(org.openmrs.module.fhir2.api.translators.PatientReferenceTranslator) Validate.notNull(org.apache.commons.lang3.Validate.notNull) Nonnull(javax.annotation.Nonnull) PersonAddressTranslator(org.openmrs.module.fhir2.api.translators.PersonAddressTranslator) PersonTranslator(org.openmrs.module.fhir2.api.translators.PersonTranslator) PersonAddress(org.openmrs.PersonAddress) PersonName(org.openmrs.PersonName) HumanName(org.hl7.fhir.r4.model.HumanName) Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) PersonAttribute(org.openmrs.PersonAttribute)

Example 33 with Address

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;
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) ProviderAttribute(org.openmrs.ProviderAttribute) Person(org.openmrs.Person)

Example 34 with Address

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;
}
Also used : EmailDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.EmailDto) ArrayList(java.util.ArrayList) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Strings(com.google.common.base.Strings) Address(org.hl7.fhir.r4.model.Address) ObjectUtils(org.apache.commons.lang3.ObjectUtils) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) StringType(org.hl7.fhir.r4.model.StringType) PatientDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.PatientDto) ZoneOffset(java.time.ZoneOffset) PatientInfo(org.hl7.gravity.refimpl.sdohexchange.info.PatientInfo) Patient(org.hl7.fhir.r4.model.Patient) Converter(org.springframework.core.convert.converter.Converter) Period(java.time.Period) Enumerations(org.hl7.fhir.r4.model.Enumerations) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Organization(org.hl7.fhir.r4.model.Organization) List(java.util.List) UsCorePatientExtensions(org.hl7.gravity.refimpl.sdohexchange.fhir.UsCorePatientExtensions) PhoneDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.PhoneDto) Coding(org.hl7.fhir.r4.model.Coding) LocalDate(java.time.LocalDate) Optional(java.util.Optional) Extension(org.hl7.fhir.r4.model.Extension) FhirUtil(org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil) Extension(org.hl7.fhir.r4.model.Extension) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Coding(org.hl7.fhir.r4.model.Coding) Patient(org.hl7.fhir.r4.model.Patient) EmailDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.EmailDto) PhoneDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.PhoneDto) LocalDate(java.time.LocalDate) PatientDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.PatientDto)

Example 35 with Address

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);
}
Also used : Address(org.hl7.fhir.dstu3.model.Address) Test(org.junit.jupiter.api.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