Search in sources :

Example 1 with POCDMT000002UK01IntendedRecipient

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

the class LocationMapperTest method shouldMapRecipientToLocation.

@Test
public void shouldMapRecipientToLocation() {
    POCDMT000002UK01IntendedRecipient itkIntendedRecipient = prepareIntendedRecipientMocks();
    Location referenceRecipientToLocation = locationMapper.mapRecipientToLocation(itkIntendedRecipient, organization);
    assertThat(referenceRecipientToLocation.getId()).isEqualTo(RANDOM_UUID);
    assertThat(referenceRecipientToLocation.getAddress()).isEqualTo(address);
    assertThat(referenceRecipientToLocation.getTelecom()).isEqualTo(List.of(contactPoint));
    assertThat(referenceRecipientToLocation.getManagingOrganization()).isNotNull();
    assertThat(referenceRecipientToLocation.getManagingOrganizationTarget()).isEqualTo(organization);
    assertThat(referenceRecipientToLocation.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
}
Also used : POCDMT000002UK01IntendedRecipient(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01IntendedRecipient) Location(org.hl7.fhir.dstu3.model.Location) Test(org.junit.jupiter.api.Test)

Example 2 with POCDMT000002UK01IntendedRecipient

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

the class LocationMapperTest method shouldMapRecipientToLocationWithoutOrganizationIfItsEmpty.

@Test
public void shouldMapRecipientToLocationWithoutOrganizationIfItsEmpty() {
    POCDMT000002UK01IntendedRecipient itkIntendedRecipient = prepareIntendedRecipientMocks();
    Location referenceRecipientToLocation = locationMapper.mapRecipientToLocation(itkIntendedRecipient, new Organization());
    assertThat(referenceRecipientToLocation.getId()).isEqualTo(RANDOM_UUID);
    assertThat(referenceRecipientToLocation.getAddress()).isEqualTo(address);
    assertThat(referenceRecipientToLocation.getTelecom()).isEqualTo(List.of(contactPoint));
    assertThat(referenceRecipientToLocation.hasManagingOrganization()).isFalse();
    assertThat(referenceRecipientToLocation.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) POCDMT000002UK01IntendedRecipient(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01IntendedRecipient) Location(org.hl7.fhir.dstu3.model.Location) Test(org.junit.jupiter.api.Test)

Example 3 with POCDMT000002UK01IntendedRecipient

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

the class LocationMapperTest method prepareIntendedRecipientMocks.

private POCDMT000002UK01IntendedRecipient prepareIntendedRecipientMocks() {
    POCDMT000002UK01IntendedRecipient itkIntendedRecipient = mock(POCDMT000002UK01IntendedRecipient.class);
    AD itkAddress = mock(AD.class);
    TEL itkTelecom = mock(TEL.class);
    when(itkIntendedRecipient.sizeOfAddrArray()).thenReturn(new AD[] { itkAddress }.length);
    when(addressMapper.mapAddress(any())).thenReturn(address);
    when(itkIntendedRecipient.getTelecomArray()).thenReturn(new TEL[] { itkTelecom });
    when(contactPointMapper.mapContactPoint(any())).thenReturn(contactPoint);
    when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
    return itkIntendedRecipient;
}
Also used : AD(uk.nhs.connect.iucds.cda.ucr.AD) POCDMT000002UK01IntendedRecipient(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01IntendedRecipient) TEL(uk.nhs.connect.iucds.cda.ucr.TEL) IdType(org.hl7.fhir.dstu3.model.IdType)

Example 4 with POCDMT000002UK01IntendedRecipient

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

the class HealthcareServiceMapper method mapSingleHealthcareService.

private HealthcareService mapSingleHealthcareService(POCDMT000002UK01InformationRecipient informationRecipient) {
    POCDMT000002UK01IntendedRecipient intendedRecipient = informationRecipient.getIntendedRecipient();
    HealthcareService healthcareService = new HealthcareService().setActive(true);
    healthcareService.setIdElement(resourceUtil.newRandomUuid());
    Organization organization = new Organization();
    if (intendedRecipient.isSetReceivedOrganization()) {
        POCDMT000002UK01Organization receivedOrganization = intendedRecipient.getReceivedOrganization();
        organization = organizationMapper.mapOrganization(informationRecipient);
        healthcareService.setProvidedBy(resourceUtil.createReference(organization));
        healthcareService.setProvidedByTarget(organization);
        if (receivedOrganization.sizeOfNameArray() > 0) {
            ON name = receivedOrganization.getNameArray(0);
            healthcareService.setName(nodeUtil.getAllText(name.getDomNode()));
        }
    }
    Location location = locationMapper.mapRecipientToLocation(intendedRecipient, organization);
    healthcareService.addLocation(resourceUtil.createReference(location));
    if (intendedRecipient.sizeOfTelecomArray() > 0) {
        for (TEL tel : intendedRecipient.getTelecomArray()) {
            healthcareService.addTelecom(contactPointMapper.mapContactPoint(tel));
        }
    }
    return healthcareService;
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) POCDMT000002UK01IntendedRecipient(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01IntendedRecipient) HealthcareService(org.hl7.fhir.dstu3.model.HealthcareService) TEL(uk.nhs.connect.iucds.cda.ucr.TEL) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) ON(uk.nhs.connect.iucds.cda.ucr.ON) Location(org.hl7.fhir.dstu3.model.Location)

Example 5 with POCDMT000002UK01IntendedRecipient

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

the class OrganizationMapper method mapOrganization.

public Organization mapOrganization(POCDMT000002UK01InformationRecipient informationRecipient) {
    POCDMT000002UK01IntendedRecipient intendedRecipient = informationRecipient.getIntendedRecipient();
    if (intendedRecipient.isSetReceivedOrganization()) {
        Organization fhirOrganization = mapOrganization(intendedRecipient.getReceivedOrganization());
        Coding code = new Coding().setCode(String.valueOf(informationRecipient.getTypeCode())).setDisplay(nodeUtil.getNodeValueString(intendedRecipient.getReceivedOrganization().getNameArray(0)));
        CodeableConcept codeableConcept = new CodeableConcept(code);
        fhirOrganization.setType(Collections.singletonList(codeableConcept));
        return fhirOrganization;
    }
    return null;
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) Coding(org.hl7.fhir.dstu3.model.Coding) POCDMT000002UK01IntendedRecipient(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01IntendedRecipient) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

POCDMT000002UK01IntendedRecipient (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01IntendedRecipient)5 Location (org.hl7.fhir.dstu3.model.Location)3 Organization (org.hl7.fhir.dstu3.model.Organization)3 POCDMT000002UK01Organization (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization)3 Test (org.junit.jupiter.api.Test)2 TEL (uk.nhs.connect.iucds.cda.ucr.TEL)2 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 HealthcareService (org.hl7.fhir.dstu3.model.HealthcareService)1 IdType (org.hl7.fhir.dstu3.model.IdType)1 AD (uk.nhs.connect.iucds.cda.ucr.AD)1 ON (uk.nhs.connect.iucds.cda.ucr.ON)1