use of org.hl7.fhir.r4b.model.ContactPoint in project openmrs-module-fhir2 by openmrs.
the class LocationTranslatorImpl method toOpenmrsType.
/**
* @see org.openmrs.module.fhir2.api.translators.LocationTranslator#toOpenmrsType(org.openmrs.Location,
* org.hl7.fhir.r4.model.Location)
*/
@Override
public org.openmrs.Location toOpenmrsType(@Nonnull org.openmrs.Location openmrsLocation, @Nonnull Location fhirLocation) {
notNull(openmrsLocation, "The existing Openmrs location should not be null");
notNull(fhirLocation, "The Location object should not be null");
openmrsLocation.setUuid(fhirLocation.getIdElement().getIdPart());
openmrsLocation.setName(fhirLocation.getName());
openmrsLocation.setDescription(fhirLocation.getDescription());
if (fhirLocation.getAddress() != null) {
openmrsLocation.setCityVillage(fhirLocation.getAddress().getCity());
openmrsLocation.setStateProvince(fhirLocation.getAddress().getState());
openmrsLocation.setCountry(fhirLocation.getAddress().getCountry());
openmrsLocation.setPostalCode(fhirLocation.getAddress().getPostalCode());
}
if (fhirLocation.getPosition().hasLatitude()) {
openmrsLocation.setLatitude(fhirLocation.getPosition().getLatitude().toString());
}
if (fhirLocation.getPosition().hasLongitude()) {
openmrsLocation.setLongitude(fhirLocation.getPosition().getLongitude().toString());
}
fhirLocation.getTelecom().stream().map(contactPoint -> (LocationAttribute) telecomTranslator.toOpenmrsType(new LocationAttribute(), contactPoint)).distinct().filter(Objects::nonNull).forEach(openmrsLocation::addAttribute);
if (fhirLocation.getMeta().hasTag()) {
for (Coding tag : fhirLocation.getMeta().getTag()) {
openmrsLocation.addTag(locationTagTranslator.toOpenmrsType(tag));
}
}
openmrsLocation.setParentLocation(getOpenmrsParentLocation(fhirLocation.getPartOf()));
return openmrsLocation;
}
use of org.hl7.fhir.r4b.model.ContactPoint 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 org.hl7.fhir.r4b.model.ContactPoint in project integration-adaptor-111 by nhsconnect.
the class RelatedPersonMapperTest method shouldCreateRelatedPersonWhenPatientHasEcTelecom.
@Test
public void shouldCreateRelatedPersonWhenPatientHasEcTelecom() {
TEL[] telecomArray = createTelecomArray();
telecomArray[0].setUse(Collections.singletonList("EC"));
when(clinicalDocumentDocument.getRecordTargetArray(0)).thenReturn(recordTarget);
when(recordTarget.getPatientRole()).thenReturn(patientRole);
when(patientRole.getTelecomArray()).thenReturn(telecomArray);
when(contactPoint.getValue()).thenReturn(TELECOM_VALUE);
when(contactPointMapper.mapContactPoint(ArgumentMatchers.any())).thenReturn(contactPoint);
RelatedPerson relatedPerson = relatedPersonMapper.createEmergencyContactRelatedPerson(clinicalDocumentDocument, encounter);
assertThat(relatedPerson.hasRelationship()).isTrue();
assertThat(relatedPerson.getRelationship().getCoding().size()).isEqualTo(1);
assertThat(relatedPerson.getRelationship().getCodingFirstRep().getCode()).isEqualTo("C");
assertThat(relatedPerson.getRelationship().getCodingFirstRep().getDisplay()).isEqualTo("Emergency Contact");
assertThat(relatedPerson.getTelecom().get(0).getValue()).isEqualTo(TELECOM_VALUE);
}
use of org.hl7.fhir.r4b.model.ContactPoint in project integration-adaptor-111 by nhsconnect.
the class OrganizationMapperTest method mockItkOrganization.
private POCDMT000002UK01Organization mockItkOrganization() {
POCDMT000002UK01Organization itkOrganization = mock(POCDMT000002UK01Organization.class);
AD itkAddress = mock(AD.class);
TEL itkTelecom = mock(TEL.class);
CE codeEntity = mock(CE.class);
II[] iiArray = new II[] { ii };
when(itkOrganization.getIdArray()).thenReturn(iiArray);
when(ii.isSetExtension()).thenReturn(true);
when(ii.getExtension()).thenReturn(ODS_CODE);
when(itkOrganization.sizeOfIdArray()).thenReturn(1);
when(itkOrganization.getAddrArray()).thenReturn(new AD[] { itkAddress });
when(itkOrganization.getTelecomArray()).thenReturn(new TEL[] { itkTelecom });
when(itkOrganization.isSetStandardIndustryClassCode()).thenReturn(true);
when(itkOrganization.getStandardIndustryClassCode()).thenReturn(codeEntity);
when(codeEntity.getDisplayName()).thenReturn(GP_PRACTICE);
when(contactPointMapper.mapContactPoint(any())).thenReturn(contactPoint);
when(addressMapper.mapAddress(any())).thenReturn(address);
when(nodeUtil.getNodeValueString(itkOrganization.getNameArray(0))).thenReturn(ORGANIZATION_NAME);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Organization organization = organizationMapper.mapOrganization(itkOrganization);
assertThat(organization.getName()).isEqualTo(ORGANIZATION_NAME);
assertThat(organization.getAddressFirstRep()).isEqualTo(address);
assertThat(organization.getTelecomFirstRep()).isEqualTo(contactPoint);
assertThat(organization.getTypeFirstRep().getText()).isEqualTo(GP_PRACTICE);
assertThat(organization.getIdentifierFirstRep().getValue()).isEqualTo(ODS_CODE);
assertThat(organization.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
return itkOrganization;
}
use of org.hl7.fhir.r4b.model.ContactPoint in project integration-adaptor-111 by nhsconnect.
the class PractitionerMapperTest method shouldMapPractitionerFromAssociatedEntity.
@Test
public void shouldMapPractitionerFromAssociatedEntity() {
POCDMT000002UK01AssociatedEntity associatedEntity = POCDMT000002UK01AssociatedEntity.Factory.newInstance();
associatedEntity.setAssociatedPerson(createPerson());
associatedEntity.setTelecomArray(createTelecomArray());
associatedEntity.setAddrArray(createAddrArray());
when(humanNameMapper.mapHumanName(ArgumentMatchers.any())).thenReturn(humanName);
when(contactPointMapper.mapContactPoint(ArgumentMatchers.any())).thenReturn(contactPoint);
when(addressMapper.mapAddress(ArgumentMatchers.any())).thenReturn(address);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Practitioner practitioner = practitionerMapper.mapPractitioner(associatedEntity);
assertThat(practitioner.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
assertThat(practitioner.getActive()).isEqualTo(true);
assertThat(practitioner.getNameFirstRep()).isEqualTo(humanName);
assertThat(practitioner.getTelecomFirstRep()).isEqualTo(contactPoint);
assertThat(practitioner.getAddressFirstRep()).isEqualTo(address);
}
Aggregations