use of org.hl7.fhir.r5.model.ContactPoint in project openmrs-module-fhir2 by openmrs.
the class TelecomTranslatorImplTest method shouldTranslateWithCorrectProviderAttributeTypeForContactDetails.
@Test
public void shouldTranslateWithCorrectProviderAttributeTypeForContactDetails() {
ContactPoint contactPoint = new ContactPoint();
contactPoint.setId(CONTACT_POINT_ID);
contactPoint.setValue(CONTACT_POINT_VALUE);
ProviderAttributeType attributeType = new ProviderAttributeType();
attributeType.setName(PROVIDER_ATTRIBUTE_TYPE_NAME);
attributeType.setUuid(PROVIDER_ATTRIBUTE_TYPE_UUID);
when(globalPropertyService.getGlobalProperty(FhirConstants.PROVIDER_CONTACT_POINT_ATTRIBUTE_TYPE)).thenReturn(PROVIDER_ATTRIBUTE_TYPE_UUID);
when(providerService.getProviderAttributeTypeByUuid(PROVIDER_ATTRIBUTE_TYPE_UUID)).thenReturn(attributeType);
ProviderAttribute result = (ProviderAttribute) telecomTranslator.toOpenmrsType(new ProviderAttribute(), contactPoint);
assertThat(result, notNullValue());
assertThat(result.getAttributeType().getUuid(), equalTo(PROVIDER_ATTRIBUTE_TYPE_UUID));
}
use of org.hl7.fhir.r5.model.ContactPoint in project openmrs-module-fhir2 by openmrs.
the class TelecomTranslatorImplTest method shouldTranslateProviderAttributeUuidToFhirContactPointId.
@Test
public void shouldTranslateProviderAttributeUuidToFhirContactPointId() {
ProviderAttribute providerAttribute = new ProviderAttribute();
providerAttribute.setUuid(PROVIDER_ATTRIBUTE_UUID);
providerAttribute.setValue(PROVIDER_ATTRIBUTE_VALUE);
ContactPoint contactPoint = telecomTranslator.toFhirResource(providerAttribute);
assertThat(contactPoint, notNullValue());
assertThat(contactPoint.getId(), equalTo(PROVIDER_ATTRIBUTE_UUID));
}
use of org.hl7.fhir.r5.model.ContactPoint 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;
}
use of org.hl7.fhir.r5.model.ContactPoint 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 org.hl7.fhir.r5.model.ContactPoint 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;
}
Aggregations