Search in sources :

Example 1 with II

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

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

Example 3 with II

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;
}
Also used : II(uk.nhs.connect.iucds.cda.ucr.II) Organization(org.hl7.fhir.dstu3.model.Organization) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) Identifier(org.hl7.fhir.dstu3.model.Identifier) ArrayList(java.util.ArrayList) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Aggregations

II (uk.nhs.connect.iucds.cda.ucr.II)3 Organization (org.hl7.fhir.dstu3.model.Organization)2 POCDMT000002UK01Organization (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization)2 ArrayList (java.util.ArrayList)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 IdType (org.hl7.fhir.dstu3.model.IdType)1 Identifier (org.hl7.fhir.dstu3.model.Identifier)1 AD (uk.nhs.connect.iucds.cda.ucr.AD)1 CE (uk.nhs.connect.iucds.cda.ucr.CE)1 TEL (uk.nhs.connect.iucds.cda.ucr.TEL)1