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();
}
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);
}
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);
}
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);
}
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;
}
Aggregations