Search in sources :

Example 81 with ContactPoint

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;
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) ProviderAttribute(org.openmrs.ProviderAttribute) LocationAttribute(org.openmrs.LocationAttribute) PersonAttribute(org.openmrs.PersonAttribute)

Example 82 with 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());
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) PersonAttributeType(org.openmrs.PersonAttributeType) Person(org.openmrs.Person) PersonAttribute(org.openmrs.PersonAttribute) Test(org.junit.Test)

Example 83 with ContactPoint

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)));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) LocationAttribute(org.openmrs.LocationAttribute) LocationAttributeType(org.openmrs.LocationAttributeType) Location(org.openmrs.Location) Test(org.junit.Test)

Example 84 with ContactPoint

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));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) LocationAttribute(org.openmrs.LocationAttribute) LocationAttributeType(org.openmrs.LocationAttributeType) Location(org.openmrs.Location) Test(org.junit.Test)

Example 85 with ContactPoint

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));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) ProviderAttribute(org.openmrs.ProviderAttribute) Test(org.junit.Test)

Aggregations

ContactPoint (org.hl7.fhir.r4.model.ContactPoint)56 Test (org.junit.Test)28 Address (org.hl7.fhir.r4.model.Address)18 Identifier (org.hl7.fhir.r4.model.Identifier)17 HumanName (org.hl7.fhir.r4.model.HumanName)16 PersonAttribute (org.openmrs.PersonAttribute)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)14 Test (org.junit.jupiter.api.Test)14 ArrayList (java.util.ArrayList)12 Organization (org.hl7.fhir.r4.model.Organization)12 ProviderAttribute (org.openmrs.ProviderAttribute)11 HashSet (java.util.HashSet)10 IdType (org.hl7.fhir.dstu3.model.IdType)9 Patient (org.hl7.fhir.r4.model.Patient)9 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)7 ContactDetail (org.hl7.fhir.r5.model.ContactDetail)6 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)6 HashMap (java.util.HashMap)5 Base64 (org.apache.commons.codec.binary.Base64)5