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));
}
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));
}
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();
}
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));
}
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));
}
Aggregations