Search in sources :

Example 6 with ContactComponent

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);
}
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 7 with ContactComponent

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;
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) Patient(org.hl7.fhir.dstu3.model.Patient) POCDMT000002UK01Person(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Person)

Aggregations

Patient (org.hl7.fhir.dstu3.model.Patient)4 ArrayList (java.util.ArrayList)3 ContactComponent (org.hl7.fhir.dstu3.model.Patient.ContactComponent)3 Reference (org.hl7.fhir.dstu3.model.Reference)3 Point2D (java.awt.geom.Point2D)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Address (org.hl7.fhir.dstu3.model.Address)2 Coding (org.hl7.fhir.dstu3.model.Coding)2 HumanName (org.hl7.fhir.dstu3.model.HumanName)2 Meta (org.hl7.fhir.dstu3.model.Meta)2 Address (org.hl7.fhir.r4.model.Address)2 Coding (org.hl7.fhir.r4.model.Coding)2 HumanName (org.hl7.fhir.r4.model.HumanName)2 ContactComponent (org.hl7.fhir.r4.model.Patient.ContactComponent)2 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)2 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)2 Basic (org.hl7.fhir.dstu3.model.Basic)1