Work on merge

This commit is contained in:
jamesagnew 2019-10-25 08:50:34 -04:00
parent cd84af30b1
commit fd73a593ea
5 changed files with 43 additions and 24 deletions

View File

@ -93,8 +93,6 @@ public class RuntimeChildChoiceDefinition extends BaseRuntimeDeclaredChildDefini
boolean nonPreferred = false;
if (IBaseResource.class.isAssignableFrom(next)) {
elementName = getElementName() + StringUtils.capitalize(next.getSimpleName());
List<Class<? extends IBaseResource>> types = new ArrayList<Class<? extends IBaseResource>>();
types.add((Class<? extends IBaseResource>) next);
nextDef = findResourceReferenceDefinition(theClassToElementDefinitions);
myNameToChildDefinition.put(getElementName() + "Reference", nextDef);

View File

@ -43,6 +43,7 @@ import java.io.Writer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
@ -236,9 +237,9 @@ public class XmlParser extends BaseParser {
switch (childDef.getChildType()) {
case ID_DATATYPE: {
IIdType value = IIdType.class.cast(theElement);
IIdType value = (IIdType) theElement;
String encodedValue = "id".equals(theChildName) ? value.getIdPart() : value.getValue();
if (StringUtils.isNotBlank(encodedValue) || !super.hasNoExtensions(value)) {
if (StringUtils.isNotBlank(encodedValue) || !hasNoExtensions(value)) {
theEventWriter.writeStartElement(theChildName);
if (StringUtils.isNotBlank(encodedValue)) {
theEventWriter.writeAttribute("value", encodedValue);
@ -249,9 +250,9 @@ public class XmlParser extends BaseParser {
break;
}
case PRIMITIVE_DATATYPE: {
IPrimitiveType<?> pd = IPrimitiveType.class.cast(theElement);
IPrimitiveType<?> pd = (IPrimitiveType) theElement;
String value = pd.getValueAsString();
if (value != null || !super.hasNoExtensions(pd)) {
if (value != null || !hasNoExtensions(pd)) {
theEventWriter.writeStartElement(theChildName);
String elementId = getCompositeElementId(theElement);
if (isNotBlank(elementId)) {
@ -308,14 +309,14 @@ public class XmlParser extends BaseParser {
break;
}
case PRIMITIVE_XHTML: {
XhtmlDt dt = XhtmlDt.class.cast(theElement);
XhtmlDt dt = (XhtmlDt) theElement;
if (dt.hasContent()) {
encodeXhtml(dt, theEventWriter);
}
break;
}
case PRIMITIVE_XHTML_HL7ORG: {
IBaseXhtml dt = IBaseXhtml.class.cast(theElement);
IBaseXhtml dt = (IBaseXhtml) theElement;
if (!dt.isEmpty()) {
// TODO: this is probably not as efficient as it could be
XhtmlDt hdt = new XhtmlDt();
@ -354,17 +355,19 @@ public class XmlParser extends BaseParser {
}
if (nextChild instanceof RuntimeChildNarrativeDefinition) {
INarrative narr = (INarrative) nextChild.getAccessor().getFirstValueOrNull(theElement);
Optional<INarrative> narr = nextChild.getAccessor().getFirstValueOrNull(theElement);
INarrativeGenerator gen = myContext.getNarrativeGenerator();
if (gen != null && (narr == null || narr.isEmpty())) {
if (gen != null && (narr.isPresent() == false || narr.get().isEmpty())) {
gen.populateResourceNarrative(myContext, theResource);
narr = nextChild.getAccessor().getFirstValueOrNull(theElement);
}
if (narr != null && narr.isEmpty() == false) {
if (narr.isPresent() && narr.get().isEmpty() == false) {
RuntimeChildNarrativeDefinition child = (RuntimeChildNarrativeDefinition) nextChild;
String childName = nextChild.getChildNameByDatatype(child.getDatatype());
BaseRuntimeElementDefinition<?> type = child.getChildByName(childName);
encodeChildElementToStreamWriter(theResource, theEventWriter, nextChild, narr, childName, type, null, theContainedResource, nextChildElem, theEncodeContext);
encodeChildElementToStreamWriter(theResource, theEventWriter, nextChild, narr.get(), childName, type, null, theContainedResource, nextChildElem, theEncodeContext);
continue;
}
}

View File

@ -24,7 +24,11 @@ import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.jpa.model.entity.BaseResourceIndexedSearchParam;
import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString;
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
import ca.uhn.fhir.jpa.model.util.StringNormalizer;
import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
import org.apache.commons.lang3.ObjectUtils;
import org.hl7.fhir.instance.model.api.IBase;
@ -37,6 +41,7 @@ import java.util.*;
import java.util.function.Supplier;
import java.util.regex.Pattern;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
public abstract class BaseSearchParamExtractor implements ISearchParamExtractor {
@ -62,6 +67,17 @@ public abstract class BaseSearchParamExtractor implements ISearchParamExtractor
mySearchParamRegistry = theSearchParamRegistry;
}
protected void addSearchTerm(ResourceTable theEntity, Set<ResourceIndexedSearchParamString> retVal, String resourceName, String searchTerm) {
if (isBlank(searchTerm)) {
return;
}
retVal.add(createResourceIndexedSearchParamString(theEntity, resourceName, searchTerm));
}
protected void addStringParam(ResourceTable theEntity, Set<BaseResourceIndexedSearchParam> retVal, RuntimeSearchParam nextSpDef, String value) {
retVal.add(createResourceIndexedSearchParamString(theEntity, nextSpDef.getName(), value));
}
protected Set<Class<?>> getIgnoredForSearchDatatypes() {
return myIgnoredForSearchDatatypes;
}

View File

@ -690,8 +690,8 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
* Override parent because we're using FHIRPath here
*/
@Override
protected List<Object> extractValues(String thePaths, IBaseResource theResource) {
List<Object> values = new ArrayList<>();
protected List<IBase> extractValues(String thePaths, IBaseResource theResource) {
List<IBase> values = new ArrayList<>();
String[] nextPathsSplit = SPLIT_R4.split(thePaths);
for (String nextPath : nextPathsSplit) {
List<Base> allValues;
@ -707,7 +707,7 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
}
for (int i = 0; i < values.size(); i++) {
Object nextObject = values.get(i);
IBase nextObject = values.get(i);
if (nextObject instanceof Extension) {
Extension nextExtension = (Extension) nextObject;
nextObject = nextExtension.getValue();

View File

@ -110,7 +110,6 @@ public abstract class BaseStructureSpreadsheetParser extends BaseStructureParser
// Map<String,String> blockFullNameToShortName = new
// HashMap<String,String>();
Map<String, List<String>> pathToResourceTypes = new HashMap<String, List<String>>();
List<Child> blockCopies = new ArrayList<Child>();
for (int i = 2; i < rows.getLength(); i++) {
Element nextRow = (Element) rows.item(i);
@ -161,8 +160,6 @@ public abstract class BaseStructureSpreadsheetParser extends BaseStructureParser
scanForSimpleSetters(elem);
}
pathToResourceTypes.put(name, elem.getType());
}
postProcess(resource);
@ -241,12 +238,17 @@ public abstract class BaseStructureSpreadsheetParser extends BaseStructureParser
continue;
}
nextName = nextName.toLowerCase().trim().replace(".", "");
if ("name".equals(nextName) || "binding name".equals(nextName)) {
colName = j;
} else if ("reference".equals(nextName)) {
colRef = j;
} else if ("conformance".equals(nextName)) {
colStrength = j;
switch (nextName) {
case "name":
case "binding name":
colName = j;
break;
case "reference":
colRef = j;
break;
case "conformance":
colStrength = j;
break;
}
}