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