Search in sources :

Example 1 with POCDMT000002UK01AssignedAuthor

use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedAuthor in project integration-adaptor-111 by nhsconnect.

the class PractitionerRoleMapperTest method mockAuthors.

private void mockAuthors() {
    when(author.getTypeCode()).thenReturn(AUTHOR_TYPE_CODE);
    POCDMT000002UK01AssignedAuthor assignedAuthor = mock(POCDMT000002UK01AssignedAuthor.class);
    when(author.getAssignedAuthor()).thenReturn(assignedAuthor);
    CE ce = mockCode();
    when(assignedAuthor.getCode()).thenReturn(ce);
    when(assignedAuthor.getRepresentedOrganization()).thenReturn(mock(POCDMT000002UK01Organization.class));
    when(organizationMapper.mapOrganization(any(POCDMT000002UK01Organization.class))).thenReturn(organization);
    when(practitionerMapper.mapPractitioner(any(POCDMT000002UK01AssignedAuthor.class))).thenReturn(practitioner);
}
Also used : POCDMT000002UK01AssignedAuthor(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedAuthor) CE(uk.nhs.connect.iucds.cda.ucr.CE) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization)

Example 2 with POCDMT000002UK01AssignedAuthor

use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedAuthor in project integration-adaptor-111 by nhsconnect.

the class PractitionerMapperTest method shouldMapPractitionerForAssignedAuthor.

@Test
public void shouldMapPractitionerForAssignedAuthor() {
    POCDMT000002UK01AssignedAuthor associatedEntity = POCDMT000002UK01AssignedAuthor.Factory.newInstance();
    associatedEntity.setAssignedPerson(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 : POCDMT000002UK01AssignedAuthor(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedAuthor) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Example 3 with POCDMT000002UK01AssignedAuthor

use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedAuthor in project integration-adaptor-111 by nhsconnect.

the class PractitionerRoleMapper method mapAuthorRoles.

public List<PractitionerRole> mapAuthorRoles(POCDMT000002UK01Author[] authors) {
    List<PractitionerRole> roles = new ArrayList<>();
    stream(authors).filter(it -> it.getTypeCode().equals(AUTHOR_TYPE_CODE)).map(author -> {
        PractitionerRole role = new PractitionerRole();
        role.setIdElement(resourceUtil.newRandomUuid());
        POCDMT000002UK01AssignedAuthor assignedAuthor = author.getAssignedAuthor();
        role.setCode(asList(getCode(assignedAuthor.getCode())));
        Organization organization = organizationMapper.mapOrganization(assignedAuthor.getRepresentedOrganization());
        role.setOrganization(resourceUtil.createReference(organization));
        role.setOrganizationTarget(organization);
        Practitioner practitioner = practitionerMapper.mapPractitioner(assignedAuthor);
        role.setPractitioner(resourceUtil.createReference(practitioner));
        role.setPractitionerTarget(practitioner);
        return role;
    }).forEach(roles::add);
    return roles;
}
Also used : Optional.empty(java.util.Optional.empty) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) POCDMT000002UK01AssignedAuthor(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedAuthor) CE(uk.nhs.connect.iucds.cda.ucr.CE) Coding(org.hl7.fhir.dstu3.model.Coding) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) ArrayList(java.util.ArrayList) POCDMT000002UK01Author(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Author) Organization(org.hl7.fhir.dstu3.model.Organization) List(java.util.List) Component(org.springframework.stereotype.Component) POCDMT000002UK01Component1(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component1) Arrays.asList(java.util.Arrays.asList) ResourceUtil(uk.nhs.adaptors.oneoneone.cda.report.util.ResourceUtil) POCDMT000002UK01ClinicalDocument1(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1) Optional(java.util.Optional) POCDMT000002UK01ResponsibleParty(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ResponsibleParty) POCDMT000002UK01AssignedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedEntity) AllArgsConstructor(lombok.AllArgsConstructor) Arrays.stream(java.util.Arrays.stream) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) POCDMT000002UK01AssignedAuthor(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedAuthor) Practitioner(org.hl7.fhir.dstu3.model.Practitioner) Organization(org.hl7.fhir.dstu3.model.Organization) ArrayList(java.util.ArrayList) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole)

Aggregations

POCDMT000002UK01AssignedAuthor (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedAuthor)3 Practitioner (org.hl7.fhir.dstu3.model.Practitioner)2 CE (uk.nhs.connect.iucds.cda.ucr.CE)2 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Arrays.stream (java.util.Arrays.stream)1 List (java.util.List)1 Optional (java.util.Optional)1 Optional.empty (java.util.Optional.empty)1 AllArgsConstructor (lombok.AllArgsConstructor)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 IdType (org.hl7.fhir.dstu3.model.IdType)1 Organization (org.hl7.fhir.dstu3.model.Organization)1 PractitionerRole (org.hl7.fhir.dstu3.model.PractitionerRole)1 Test (org.junit.jupiter.api.Test)1 Component (org.springframework.stereotype.Component)1 ResourceUtil (uk.nhs.adaptors.oneoneone.cda.report.util.ResourceUtil)1 POCDMT000002UK01AssignedEntity (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01AssignedEntity)1 POCDMT000002UK01Author (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Author)1