From 87956bb2ffdc2483978f0a444752ee78755f9f58 Mon Sep 17 00:00:00 2001 From: Melih Aydogdu Date: Fri, 24 May 2024 17:14:30 +0200 Subject: [PATCH 1/4] 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/4] 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 f51e2ea8860b7982615012cd02e0c3e7ce21219f Mon Sep 17 00:00:00 2001 From: Melih Aydogdu Date: Fri, 24 May 2024 17:17:05 +0200 Subject: [PATCH 3/4] licence date fixed --- .../src/main/java/ca/uhn/fhir/util/ResourceReferenceInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fbc8a1d64514..46187593e635 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 - 2023 Smile CDR, Inc. + * Copyright (C) 2014 - 2024 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. From 9ee26ebe346146f5a43ef5b4e3037beab7ddb5bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 25 May 2024 05:15:55 +0000 Subject: [PATCH 4/4] Bump com.jayway.jsonpath:json-path from 2.8.0 to 2.9.0 Bumps [com.jayway.jsonpath:json-path](https://github.com/jayway/JsonPath) from 2.8.0 to 2.9.0. - [Release notes](https://github.com/jayway/JsonPath/releases) - [Changelog](https://github.com/json-path/JsonPath/blob/master/changelog.md) - [Commits](https://github.com/jayway/JsonPath/compare/json-path-2.8.0...json-path-2.9.0) --- updated-dependencies: - dependency-name: com.jayway.jsonpath:json-path 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..9d3f374e3d58 100644 --- a/pom.xml +++ b/pom.xml @@ -1113,7 +1113,7 @@ com.jayway.jsonpath json-path - 2.8.0 + 2.9.0 com.jayway.jsonpath