Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues #3042 and #3150 fix: remove implicit addition of _include and _revinclude in CapabilityStatement #5829

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import ca.uhn.fhir.rest.annotation.Read;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.api.RestSearchParameterTypeEnum;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.Bindings;
import ca.uhn.fhir.rest.server.IServerConformanceProvider;
Expand Down Expand Up @@ -434,57 +433,15 @@ && searchParamEnabled(nextBuiltInSpName)) {

// Add Include to CapabilityStatement.rest.resource
NavigableSet<String> resourceIncludes = resourceNameToIncludes.get(resourceName);
if (resourceIncludes.isEmpty()) {
List<String> includes = searchParams.values().stream()
.filter(t -> t.getParamType() == RestSearchParameterTypeEnum.REFERENCE)
.map(t -> resourceName + ":" + t.getName())
.sorted()
.collect(Collectors.toList());
terser.addElement(resource, "searchInclude", "*");
for (String nextInclude : includes) {
terser.addElement(resource, "searchInclude", nextInclude);
}
} else {
for (String resourceInclude : resourceIncludes) {
terser.addElement(resource, "searchInclude", resourceInclude);
}
for (String resourceInclude : resourceIncludes) {
terser.addElement(resource, "searchInclude", resourceInclude);
}

// Add RevInclude to CapabilityStatement.rest.resource
if (myRestResourceRevIncludesEnabled) {
NavigableSet<String> resourceRevIncludes = resourceNameToRevIncludes.get(resourceName);
if (resourceRevIncludes.isEmpty()) {
TreeSet<String> revIncludes = new TreeSet<>();
for (String nextResourceName : resourceToMethods.keySet()) {
if (isBlank(nextResourceName)) {
continue;
}

for (RuntimeSearchParam t : searchParamRegistry
.getActiveSearchParams(nextResourceName)
.values()) {
if (t.getParamType() == RestSearchParameterTypeEnum.REFERENCE) {
if (isNotBlank(t.getName())) {
boolean appropriateTarget = false;
if (t.getTargets().contains(resourceName)
|| t.getTargets().isEmpty()) {
appropriateTarget = true;
}

if (appropriateTarget) {
revIncludes.add(nextResourceName + ":" + t.getName());
}
}
}
}
}
for (String nextInclude : revIncludes) {
terser.addElement(resource, "searchRevInclude", nextInclude);
}
} else {
for (String resourceInclude : resourceRevIncludes) {
terser.addElement(resource, "searchRevInclude", resourceInclude);
}
for (String resourceInclude : resourceRevIncludes) {
terser.addElement(resource, "searchRevInclude", resourceInclude);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ public List<Observation> search(@OptionalParam(name = "subject") ReferenceParam
}

@Test
public void testRevIncludes_Inferred() throws Exception {
public void testRevIncludes_NotSpecifiedReturnsEmptyList() throws Exception {

class PatientResourceProvider implements IResourceProvider {

Expand Down Expand Up @@ -1291,7 +1291,7 @@ public List<Observation> search(@OptionalParam(name = "subject") ReferenceParam
CapabilityStatementRestResourceComponent patientResource = resources.stream()
.filter(resource -> "Patient".equals(resource.getType()))
.findFirst().get();
assertThat(toStrings(patientResource.getSearchRevInclude()), containsInAnyOrder("Observation:subject"));
assertTrue(patientResource.getSearchRevInclude().isEmpty());
}

@Test
Expand Down
Loading