Search in sources :

Example 6 with EncounterLocationComponent

use of org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent in project integration-adaptor-111 by nhsconnect.

the class LocationMapperTest method shouldMapOrganizationToLocationComponent.

@Test
public void shouldMapOrganizationToLocationComponent() {
    POCDMT000002UK01Organization itkOrganization = mock(POCDMT000002UK01Organization.class);
    POCDMT000002UK01OrganizationPartOf partOf = mock(POCDMT000002UK01OrganizationPartOf.class);
    IVLTS effectiveTime = mock(IVLTS.class);
    when(organizationMapper.mapOrganization(any(POCDMT000002UK01Organization.class))).thenReturn(organization);
    when(itkOrganization.isSetAsOrganizationPartOf()).thenReturn(true);
    when(itkOrganization.getAsOrganizationPartOf()).thenReturn(partOf);
    when(partOf.getEffectiveTime()).thenReturn(effectiveTime);
    when(periodMapper.mapPeriod(any())).thenReturn(period);
    when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
    Encounter.EncounterLocationComponent encounterLocationComponent = locationMapper.mapOrganizationToLocationComponent(itkOrganization);
    assertThat(encounterLocationComponent.getLocationTarget().getIdElement().getValue()).isEqualTo(RANDOM_UUID);
    assertThat(encounterLocationComponent.getLocationTarget().getManagingOrganizationTarget()).isEqualTo(organization);
    assertThat(encounterLocationComponent.getPeriod()).isEqualTo(period);
}
Also used : IVLTS(uk.nhs.connect.iucds.cda.ucr.IVLTS) Encounter(org.hl7.fhir.dstu3.model.Encounter) POCDMT000002UK01OrganizationPartOf(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01OrganizationPartOf) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) IdType(org.hl7.fhir.dstu3.model.IdType) Test(org.junit.jupiter.api.Test)

Example 7 with EncounterLocationComponent

use of org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent in project integration-adaptor-111 by nhsconnect.

the class LocationMapper method mapOrganizationToLocationComponent.

public Encounter.EncounterLocationComponent mapOrganizationToLocationComponent(POCDMT000002UK01Organization organization) {
    Encounter.EncounterLocationComponent encounterLocationComponent = new Encounter.EncounterLocationComponent();
    encounterLocationComponent.setStatus(Encounter.EncounterLocationStatus.ACTIVE);
    Location location = new Location();
    location.setIdElement(resourceUtil.newRandomUuid());
    Organization managingOrganization = organizationMapper.mapOrganization(organization);
    location.setManagingOrganization(resourceUtil.createReference(managingOrganization));
    location.setManagingOrganizationTarget(managingOrganization);
    encounterLocationComponent.setLocation(resourceUtil.createReference(location));
    encounterLocationComponent.setLocationTarget(location);
    if (organization.isSetAsOrganizationPartOf()) {
        if (organization.getAsOrganizationPartOf().getEffectiveTime() != null) {
            encounterLocationComponent.setPeriod(periodMapper.mapPeriod(organization.getAsOrganizationPartOf().getEffectiveTime()));
        }
    }
    return encounterLocationComponent;
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) POCDMT000002UK01Organization(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization) POCDMT000002UK01EncompassingEncounter(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01EncompassingEncounter) Encounter(org.hl7.fhir.dstu3.model.Encounter) POCDMT000002UK01Location(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Location) Location(org.hl7.fhir.dstu3.model.Location)

Example 8 with EncounterLocationComponent

use of org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent in project integration-adaptor-111 by nhsconnect.

the class LocationMapper method mapHealthcareFacilityToLocationComponent.

public Encounter.EncounterLocationComponent mapHealthcareFacilityToLocationComponent(POCDMT000002UK01ClinicalDocument1 clinicalDocument) {
    POCDMT000002UK01EncompassingEncounter encompassingEncounter = clinicalDocument.getComponentOf().getEncompassingEncounter();
    POCDMT000002UK01Place place = Optional.ofNullable(encompassingEncounter).map(POCDMT000002UK01EncompassingEncounter::getLocation).map(POCDMT000002UK01Location::getHealthCareFacility).map(POCDMT000002UK01HealthCareFacility::getLocation).orElse(null);
    if (place != null) {
        Location location = new Location();
        location.setIdElement(resourceUtil.newRandomUuid());
        location.setName(nodeUtil.getAllText(place.getName().getDomNode()));
        AD address = place.getAddr();
        if (address != null) {
            location.setAddress(addressMapper.mapAddress(address));
        }
        Encounter.EncounterLocationComponent encounterLocationComponent = new Encounter.EncounterLocationComponent();
        encounterLocationComponent.setStatus(Encounter.EncounterLocationStatus.COMPLETED);
        encounterLocationComponent.setLocation(resourceUtil.createReference(location));
        encounterLocationComponent.setLocationTarget(location);
        return encounterLocationComponent;
    }
    return null;
}
Also used : POCDMT000002UK01Location(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Location) POCDMT000002UK01EncompassingEncounter(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01EncompassingEncounter) AD(uk.nhs.connect.iucds.cda.ucr.AD) POCDMT000002UK01Place(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Place) POCDMT000002UK01EncompassingEncounter(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01EncompassingEncounter) Encounter(org.hl7.fhir.dstu3.model.Encounter) POCDMT000002UK01Location(uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Location) Location(org.hl7.fhir.dstu3.model.Location)

