Search in sources :

Example 31 with HumanName

use of org.hl7.fhir.dstu2.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;
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) Address(org.hl7.fhir.r4.model.Address) PersonAddress(org.openmrs.PersonAddress) ProviderAttribute(org.openmrs.ProviderAttribute) Person(org.openmrs.Person)

Example 32 with HumanName

use of org.hl7.fhir.dstu2.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);
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) Identifier(org.hl7.fhir.r4.model.Identifier) Before(org.junit.Before)

Example 33 with HumanName

use of org.hl7.fhir.dstu2.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);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Before(org.junit.Before)

Example 34 with HumanName

use of org.hl7.fhir.dstu2.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);
}
Also used : Practitioner(org.hl7.fhir.dstu3.model.Practitioner) POCDMT000002UK01AssociatedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssociatedEntity) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Example 35 with HumanName

use of org.hl7.fhir.dstu2.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);
}
Also used : Practitioner(org.hl7.fhir.dstu3.model.Practitioner) POCDMT000002UK01AssignedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedEntity) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Aggregations

HumanName (org.hl7.fhir.r4.model.HumanName)84 HumanName (org.hl7.fhir.dstu3.model.HumanName)37 Patient (org.hl7.fhir.r4.model.Patient)37 Test (org.junit.jupiter.api.Test)29 ArrayList (java.util.ArrayList)27 Patient (org.hl7.fhir.dstu3.model.Patient)27 Test (org.junit.Test)26 MethodOutcome (ca.uhn.fhir.rest.api.MethodOutcome)23 Address (org.hl7.fhir.r4.model.Address)20 Identifier (org.hl7.fhir.r4.model.Identifier)20 PersonName (org.openmrs.PersonName)17 CamelSpringBootTest (org.apache.camel.test.spring.junit5.CamelSpringBootTest)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 GET (javax.ws.rs.GET)15 Path (javax.ws.rs.Path)15 Produces (javax.ws.rs.Produces)15 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)15 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 StringType (org.hl7.fhir.r4.model.StringType)14 Date (java.util.Date)13