use of org.hl7.fhir.r4.model.Patient.ContactComponent 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 org.hl7.fhir.r4.model.Patient.ContactComponent in project integration-adaptor-111 by nhsconnect.
the class GuardianMapper method mapGuardian.
public Patient.ContactComponent mapGuardian(POCDMT000002UK01Guardian guardian) {
Patient.ContactComponent contactComponent = new Patient.ContactComponent();
if (guardian.isSetGuardianPerson()) {
POCDMT000002UK01Person guardianPerson = guardian.getGuardianPerson();
if (guardianPerson.sizeOfNameArray() > 0) {
contactComponent.setName(humanNameMapper.mapHumanName(guardianPerson.getNameArray(0)));
}
}
if (guardian.sizeOfAddrArray() > 0) {
contactComponent.setAddress(addressMapper.mapAddress(guardian.getAddrArray(0)));
}
if (guardian.isSetGuardianOrganization()) {
Organization managingOrganization = organizationMapper.mapOrganization(guardian.getGuardianOrganization());
contactComponent.setOrganization(resourceUtil.createReference(managingOrganization));
contactComponent.setOrganizationTarget(managingOrganization);
}
return contactComponent;
}
Aggregations