Example 9 with EncounterLocationComponent

use of org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent in project eCRNow by drajer-health.

the class R4ResourcesData method loadPractitionersLocationAndOrganization.

public void loadPractitionersLocationAndOrganization(FhirContext context, IGenericClient client, LaunchDetails launchDetails, R4FhirData r4FhirData, Encounter encounter, Bundle bundle, Date start, Date end) {
    if (encounter != null) {
        // Load Practitioners
        if (encounter.getParticipant() != null) {
            List<Practitioner> practitionerList = new ArrayList<>();
            Map<String, String> practitionerMap = new HashMap<>();
            List<EncounterParticipantComponent> participants = encounter.getParticipant();
            for (EncounterParticipantComponent participant : participants) {
                if (participant.getIndividual() != null) {
                    Reference practitionerReference = participant.getIndividual();
                    String practitionerID = practitionerReference.getReferenceElement().getIdPart();
                    if (!practitionerMap.containsKey(practitionerID)) {
                        Practitioner practitioner = (Practitioner) fhirContextInitializer.getResouceById(launchDetails, client, context, "Practitioner", practitionerID);
                        if (practitioner != null) {
                            practitionerList.add(practitioner);
                            practitionerMap.put(practitionerID, practitioner.getResourceType().name());
                            BundleEntryComponent practitionerEntry = new BundleEntryComponent().setResource(practitioner);
                            bundle.addEntry(practitionerEntry);
                        }
                    }
                }
            }
            if (!practitionerList.isEmpty()) {
                r4FhirData.setPractitionersList(practitionerList);
            }
        }
        // Load Location
        if (Boolean.TRUE.equals(encounter.hasServiceProvider())) {
            Reference organizationReference = encounter.getServiceProvider();
            if (organizationReference.hasReferenceElement()) {
                Organization organization = (Organization) fhirContextInitializer.getResouceById(launchDetails, client, context, "Organization", organizationReference.getReferenceElement().getIdPart());
                if (organization != null) {
                    BundleEntryComponent organizationEntry = new BundleEntryComponent().setResource(organization);
                    bundle.addEntry(organizationEntry);
                    r4FhirData.setOrganization(organization);
                }
            }
        }
        if (Boolean.TRUE.equals(encounter.hasLocation())) {
            List<Location> locationList = new ArrayList<>();
            List<EncounterLocationComponent> enocunterLocations = encounter.getLocation();
            for (EncounterLocationComponent location : enocunterLocations) {
                if (location.getLocation() != null) {
                    Reference locationReference = location.getLocation();
                    Location locationResource = (Location) fhirContextInitializer.getResouceById(launchDetails, client, context, "Location", locationReference.getReferenceElement().getIdPart());
                    if (locationResource != null) {
                        locationList.add(locationResource);
                        BundleEntryComponent locationEntry = new BundleEntryComponent().setResource(locationResource);
                        bundle.addEntry(locationEntry);
                    }
                }
            }
            r4FhirData.setLocationList(locationList);
        }
    } else {
        logger.debug("Encounter is null, cannot fetch Practitioners");
    }
}
Also used : HashMap(java.util.HashMap) EncounterLocationComponent(org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent) ArrayList(java.util.ArrayList) EncounterParticipantComponent(org.hl7.fhir.r4.model.Encounter.EncounterParticipantComponent) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)

Example 10 with EncounterLocationComponent

use of org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent in project nia-patient-switching-standard-adaptor by NHSDigital.

the class EncounterMapper method setEncounterLocation.

private void setEncounterLocation(Encounter encounter, RCMRMT030101UK04EhrComposition ehrComposition) {
    if (ehrComposition.getLocation() != null) {
        var location = new EncounterLocationComponent();
        location.setLocation(new Reference(LOCATION_REFERENCE.formatted(ehrComposition.getId().getRoot())));
        encounter.setLocation(List.of(location));
    }
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) EncounterLocationComponent(org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent)

Aggregations

ArrayList (java.util.ArrayList)4 Encounter (org.hl7.fhir.dstu3.model.Encounter)4 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)4 EncounterLocationComponent (org.hl7.fhir.r4.model.Encounter.EncounterLocationComponent)4 Encounter (org.hl7.fhir.r4.model.Encounter)3 Location (org.hl7.fhir.r4.model.Location)3 Reference (org.hl7.fhir.r4.model.Reference)3 EncounterLocationComponent (org.hl7.fhir.dstu3.model.Encounter.EncounterLocationComponent)2 Location (org.hl7.fhir.dstu3.model.Location)2 Organization (org.hl7.fhir.dstu3.model.Organization)2 Reference (org.hl7.fhir.dstu3.model.Reference)2 Resource (org.hl7.fhir.r4.model.Resource)2 Test (org.junit.Test)2 IVLTS (uk.nhs.connect.iucds.cda.ucr.IVLTS)2 POCDMT000002UK01EncompassingEncounter (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01EncompassingEncounter)2 POCDMT000002UK01Location (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Location)2 POCDMT000002UK01Organization (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Organization)2 Arrays (java.util.Arrays)1 Arrays.stream (java.util.Arrays.stream)1 HashMap (java.util.HashMap)1