Search in sources :

Example 41 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project integration-adaptor-111 by nhsconnect.

the class PractitionerRoleMapperTest method shouldMapResponsibleParty.

@Test
public void shouldMapResponsibleParty() {
    mockResponsibleParty();
    when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
    PractitionerRole role = practitionerRoleMapper.mapResponsibleParty(clinicalDocument).get();
    Coding codingFirstRep = role.getCodeFirstRep().getCodingFirstRep();
    assertThat(codingFirstRep.getCode()).isEqualTo(CODE);
    assertThat(codingFirstRep.getSystem()).isEqualTo(CODE_SYSTEM);
    assertThat(codingFirstRep.getDisplay()).isEqualTo(DISPLAY_NAME);
    assertThat(role.getOrganizationTarget()).isEqualTo(organization);
    assertThat(role.getPractitionerTarget()).isEqualTo(practitioner);
    assertThat(role.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
}
Also used : Coding(org.hl7.fhir.dstu3.model.Coding) PractitionerRole(org.hl7.fhir.dstu3.model.PractitionerRole) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Example 42 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION 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 43 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project integration-adaptor-111 by nhsconnect.

the class LocationMapper method mapRecipientToLocation.

public Location mapRecipientToLocation(POCDMT000002UK01IntendedRecipient intendedRecipient, Organization organization) {
    Location location = new Location();
    if (intendedRecipient.sizeOfAddrArray() > 0) {
        location.setAddress(addressMapper.mapAddress(intendedRecipient.getAddrArray(0)));
    }
    location.setTelecom(Arrays.stream(intendedRecipient.getTelecomArray()).map(contactPointMapper::mapContactPoint).collect(Collectors.toList()));
    if (!organization.isEmpty()) {
        location.setManagingOrganization(resourceUtil.createReference(organization));
        location.setManagingOrganizationTarget(organization);
    }
    if (location.isEmpty()) {
        return null;
    }
    location.setIdElement(resourceUtil.newRandomUuid());
    return location;
}
Also used : POCDMT000002UK01Location(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Location) Location(org.hl7.fhir.dstu3.model.Location)

Example 44 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project integration-adaptor-111 by nhsconnect.

the class OrganizationMapper method mapOrganization.

public Organization mapOrganization(POCDMT000002UK01Organization itkOrganization) {
    Organization fhirOrganization = new Organization();
    fhirOrganization.setIdElement(resourceUtil.newRandomUuid());
    fhirOrganization.setName(nodeUtil.getNodeValueString(itkOrganization.getNameArray(0)));
    fhirOrganization.setAddress(Arrays.stream(itkOrganization.getAddrArray()).map(addressMapper::mapAddress).collect(Collectors.toList()));
    fhirOrganization.setTelecom(Arrays.stream(itkOrganization.getTelecomArray()).map(contactPointMapper::mapContactPoint).collect(Collectors.toList()));
    if (itkOrganization.isSetStandardIndustryClassCode()) {
        fhirOrganization.setType(Collections.singletonList(new CodeableConcept().setText(itkOrganization.getStandardIndustryClassCode().getDisplayName())));
    }
    if (itkOrganization.isSetAsOrganizationPartOf()) {
        if (itkOrganization.getAsOrganizationPartOf().getWholeOrganization() != null) {
            Organization partOf = mapOrganization(itkOrganization.getAsOrganizationPartOf().getWholeOrganization());
            fhirOrganization.setPartOf(resourceUtil.createReference(partOf));
            fhirOrganization.setPartOfTarget(partOf);
        }
    }
    if (itkOrganization.sizeOfIdArray() > 0) {
        List<Identifier> identifierList = new ArrayList<>();
        for (II id : itkOrganization.getIdArray()) {
            if (id.isSetExtension()) {
                identifierList.add(new Identifier().setValue(id.getExtension()));
            }
        }
        fhirOrganization.setIdentifier(identifierList);
    }
    return fhirOrganization;
}
Also used : II(uk.nhs.connect.iucds.cda.ucr.II) Organization(org.hl7.fhir.dstu3.model.Organization) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) Identifier(org.hl7.fhir.dstu3.model.Identifier) ArrayList(java.util.ArrayList) CodeableConcept(org.hl7.fhir.dstu3.model.CodeableConcept)

Example 45 with ORGANIZATION

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ORGANIZATION in project integration-adaptor-111 by nhsconnect.

the class EncounterReportBundleService method addSubject.

private void addSubject(Bundle bundle, Encounter encounter) {
    if (encounter.getSubjectTarget() instanceof Patient) {
        Patient patient = (Patient) encounter.getSubjectTarget();
        addEntry(bundle, patient);
        if (patient.hasGeneralPractitioner()) {
            for (Reference gp : patient.getGeneralPractitioner()) {
                Organization organization = (Organization) gp.getResource();
                addEntry(bundle, organization);
            }
        }
    }
    if (encounter.getSubjectTarget() instanceof Group) {
        Group group = (Group) encounter.getSubjectTarget();
        addEntry(bundle, group);
        for (Group.GroupMemberComponent groupMemberComponent : group.getMember()) {
            bundle.addEntry().setFullUrl(groupMemberComponent.getIdElement().getValue()).setResource(groupMemberComponent.getEntityTarget());
        }
    }
}
Also used : Group(org.hl7.fhir.dstu3.model.Group) Organization(org.hl7.fhir.dstu3.model.Organization) Reference(org.hl7.fhir.dstu3.model.Reference) Patient(org.hl7.fhir.dstu3.model.Patient)

Aggregations

Test (org.junit.jupiter.api.Test)101 Organization (org.hl7.fhir.dstu3.model.Organization)90 Organization (org.hl7.fhir.r4.model.Organization)69 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)41 Resource (org.hl7.fhir.r4.model.Resource)38 ArrayList (java.util.ArrayList)34 List (java.util.List)33 Reference (org.hl7.fhir.r4.model.Reference)33 Identifier (org.hl7.fhir.r4.model.Identifier)30 Bundle (org.hl7.fhir.dstu3.model.Bundle)27 UUID (java.util.UUID)26 IGenericClient (ca.uhn.fhir.rest.client.api.IGenericClient)25 Patient (org.hl7.fhir.r4.model.Patient)25 IdType (org.hl7.fhir.dstu3.model.IdType)24 Bundle (org.hl7.fhir.r4.model.Bundle)24 Coding (org.hl7.fhir.r4.model.Coding)24 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)19 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)17 Reference (org.hl7.fhir.dstu3.model.Reference)16 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)16