use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization 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.POCDMT000002UK01Organization in project integration-adaptor-111 by nhsconnect.
the class OrganizationMapper method mapOrganization.
public Organization mapOrganization(POCDMT000002UK01Organization itkOrganization) {
Organization fhirOrganization = new Organization();
fhirOrganization.setIdElement(resourceUtil.newRandomUuid());
fhirOrganization.setName(nodeUtil.getNodeValueString(itkOrganization.getNameArray(0)));
fhirOrganization.setAddress(Arrays.stream(itkOrganization.getAddrArray()).map(addressMapper::mapAddress).collect(Collectors.toList()));
fhirOrganization.setTelecom(Arrays.stream(itkOrganization.getTelecomArray()).map(contactPointMapper::mapContactPoint).collect(Collectors.toList()));
if (itkOrganization.isSetStandardIndustryClassCode()) {
fhirOrganization.setType(Collections.singletonList(new CodeableConcept().setText(itkOrganization.getStandardIndustryClassCode().getDisplayName())));
}
if (itkOrganization.isSetAsOrganizationPartOf()) {
if (itkOrganization.getAsOrganizationPartOf().getWholeOrganization() != null) {
Organization partOf = mapOrganization(itkOrganization.getAsOrganizationPartOf().getWholeOrganization());
fhirOrganization.setPartOf(resourceUtil.createReference(partOf));
fhirOrganization.setPartOfTarget(partOf);
}
}
if (itkOrganization.sizeOfIdArray() > 0) {
List<Identifier> identifierList = new ArrayList<>();
for (II id : itkOrganization.getIdArray()) {
if (id.isSetExtension()) {
identifierList.add(new Identifier().setValue(id.getExtension()));
}
}
fhirOrganization.setIdentifier(identifierList);
}
return fhirOrganization;
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization in project integration-adaptor-111 by nhsconnect.
the class GuardianMapperTest method mockGuardianOrganization.
private void mockGuardianOrganization(POCDMT000002UK01Guardian guardian) {
when(guardian.isSetGuardianOrganization()).thenReturn(true);
POCDMT000002UK01Organization itkOrganization = mock(POCDMT000002UK01Organization.class);
when(guardian.getGuardianOrganization()).thenReturn(itkOrganization);
when(organizationMapper.mapOrganization(any(POCDMT000002UK01Organization.class))).thenReturn(managingOrganization);
when(resourceUtil.createReference(managingOrganization)).thenReturn(new Reference(managingOrganization));
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization in project integration-adaptor-111 by nhsconnect.
the class EncounterMapperTest method setUp.
@BeforeEach
public void setUp() {
POCDMT000002UK01RecordTarget recordTarget = mock(POCDMT000002UK01RecordTarget.class);
POCDMT000002UK01PatientRole patientRole = mock(POCDMT000002UK01PatientRole.class);
POCDMT000002UK01Organization organization = mock(POCDMT000002UK01Organization.class);
when(clinicalDocument.getRecordTargetArray()).thenReturn(new POCDMT000002UK01RecordTarget[] { recordTarget });
when(clinicalDocument.getRecordTargetArray(0)).thenReturn(recordTarget);
when(clinicalDocument.sizeOfRecordTargetArray()).thenReturn(1);
when(recordTarget.getPatientRole()).thenReturn(patientRole);
when(patientRole.getProviderOrganization()).thenReturn(organization);
mockClinicalDocument(clinicalDocument);
mockEncompassingEncounter();
mockParticipant(clinicalDocument);
mockLocation();
mockPeriod();
mockServiceProvider();
mockAppointment();
mockSubject();
mockParticipantWithAuthorInformantAndDataEnterer(clinicalDocument);
mockEncounterTypeAndReason();
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization in project integration-adaptor-111 by nhsconnect.
the class LocationMapperTest method shouldMapOrganizationToLocationComponent.
@Test
public void shouldMapOrganizationToLocationComponent() {
POCDMT000002UK01Organization itkOrganization = mock(POCDMT000002UK01Organization.class);
POCDMT000002UK01OrganizationPartOf partOf = mock(POCDMT000002UK01OrganizationPartOf.class);
IVLTS effectiveTime = mock(IVLTS.class);
when(organizationMapper.mapOrganization(any(POCDMT000002UK01Organization.class))).thenReturn(organization);
when(itkOrganization.isSetAsOrganizationPartOf()).thenReturn(true);
when(itkOrganization.getAsOrganizationPartOf()).thenReturn(partOf);
when(partOf.getEffectiveTime()).thenReturn(effectiveTime);
when(periodMapper.mapPeriod(any())).thenReturn(period);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Encounter.EncounterLocationComponent encounterLocationComponent = locationMapper.mapOrganizationToLocationComponent(itkOrganization);
assertThat(encounterLocationComponent.getLocationTarget().getIdElement().getValue()).isEqualTo(RANDOM_UUID);
assertThat(encounterLocationComponent.getLocationTarget().getManagingOrganizationTarget()).isEqualTo(organization);
assertThat(encounterLocationComponent.getPeriod()).isEqualTo(period);
}
Aggregations