Support for ancestor filter with IN operator for LOINC has been added.

This commit is contained in:
Diederik Muylwyk 2019-09-30 10:25:29 -04:00
parent 7eaa5d5574
commit dbd5331f5a
3 changed files with 27 additions and 14 deletions

View File

@ -990,22 +990,33 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
} }
private void addLoincFilterAncestorEqual(String theSystem, QueryBuilder theQb, BooleanJunction<?> theBool, ValueSet.ConceptSetFilterComponent theFilter) { private void addLoincFilterAncestorEqual(String theSystem, QueryBuilder theQb, BooleanJunction<?> theBool, ValueSet.ConceptSetFilterComponent theFilter) {
TermConcept code = findCode(theSystem, theFilter.getValue()) addLoincFilterAncestorEqual(theSystem, theQb, theBool, theFilter.getProperty(), theFilter.getValue());
.orElseThrow(() -> new InvalidRequestException("Invalid filter criteria - code does not exist: {" + theSystem + "}" + theFilter.getValue())); }
logFilteringValueOnProperty(theFilter.getValue(), theFilter.getProperty()); private void addLoincFilterAncestorEqual(String theSystem, QueryBuilder theQb, BooleanJunction<?> theBool, String theProperty, String theValue) {
theBool.must(theQb.keyword().onField("myParentPids").matching("" + code.getId()).createQuery()); List<Term> terms = getAncestorTerms(theSystem, theProperty, theValue);
theBool.must(new TermsQuery(terms));
} }
private void addLoincFilterAncestorIn(String theSystem, QueryBuilder theQb, BooleanJunction<?> theBool, ValueSet.ConceptSetFilterComponent theFilter) { private void addLoincFilterAncestorIn(String theSystem, QueryBuilder theQb, BooleanJunction<?> theBool, ValueSet.ConceptSetFilterComponent theFilter) {
throw new UnsupportedOperationException(); String[] values = theFilter.getValue().split(",");
// FIXME: DM 2019-09-30 - Working on this presently. List<Term> terms = new ArrayList<>();
// FIXME: DM 2019-09-25 - Filter with op=IN on ancestor; see #1512 in GitHub. for (String value : values) {
// FIXME: DM 2019-09-26 - Once implemented, fix changelog entry for #1454 in changes.xml terms.addAll(getAncestorTerms(theSystem, theFilter.getProperty(), value));
// String[] values = theFilter.getValue().split(","); }
// for (String value : values) { theBool.must(new TermsQuery(terms));
// logFilteringValueOnProperty(value, theFilter.getProperty()); }
// }
private List<Term> getAncestorTerms(String theSystem, String theProperty, String theValue) {
List<Term> retVal = new ArrayList<>();
TermConcept code = findCode(theSystem, theValue)
.orElseThrow(() -> new InvalidRequestException("Invalid filter criteria - code does not exist: {" + theSystem + "}" + theValue));
retVal.add(new Term("myParentPids", "" + code.getId()));
logFilteringValueOnProperty(theValue, theProperty);
return retVal;
} }
private void handleFilterLoincDescendant(String theSystem, QueryBuilder theQb, BooleanJunction<?> theBool, ValueSet.ConceptSetFilterComponent theFilter) { private void handleFilterLoincDescendant(String theSystem, QueryBuilder theQb, BooleanJunction<?> theBool, ValueSet.ConceptSetFilterComponent theFilter) {

View File

@ -619,7 +619,6 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test {
assertThat(codes, containsInAnyOrder("50015-7", "43343-3", "43343-4", "47239-9")); assertThat(codes, containsInAnyOrder("50015-7", "43343-3", "43343-4", "47239-9"));
} }
@Ignore("Not yet implemented; see #1512 in GitHub.")
@Test @Test
public void testExpandValueSetPropertyFilterLoincAncestorWithExcludeAndIn() { public void testExpandValueSetPropertyFilterLoincAncestorWithExcludeAndIn() {
createLoincSystemWithSomeCodes(); createLoincSystemWithSomeCodes();
@ -707,7 +706,6 @@ public class TerminologySvcImplDstu3Test extends BaseJpaDstu3Test {
assertEquals(0, outcome.getExpansion().getContains().size()); assertEquals(0, outcome.getExpansion().getContains().size());
} }
@Ignore("Not yet implemented; see #1512 in GitHub.")
@Test @Test
public void testExpandValueSetPropertyFilterLoincAncestorWithIncludeAndIn() { public void testExpandValueSetPropertyFilterLoincAncestorWithIncludeAndIn() {
createLoincSystemWithSomeCodes(); createLoincSystemWithSomeCodes();

View File

@ -249,6 +249,10 @@
<![CDATA[<code>=</code>]]> or <![CDATA[<code>in</code>]]> operators. At present, the <![CDATA[<code>=</code>]]> or <![CDATA[<code>in</code>]]> operators. At present, the
<![CDATA[<code>ancestor</code>]]> filter can only be used with the <![CDATA[<code>=</code>]]> operator. <![CDATA[<code>ancestor</code>]]> filter can only be used with the <![CDATA[<code>=</code>]]> operator.
</action> </action>
<action type="add" issue="1512">
Support for the LOINC <![CDATA[<code>ancestor</code>]]> filter with the <![CDATA[<code>in</code>]]>
operator has been added.
</action>
<action type="fix"> <action type="fix">
The JPA server failed to find codes defined in not-present codesystems in some cases, and reported The JPA server failed to find codes defined in not-present codesystems in some cases, and reported
that the CodeSystem did not exist. This has been corrected. that the CodeSystem did not exist. This has been corrected.