Search in sources :

Example 1 with TEL

use of uk.nhs.connect.iucds.cda.ucr.TEL in project integration-adaptor-111 by nhsconnect.

the class RelatedPersonMapperTest method shouldCreateRelatedPersonWhenPatientHasEcTelecom.

@Test
public void shouldCreateRelatedPersonWhenPatientHasEcTelecom() {
    TEL[] telecomArray = createTelecomArray();
    telecomArray[0].setUse(Collections.singletonList("EC"));
    when(clinicalDocumentDocument.getRecordTargetArray(0)).thenReturn(recordTarget);
    when(recordTarget.getPatientRole()).thenReturn(patientRole);
    when(patientRole.getTelecomArray()).thenReturn(telecomArray);
    when(contactPoint.getValue()).thenReturn(TELECOM_VALUE);
    when(contactPointMapper.mapContactPoint(ArgumentMatchers.any())).thenReturn(contactPoint);
    RelatedPerson relatedPerson = relatedPersonMapper.createEmergencyContactRelatedPerson(clinicalDocumentDocument, encounter);
    assertThat(relatedPerson.hasRelationship()).isTrue();
    assertThat(relatedPerson.getRelationship().getCoding().size()).isEqualTo(1);
    assertThat(relatedPerson.getRelationship().getCodingFirstRep().getCode()).isEqualTo("C");
    assertThat(relatedPerson.getRelationship().getCodingFirstRep().getDisplay()).isEqualTo("Emergency Contact");
    assertThat(relatedPerson.getTelecom().get(0).getValue()).isEqualTo(TELECOM_VALUE);
}
Also used : TEL(uk.nhs.connect.iucds.cda.ucr.TEL) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) Test(org.junit.jupiter.api.Test)

Example 2 with TEL

use of uk.nhs.connect.iucds.cda.ucr.TEL in project integration-adaptor-111 by nhsconnect.

the class RelatedPersonMapperTest method shouldMapRelatedPersonWithTwoCodingsInRelationship.

@Test
public void shouldMapRelatedPersonWithTwoCodingsInRelationship() {
    setup();
    TEL[] telecomArray = createTelecomArray();
    telecomArray[0].setUse(Collections.singletonList("EC"));
    relatedEntity.setTelecomArray(telecomArray);
    informant12.setRelatedEntity(relatedEntity);
    RelatedPerson relatedPerson = relatedPersonMapper.mapRelatedPerson(informant12, encounter);
    assertThat(relatedPerson.hasRelationship()).isTrue();
    assertThat(relatedPerson.getRelationship().getCoding().size()).isEqualTo(2);
}
Also used : TEL(uk.nhs.connect.iucds.cda.ucr.TEL) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) Test(org.junit.jupiter.api.Test)

Example 3 with TEL

use of uk.nhs.connect.iucds.cda.ucr.TEL 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 4 with TEL

use of uk.nhs.connect.iucds.cda.ucr.TEL in project integration-adaptor-111 by nhsconnect.

the class ContactPointMapperTest method shouldMapContactPointPhone.

@Test
public void shouldMapContactPointPhone() {
    TEL tel = TEL.Factory.newInstance();
    tel.setValue(TEL_NUMBER);
    tel.setUse(singletonList(USE_ITK_HOME));
    tel.addNewUseablePeriod();
    when(periodMapper.mapPeriod(ArgumentMatchers.any())).thenReturn(period);
    ContactPoint contactPoint = contactPointMapper.mapContactPoint(tel);
    assertThat(contactPoint.getValue()).isEqualTo(TEL_NUMBER);
    assertThat(contactPoint.getUse()).isEqualTo(HOME);
    assertThat(contactPoint.getPeriod()).isEqualTo(period);
    assertThat(contactPoint.getSystem()).isEqualTo(PHONE);
}
Also used : ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) TEL(uk.nhs.connect.iucds.cda.ucr.TEL) Test(org.junit.jupiter.api.Test)

Example 5 with TEL

use of uk.nhs.connect.iucds.cda.ucr.TEL in project integration-adaptor-111 by nhsconnect.

the class RelatedPersonMapperTest method shouldNotCreateRelatedPersonWithoutEcTelecom.

@Test
public void shouldNotCreateRelatedPersonWithoutEcTelecom() {
    TEL[] telecomArray = createTelecomArray();
    telecomArray[0].setUse(Collections.singletonList("H"));
    when(clinicalDocumentDocument.getRecordTargetArray(0)).thenReturn(recordTarget);
    when(recordTarget.getPatientRole()).thenReturn(patientRole);
    when(patientRole.getTelecomArray()).thenReturn(telecomArray);
    RelatedPerson relatedPerson = relatedPersonMapper.createEmergencyContactRelatedPerson(clinicalDocumentDocument, encounter);
    assertThat(relatedPerson).isNull();
}
Also used : TEL(uk.nhs.connect.iucds.cda.ucr.TEL) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) Test(org.junit.jupiter.api.Test)

Aggregations

TEL (uk.nhs.connect.iucds.cda.ucr.TEL)10 Test (org.junit.jupiter.api.Test)5 RelatedPerson (org.hl7.fhir.dstu3.model.RelatedPerson)4 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)3 AD (uk.nhs.connect.iucds.cda.ucr.AD)3 IdType (org.hl7.fhir.dstu3.model.IdType)2 Organization (org.hl7.fhir.dstu3.model.Organization)2 CE (uk.nhs.connect.iucds.cda.ucr.CE)2 POCDMT000002UK01IntendedRecipient (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01IntendedRecipient)2 POCDMT000002UK01Organization (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization)2 Arrays.stream (java.util.Arrays.stream)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 AllArgsConstructor (lombok.AllArgsConstructor)1 Address (org.hl7.fhir.dstu3.model.Address)1 CodeableConcept (org.hl7.fhir.dstu3.model.CodeableConcept)1 Coding (org.hl7.fhir.dstu3.model.Coding)1 Encounter (org.hl7.fhir.dstu3.model.Encounter)1