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 9e72544ca61b09dbdbbf9252aea4049f08273c4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 15:17:28 +0000 Subject: [PATCH 3/3] Bump urllib3 from 1.26.15 to 1.26.18 in /.github/workflows/cdr_check Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.15 to 1.26.18. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/1.26.15...1.26.18) --- updated-dependencies: - dependency-name: urllib3 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- .github/workflows/cdr_check/poetry.lock | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cdr_check/poetry.lock b/.github/workflows/cdr_check/poetry.lock index c306aa76e708..e30e2ca24c20 100644 --- a/.github/workflows/cdr_check/poetry.lock +++ b/.github/workflows/cdr_check/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "certifi" version = "2022.12.7" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -16,7 +15,6 @@ files = [ name = "charset-normalizer" version = "3.1.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false python-versions = ">=3.7.0" files = [ @@ -101,7 +99,6 @@ files = [ name = "idna" version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -113,7 +110,6 @@ files = [ name = "requests" version = "2.28.2" description = "Python HTTP for Humans." -category = "main" optional = false python-versions = ">=3.7, <4" files = [ @@ -133,18 +129,17 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "urllib3" -version = "1.26.15" +version = "1.26.18" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" files = [ - {file = "urllib3-1.26.15-py2.py3-none-any.whl", hash = "sha256:aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42"}, - {file = "urllib3-1.26.15.tar.gz", hash = "sha256:8a388717b9476f934a21484e8c8e61875ab60644d29b9b39e11e4b9dc1c6b305"}, + {file = "urllib3-1.26.18-py2.py3-none-any.whl", hash = "sha256:34b97092d7e0a3a8cf7cd10e386f401b3737364026c45e622aa02903dffe0f07"}, + {file = "urllib3-1.26.18.tar.gz", hash = "sha256:f8ecc1bba5667413457c529ab955bf8c67b45db799d159066261719e328580a0"}, ] [package.extras] -brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] +brotli = ["brotli (==1.0.9)", "brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"] socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]