use of uk.nhs.connect.iucds.cda.ucr.II 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.II in project integration-adaptor-111 by nhsconnect.
the class PatientMapperTest method mockIdentifier.
private void mockIdentifier(POCDMT000002UK01PatientRole patientRole) {
II id = mock(II.class);
when(id.getRoot()).thenReturn(NHS_NUMBER_VERIFIED_OID);
when(id.getExtension()).thenReturn(NHS_NUMBER);
II[] ids = new II[] { id };
when(patientRole.getIdArray()).thenReturn(ids);
}
use of uk.nhs.connect.iucds.cda.ucr.II 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;
}
Aggregations