Merge pull request #2336 from hapifhir/add_prefix_and_suffix_to_human_name_search
refactor and modify for prefix and suffix
This commit is contained in:
commit
8b924171e7
|
@ -36,12 +36,14 @@ import org.hl7.fhir.r4.model.Patient;
|
|||
import org.hl7.fhir.r4.model.Quantity;
|
||||
import org.hl7.fhir.r4.model.Reference;
|
||||
import org.hl7.fhir.r4.model.SearchParameter;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -88,14 +90,18 @@ public class SearchParamExtractorR4Test {
|
|||
@Test
|
||||
public void testName() {
|
||||
Patient patient = new Patient();
|
||||
List<StringType> suffixStrings = Arrays.asList(new StringType("the Great"));
|
||||
List<StringType> prefixStrings = Arrays.asList(new StringType("King"));
|
||||
HumanName humanName = patient.addName();
|
||||
humanName.addGiven("Jimmy");
|
||||
humanName.setFamily("Jones");
|
||||
humanName.setText("Jimmy Jones");
|
||||
humanName.setText("King Jimmy Jones the Great");
|
||||
humanName.setSuffix(suffixStrings);
|
||||
humanName.setPrefix(prefixStrings);
|
||||
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"));
|
||||
assertThat(nameValues, containsInAnyOrder("Jimmy", "Jones", "King Jimmy Jones the Great", "King", "the Great"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -69,6 +69,7 @@ import javax.measure.unit.NonSI;
|
|||
import javax.measure.unit.Unit;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
@ -133,6 +134,8 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
private BaseRuntimeChildDefinition myHumanNameFamilyValueChild;
|
||||
private BaseRuntimeChildDefinition myHumanNameGivenValueChild;
|
||||
private BaseRuntimeChildDefinition myHumanNameTextValueChild;
|
||||
private BaseRuntimeChildDefinition myHumanNamePrefixValueChild;
|
||||
private BaseRuntimeChildDefinition myHumanNameSuffixValueChild;
|
||||
private BaseRuntimeChildDefinition myContactPointValueValueChild;
|
||||
private BaseRuntimeChildDefinition myIdentifierSystemValueChild;
|
||||
private BaseRuntimeChildDefinition myIdentifierValueValueChild;
|
||||
|
@ -868,19 +871,13 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void addString_HumanName(String theResourceType, Set<ResourceIndexedSearchParamString> theParams, RuntimeSearchParam theSearchParam, IBase theValue) {
|
||||
List<String> families = extractValuesAsStrings(myHumanNameFamilyValueChild, theValue);
|
||||
for (String next : families) {
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, next);
|
||||
}
|
||||
List<String> givens = extractValuesAsStrings(myHumanNameGivenValueChild, theValue);
|
||||
for (String next : givens) {
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, next);
|
||||
}
|
||||
List<String> texts = extractValuesAsStrings(myHumanNameTextValueChild, theValue);
|
||||
for (String next : texts) {
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, next);
|
||||
List<BaseRuntimeChildDefinition> myHumanNameChildren = Arrays.asList(myHumanNameFamilyValueChild, myHumanNameGivenValueChild, myHumanNameTextValueChild, myHumanNamePrefixValueChild, myHumanNameSuffixValueChild);
|
||||
for (BaseRuntimeChildDefinition theChild : myHumanNameChildren) {
|
||||
List<String> indices = extractValuesAsStrings(theChild, theValue);
|
||||
for (String next : indices) {
|
||||
createStringIndexIfNotBlank(theResourceType, theParams, theSearchParam, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1144,6 +1141,8 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
|
|||
myHumanNameFamilyValueChild = humanNameDefinition.getChildByName("family");
|
||||
myHumanNameGivenValueChild = humanNameDefinition.getChildByName("given");
|
||||
myHumanNameTextValueChild = humanNameDefinition.getChildByName("text");
|
||||
myHumanNamePrefixValueChild = humanNameDefinition.getChildByName("prefix");
|
||||
myHumanNameSuffixValueChild = humanNameDefinition.getChildByName("suffix");
|
||||
|
||||
BaseRuntimeElementCompositeDefinition<?> contactPointDefinition = (BaseRuntimeElementCompositeDefinition<?>) getContext().getElementDefinition("ContactPoint");
|
||||
myContactPointValueValueChild = contactPointDefinition.getChildByName("value");
|
||||
|
|
Loading…
Reference in New Issue