use of org.hl7.fhir.r5.model.HumanName 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;
}
use of org.hl7.fhir.r5.model.HumanName in project openmrs-module-fhir2 by openmrs.
the class PractitionerFhirResourceProviderTest method initPractitioner.
@Before
public void initPractitioner() {
HumanName name = new HumanName();
name.addGiven(GIVEN_NAME);
name.setFamily(FAMILY_NAME);
Identifier theIdentifier = new Identifier();
theIdentifier.setValue(PRACTITIONER_IDENTIFIER);
practitioner = new Practitioner();
practitioner.setId(PRACTITIONER_UUID);
practitioner.addName(name);
practitioner.addIdentifier(theIdentifier);
setProvenanceResources(practitioner);
}
use of org.hl7.fhir.r5.model.HumanName in project openmrs-module-fhir2 by openmrs.
the class RelatedPersonFhirResourceProviderTest method initRelatedPerson.
@Before
public void initRelatedPerson() {
HumanName name = new HumanName();
name.addGiven(GIVEN_NAME);
name.setFamily(FAMILY_NAME);
relatedPerson = new RelatedPerson();
relatedPerson.setId(RELATED_PERSON_UUID);
relatedPerson.setGender(Enumerations.AdministrativeGender.MALE);
relatedPerson.addName(name);
setProvenanceResources(relatedPerson);
}
use of org.hl7.fhir.r5.model.HumanName in project integration-adaptor-111 by nhsconnect.
the class PractitionerMapperTest method shouldMapPractitionerFromAssociatedEntity.
@Test
public void shouldMapPractitionerFromAssociatedEntity() {
POCDMT000002UK01AssociatedEntity associatedEntity = POCDMT000002UK01AssociatedEntity.Factory.newInstance();
associatedEntity.setAssociatedPerson(createPerson());
associatedEntity.setTelecomArray(createTelecomArray());
associatedEntity.setAddrArray(createAddrArray());
when(humanNameMapper.mapHumanName(ArgumentMatchers.any())).thenReturn(humanName);
when(contactPointMapper.mapContactPoint(ArgumentMatchers.any())).thenReturn(contactPoint);
when(addressMapper.mapAddress(ArgumentMatchers.any())).thenReturn(address);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Practitioner practitioner = practitionerMapper.mapPractitioner(associatedEntity);
assertThat(practitioner.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
assertThat(practitioner.getActive()).isEqualTo(true);
assertThat(practitioner.getNameFirstRep()).isEqualTo(humanName);
assertThat(practitioner.getTelecomFirstRep()).isEqualTo(contactPoint);
assertThat(practitioner.getAddressFirstRep()).isEqualTo(address);
}
use of org.hl7.fhir.r5.model.HumanName in project integration-adaptor-111 by nhsconnect.
the class PractitionerMapperTest method shouldMapPractitionerFromAssignedEntity.
@Test
public void shouldMapPractitionerFromAssignedEntity() {
POCDMT000002UK01AssignedEntity assignedEntity = POCDMT000002UK01AssignedEntity.Factory.newInstance();
assignedEntity.setAssignedPerson(createPerson());
assignedEntity.setTelecomArray(createTelecomArray());
assignedEntity.setAddrArray(createAddrArray());
when(humanNameMapper.mapHumanName(ArgumentMatchers.any())).thenReturn(humanName);
when(contactPointMapper.mapContactPoint(ArgumentMatchers.any())).thenReturn(contactPoint);
when(addressMapper.mapAddress(ArgumentMatchers.any())).thenReturn(address);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Practitioner practitioner = practitionerMapper.mapPractitioner(assignedEntity);
assertThat(practitioner.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
assertThat(practitioner.getActive()).isEqualTo(true);
assertThat(practitioner.getNameFirstRep()).isEqualTo(humanName);
assertThat(practitioner.getTelecomFirstRep()).isEqualTo(contactPoint);
assertThat(practitioner.getAddressFirstRep()).isEqualTo(address);
}
Aggregations