Search in sources :

Example 16 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project openmrs-module-fhir2 by openmrs.

the class PractitionerTranslatorProviderImplTest method shouldTranslateFhirContactPointToPersonAttribute.

@Test
public void shouldTranslateFhirContactPointToPersonAttribute() {
    ProviderAttributeType attributeType = new ProviderAttributeType();
    attributeType.setName(PERSON_ATTRIBUTE_TYPE_NAME);
    attributeType.setUuid(PERSON_ATTRIBUTE_TYPE_UUID);
    ProviderAttribute providerAttribute = new ProviderAttribute();
    providerAttribute.setUuid(PERSON_ATTRIBUTE_UUID);
    providerAttribute.setValue(PERSON_ATTRIBUTE_VALUE);
    providerAttribute.setAttributeType(attributeType);
    ContactPoint contactPoint = new ContactPoint();
    contactPoint.setId(PERSON_ATTRIBUTE_UUID);
    contactPoint.setValue(PERSON_ATTRIBUTE_VALUE);
    practitioner.addTelecom(contactPoint);
    when(telecomTranslator.toOpenmrsType(any(), any())).thenReturn(providerAttribute);
    Provider provider = practitionerTranslator.toOpenmrsType(practitioner);
    assertThat(provider, notNullValue());
    assertThat(provider.getAttributes(), notNullValue());
    assertThat(provider.getAttributes().size(), greaterThanOrEqualTo(1));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) ProviderAttribute(org.openmrs.ProviderAttribute) ProviderAttributeType(org.openmrs.ProviderAttributeType) Provider(org.openmrs.Provider) Test(org.junit.Test)

Example 17 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project openmrs-module-fhir2 by openmrs.

the class TelecomTranslatorImplTest method shouldTranslateFhirContactPointValueToProviderAttributeValue.

@Test
public void shouldTranslateFhirContactPointValueToProviderAttributeValue() {
    ContactPoint contactPoint = new ContactPoint();
    contactPoint.setValue(CONTACT_POINT_VALUE);
    ProviderAttribute result = (ProviderAttribute) telecomTranslator.toOpenmrsType(new ProviderAttribute(), contactPoint);
    assertThat(result, notNullValue());
    assertThat(result.getValue(), equalTo(CONTACT_POINT_VALUE));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) ProviderAttribute(org.openmrs.ProviderAttribute) Test(org.junit.Test)

Example 18 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project openmrs-module-fhir2 by openmrs.

the class TelecomTranslatorImplTest method setUp.

@Before
public void setUp() {
    telecomTranslator = new TelecomTranslatorImpl();
    telecomTranslator.setPersonService(personService);
    telecomTranslator.setLocationService(locationService);
    telecomTranslator.setProviderService(providerService);
    telecomTranslator.setGlobalPropertyService(globalPropertyService);
    locationAttribute = new LocationAttribute();
    contactPoint = new ContactPoint();
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) LocationAttribute(org.openmrs.LocationAttribute) Before(org.junit.Before)

Example 19 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project openmrs-module-fhir2 by openmrs.

the class TelecomTranslatorImplTest method shouldUpdatePersonAttributeWithTheCorrectPersonAttributeTypeUuid.

@Test
public void shouldUpdatePersonAttributeWithTheCorrectPersonAttributeTypeUuid() {
    PersonAttribute personAttribute = new PersonAttribute();
    personAttribute.setUuid(PERSON_ATTRIBUTE_UUID);
    personAttribute.setValue(PERSON_ATTRIBUTE_VALUE);
    PersonAttributeType attributeType = new PersonAttributeType();
    attributeType.setName(ATTRIBUTE_TYPE_NAME);
    attributeType.setUuid(PERSON_ATTRIBUTE_TYPE_UUID);
    personAttribute.setAttributeType(attributeType);
    ContactPoint contactPoint = new ContactPoint();
    contactPoint.setId(NEW_PERSON_ATTRIBUTE_UUID);
    contactPoint.setValue(NEW_PERSON_ATTRIBUTE_VALUE);
    when(globalPropertyService.getGlobalProperty(FhirConstants.PERSON_CONTACT_POINT_ATTRIBUTE_TYPE)).thenReturn(PERSON_ATTRIBUTE_TYPE_UUID);
    when(personService.getPersonAttributeTypeByUuid(PERSON_ATTRIBUTE_TYPE_UUID)).thenReturn(attributeType);
    PersonAttribute result = (PersonAttribute) telecomTranslator.toOpenmrsType(personAttribute, contactPoint);
    assertThat(result, notNullValue());
    assertThat(result.getValue(), notNullValue());
    assertThat(result.getAttributeType().getUuid(), equalTo(PERSON_ATTRIBUTE_TYPE_UUID));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) PersonAttributeType(org.openmrs.PersonAttributeType) PersonAttribute(org.openmrs.PersonAttribute) Test(org.junit.Test)

Example 20 with ContactPoint

use of org.hl7.fhir.dstu2.model.ContactPoint in project openmrs-module-fhir2 by openmrs.

the class TelecomTranslatorImplTest method shouldTranslatePersonAttributeValueToFhirContactPointValue.

@Test
public void shouldTranslatePersonAttributeValueToFhirContactPointValue() {
    PersonAttribute personAttribute = new PersonAttribute();
    personAttribute.setValue(PERSON_ATTRIBUTE_VALUE);
    ContactPoint contactPoint = telecomTranslator.toFhirResource(personAttribute);
    assertThat(contactPoint, notNullValue());
    assertThat(contactPoint.getValue(), equalTo(PERSON_ATTRIBUTE_VALUE));
}
Also used : ContactPoint(org.hl7.fhir.r4.model.ContactPoint) PersonAttribute(org.openmrs.PersonAttribute) 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