mirror of
https://github.com/hapifhir/hapi-fhir.git
synced 2025-03-09 14:33:32 +00:00
Improve search bundle parts (#5781)
* Respect other non-match/include entries * Changelog * minor license files * Another test
This commit is contained in:
parent
7005e83b03
commit
7344f01217
@ -29,6 +29,7 @@ import java.util.Map;
|
|||||||
public enum BundleEntrySearchModeEnum {
|
public enum BundleEntrySearchModeEnum {
|
||||||
MATCH("match", "http://hl7.org/fhir/search-entry-mode"),
|
MATCH("match", "http://hl7.org/fhir/search-entry-mode"),
|
||||||
INCLUDE("include", "http://hl7.org/fhir/search-entry-mode"),
|
INCLUDE("include", "http://hl7.org/fhir/search-entry-mode"),
|
||||||
|
OUTCOME("outcome", "http://hl7.org/fhir/search-entry-mode"),
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +80,7 @@ public enum BundleEntrySearchModeEnum {
|
|||||||
/**
|
/**
|
||||||
* Returns the enumerated value associated with this code
|
* Returns the enumerated value associated with this code
|
||||||
*/
|
*/
|
||||||
public BundleEntrySearchModeEnum forCode(String theCode) {
|
public static BundleEntrySearchModeEnum forCode(String theCode) {
|
||||||
BundleEntrySearchModeEnum retVal = CODE_TO_ENUM.get(theCode);
|
BundleEntrySearchModeEnum retVal = CODE_TO_ENUM.get(theCode);
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,7 @@ public class SearchBundleEntryParts {
|
|||||||
public SearchBundleEntryParts(String theFullUrl, IBaseResource theResource, String theSearchMode) {
|
public SearchBundleEntryParts(String theFullUrl, IBaseResource theResource, String theSearchMode) {
|
||||||
myFullUrl = theFullUrl;
|
myFullUrl = theFullUrl;
|
||||||
myResource = theResource;
|
myResource = theResource;
|
||||||
if (BundleEntrySearchModeEnum.INCLUDE.getCode().equalsIgnoreCase(theSearchMode)) {
|
mySearchMode = BundleEntrySearchModeEnum.forCode(theSearchMode);
|
||||||
mySearchMode = BundleEntrySearchModeEnum.INCLUDE;
|
|
||||||
} else {
|
|
||||||
mySearchMode = BundleEntrySearchModeEnum.MATCH;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFullUrl() {
|
public String getFullUrl() {
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
type: fix
|
||||||
|
issue: 5780
|
||||||
|
title: "SearchBundleEntryParts now correctly respects `OUTCOME` and `null` search modes in a bundle entry. In the public space, this means `BundleUtil#getSearchBundleEntryParts()` no longer incorrectly infers information about the entry mode "
|
@ -1,3 +1,22 @@
|
|||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR JPA Model
|
||||||
|
* %%
|
||||||
|
* 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
package ca.uhn.fhir.jpa.logging;
|
package ca.uhn.fhir.jpa.logging;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR JPA Model
|
||||||
|
* %%
|
||||||
|
* 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
package ca.uhn.fhir.jpa.logging;
|
package ca.uhn.fhir.jpa.logging;
|
||||||
|
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR JPA Model
|
||||||
|
* %%
|
||||||
|
* 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
package ca.uhn.fhir.jpa.logging;
|
package ca.uhn.fhir.jpa.logging;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR JPA Model
|
||||||
|
* %%
|
||||||
|
* 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
package ca.uhn.fhir.jpa.logging;
|
package ca.uhn.fhir.jpa.logging;
|
||||||
|
|
||||||
import ca.uhn.fhir.i18n.Msg;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR JPA Model
|
||||||
|
* %%
|
||||||
|
* 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
package ca.uhn.fhir.jpa.logging;
|
package ca.uhn.fhir.jpa.logging;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR JPA Model
|
||||||
|
* %%
|
||||||
|
* 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
package ca.uhn.fhir.jpa.logging;
|
package ca.uhn.fhir.jpa.logging;
|
||||||
|
|
||||||
import ca.uhn.fhir.i18n.Msg;
|
import ca.uhn.fhir.i18n.Msg;
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR JPA Model
|
||||||
|
* %%
|
||||||
|
* 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
package ca.uhn.fhir.jpa.logging;
|
package ca.uhn.fhir.jpa.logging;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,22 @@
|
|||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR JPA Model
|
||||||
|
* %%
|
||||||
|
* 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
package ca.uhn.fhir.jpa.logging;
|
package ca.uhn.fhir.jpa.logging;
|
||||||
|
|
||||||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||||
|
@ -41,6 +41,7 @@ import static org.hamcrest.Matchers.equalTo;
|
|||||||
import static org.hamcrest.Matchers.hasSize;
|
import static org.hamcrest.Matchers.hasSize;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
import static org.hl7.fhir.r4.model.Bundle.HTTPVerb.DELETE;
|
import static org.hl7.fhir.r4.model.Bundle.HTTPVerb.DELETE;
|
||||||
import static org.hl7.fhir.r4.model.Bundle.HTTPVerb.GET;
|
import static org.hl7.fhir.r4.model.Bundle.HTTPVerb.GET;
|
||||||
import static org.hl7.fhir.r4.model.Bundle.HTTPVerb.POST;
|
import static org.hl7.fhir.r4.model.Bundle.HTTPVerb.POST;
|
||||||
@ -464,6 +465,96 @@ public class BundleUtilTest {
|
|||||||
assertThat(searchBundleEntryParts.get(1).getFullUrl(), is(containsString("Condition/")));
|
assertThat(searchBundleEntryParts.get(1).getFullUrl(), is(containsString("Condition/")));
|
||||||
assertThat(searchBundleEntryParts.get(1).getResource(), is(notNullValue()));
|
assertThat(searchBundleEntryParts.get(1).getResource(), is(notNullValue()));
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void testConvertingToSearchBundleEntryPartsRespectsMissingMode() {
|
||||||
|
|
||||||
|
//Given
|
||||||
|
String bundleString = """
|
||||||
|
{
|
||||||
|
"resourceType": "Bundle",
|
||||||
|
"id": "bd194b7f-ac1e-429a-a206-ee2c470f23b5",
|
||||||
|
"type": "searchset",
|
||||||
|
"total": 1,
|
||||||
|
"link": [
|
||||||
|
{
|
||||||
|
"relation": "self",
|
||||||
|
"url": "http://localhost:8000/Condition?_count=1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"entry": [
|
||||||
|
{
|
||||||
|
"fullUrl": "http://localhost:8000/Condition/1626",
|
||||||
|
"resource": {
|
||||||
|
"resourceType": "Condition",
|
||||||
|
"id": "1626",
|
||||||
|
"identifier": [
|
||||||
|
{
|
||||||
|
"system": "urn:hssc:musc:conditionid",
|
||||||
|
"value": "1064115000.1.5"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}""";
|
||||||
|
Bundle bundle = ourCtx.newJsonParser().parseResource(Bundle.class, bundleString);
|
||||||
|
|
||||||
|
//When
|
||||||
|
List<SearchBundleEntryParts> searchBundleEntryParts = BundleUtil.getSearchBundleEntryParts(ourCtx, bundle);
|
||||||
|
|
||||||
|
//Then
|
||||||
|
assertThat(searchBundleEntryParts, hasSize(1));
|
||||||
|
assertThat(searchBundleEntryParts.get(0).getSearchMode(), is(nullValue()));
|
||||||
|
assertThat(searchBundleEntryParts.get(0).getFullUrl(), is(containsString("Condition/1626")));
|
||||||
|
assertThat(searchBundleEntryParts.get(0).getResource(), is(notNullValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConvertingToSearchBundleEntryPartsRespectsOutcomeMode() {
|
||||||
|
|
||||||
|
//Given
|
||||||
|
String bundleString = """
|
||||||
|
{
|
||||||
|
"resourceType": "Bundle",
|
||||||
|
"id": "bd194b7f-ac1e-429a-a206-ee2c470f23b5",
|
||||||
|
"type": "searchset",
|
||||||
|
"total": 1,
|
||||||
|
"link": [
|
||||||
|
{
|
||||||
|
"relation": "self",
|
||||||
|
"url": "http://localhost:8000/Condition?_count=1"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"entry": [
|
||||||
|
{
|
||||||
|
"fullUrl": "http://localhost:8000/Condition/1626",
|
||||||
|
"resource": {
|
||||||
|
"resourceType": "Condition",
|
||||||
|
"id": "1626",
|
||||||
|
"identifier": [
|
||||||
|
{
|
||||||
|
"system": "urn:hssc:musc:conditionid",
|
||||||
|
"value": "1064115000.1.5"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"search": {
|
||||||
|
"mode": "outcome"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}""";
|
||||||
|
Bundle bundle = ourCtx.newJsonParser().parseResource(Bundle.class, bundleString);
|
||||||
|
|
||||||
|
//When
|
||||||
|
List<SearchBundleEntryParts> searchBundleEntryParts = BundleUtil.getSearchBundleEntryParts(ourCtx, bundle);
|
||||||
|
|
||||||
|
//Then
|
||||||
|
assertThat(searchBundleEntryParts, hasSize(1));
|
||||||
|
assertThat(searchBundleEntryParts.get(0).getSearchMode(), is(equalTo(BundleEntrySearchModeEnum.OUTCOME)));
|
||||||
|
assertThat(searchBundleEntryParts.get(0).getFullUrl(), is(containsString("Condition/1626")));
|
||||||
|
assertThat(searchBundleEntryParts.get(0).getResource(), is(notNullValue()));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransactionSorterReturnsDeletesInCorrectProcessingOrder() {
|
public void testTransactionSorterReturnsDeletesInCorrectProcessingOrder() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user