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 {
|
||||
MATCH("match", "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
|
||||
*/
|
||||
public BundleEntrySearchModeEnum forCode(String theCode) {
|
||||
public static BundleEntrySearchModeEnum forCode(String theCode) {
|
||||
BundleEntrySearchModeEnum retVal = CODE_TO_ENUM.get(theCode);
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -30,11 +30,7 @@ public class SearchBundleEntryParts {
|
|||
public SearchBundleEntryParts(String theFullUrl, IBaseResource theResource, String theSearchMode) {
|
||||
myFullUrl = theFullUrl;
|
||||
myResource = theResource;
|
||||
if (BundleEntrySearchModeEnum.INCLUDE.getCode().equalsIgnoreCase(theSearchMode)) {
|
||||
mySearchMode = BundleEntrySearchModeEnum.INCLUDE;
|
||||
} else {
|
||||
mySearchMode = BundleEntrySearchModeEnum.MATCH;
|
||||
}
|
||||
mySearchMode = BundleEntrySearchModeEnum.forCode(theSearchMode);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
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.is;
|
||||
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.GET;
|
||||
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).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
|
||||
public void testTransactionSorterReturnsDeletesInCorrectProcessingOrder() {
|
||||
|
|
Loading…
Reference in New Issue