Search in sources :

Example 1 with AD

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;
}
Also used : II(uk.nhs.connect.iucds.cda.ucr.II) CE(uk.nhs.connect.iucds.cda.ucr.CE) AD(uk.nhs.connect.iucds.cda.ucr.AD) Organization(org.hl7.fhir.dstu3.model.Organization) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) TEL(uk.nhs.connect.iucds.cda.ucr.TEL) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) IdType(org.hl7.fhir.dstu3.model.IdType)

Example 2 with AD

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

Example 3 with AD

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

Example 4 with AD

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);
}
Also used : AD(uk.nhs.connect.iucds.cda.ucr.AD) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with AD

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

Aggregations

AD (uk.nhs.connect.iucds.cda.ucr.AD)8 IdType (org.hl7.fhir.dstu3.model.IdType)4 Encounter (org.hl7.fhir.dstu3.model.Encounter)2 Location (org.hl7.fhir.dstu3.model.Location)2 Test (org.junit.jupiter.api.Test)2 TEL (uk.nhs.connect.iucds.cda.ucr.TEL)2 Organization (org.hl7.fhir.dstu3.model.Organization)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 CE (uk.nhs.connect.iucds.cda.ucr.CE)1 II (uk.nhs.connect.iucds.cda.ucr.II)1 PN (uk.nhs.connect.iucds.cda.ucr.PN)1 POCDMT000002UK01EncompassingEncounter (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01EncompassingEncounter)1 POCDMT000002UK01IntendedRecipient (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01IntendedRecipient)1 POCDMT000002UK01Location (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Location)1 POCDMT000002UK01Organization (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization)1 POCDMT000002UK01ParticipantRole (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ParticipantRole)1 POCDMT000002UK01Place (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Place)1 POCDMT000002UK01PlayingEntity (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PlayingEntity)1