Search in sources :

Example 1 with PN

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);
}
Also used : POCDMT000002UK01Person(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Person) PN(uk.nhs.connect.iucds.cda.ucr.PN)

Example 2 with PN

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);
}
Also used : HumanName(org.hl7.fhir.dstu3.model.HumanName) PN(uk.nhs.connect.iucds.cda.ucr.PN) Test(org.junit.jupiter.api.Test)

Example 3 with PN

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;
}
Also used : POCDMT000002UK01Person(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Person) PN(uk.nhs.connect.iucds.cda.ucr.PN)

Example 4 with PN

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);
}
Also used : AD(uk.nhs.connect.iucds.cda.ucr.AD) PN(uk.nhs.connect.iucds.cda.ucr.PN) POCDMT000002UK01ParticipantRole(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ParticipantRole) POCDMT000002UK01PlayingEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PlayingEntity) IdType(org.hl7.fhir.dstu3.model.IdType) Location(org.hl7.fhir.dstu3.model.Location) Test(org.junit.jupiter.api.Test)

Example 5 with PN

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);
}
Also used : PN(uk.nhs.connect.iucds.cda.ucr.PN)

Aggregations

PN (uk.nhs.connect.iucds.cda.ucr.PN)6 POCDMT000002UK01Person (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Person)3 Test (org.junit.jupiter.api.Test)2 HumanName (org.hl7.fhir.dstu3.model.HumanName)1 IdType (org.hl7.fhir.dstu3.model.IdType)1 Location (org.hl7.fhir.dstu3.model.Location)1 AD (uk.nhs.connect.iucds.cda.ucr.AD)1 POCDMT000002UK01ParticipantRole (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ParticipantRole)1 POCDMT000002UK01PlayingEntity (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PlayingEntity)1