use of uk.nhs.connect.iucds.cda.ucr.PN in project integration-adaptor-111 by nhsconnect.
the class GuardianMapperTest method mockGuardianPerson.
private void mockGuardianPerson(POCDMT000002UK01Guardian guardian) {
POCDMT000002UK01Person guardianPerson = mock(POCDMT000002UK01Person.class);
when(guardian.isSetGuardianPerson()).thenReturn(true);
when(guardian.getGuardianPerson()).thenReturn(guardianPerson);
PN personName = mock(PN.class);
when(guardianPerson.sizeOfNameArray()).thenReturn(1);
when(guardianPerson.getNameArray(0)).thenReturn(personName);
when(humanNameMapper.mapHumanName(any())).thenReturn(humanName);
}
use of uk.nhs.connect.iucds.cda.ucr.PN in project integration-adaptor-111 by nhsconnect.
the class HumanNameMapperTest method shouldMapHumanName.
@Test
public void shouldMapHumanName() {
PN pn = PN.Factory.newInstance();
pn.addNewGiven().set(XmlString.Factory.newValue(GIVEN));
pn.addNewPrefix().set(XmlString.Factory.newValue(PREFIX));
pn.addNewSuffix().set(XmlString.Factory.newValue(SUFFIX));
pn.addNewFamily().set(XmlString.Factory.newValue(FAMILY));
pn.addNewValidTime();
when(periodMapper.mapPeriod(ArgumentMatchers.any())).thenReturn(period);
when(nodeUtil.hasSubNodes(any())).thenReturn(true);
when(itkPersonName.getGivenArray()).thenReturn(pn.getGivenArray());
when(nodeUtil.getNodeValueString(pn.getGivenArray(0))).thenReturn(GIVEN);
when(itkPersonName.getPrefixArray()).thenReturn(pn.getPrefixArray());
when(nodeUtil.getNodeValueString(pn.getPrefixArray(0))).thenReturn(PREFIX);
when(itkPersonName.getSuffixArray()).thenReturn(pn.getSuffixArray());
when(nodeUtil.getNodeValueString(pn.getSuffixArray(0))).thenReturn(SUFFIX);
when(itkPersonName.sizeOfFamilyArray()).thenReturn(1);
when(itkPersonName.getFamilyArray(0)).thenReturn(pn.getFamilyArray(0));
when(nodeUtil.getNodeValueString(pn.getFamilyArray(0))).thenReturn(FAMILY);
when(itkPersonName.isSetValidTime()).thenReturn(true);
HumanName humanName = humanNameMapper.mapHumanName(itkPersonName);
assertThat(humanName.getGivenAsSingleString()).isEqualTo(GIVEN);
assertThat(humanName.getPrefixAsSingleString()).isEqualTo(PREFIX);
assertThat(humanName.getSuffixAsSingleString()).isEqualTo(SUFFIX);
assertThat(humanName.getFamily()).isEqualTo(FAMILY);
assertThat(humanName.getPeriod()).isEqualTo(period);
assertThat(humanName.getUse()).isEqualTo(OFFICIAL);
}
use of uk.nhs.connect.iucds.cda.ucr.PN in project integration-adaptor-111 by nhsconnect.
the class RelatedPersonMapperTest method createPerson.
private POCDMT000002UK01Person createPerson() {
POCDMT000002UK01Person person = POCDMT000002UK01Person.Factory.newInstance();
PN pn = PN.Factory.newInstance();
PN[] pnArray = { pn };
person.setNameArray(pnArray);
return person;
}
use of uk.nhs.connect.iucds.cda.ucr.PN 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);
}
use of uk.nhs.connect.iucds.cda.ucr.PN in project integration-adaptor-111 by nhsconnect.
the class PatientMapperTest method mockNames.
private void mockNames(POCDMT000002UK01Patient itkPatient) {
when(itkPatient.sizeOfNameArray()).thenReturn(1);
PN itkPersonName = mock(PN.class);
when(itkPatient.getNameArray()).thenReturn(Arrays.array(itkPersonName));
when(humanNameMapper.mapHumanName(any())).thenReturn(humanName);
}
Aggregations