Elements query cleanup
This commit is contained in:
parent
c7d857df98
commit
4498335ae5
|
@ -87,18 +87,19 @@ public class ElementsParameter implements IParameter {
|
|||
if (theExclude) {
|
||||
paramName = Constants.PARAM_ELEMENTS + Constants.PARAM_ELEMENTS_EXCLUDE_MODIFIER;
|
||||
}
|
||||
String[] summary = theRequest.getParameters().get(paramName);
|
||||
String[] elementsValues = theRequest.getParameters().get(paramName);
|
||||
|
||||
if (summary != null && summary.length > 0) {
|
||||
Set<String> retVal = new HashSet<String>();
|
||||
for (String next : summary) {
|
||||
if (elementsValues != null && elementsValues.length > 0) {
|
||||
Set<String> retVal = new HashSet<>();
|
||||
for (String next : elementsValues) {
|
||||
StringTokenizer tok = new StringTokenizer(next, ",");
|
||||
while (tok.hasMoreTokens()) {
|
||||
String token = tok.nextToken();
|
||||
if (isNotBlank(token)) {
|
||||
if (token.contains(".") && standardMode) {
|
||||
continue;
|
||||
}
|
||||
if (token.contains("."))
|
||||
if (standardMode) {
|
||||
continue;
|
||||
}
|
||||
retVal.add(token);
|
||||
}
|
||||
}
|
||||
|
@ -107,11 +108,6 @@ public class ElementsParameter implements IParameter {
|
|||
return null;
|
||||
}
|
||||
|
||||
// Always include the meta element even for subsetted values
|
||||
if (!theExclude) {
|
||||
retVal.add("meta");
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ElementsParamR4Test {
|
|||
assertThat(responseContent, not(containsString("<div>THE DIV</div>")));
|
||||
assertThat(responseContent, (containsString("family")));
|
||||
assertThat(responseContent, (containsString("maritalStatus")));
|
||||
assertThat(ourLastElements, containsInAnyOrder("meta", "name", "maritalStatus"));
|
||||
assertThat(ourLastElements, containsInAnyOrder("name", "maritalStatus"));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class ElementsParamR4Test {
|
|||
assertThat(responseContent, not(containsString("<div>THE DIV</div>")));
|
||||
assertThat(responseContent, (containsString("family")));
|
||||
assertThat(responseContent, not(containsString("maritalStatus")));
|
||||
assertThat(ourLastElements, containsInAnyOrder("meta", "name"));
|
||||
assertThat(ourLastElements, containsInAnyOrder("name"));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class ElementsParamR4Test {
|
|||
assertThat(responseContent, not(containsString("THE DIV")));
|
||||
assertThat(responseContent, containsString("family"));
|
||||
assertThat(responseContent, containsString("maritalStatus"));
|
||||
assertThat(ourLastElements, containsInAnyOrder("meta", "name", "maritalStatus"));
|
||||
assertThat(ourLastElements, containsInAnyOrder("name", "maritalStatus"));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ public class ElementsParamR4Test {
|
|||
assertThat(responseContent, containsString("THE DIV"));
|
||||
assertThat(responseContent, not(containsString("family")));
|
||||
assertThat(responseContent, not(containsString("maritalStatus")));
|
||||
assertThat(ourLastElements, containsInAnyOrder("meta", "text"));
|
||||
assertThat(ourLastElements, containsInAnyOrder( "text"));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -184,6 +184,34 @@ public class ElementsParamR4Test {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* A search on procedure, with only resource specific elements filters that are specifically
|
||||
* on other resources but Procedure, should not affect the output of the procedure resource.
|
||||
*/
|
||||
@Test
|
||||
public void testMultiResourceElementsFilterDoesntAffectFocalResource() throws IOException {
|
||||
createProcedureWithLongChain();
|
||||
verifyXmlAndJson(
|
||||
"http://localhost:" + ourPort + "/Procedure?_include=*&_elements=Observation.subject",
|
||||
bundle -> {
|
||||
Procedure procedure = (Procedure) bundle.getEntry().get(0).getResource();
|
||||
assertEquals(true, procedure.getMeta().isEmpty());
|
||||
assertEquals("REASON_CODE", procedure.getReasonCode().get(0).getCoding().get(0).getCode());
|
||||
assertEquals("USED_CODE", procedure.getUsedCode().get(0).getCoding().get(0).getCode());
|
||||
|
||||
DiagnosticReport dr = (DiagnosticReport) bundle.getEntry().get(1).getResource();
|
||||
assertEquals(true, dr.getMeta().isEmpty());
|
||||
assertEquals(1, dr.getResult().size());
|
||||
|
||||
Observation obs = (Observation ) bundle.getEntry().get(2).getResource();
|
||||
assertEquals("SUBSETTED", obs.getMeta().getTag().get(0).getCode());
|
||||
assertEquals(null, obs.getStatus());
|
||||
assertEquals(0, obs.getCode().getCoding().size());
|
||||
assertEquals(false, obs.hasValue());
|
||||
assertEquals("Patient/123", obs.getSubject().getReference());
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultiResourceElementsFilterWithMetadataExcludedStandardMode() throws IOException {
|
||||
ourServlet.setElementsSupport(ElementsSupportEnum.STANDARD);
|
||||
|
|
Loading…
Reference in New Issue