From 87956bb2ffdc2483978f0a444752ee78755f9f58 Mon Sep 17 00:00:00 2001 From: Melih Aydogdu Date: Fri, 24 May 2024 17:14:30 +0200 Subject: [PATCH 1/3] target resource name check supported --- .../ca/uhn/fhir/util/ResourceReferenceInfo.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ResourceReferenceInfo.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ResourceReferenceInfo.java index 4dde180e6c75..fbc8a1d64514 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ResourceReferenceInfo.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/ResourceReferenceInfo.java @@ -2,7 +2,7 @@ * #%L * HAPI FHIR - Core Library * %% - * Copyright (C) 2014 - 2024 Smile CDR, Inc. + * Copyright (C) 2014 - 2023 Smile CDR, Inc. * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,10 +93,17 @@ public boolean matchesInclude(Include theInclude) { int colonIndex = theInclude.getValue().indexOf(':'); if (colonIndex != -1) { // DSTU2+ style - String resourceName = theInclude.getValue().substring(0, colonIndex); - String paramName = theInclude.getValue().substring(colonIndex + 1); + String targetResourceName = theInclude.getParamTargetType(); + if (targetResourceName != null + && !targetResourceName.equals( + myResource.getReferenceElement().getResourceType())) { + return false; + } + + String resourceName = theInclude.getParamType(); RuntimeResourceDefinition resourceDef = myContext.getResourceDefinition(resourceName); if (resourceDef != null) { + String paramName = theInclude.getParamName(); RuntimeSearchParam searchParamDef = resourceDef.getSearchParam(paramName); if (searchParamDef != null) { final String completeName = myOwningResource + "." + myName; From e84814b48106e429b313806080e34028faa59d4b Mon Sep 17 00:00:00 2001 From: Melih Aydogdu Date: Fri, 24 May 2024 17:14:54 +0200 Subject: [PATCH 2/3] resource reference info tests added --- .../fhir/util/ResourceReferenceInfoTest.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/util/ResourceReferenceInfoTest.java diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/util/ResourceReferenceInfoTest.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/util/ResourceReferenceInfoTest.java new file mode 100644 index 000000000000..e85b5abf93fd --- /dev/null +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/util/ResourceReferenceInfoTest.java @@ -0,0 +1,48 @@ +package ca.uhn.fhir.util; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.model.api.Include; +import org.hl7.fhir.dstu3.model.Patient; +import org.hl7.fhir.dstu3.model.Reference; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ResourceReferenceInfoTest { + + private ResourceReferenceInfo resourceReferenceInfo; + + private final FhirContext fhirContext = FhirContext.forDstu3(); + + @BeforeEach + public void setUp() { + Reference theElement = new Reference() + .setReference("Practitioner/123") + .setDisplay("Test Practitioner"); + + Patient theOwningResource = new Patient() + .addGeneralPractitioner(theElement); + + resourceReferenceInfo = + new ResourceReferenceInfo(fhirContext, theOwningResource, List.of("generalPractitioner"), theElement); + } + + @Test + public void matchesInclude_hasTargetResourceType_matched() { + assertTrue(resourceReferenceInfo.matchesInclude(new Include("Patient:general-practitioner:Practitioner"))); + } + + @Test + public void matchesInclude_hasNotTargetResourceType_matched() { + assertTrue(resourceReferenceInfo.matchesInclude(new Include("Patient:general-practitioner"))); + } + + @Test + public void matchesInclude_hasDifferentTargetResourceType_notMatched() { + assertFalse(resourceReferenceInfo.matchesInclude(new Include("Patient:general-practitioner:Organization"))); + } +} From 27a36ee5759e533f767850843da78e928f7b5a34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 15:16:19 +0000 Subject: [PATCH 3/3] Bump org.elasticsearch:elasticsearch from 8.9.2 to 8.13.0 Bumps [org.elasticsearch:elasticsearch](https://github.com/elastic/elasticsearch) from 8.9.2 to 8.13.0. - [Release notes](https://github.com/elastic/elasticsearch/releases) - [Changelog](https://github.com/elastic/elasticsearch/blob/main/CHANGELOG.md) - [Commits](https://github.com/elastic/elasticsearch/compare/v8.9.2...v8.13.0) --- updated-dependencies: - dependency-name: org.elasticsearch:elasticsearch dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 08b3a1c9d6a6..e9eb87008c2c 100644 --- a/pom.xml +++ b/pom.xml @@ -1932,7 +1932,7 @@ org.elasticsearch elasticsearch - 8.9.2 + 8.13.0 org.hibernate.search