use of org.hl7.fhir.r4.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);
}
use of org.hl7.fhir.r4.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;
}
use of org.hl7.fhir.r4.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;
}
use of org.hl7.fhir.r4.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");
}
}
use of org.hl7.fhir.r4.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));
}
}
Aggregations