fixed name text indexing (#2309)

* fixed name text indexing

* fixed name text indexing
This commit is contained in:
Ken Stevens 2021-01-22 15:39:26 -05:00 committed by GitHub
parent feff734736
commit 749934d5f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
type: fix
issue: 2309
title: "In the JPA server, HumanName.name.text was not being indexed and therefore was not searchable. This has been corrected."

View File

@ -30,6 +30,7 @@ import org.hl7.fhir.r4.model.Coding;
import org.hl7.fhir.r4.model.Consent;
import org.hl7.fhir.r4.model.Encounter;
import org.hl7.fhir.r4.model.Extension;
import org.hl7.fhir.r4.model.HumanName;
import org.hl7.fhir.r4.model.Observation;
import org.hl7.fhir.r4.model.Patient;
import org.hl7.fhir.r4.model.Quantity;
@ -50,6 +51,8 @@ import java.util.Set;
import java.util.stream.Collectors;
import static java.util.Comparator.comparing;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@ -82,6 +85,19 @@ public class SearchParamExtractorR4Test {
assertEquals("CODE", token.getValue());
}
@Test
public void testName() {
Patient patient = new Patient();
HumanName humanName = patient.addName();
humanName.addGiven("Jimmy");
humanName.setFamily("Jones");
humanName.setText("Jimmy Jones");
SearchParamExtractorR4 extractor = new SearchParamExtractorR4(new ModelConfig(), new PartitionSettings(), ourCtx, mySearchParamRegistry);
ISearchParamExtractor.SearchParamSet<ResourceIndexedSearchParamString> stringSearchParams = extractor.extractSearchParamStrings(patient);
List<String> nameValues = stringSearchParams.stream().filter(param -> "name".equals(param.getParamName())).map(ResourceIndexedSearchParamString::getValueExact).collect(Collectors.toList());
assertThat(nameValues, containsInAnyOrder("Jimmy", "Jones", "Jimmy Jones"));
}
@Test
public void testTokenOnSearchParamContext() {
SearchParameter sp = new SearchParameter();

View File

@ -132,6 +132,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
private BaseRuntimeChildDefinition myDurationValueValueChild;
private BaseRuntimeChildDefinition myHumanNameFamilyValueChild;
private BaseRuntimeChildDefinition myHumanNameGivenValueChild;
private BaseRuntimeChildDefinition myHumanNameTextValueChild;
private BaseRuntimeChildDefinition myContactPointValueValueChild;
private BaseRuntimeChildDefinition myIdentifierSystemValueChild;
private BaseRuntimeChildDefinition myIdentifierValueValueChild;
@ -877,6 +878,10 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
for (String next : givens) {
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, next);
}
List<String> texts = extractValuesAsStrings(myHumanNameTextValueChild, theValue);
for (String next : texts) {
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, next);
}
}
private void addString_Quantity(String theResourceType, Set<ResourceIndexedSearchParamString> theParams, RuntimeSearchParam theSearchParam, IBase theValue) {
@ -1138,6 +1143,7 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
BaseRuntimeElementCompositeDefinition<?> humanNameDefinition = (BaseRuntimeElementCompositeDefinition<?>) getContext().getElementDefinition("HumanName");
myHumanNameFamilyValueChild = humanNameDefinition.getChildByName("family");
myHumanNameGivenValueChild = humanNameDefinition.getChildByName("given");
myHumanNameTextValueChild = humanNameDefinition.getChildByName("text");
BaseRuntimeElementCompositeDefinition<?> contactPointDefinition = (BaseRuntimeElementCompositeDefinition<?>) getContext().getElementDefinition("ContactPoint");
myContactPointValueValueChild = contactPointDefinition.getChildByName("value");