use of uk.nhs.connect.iucds.cda.ucr.AD in project integration-adaptor-111 by nhsconnect.
the class OrganizationMapperTest method mockItkOrganization.
private POCDMT000002UK01Organization mockItkOrganization() {
POCDMT000002UK01Organization itkOrganization = mock(POCDMT000002UK01Organization.class);
AD itkAddress = mock(AD.class);
TEL itkTelecom = mock(TEL.class);
CE codeEntity = mock(CE.class);
II[] iiArray = new II[] { ii };
when(itkOrganization.getIdArray()).thenReturn(iiArray);
when(ii.isSetExtension()).thenReturn(true);
when(ii.getExtension()).thenReturn(ODS_CODE);
when(itkOrganization.sizeOfIdArray()).thenReturn(1);
when(itkOrganization.getAddrArray()).thenReturn(new AD[] { itkAddress });
when(itkOrganization.getTelecomArray()).thenReturn(new TEL[] { itkTelecom });
when(itkOrganization.isSetStandardIndustryClassCode()).thenReturn(true);
when(itkOrganization.getStandardIndustryClassCode()).thenReturn(codeEntity);
when(codeEntity.getDisplayName()).thenReturn(GP_PRACTICE);
when(contactPointMapper.mapContactPoint(any())).thenReturn(contactPoint);
when(addressMapper.mapAddress(any())).thenReturn(address);
when(nodeUtil.getNodeValueString(itkOrganization.getNameArray(0))).thenReturn(ORGANIZATION_NAME);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Organization organization = organizationMapper.mapOrganization(itkOrganization);
assertThat(organization.getName()).isEqualTo(ORGANIZATION_NAME);
assertThat(organization.getAddressFirstRep()).isEqualTo(address);
assertThat(organization.getTelecomFirstRep()).isEqualTo(contactPoint);
assertThat(organization.getTypeFirstRep().getText()).isEqualTo(GP_PRACTICE);
assertThat(organization.getIdentifierFirstRep().getValue()).isEqualTo(ODS_CODE);
assertThat(organization.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
return itkOrganization;
}
use of uk.nhs.connect.iucds.cda.ucr.AD in project integration-adaptor-111 by nhsconnect.
the class GuardianMapperTest method mockAddress.
private void mockAddress(POCDMT000002UK01Guardian guardian) {
when(guardian.sizeOfAddrArray()).thenReturn(1);
AD itkAddress = mock(AD.class);
when(guardian.getAddrArray(0)).thenReturn(itkAddress);
when(addressMapper.mapAddress(any())).thenReturn(address);
}
use of uk.nhs.connect.iucds.cda.ucr.AD in project integration-adaptor-111 by nhsconnect.
the class LocationMapperTest method shouldMapHealthcareFacilityToLocation.
@Test
public void shouldMapHealthcareFacilityToLocation() {
String locationName = "Moving castle";
AD itkAddress = mock(AD.class);
when(nodeUtil.getAllText(any())).thenReturn(locationName);
when(clinicalDocument.getComponentOf().getEncompassingEncounter().getLocation().getHealthCareFacility().getLocation().getAddr()).thenReturn(itkAddress);
when(addressMapper.mapAddress(eq(itkAddress))).thenReturn(address);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Encounter.EncounterLocationComponent locationComponent = locationMapper.mapHealthcareFacilityToLocationComponent(clinicalDocument);
assertThat(locationComponent.getLocationTarget().getIdElement().getValue()).isEqualTo(RANDOM_UUID);
assertThat(locationComponent.getLocationTarget().getAddress()).isEqualTo(address);
assertThat(locationComponent.getLocationTarget().getName()).isEqualTo(locationName);
assertThat(locationComponent.getStatus()).isEqualTo(Encounter.EncounterLocationStatus.COMPLETED);
}
use of uk.nhs.connect.iucds.cda.ucr.AD in project integration-adaptor-111 by nhsconnect.
the class AddressMapperTest method setup.
@BeforeEach
public void setup() {
AD ad = AD.Factory.newInstance();
ad.addNewStreetAddressLine().set(XmlString.Factory.newValue(ADDRESS_LINE));
ad.addNewCity().set(XmlString.Factory.newValue(CITY));
ad.addNewPostalCode().set(XmlString.Factory.newValue(POSTAL_CODE));
ad.addNewCountry().set(XmlString.Factory.newValue(COUNTRY));
ad.addNewDesc().set(XmlString.Factory.newValue(DESCRIPTION));
ad.addNewState().set(XmlString.Factory.newValue(STATE));
ad.addNewPrecinct().set(XmlString.Factory.newValue(DISTRICT));
ad.addNewUseablePeriod();
when(itkAddress.sizeOfUseablePeriodArray()).thenReturn(1);
when(periodMapper.mapPeriod(ArgumentMatchers.any())).thenReturn(period);
when(itkAddress.getStreetAddressLineArray()).thenReturn(ad.getStreetAddressLineArray());
when(nodeUtil.getNodeValueString(ad.getStreetAddressLineArray(0))).thenReturn(ADDRESS_LINE);
when(itkAddress.isSetUse()).thenReturn(true);
when(itkAddress.getUse()).thenReturn(ADDRESS_USE_LIST);
when(itkAddress.sizeOfPostalCodeArray()).thenReturn(1);
when(itkAddress.getPostalCodeArray(0)).thenReturn(ad.getPostalCodeArray(0));
when(nodeUtil.getNodeValueString(ad.getPostalCodeArray(0))).thenReturn(POSTAL_CODE);
when(itkAddress.sizeOfCityArray()).thenReturn(1);
when(itkAddress.getCityArray(0)).thenReturn(ad.getCityArray(0));
when(nodeUtil.getNodeValueString(ad.getCityArray(0))).thenReturn(CITY);
when(itkAddress.sizeOfDescArray()).thenReturn(1);
when(itkAddress.getDescArray(0)).thenReturn(ad.getDescArray(0));
when(nodeUtil.getNodeValueString(ad.getDescArray(0))).thenReturn(DESCRIPTION);
when(itkAddress.sizeOfCountryArray()).thenReturn(1);
when(itkAddress.getCountryArray(0)).thenReturn(ad.getCountryArray(0));
when(nodeUtil.getNodeValueString(ad.getCountryArray(0))).thenReturn(COUNTRY);
when(itkAddress.sizeOfStateArray()).thenReturn(1);
when(itkAddress.getStateArray(0)).thenReturn(ad.getStateArray(0));
when(nodeUtil.getNodeValueString(ad.getStateArray(0))).thenReturn(STATE);
when(itkAddress.getPrecinctArray(0)).thenReturn(ad.getPrecinctArray(0));
when(nodeUtil.getNodeValueString(ad.getPrecinctArray(0))).thenReturn(DISTRICT);
}
use of uk.nhs.connect.iucds.cda.ucr.AD in project integration-adaptor-111 by nhsconnect.
the class LocationMapperTest method shouldMapRoleToLocation.
@Test
public void shouldMapRoleToLocation() {
POCDMT000002UK01ParticipantRole participantRole = mock(POCDMT000002UK01ParticipantRole.class);
POCDMT000002UK01PlayingEntity playingEntity = mock(POCDMT000002UK01PlayingEntity.class);
AD itkAddress = mock(AD.class);
PN personName = mock(PN.class);
when(participantRole.sizeOfAddrArray()).thenReturn(1);
when(participantRole.isSetPlayingEntity()).thenReturn(true);
when(participantRole.getAddrArray(anyInt())).thenReturn(itkAddress);
when(participantRole.getPlayingEntity()).thenReturn(playingEntity);
when(playingEntity.getNameArray(anyInt())).thenReturn(personName);
when(humanNameMapper.mapHumanName(isA(PN.class))).thenReturn(humanName);
when(addressMapper.mapAddress(isA(AD.class))).thenReturn(address);
when(humanName.getText()).thenReturn(NAME);
when(nodeUtil.getNodeValueString(playingEntity.getDesc())).thenReturn(DESCRIPTION);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Location location = locationMapper.mapRoleToLocation(participantRole);
assertThat(location.getAddress()).isEqualTo(address);
assertThat(location.getName()).isEqualTo(NAME);
assertThat(location.getDescription()).isEqualTo(DESCRIPTION);
assertThat(location.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
}
Aggregations