Search in sources :

Example 1 with POCDMT000002UK01PatientRole

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

Example 2 with POCDMT000002UK01PatientRole

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

the class GroupMapperTest method mapGroupTest.

@Test
public void mapGroupTest() {
    POCDMT000002UK01RecordTarget recordTarget = mock(POCDMT000002UK01RecordTarget.class);
    POCDMT000002UK01PatientRole patientRole = mock(POCDMT000002UK01PatientRole.class);
    when(recordTarget.getPatientRole()).thenReturn(patientRole);
    when(patientMapper.mapPatient(any())).thenReturn(fhirPatient);
    when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
    when(resourceUtil.createReference(fhirPatient)).thenReturn(new Reference(fhirPatient));
    group = groupMapper.mapGroup(Arrays.array(recordTarget));
    assertThat(group.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
    assertThat(group.getActive()).isEqualTo(true);
    assertThat(group.getType().compareTo(Group.GroupType.PERSON)).isEqualTo(0);
    assertThat(group.getMemberFirstRep().getEntity().getResource()).isEqualTo(fhirPatient);
    assertThat(group.getMemberFirstRep().getEntityTarget()).isEqualTo(fhirPatient);
}
Also used : POCDMT000002UK01PatientRole(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PatientRole) Reference(org.hl7.fhir.dstu3.model.Reference) POCDMT000002UK01RecordTarget(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RecordTarget) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Example 3 with POCDMT000002UK01PatientRole

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

the class PatientMapperTest method shouldMapPatient.

@Test
@SuppressWarnings("MagicNumber")
public void shouldMapPatient() {
    POCDMT000002UK01PatientRole patientRole = mock(POCDMT000002UK01PatientRole.class);
    POCDMT000002UK01Patient itkPatient = mock(POCDMT000002UK01Patient.class);
    when(patientRole.isSetPatient()).thenReturn(true);
    when(patientRole.getPatient()).thenReturn(itkPatient);
    when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
    when(resourceUtil.createReference(organization)).thenReturn(new Reference(organization));
    mockNames(itkPatient);
    mockAddress(patientRole);
    mockIdentifier(patientRole);
    mockContactPoint(patientRole);
    mockGeneralPractitioner(patientRole);
    mockLanguage(itkPatient);
    mockGuardian(itkPatient);
    mockExtensions(itkPatient);
    mockBirthTime(itkPatient);
    mockBirthPlace(itkPatient);
    mockGender(itkPatient);
    mockMaritalStatus(itkPatient);
    Patient fhirPatient = patientMapper.mapPatient(patientRole);
    assertThat(fhirPatient.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
    assertThat(fhirPatient.getActive()).isEqualTo(true);
    assertThat(fhirPatient.getNameFirstRep()).isEqualTo(humanName);
    assertThat(fhirPatient.getAddressFirstRep()).isEqualTo(address);
    assertThat(fhirPatient.getTelecomFirstRep()).isEqualTo(contactPoint);
    assertThat(fhirPatient.getGeneralPractitionerFirstRep().getResource()).isEqualTo(organization);
    assertThat(fhirPatient.getLanguage()).isEqualTo("EN");
    assertThat(fhirPatient.getContactFirstRep()).isEqualTo(contactComponent);
    assertThat(fhirPatient.getExtension().size()).isEqualTo(3);
    assertThat(fhirPatient.getBirthDate()).isEqualTo(date);
    assertThat(fhirPatient.getGender().toCode()).isEqualTo("unknown");
    assertThat(fhirPatient.getMaritalStatus().getCoding().get(0).getDisplay()).isEqualTo("Married");
    assertThat(fhirPatient.getMaritalStatus().getCoding().get(0).getSystem()).isEqualTo("http://hl7.org/fhir/v3/MaritalStatus");
    assertThat(fhirPatient.getMaritalStatus().getCoding().get(0).getCode()).isEqualTo("M");
    verifyNhsNumber(fhirPatient);
}
Also used : POCDMT000002UK01Patient(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Patient) POCDMT000002UK01PatientRole(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PatientRole) Reference(org.hl7.fhir.dstu3.model.Reference) POCDMT000002UK01Patient(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Patient) Patient(org.hl7.fhir.dstu3.model.Patient) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Example 4 with POCDMT000002UK01PatientRole

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

the class PatientMapperTest method shouldMapPatientNullification.

@Test
public void shouldMapPatientNullification() {
    POCDMT000002UK01PatientRole patientRole = mock(POCDMT000002UK01PatientRole.class);
    when(patientRole.isSetPatient()).thenReturn(false);
    mockIdentifier(patientRole);
    Patient patient = patientMapper.mapPatient(patientRole);
    assertThat(patient.getActive()).isEqualTo(true);
    verifyNhsNumber(patient);
}
Also used : POCDMT000002UK01PatientRole(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PatientRole) POCDMT000002UK01Patient(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Patient) Patient(org.hl7.fhir.dstu3.model.Patient) Test(org.junit.jupiter.api.Test)

Example 5 with POCDMT000002UK01PatientRole

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

the class RelatedPersonMapper method createEmergencyContactRelatedPerson.

public RelatedPerson createEmergencyContactRelatedPerson(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter) {
    RelatedPerson relatedPerson = new RelatedPerson();
    TEL[] telecomArray = Optional.ofNullable(clinicalDocument).map(document -> document.getRecordTargetArray(0)).map(POCDMT000002UK01RecordTarget::getPatientRole).map(POCDMT000002UK01PatientRole::getTelecomArray).orElse(null);
    if (getEmergencyTelecom(telecomArray).isPresent()) {
        relatedPerson.setIdElement(resourceUtil.newRandomUuid());
        relatedPerson.setPatient(encounter.getSubject());
        relatedPerson.setTelecom(getTelecomFromITK(new TEL[] { getEmergencyTelecom(telecomArray).get() }));
        markEmergencyContact(telecomArray, relatedPerson);
        return relatedPerson;
    }
    return null;
}
Also used : CollectionUtils.isEmpty(org.springframework.util.CollectionUtils.isEmpty) Coding(org.hl7.fhir.dstu3.model.Coding) POCDMT000002UK01RecordTarget(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RecordTarget) DateUtil(uk.nhs.adaptors.oneoneone.cda.report.util.DateUtil) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept) POCDMT000002UK01RelatedEntity(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RelatedEntity) Period(org.hl7.fhir.dstu3.model.Period) POCDMT000002UK01ClinicalDocument1(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01ClinicalDocument1) PN(uk.nhs.connect.iucds.cda.ucr.PN) TEL(uk.nhs.connect.iucds.cda.ucr.TEL) POCDMT000002UK01PatientRole(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PatientRole) Address(org.hl7.fhir.dstu3.model.Address) AD(uk.nhs.connect.iucds.cda.ucr.AD) CE(uk.nhs.connect.iucds.cda.ucr.CE) POCDMT000002UK01Person(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Person) Collections.emptyList(java.util.Collections.emptyList) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson) IVLTS(uk.nhs.connect.iucds.cda.ucr.IVLTS) Collectors(java.util.stream.Collectors) Encounter(org.hl7.fhir.dstu3.model.Encounter) List(java.util.List) Component(org.springframework.stereotype.Component) UNKNOWN(org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN) ResourceUtil(uk.nhs.adaptors.oneoneone.cda.report.util.ResourceUtil) Optional(java.util.Optional) POCDMT000002UK01Informant12(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Informant12) AllArgsConstructor(lombok.AllArgsConstructor) Arrays.stream(java.util.Arrays.stream) HumanName(org.hl7.fhir.dstu3.model.HumanName) ContactPoint(org.hl7.fhir.dstu3.model.ContactPoint) POCDMT000002UK01RecordTarget(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RecordTarget) TEL(uk.nhs.connect.iucds.cda.ucr.TEL) RelatedPerson(org.hl7.fhir.dstu3.model.RelatedPerson)

Aggregations

POCDMT000002UK01PatientRole (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PatientRole)6 Patient (org.hl7.fhir.dstu3.model.Patient)3 Test (org.junit.jupiter.api.Test)3 POCDMT000002UK01RecordTarget (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01RecordTarget)3 IdType (org.hl7.fhir.dstu3.model.IdType)2 Reference (org.hl7.fhir.dstu3.model.Reference)2 POCDMT000002UK01Patient (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Patient)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 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)1 Encounter (org.hl7.fhir.dstu3.model.Encounter)1 UNKNOWN (org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender.UNKNOWN)1 HumanName (org.hl7.fhir.dstu3.model.HumanName)1