use of org.hl7.fhir.r4b.model.ContactPoint in project openmrs-module-fhir2 by openmrs.
the class TelecomTranslatorImpl method toFhirResource.
@Override
public ContactPoint toFhirResource(@Nonnull BaseOpenmrsData attribute) {
if (attribute == null || attribute.getVoided()) {
return null;
}
ContactPoint contactPoint = new ContactPoint();
if (attribute instanceof PersonAttribute) {
PersonAttribute personAttribute = (PersonAttribute) attribute;
contactPoint.setId(personAttribute.getUuid());
contactPoint.setValue(personAttribute.getValue());
} else if (attribute instanceof LocationAttribute) {
LocationAttribute locationAttribute = (LocationAttribute) attribute;
contactPoint.setId(locationAttribute.getUuid());
contactPoint.setValue(locationAttribute.getValue().toString());
} else if (attribute instanceof ProviderAttribute) {
ProviderAttribute providerAttribute = (ProviderAttribute) attribute;
contactPoint.setId(providerAttribute.getUuid());
contactPoint.setValue(providerAttribute.getValue().toString());
}
return contactPoint;
}
use of org.hl7.fhir.r4b.model.ContactPoint in project openmrs-module-fhir2 by openmrs.
the class PersonTranslatorImplTest method shouldTranslatePersonAttributeToFhirContactPoint.
@Test
public void shouldTranslatePersonAttributeToFhirContactPoint() {
ContactPoint contactPoint = new ContactPoint();
contactPoint.setId(CONTACT_ID);
contactPoint.setValue(CONTACT_VALUE);
PersonAttributeType attributeType = new PersonAttributeType();
attributeType.setName(PERSON_ATTRIBUTE_TYPE_NAME);
attributeType.setUuid(PERSON_ATTRIBUTE_TYPE_UUID);
PersonAttribute personAttribute = new PersonAttribute();
personAttribute.setUuid(PERSON_ATTRIBUTE_UUID);
personAttribute.setValue(PERSON_ATTRIBUTE_VALUE);
personAttribute.setAttributeType(attributeType);
Person person = new Person();
org.hl7.fhir.r4.model.Person result = personTranslator.toFhirResource(person);
assertThat(result, notNullValue());
assertThat(result.getTelecom(), notNullValue());
}
use of org.hl7.fhir.r4b.model.ContactPoint in project openmrs-module-fhir2 by openmrs.
the class LocationTranslatorImplTest method shouldTranslateFhirContactPointToLocationAttribute.
@Test
public void shouldTranslateFhirContactPointToLocationAttribute() {
LocationAttribute locationAttribute = new LocationAttribute();
locationAttribute.setUuid(LOCATION_ATTRIBUTE_UUID);
locationAttribute.setValue(LOCATION_ATTRIBUTE_VALUE);
LocationAttributeType attributeType = new LocationAttributeType();
attributeType.setName(LOCATION_ATTRIBUTE_TYPE_NAME);
attributeType.setUuid(LOCATION_ATTRIBUTE_TYPE_UUID);
locationAttribute.setAttributeType(attributeType);
org.hl7.fhir.r4.model.Location location = new org.hl7.fhir.r4.model.Location();
ContactPoint contactPoint = location.addTelecom();
contactPoint.setId(LOCATION_ATTRIBUTE_UUID);
contactPoint.setValue(LOCATION_ATTRIBUTE_VALUE);
when(telecomTranslator.toOpenmrsType(any(LocationAttribute.class), eq(contactPoint))).thenReturn(locationAttribute);
Location omrsLocation = locationTranslator.toOpenmrsType(location);
assertThat(omrsLocation, notNullValue());
assertThat(omrsLocation.getAttributes(), notNullValue());
assertThat(omrsLocation.getAttributes(), hasSize(greaterThanOrEqualTo(1)));
}
use of org.hl7.fhir.r4b.model.ContactPoint in project openmrs-module-fhir2 by openmrs.
the class LocationTranslatorImplTest method getLocationContactDetails_shouldWorkAsExpected.
@Test
public void getLocationContactDetails_shouldWorkAsExpected() {
Location omrsLocation = new Location();
omrsLocation.setUuid(LOCATION_UUID);
LocationAttribute locationAttribute = new LocationAttribute();
locationAttribute.setUuid(LOCATION_ATTRIBUTE_UUID);
locationAttribute.setValue(LOCATION_ATTRIBUTE_VALUE);
LocationAttributeType attributeType = new LocationAttributeType();
attributeType.setUuid(LOCATION_ATTRIBUTE_TYPE_UUID);
attributeType.setName(LOCATION_ATTRIBUTE_TYPE_NAME);
locationAttribute.setAttributeType(attributeType);
omrsLocation.setAttribute(locationAttribute);
List<ContactPoint> contactPoints = locationTranslator.getLocationContactDetails(omrsLocation);
assertThat(contactPoints, notNullValue());
assertThat(omrsLocation.getActiveAttributes().size(), equalTo(1));
}
use of org.hl7.fhir.r4b.model.ContactPoint in project openmrs-module-fhir2 by openmrs.
the class TelecomTranslatorImplTest method shouldUpdateProviderAttributeUuid.
@Test
public void shouldUpdateProviderAttributeUuid() {
ProviderAttribute providerAttribute = new ProviderAttribute();
providerAttribute.setUuid(PROVIDER_ATTRIBUTE_UUID);
ContactPoint contactPoint = new ContactPoint();
contactPoint.setId(NEW_PROVIDER_ATTRIBUTE_UUID);
ProviderAttribute result = (ProviderAttribute) telecomTranslator.toOpenmrsType(providerAttribute, contactPoint);
assertThat(result, notNullValue());
assertThat(result.getUuid(), notNullValue());
assertThat(result.getUuid(), equalTo(NEW_PROVIDER_ATTRIBUTE_UUID));
}
Aggregations