Rationalize search param extractor

This commit is contained in:
James Agnew 2019-09-28 19:23:21 -04:00
parent 663431f571
commit c0eb662a21
4 changed files with 33 additions and 164 deletions

View File

@ -154,6 +154,21 @@ public class SearchParamExtractorR4Test {
assertEquals(1, links.size());
}
@Test
public void testIndexNumberFromDuration() {
Duration duration = new Duration();
duration.setValue(123);
Encounter enc = new Encounter();
enc.setLength(duration);
SearchParamExtractorR4 extractor = new SearchParamExtractorR4();
ResourceTable table = new ResourceTable();
extractor.extractSearchParamNumber(table, enc);
}
@Test
public void testExtractComponentQuantities() {
Observation o1 = new Observation();

View File

@ -154,11 +154,6 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
continue;
}
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
for (Object nextObject : extractValues(nextPath, theResource)) {
if (nextObject == null) {
continue;
@ -212,11 +207,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
// Consent#source-identifier has a path that isn't typed - This is a one-off to deal with that
continue;
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
}
if (nextEntity != null) {
nextEntity.setResource(theEntity);
@ -254,10 +245,6 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
}
String resourceName = nextSpDef.getName();
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof Duration) {
Duration nextValue = (Duration) nextObject;
@ -319,11 +306,8 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}
@ -357,10 +341,6 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
}
String resourceName = nextSpDef.getName();
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof Quantity) {
Quantity nextValue = (Quantity) nextObject;
@ -372,11 +352,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
} else if (nextObject instanceof LocationPositionComponent) {
continue;
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}
@ -423,18 +399,13 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
continue;
}
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof IPrimitiveType<?>) {
IPrimitiveType<?> nextValue = (IPrimitiveType<?>) nextObject;
String searchTerm = nextValue.getValueAsString();
addSearchTerm(theEntity, retVal, nextSpName, searchTerm);
} else {
if (nextObject instanceof HumanName) {
ArrayList<StringType> allNames = new ArrayList<StringType>();
ArrayList<StringType> allNames = new ArrayList<>();
HumanName nextHumanName = (HumanName) nextObject;
if (isNotBlank(nextHumanName.getFamily())) {
allNames.add(nextHumanName.getFamilyElement());
@ -473,9 +444,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
}
}
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + nextSpName + " is of unexpected datatype: " + nextObject.getClass());
}
throw new ConfigurationException("Search param " + nextSpName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}
@ -510,11 +479,6 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
continue;
}
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
List<String> systems = new ArrayList<>();
List<String> codes = new ArrayList<>();
@ -603,11 +567,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
ourLog.warn("Position search not currently supported, not indexing location");
continue;
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
}
}
@ -667,10 +627,6 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
}
String resourceName = nextSpDef.getName();
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof UriType) {
UriType nextValue = (UriType) nextObject;
@ -685,11 +641,7 @@ public class SearchParamExtractorDstu3 extends BaseSearchParamExtractor implemen
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
}
}
}

View File

@ -193,11 +193,6 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
continue;
}
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
for (Object nextObject : extractValues(nextPath, theResource)) {
if (nextObject == null) {
continue;
@ -248,11 +243,7 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
// CarePlan.activitydate can be a string
continue;
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
}
if (nextEntity != null) {
nextEntity.setResource(theEntity);
@ -290,10 +281,6 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
}
String resourceName = nextSpDef.getName();
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof Duration) {
Duration nextValue = (Duration) nextObject;
@ -355,11 +342,7 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}
@ -393,10 +376,6 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
}
String resourceName = nextSpDef.getName();
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof Quantity) {
Quantity nextValue = (Quantity) nextObject;
@ -411,11 +390,7 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
} else if (ourIgnoredForSearchDatatypes.contains(nextObject.getClass())) {
continue;
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}
@ -462,11 +437,6 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
continue;
}
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof IPrimitiveType<?>) {
IPrimitiveType<?> nextValue = (IPrimitiveType<?>) nextObject;
String searchTerm = nextValue.getValueAsString();
@ -512,9 +482,7 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
}
}
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + nextSpName + " is of unexpected datatype: " + nextObject.getClass());
}
throw new ConfigurationException("Search param " + nextSpName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}
@ -550,11 +518,6 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
continue;
}
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
List<String> systems = new ArrayList<>();
List<String> codes = new ArrayList<>();
@ -639,11 +602,7 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
// Consent#source-identifier has a path that isn't typed - This is a one-off to deal with that
continue;
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + nextSpDef.getName() + " with path " + nextPath + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + nextSpDef.getName() + " with path " + nextPath + " is of unexpected datatype: " + nextObject.getClass());
}
}
@ -703,10 +662,6 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
}
String resourceName = nextSpDef.getName();
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof UriType) {
UriType nextValue = (UriType) nextObject;
@ -721,11 +676,7 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}

View File

@ -182,11 +182,6 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
continue;
}
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
for (Object nextObject : extractValues(nextPath, theResource)) {
if (nextObject == null) {
continue;
@ -237,11 +232,7 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
// CarePlan.activitydate can be a string
continue;
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + nextSpDef.getName() + " is of unexpected datatype: " + nextObject.getClass());
}
if (nextEntity != null) {
nextEntity.setResource(theEntity);
@ -279,10 +270,6 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
}
String resourceName = nextSpDef.getName();
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof Duration) {
Duration nextValue = (Duration) nextObject;
@ -344,11 +331,7 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}
@ -382,10 +365,6 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
}
String resourceName = nextSpDef.getName();
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof Quantity) {
Quantity nextValue = (Quantity) nextObject;
@ -400,11 +379,7 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
} else if (ourIgnoredForSearchDatatypes.contains(nextObject.getClass())) {
continue;
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}
@ -451,11 +426,6 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
continue;
}
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof IPrimitiveType<?>) {
IPrimitiveType<?> nextValue = (IPrimitiveType<?>) nextObject;
String searchTerm = nextValue.getValueAsString();
@ -501,9 +471,7 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
}
}
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + nextSpName + " is of unexpected datatype: " + nextObject.getClass());
}
throw new ConfigurationException("Search param " + nextSpName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}
@ -539,11 +507,6 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
continue;
}
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
List<String> systems = new ArrayList<>();
List<String> codes = new ArrayList<>();
@ -628,11 +591,7 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
// Consent#source-identifier has a path that isn't typed - This is a one-off to deal with that
continue;
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + nextSpDef.getName() + " with path " + nextPath + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + nextSpDef.getName() + " with path " + nextPath + " is of unexpected datatype: " + nextObject.getClass());
}
}
@ -692,10 +651,6 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
}
String resourceName = nextSpDef.getName();
boolean multiType = false;
if (nextPath.endsWith("[x]")) {
multiType = true;
}
if (nextObject instanceof UriType) {
UriType nextValue = (UriType) nextObject;
@ -710,11 +665,7 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements
nextEntity.setResource(theEntity);
retVal.add(nextEntity);
} else {
if (!multiType) {
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
} else {
continue;
}
throw new ConfigurationException("Search param " + resourceName + " is of unexpected datatype: " + nextObject.getClass());
}
}
}