diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java index 2f938766503..708c45e9eaa 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java @@ -66,13 +66,17 @@ public abstract class BaseRuntimeChildDefinition { } public interface IAccessor { - List getValues(Object theTarget); + List getValues(IBase theTarget); + + default IBase getFirstValueOrNull(IBase theTarget) { + return getValues(theTarget).stream().findFirst().orElse(null); + } } public interface IMutator { - void addValue(Object theTarget, IBase theValue); + void addValue(IBase theTarget, IBase theValue); - void setValue(Object theTarget, IBase theValue); + void setValue(IBase theTarget, IBase theValue); } BaseRuntimeElementDefinition findResourceReferenceDefinition(Map, BaseRuntimeElementDefinition> theClassToElementDefinitions) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeDeclaredChildDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeDeclaredChildDefinition.java index fb5060b24a1..cb0e158ce3b 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeDeclaredChildDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeDeclaredChildDefinition.java @@ -20,34 +20,33 @@ package ca.uhn.fhir.context; * #L% */ +import ca.uhn.fhir.model.api.annotation.Child; +import ca.uhn.fhir.model.api.annotation.Description; +import ca.uhn.fhir.util.ValidateUtil; +import org.apache.commons.lang3.Validate; +import org.hl7.fhir.instance.model.api.IBase; + import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.apache.commons.lang3.Validate; -import org.hl7.fhir.instance.model.api.IBase; - -import ca.uhn.fhir.model.api.annotation.Child; -import ca.uhn.fhir.model.api.annotation.Description; -import ca.uhn.fhir.util.ValidateUtil; - public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChildDefinition { private final IAccessor myAccessor; - private String myBindingValueSet; private final String myElementName; private final Field myField; private final String myFormalDefinition; private final int myMax; private final int myMin; - private boolean myModifier; - private final IMutator myMutator; private final String myShortDefinition; + private String myBindingValueSet; + private boolean myModifier; private boolean mySummary; + BaseRuntimeDeclaredChildDefinition(Field theField, Child theChildAnnotation, Description theDescriptionAnnotation, String theElementName) throws ConfigurationException { super(); - Validate.notNull(theField, "No field speficied"); + Validate.notNull(theField, "No field specified"); ValidateUtil.isGreaterThanOrEqualTo(theChildAnnotation.min(), 0, "Min must be >= 0"); Validate.isTrue(theChildAnnotation.max() == -1 || theChildAnnotation.max() >= theChildAnnotation.min(), "Max must be >= Min (unless it is -1 / unlimited)"); Validate.notBlank(theElementName, "Element name must not be blank"); @@ -87,6 +86,10 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil return myBindingValueSet; } + void setBindingValueSet(String theBindingValueSet) { + myBindingValueSet = theBindingValueSet; + } + @Override public String getElementName() { return myElementName; @@ -119,107 +122,99 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil return myShortDefinition; } - public BaseRuntimeElementDefinition getSingleChildOrThrow() { - if (getValidChildNames().size() != 1) { - throw new IllegalStateException("This child has " + getValidChildNames().size() + " children, expected 1. This is a HAPI bug. Found: " + getValidChildNames()); - } - return getChildByName(getValidChildNames().iterator().next()); - } - public boolean isModifier() { return myModifier; } + protected void setModifier(boolean theModifier) { + myModifier = theModifier; + } + @Override public boolean isSummary() { return mySummary; } - void setBindingValueSet(String theBindingValueSet) { - myBindingValueSet = theBindingValueSet; - } - - protected void setModifier(boolean theModifier) { - myModifier = theModifier; - } - private final class FieldListAccessor implements IAccessor { @SuppressWarnings("unchecked") @Override - public List getValues(Object theTarget) { - List retVal; - try { - retVal = (List) myField.get(theTarget); - } catch (Exception e) { - throw new ConfigurationException("Failed to get value", e); - } - + public List getValues(IBase theTarget) { + List retVal = (List) getFieldValue(theTarget, myField); if (retVal == null) { retVal = Collections.emptyList(); } return retVal; } + } protected final class FieldListMutator implements IMutator { @Override - public void addValue(Object theTarget, IBase theValue) { + public void addValue(IBase theTarget, IBase theValue) { addValue(theTarget, theValue, false); } - private void addValue(Object theTarget, IBase theValue, boolean theClear) { - try { - @SuppressWarnings("unchecked") - List existingList = (List) myField.get(theTarget); - if (existingList == null) { - existingList = new ArrayList(2); - myField.set(theTarget, existingList); - } - if (theClear) { - existingList.clear(); - } - existingList.add(theValue); - } catch (Exception e) { - throw new ConfigurationException("Failed to set value", e); + private void addValue(IBase theTarget, IBase theValue, boolean theClear) { + @SuppressWarnings("unchecked") + List existingList = (List) getFieldValue(theTarget, myField); + if (existingList == null) { + existingList = new ArrayList<>(2); + setFieldValue(theTarget, existingList, myField); } + if (theClear) { + existingList.clear(); + } + existingList.add(theValue); } @Override - public void setValue(Object theTarget, IBase theValue) { + public void setValue(IBase theTarget, IBase theValue) { addValue(theTarget, theValue, true); } } private final class FieldPlainAccessor implements IAccessor { @Override - public List getValues(Object theTarget) { - try { - Object values = myField.get(theTarget); - if (values == null) { - return Collections.emptyList(); - } - List retVal = Collections.singletonList((IBase) values); - return retVal; - } catch (Exception e) { - throw new ConfigurationException("Failed to get value", e); + public List getValues(IBase theTarget) { + Object values = getFieldValue(theTarget, myField); + if (values == null) { + return Collections.emptyList(); } + return Collections.singletonList((IBase) values); + } + + @Override + public IBase getFirstValueOrNull(IBase theTarget) { + return (IBase) getFieldValue(theTarget, myField); } } protected final class FieldPlainMutator implements IMutator { @Override - public void addValue(Object theTarget, IBase theValue) { - try { - myField.set(theTarget, theValue); - } catch (Exception e) { - throw new ConfigurationException("Failed to set value", e); - } + public void addValue(IBase theTarget, IBase theValue) { + setFieldValue(theTarget, theValue, myField); } @Override - public void setValue(Object theTarget, IBase theValue) { + public void setValue(IBase theTarget, IBase theValue) { addValue(theTarget, theValue); } } + private static void setFieldValue(IBase theTarget, Object theValue, Field theField) { + try { + theField.set(theTarget, theValue); + } catch (IllegalAccessException e) { + throw new ConfigurationException("Failed to set value", e); + } + } + + private static Object getFieldValue(IBase theTarget, Field theField) { + try { + return theField.get(theTarget); + } catch (IllegalAccessException e) { + throw new ConfigurationException("Failed to get value", e); + } + } + } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java index c8007015a48..c96523bd18d 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/RuntimeChildUndeclaredExtensionDefinition.java @@ -68,7 +68,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD public IAccessor getAccessor() { return new IAccessor() { @Override - public List getValues(Object theTarget) { + public List getValues(IBase theTarget) { ExtensionDt target = (ExtensionDt) theTarget; if (target.getValue() != null) { return Collections.singletonList((IBase) target.getValue()); @@ -76,6 +76,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD ArrayList retVal = new ArrayList(target.getUndeclaredExtensions()); return retVal; } + }; } @@ -113,7 +114,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD public IMutator getMutator() { return new IMutator() { @Override - public void addValue(Object theTarget, IBase theValue) { + public void addValue(IBase theTarget, IBase theValue) { ExtensionDt target = (ExtensionDt) theTarget; if (theValue instanceof IDatatype) { target.setValue((IDatatype) theTarget); @@ -123,7 +124,7 @@ public class RuntimeChildUndeclaredExtensionDefinition extends BaseRuntimeChildD } @Override - public void setValue(Object theTarget, IBase theValue) { + public void setValue(IBase theTarget, IBase theValue) { ExtensionDt target = (ExtensionDt) theTarget; if (theValue instanceof IDatatype) { target.setValue((IDatatype) theTarget); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java index 68938a4488e..3ba302fa0a1 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/ParserState.java @@ -19,17 +19,6 @@ package ca.uhn.fhir.parser; * limitations under the License. * #L% */ -import static org.apache.commons.lang3.StringUtils.*; - -import java.util.*; - -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; - -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.Validate; -import org.apache.commons.lang3.tuple.Pair; -import org.hl7.fhir.instance.model.api.*; import ca.uhn.fhir.context.*; import ca.uhn.fhir.context.BaseRuntimeChildDefinition.IMutator; @@ -37,21 +26,32 @@ import ca.uhn.fhir.model.api.*; import ca.uhn.fhir.model.api.annotation.Child; import ca.uhn.fhir.model.base.composite.BaseResourceReferenceDt; import ca.uhn.fhir.model.base.resource.ResourceMetadataMap; -import ca.uhn.fhir.model.primitive.*; +import ca.uhn.fhir.model.primitive.IdDt; +import ca.uhn.fhir.model.primitive.InstantDt; +import ca.uhn.fhir.model.primitive.XhtmlDt; import ca.uhn.fhir.parser.json.JsonLikeValue.ScalarType; import ca.uhn.fhir.parser.json.JsonLikeValue.ValueType; import ca.uhn.fhir.util.*; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.commons.lang3.tuple.Pair; +import org.hl7.fhir.instance.model.api.*; + +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; +import java.util.*; + +import static org.apache.commons.lang3.StringUtils.*; class ParserState { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ParserState.class); - - private List myComments = new ArrayList(2); private final FhirContext myContext; private final IParserErrorHandler myErrorHandler; private final boolean myJsonMode; - private T myObject; private final IParser myParser; + private List myComments = new ArrayList(2); + private T myObject; private IBase myPreviousElement; private BaseState myState; @@ -152,38 +152,6 @@ class ParserState { } } - - /** - * @param theResourceType - * May be null - */ - static ParserState getPreResourceInstance(IParser theParser, Class theResourceType, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) - throws DataFormatException { - ParserState retVal = new ParserState(theParser, theContext, theJsonMode, theErrorHandler); - if (theResourceType == null) { - if (theContext.getVersion().getVersion().isRi()) { - retVal.push(retVal.new PreResourceStateHl7Org(theResourceType)); - } else { - retVal.push(retVal.new PreResourceStateHapi(theResourceType)); - } - } else { - if (IResource.class.isAssignableFrom(theResourceType)) { - retVal.push(retVal.new PreResourceStateHapi(theResourceType)); - } else { - retVal.push(retVal.new PreResourceStateHl7Org(theResourceType)); - } - } - return retVal; - } - - static ParserState getPreTagListInstance(IParser theParser, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) { - ParserState retVal = new ParserState(theParser, theContext, theJsonMode, theErrorHandler); - retVal.push(retVal.new PreTagListState()); - return retVal; - } - - - private abstract class BaseState { private PreResourceState myPreResourceState; @@ -195,8 +163,7 @@ class ParserState { } /** - * @param theValue - * The attribute value + * @param theValue The attribute value */ public void attributeValue(String theName, String theValue) throws DataFormatException { myErrorHandler.unknownAttribute(null, theName); @@ -211,8 +178,7 @@ class ParserState { } /** - * @param theNamespaceUri - * The XML namespace (if XML) or null + * @param theNamespaceUri The XML namespace (if XML) or null */ public void enteringNewElement(String theNamespaceUri, String theLocalPart) throws DataFormatException { myErrorHandler.unknownElement(null, theLocalPart); @@ -275,8 +241,7 @@ class ParserState { } /** - * @param theData - * The string value + * @param theData The string value */ public void string(String theData) { // ignore by default @@ -287,8 +252,7 @@ class ParserState { } /** - * @param theNextEvent - * The XML event + * @param theNextEvent The XML event */ public void xmlEvent(XMLEvent theNextEvent) { // ignore @@ -414,30 +378,30 @@ class ParserState { } switch (target.getChildType()) { - case COMPOSITE_DATATYPE: { - BaseRuntimeElementCompositeDefinition compositeTarget = (BaseRuntimeElementCompositeDefinition) target; - ICompositeType newChildInstance = (ICompositeType) compositeTarget.newInstance(myDefinition.getInstanceConstructorArguments()); - myDefinition.getMutator().addValue(myParentInstance, newChildInstance); - ElementCompositeState newState = new ElementCompositeState(myPreResourceState, theLocalPart, compositeTarget, newChildInstance); - push(newState); - return; - } - case ID_DATATYPE: - case PRIMITIVE_DATATYPE: { - RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target; - IPrimitiveType newChildInstance = primitiveTarget.newInstance(myDefinition.getInstanceConstructorArguments()); - myDefinition.getMutator().addValue(myParentInstance, newChildInstance); - PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance); - push(newState); - return; - } - case PRIMITIVE_XHTML: - case RESOURCE: - case RESOURCE_BLOCK: - case UNDECL_EXT: - case EXTENSION_DECLARED: - default: - break; + case COMPOSITE_DATATYPE: { + BaseRuntimeElementCompositeDefinition compositeTarget = (BaseRuntimeElementCompositeDefinition) target; + ICompositeType newChildInstance = (ICompositeType) compositeTarget.newInstance(myDefinition.getInstanceConstructorArguments()); + myDefinition.getMutator().addValue(myParentInstance, newChildInstance); + ElementCompositeState newState = new ElementCompositeState(myPreResourceState, theLocalPart, compositeTarget, newChildInstance); + push(newState); + return; + } + case ID_DATATYPE: + case PRIMITIVE_DATATYPE: { + RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target; + IPrimitiveType newChildInstance = primitiveTarget.newInstance(myDefinition.getInstanceConstructorArguments()); + myDefinition.getMutator().addValue(myParentInstance, newChildInstance); + PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance); + push(newState); + return; + } + case PRIMITIVE_XHTML: + case RESOURCE: + case RESOURCE_BLOCK: + case UNDECL_EXT: + case EXTENSION_DECLARED: + default: + break; } } @@ -545,81 +509,81 @@ class ParserState { } switch (target.getChildType()) { - case COMPOSITE_DATATYPE: { - BaseRuntimeElementCompositeDefinition compositeTarget = (BaseRuntimeElementCompositeDefinition) target; - ICompositeType newChildInstance = (ICompositeType) compositeTarget.newInstance(child.getInstanceConstructorArguments()); - child.getMutator().addValue(myInstance, newChildInstance); - ParserState.ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), theChildName, compositeTarget, newChildInstance); - push(newState); - return; - } - case ID_DATATYPE: - case PRIMITIVE_DATATYPE: { - RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target; - IPrimitiveType newChildInstance; - newChildInstance = primitiveTarget.newInstance(child.getInstanceConstructorArguments()); - child.getMutator().addValue(myInstance, newChildInstance); - PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance); - push(newState); - return; - } - case RESOURCE_BLOCK: { - RuntimeResourceBlockDefinition blockTarget = (RuntimeResourceBlockDefinition) target; - IBase newBlockInstance = blockTarget.newInstance(); - child.getMutator().addValue(myInstance, newBlockInstance); - ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), theChildName, blockTarget, newBlockInstance); - push(newState); - return; - } - case PRIMITIVE_XHTML: { - RuntimePrimitiveDatatypeNarrativeDefinition xhtmlTarget = (RuntimePrimitiveDatatypeNarrativeDefinition) target; - XhtmlDt newDt = xhtmlTarget.newInstance(); - child.getMutator().addValue(myInstance, newDt); - XhtmlState state = new XhtmlState(getPreResourceState(), newDt, true); - push(state); - return; - } - case PRIMITIVE_XHTML_HL7ORG: { - RuntimePrimitiveDatatypeXhtmlHl7OrgDefinition xhtmlTarget = (RuntimePrimitiveDatatypeXhtmlHl7OrgDefinition) target; - IBaseXhtml newDt = xhtmlTarget.newInstance(); - child.getMutator().addValue(myInstance, newDt); - XhtmlStateHl7Org state = new XhtmlStateHl7Org(getPreResourceState(), newDt); - push(state); - return; - } - case CONTAINED_RESOURCES: { - List values = child.getAccessor().getValues(myInstance); - Object newDt; - if (values == null || values.isEmpty() || values.get(0) == null) { - newDt = newContainedDt((IResource) getPreResourceState().myInstance); - child.getMutator().addValue(myInstance, (IBase) newDt); - } else { - newDt = values.get(0); + case COMPOSITE_DATATYPE: { + BaseRuntimeElementCompositeDefinition compositeTarget = (BaseRuntimeElementCompositeDefinition) target; + ICompositeType newChildInstance = (ICompositeType) compositeTarget.newInstance(child.getInstanceConstructorArguments()); + child.getMutator().addValue(myInstance, newChildInstance); + ParserState.ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), theChildName, compositeTarget, newChildInstance); + push(newState); + return; } - ContainedResourcesStateHapi state = new ContainedResourcesStateHapi(getPreResourceState()); - push(state); - return; - } - case CONTAINED_RESOURCE_LIST: { - ContainedResourcesStateHl7Org state = new ContainedResourcesStateHl7Org(getPreResourceState()); - push(state); - return; - } - case RESOURCE: { - if (myInstance instanceof IAnyResource || myInstance instanceof IBaseBackboneElement || myInstance instanceof IBaseElement) { - ParserState.PreResourceStateHl7Org state = new PreResourceStateHl7Org(myInstance, child.getMutator(), null); - push(state); - } else { - ParserState.PreResourceStateHapi state = new PreResourceStateHapi(myInstance, child.getMutator(), null); - push(state); + case ID_DATATYPE: + case PRIMITIVE_DATATYPE: { + RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target; + IPrimitiveType newChildInstance; + newChildInstance = primitiveTarget.newInstance(child.getInstanceConstructorArguments()); + child.getMutator().addValue(myInstance, newChildInstance); + PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance); + push(newState); + return; + } + case RESOURCE_BLOCK: { + RuntimeResourceBlockDefinition blockTarget = (RuntimeResourceBlockDefinition) target; + IBase newBlockInstance = blockTarget.newInstance(); + child.getMutator().addValue(myInstance, newBlockInstance); + ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), theChildName, blockTarget, newBlockInstance); + push(newState); + return; + } + case PRIMITIVE_XHTML: { + RuntimePrimitiveDatatypeNarrativeDefinition xhtmlTarget = (RuntimePrimitiveDatatypeNarrativeDefinition) target; + XhtmlDt newDt = xhtmlTarget.newInstance(); + child.getMutator().addValue(myInstance, newDt); + XhtmlState state = new XhtmlState(getPreResourceState(), newDt, true); + push(state); + return; + } + case PRIMITIVE_XHTML_HL7ORG: { + RuntimePrimitiveDatatypeXhtmlHl7OrgDefinition xhtmlTarget = (RuntimePrimitiveDatatypeXhtmlHl7OrgDefinition) target; + IBaseXhtml newDt = xhtmlTarget.newInstance(); + child.getMutator().addValue(myInstance, newDt); + XhtmlStateHl7Org state = new XhtmlStateHl7Org(getPreResourceState(), newDt); + push(state); + return; + } + case CONTAINED_RESOURCES: { + List values = child.getAccessor().getValues(myInstance); + Object newDt; + if (values == null || values.isEmpty() || values.get(0) == null) { + newDt = newContainedDt((IResource) getPreResourceState().myInstance); + child.getMutator().addValue(myInstance, (IBase) newDt); + } else { + newDt = values.get(0); + } + ContainedResourcesStateHapi state = new ContainedResourcesStateHapi(getPreResourceState()); + push(state); + return; + } + case CONTAINED_RESOURCE_LIST: { + ContainedResourcesStateHl7Org state = new ContainedResourcesStateHl7Org(getPreResourceState()); + push(state); + return; + } + case RESOURCE: { + if (myInstance instanceof IAnyResource || myInstance instanceof IBaseBackboneElement || myInstance instanceof IBaseElement) { + ParserState.PreResourceStateHl7Org state = new PreResourceStateHl7Org(myInstance, child.getMutator(), null); + push(state); + } else { + ParserState.PreResourceStateHapi state = new PreResourceStateHapi(myInstance, child.getMutator(), null); + push(state); + } + return; + } + case UNDECL_EXT: + case EXTENSION_DECLARED: { + // Throw an exception because this shouldn't happen here + break; } - return; - } - case UNDECL_EXT: - case EXTENSION_DECLARED: { - // Throw an exception because this shouldn't happen here - break; - } } throw new DataFormatException("Illegal resource position: " + target.getChildType()); @@ -716,32 +680,32 @@ class ParserState { if (target != null) { switch (target.getChildType()) { - case COMPOSITE_DATATYPE: { - BaseRuntimeElementCompositeDefinition compositeTarget = (BaseRuntimeElementCompositeDefinition) target; - ICompositeType newChildInstance = (ICompositeType) compositeTarget.newInstance(); - myExtension.setValue(newChildInstance); - ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), theLocalPart, compositeTarget, newChildInstance); - push(newState); - return; - } - case ID_DATATYPE: - case PRIMITIVE_DATATYPE: { - RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target; - IPrimitiveType newChildInstance = primitiveTarget.newInstance(); - myExtension.setValue(newChildInstance); - PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance); - push(newState); - return; - } - case CONTAINED_RESOURCES: - case CONTAINED_RESOURCE_LIST: - case EXTENSION_DECLARED: - case PRIMITIVE_XHTML: - case PRIMITIVE_XHTML_HL7ORG: - case RESOURCE: - case RESOURCE_BLOCK: - case UNDECL_EXT: - break; + case COMPOSITE_DATATYPE: { + BaseRuntimeElementCompositeDefinition compositeTarget = (BaseRuntimeElementCompositeDefinition) target; + ICompositeType newChildInstance = (ICompositeType) compositeTarget.newInstance(); + myExtension.setValue(newChildInstance); + ElementCompositeState newState = new ElementCompositeState(getPreResourceState(), theLocalPart, compositeTarget, newChildInstance); + push(newState); + return; + } + case ID_DATATYPE: + case PRIMITIVE_DATATYPE: { + RuntimePrimitiveDatatypeDefinition primitiveTarget = (RuntimePrimitiveDatatypeDefinition) target; + IPrimitiveType newChildInstance = primitiveTarget.newInstance(); + myExtension.setValue(newChildInstance); + PrimitiveState newState = new PrimitiveState(getPreResourceState(), newChildInstance); + push(newState); + return; + } + case CONTAINED_RESOURCES: + case CONTAINED_RESOURCE_LIST: + case EXTENSION_DECLARED: + case PRIMITIVE_XHTML: + case PRIMITIVE_XHTML_HL7ORG: + case RESOURCE: + case RESOURCE_BLOCK: + case UNDECL_EXT: + break; } } @@ -890,7 +854,6 @@ class ParserState { } - private abstract class PreResourceState extends BaseState { private Map myContainedResources; @@ -1008,14 +971,14 @@ class ParserState { if (wantedProfileType != null && !wantedProfileType.equals(myInstance.getClass())) { if (myResourceType == null || myResourceType.isAssignableFrom(wantedProfileType)) { - ourLog.debug("Converting resource of type {} to type defined for profile \"{}\": {}", new Object[] { myInstance.getClass().getName(), usedProfile, wantedProfileType }); + ourLog.debug("Converting resource of type {} to type defined for profile \"{}\": {}", new Object[]{myInstance.getClass().getName(), usedProfile, wantedProfileType}); /* * This isn't the most efficient thing really.. If we want a specific * type we just re-parse into that type. The problem is that we don't know * until we've parsed the resource which type we want to use because the * profile declarations are in the text of the resource itself. - * + * * At some point it would be good to write code which can present a view * of one type backed by another type and use that. */ @@ -1094,7 +1057,7 @@ class ParserState { @Override public void acceptElement(IBaseResource theResource, IBase theElement, List thePathToElement, BaseRuntimeChildDefinition theChildDefinition, - BaseRuntimeElementDefinition theDefinition) { + BaseRuntimeElementDefinition theDefinition) { if (theElement instanceof BaseResourceReferenceDt) { BaseResourceReferenceDt nextRef = (BaseResourceReferenceDt) theElement; String ref = nextRef.getReference().getValue(); @@ -1137,7 +1100,7 @@ class ParserState { private class PreResourceStateHapi extends PreResourceState { private IMutator myMutator; - private Object myTarget; + private IBase myTarget; public PreResourceStateHapi(Class theResourceType) { @@ -1145,7 +1108,7 @@ class ParserState { assert theResourceType == null || IResource.class.isAssignableFrom(theResourceType); } - public PreResourceStateHapi(Object theTarget, IMutator theMutator, Class theResourceType) { + public PreResourceStateHapi(IBase theTarget, IMutator theMutator, Class theResourceType) { super(theResourceType); myTarget = theTarget; myMutator = theMutator; @@ -1175,18 +1138,18 @@ class ParserState { String resourceName = myContext.getResourceDefinition(nextResource).getName(); String bundleIdPart = nextResource.getId().getIdPart(); if (isNotBlank(bundleIdPart)) { - // if (isNotBlank(entryBaseUrl)) { - // nextResource.setId(new IdDt(entryBaseUrl, resourceName, bundleIdPart, version)); - // } else { - IdDt previousId = nextResource.getId(); - nextResource.setId(new IdDt(null, resourceName, bundleIdPart, version)); - // Copy extensions - if (!previousId.getAllUndeclaredExtensions().isEmpty()) { - for (final ExtensionDt ext : previousId.getAllUndeclaredExtensions()) { - nextResource.getId().addUndeclaredExtension(ext); - } - } - // } + // if (isNotBlank(entryBaseUrl)) { + // nextResource.setId(new IdDt(entryBaseUrl, resourceName, bundleIdPart, version)); + // } else { + IdDt previousId = nextResource.getId(); + nextResource.setId(new IdDt(null, resourceName, bundleIdPart, version)); + // Copy extensions + if (!previousId.getAllUndeclaredExtensions().isEmpty()) { + for (final ExtensionDt ext : previousId.getAllUndeclaredExtensions()) { + nextResource.getId().addUndeclaredExtension(ext); + } + } + // } } } @@ -1195,13 +1158,13 @@ class ParserState { private class PreResourceStateHl7Org extends PreResourceState { private IMutator myMutator; - private Object myTarget; + private IBase myTarget; public PreResourceStateHl7Org(Class theResourceType) { super(theResourceType); } - public PreResourceStateHl7Org(Object theTarget, IMutator theMutator, Class theResourceType) { + public PreResourceStateHl7Org(IBase theTarget, IMutator theMutator, Class theResourceType) { super(theResourceType); myMutator = theMutator; myTarget = theTarget; @@ -1463,21 +1426,21 @@ class ParserState { String value = defaultIfBlank(theValue, null); switch (mySubState) { - case TERM: - myTerm = (value); - break; - case LABEL: - myLabel = (value); - break; - case SCHEME: - myScheme = (value); - break; - case NONE: - // This handles JSON encoding, which is a bit weird - enteringNewElement(null, theName); - attributeValue(null, value); - endingElement(); - break; + case TERM: + myTerm = (value); + break; + case LABEL: + myLabel = (value); + break; + case SCHEME: + myScheme = (value); + break; + case NONE: + // This handles JSON encoding, which is a bit weird + enteringNewElement(null, theName); + attributeValue(null, value); + endingElement(); + break; } } @@ -1604,4 +1567,32 @@ class ParserState { } + /** + * @param theResourceType May be null + */ + static ParserState getPreResourceInstance(IParser theParser, Class theResourceType, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) + throws DataFormatException { + ParserState retVal = new ParserState(theParser, theContext, theJsonMode, theErrorHandler); + if (theResourceType == null) { + if (theContext.getVersion().getVersion().isRi()) { + retVal.push(retVal.new PreResourceStateHl7Org(theResourceType)); + } else { + retVal.push(retVal.new PreResourceStateHapi(theResourceType)); + } + } else { + if (IResource.class.isAssignableFrom(theResourceType)) { + retVal.push(retVal.new PreResourceStateHapi(theResourceType)); + } else { + retVal.push(retVal.new PreResourceStateHl7Org(theResourceType)); + } + } + return retVal; + } + + static ParserState getPreTagListInstance(IParser theParser, FhirContext theContext, boolean theJsonMode, IParserErrorHandler theErrorHandler) { + ParserState retVal = new ParserState(theParser, theContext, theJsonMode, theErrorHandler); + retVal.push(retVal.new PreTagListState()); + return retVal; + } + } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java index ebd305e4a47..c1b866a0489 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java @@ -354,17 +354,10 @@ public class XmlParser extends BaseParser { } if (nextChild instanceof RuntimeChildNarrativeDefinition) { + INarrative narr = (INarrative) nextChild.getAccessor().getFirstValueOrNull(theElement); + INarrativeGenerator gen = myContext.getNarrativeGenerator(); - INarrative narr; - if (theResource instanceof IResource) { - narr = ((IResource) theResource).getText(); - } else if (theResource instanceof IDomainResource) { - narr = ((IDomainResource) theResource).getText(); - } else { - narr = null; - } - // FIXME potential null access on narr see line 623 - if (gen != null && narr.isEmpty()) { + if (gen != null && (narr == null || narr.isEmpty())) { gen.populateResourceNarrative(myContext, theResource); } if (narr != null && narr.isEmpty() == false) { diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/FhirTerser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/FhirTerser.java index e0ff89a043f..161ab949a26 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/FhirTerser.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/FhirTerser.java @@ -216,12 +216,12 @@ public class FhirTerser { } public Object getSingleValueOrNull(IBase theTarget, String thePath) { - Class wantedType = Object.class; + Class wantedType = IBase.class; return getSingleValueOrNull(theTarget, thePath, wantedType); } - public T getSingleValueOrNull(IBase theTarget, String thePath, Class theWantedType) { + public T getSingleValueOrNull(IBase theTarget, String thePath, Class theWantedType) { Validate.notNull(theTarget, "theTarget must not be null"); Validate.notBlank(thePath, "thePath must not be empty"); @@ -241,12 +241,12 @@ public class FhirTerser { return retVal.get(0); } - private List getValues(BaseRuntimeElementCompositeDefinition theCurrentDef, Object theCurrentObj, List theSubList, Class theWantedClass) { + private List getValues(BaseRuntimeElementCompositeDefinition theCurrentDef, IBase theCurrentObj, List theSubList, Class theWantedClass) { return getValues(theCurrentDef, theCurrentObj, theSubList, theWantedClass, false, false); } @SuppressWarnings("unchecked") - private List getValues(BaseRuntimeElementCompositeDefinition theCurrentDef, Object theCurrentObj, List theSubList, Class theWantedClass, boolean theCreate, boolean theAddExtension) { + private List getValues(BaseRuntimeElementCompositeDefinition theCurrentDef, IBase theCurrentObj, List theSubList, Class theWantedClass, boolean theCreate, boolean theAddExtension) { String name = theSubList.get(0); List retVal = new ArrayList<>(); @@ -325,7 +325,7 @@ public class FhirTerser { List values = retVal; retVal = new ArrayList<>(); for (T nextElement : values) { - BaseRuntimeElementCompositeDefinition nextChildDef = (BaseRuntimeElementCompositeDefinition) myContext.getElementDefinition((Class) nextElement.getClass()); + BaseRuntimeElementCompositeDefinition nextChildDef = (BaseRuntimeElementCompositeDefinition) myContext.getElementDefinition(nextElement.getClass()); List foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass, theCreate, theAddExtension); retVal.addAll(foundValues); } @@ -410,7 +410,7 @@ public class FhirTerser { List values = retVal; retVal = new ArrayList<>(); for (T nextElement : values) { - BaseRuntimeElementCompositeDefinition nextChildDef = (BaseRuntimeElementCompositeDefinition) myContext.getElementDefinition((Class) nextElement.getClass()); + BaseRuntimeElementCompositeDefinition nextChildDef = (BaseRuntimeElementCompositeDefinition) myContext.getElementDefinition(nextElement.getClass()); List foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass, theCreate, theAddExtension); retVal.addAll(foundValues); } @@ -476,9 +476,10 @@ public class FhirTerser { * @return A list of values of type {@link Object}. */ public List getValues(IBaseResource theResource, String thePath) { - Class wantedClass = Object.class; + Class wantedClass = IBase.class; - return getValues(theResource, thePath, wantedClass); + List values = getValues(theResource, thePath, wantedClass); + return values; } /** @@ -491,9 +492,10 @@ public class FhirTerser { * @return A list of values of type {@link Object}. */ public List getValues(IBaseResource theResource, String thePath, boolean theCreate) { - Class wantedClass = Object.class; + Class wantedClass = IBase.class; - return getValues(theResource, thePath, wantedClass, theCreate); + List retVal = getValues(theResource, thePath, wantedClass, theCreate); + return retVal; } /** @@ -507,9 +509,10 @@ public class FhirTerser { * @return A list of values of type {@link Object}. */ public List getValues(IBaseResource theResource, String thePath, boolean theCreate, boolean theAddExtension) { - Class wantedClass = Object.class; + Class wantedClass = IBase.class; - return getValues(theResource, thePath, wantedClass, theCreate, theAddExtension); + List retVal = getValues(theResource, thePath, wantedClass, theCreate, theAddExtension); + return retVal; } /** @@ -522,7 +525,7 @@ public class FhirTerser { * @param Type declared by theWantedClass * @return A list of values of type theWantedClass. */ - public List getValues(IBaseResource theResource, String thePath, Class theWantedClass) { + public List getValues(IBaseResource theResource, String thePath, Class theWantedClass) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource); List parts = parsePath(def, thePath); return getValues(def, theResource, parts, theWantedClass); @@ -539,7 +542,7 @@ public class FhirTerser { * @param Type declared by theWantedClass * @return A list of values of type theWantedClass. */ - public List getValues(IBaseResource theResource, String thePath, Class theWantedClass, boolean theCreate) { + public List getValues(IBaseResource theResource, String thePath, Class theWantedClass, boolean theCreate) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource); List parts = parsePath(def, thePath); return getValues(def, theResource, parts, theWantedClass, theCreate, false); @@ -557,7 +560,7 @@ public class FhirTerser { * @param Type declared by theWantedClass * @return A list of values of type theWantedClass. */ - public List getValues(IBaseResource theResource, String thePath, Class theWantedClass, boolean theCreate, boolean theAddExtension) { + public List getValues(IBaseResource theResource, String thePath, Class theWantedClass, boolean theCreate, boolean theAddExtension) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource); List parts = parsePath(def, thePath); return getValues(def, theResource, parts, theWantedClass, theCreate, theAddExtension); diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index d7c8c3373db..1ea96f82d6a 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -276,6 +276,12 @@ org.apache.commons commons-dbcp2 test + + + commons-logging + commons-logging + + junit @@ -500,6 +506,12 @@ org.hibernate hibernate-search-elasticsearch + + + commons-logging + commons-logging + + diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IJpaDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IJpaDao.java index c0523f0a3bb..d90d97d969a 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IJpaDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/IJpaDao.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.dao; +/*- + * #%L + * HAPI FHIR JPA Server + * %% + * Copyright (C) 2014 - 2019 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.rest.api.server.RequestDetails; import org.hl7.fhir.instance.model.api.IBaseResource; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilder.java index d422687feae..5f4fe3de927 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilder.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.search.elastic; +/*- + * #%L + * HAPI FHIR JPA Server + * %% + * Copyright (C) 2014 - 2019 University Health Network + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ + import org.hibernate.search.cfg.Environment; import org.hibernate.search.elasticsearch.cfg.ElasticsearchEnvironment; import org.hibernate.search.elasticsearch.cfg.ElasticsearchIndexStatus; diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchMappingProvider.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchMappingProvider.java index f82209cbdb2..adf053bf692 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchMappingProvider.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchMappingProvider.java @@ -2,7 +2,7 @@ package ca.uhn.fhir.jpa.search.elastic; /*- * #%L - * HAPI FHIR JPA Server - ElasticSearch Integration + * HAPI FHIR JPA Server * %% * Copyright (C) 2014 - 2019 University Health Network * %% diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java index 876ab67b838..990b8454a62 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java @@ -80,8 +80,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { bulkExportJob.addIndex("IDX_BLKEX_EXPTIME").unique(false).withColumns("EXP_TIME"); bulkExportJob.addIndex("IDX_BLKEX_JOB_ID").unique(true).withColumns("JOB_ID"); - - // HFJ_BLK_EXPORT_COLLECTION + // HFJ_BLK_EXPORT_COLLECTION version.addIdGenerator("SEQ_BLKEXCOL_PID"); Builder.BuilderAddTableByColumns bulkExportCollection = version.addTableByColumns("HFJ_BLK_EXPORT_COLLECTION", "PID"); bulkExportCollection.addColumn("PID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG); @@ -99,7 +98,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { bulkExportCollectionFile.addColumn("RES_ID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 100); bulkExportCollectionFile.addForeignKey("FK_BLKEXCOLFILE_COLLECT").toColumn("COLLECTION_PID").references("HFJ_BLK_EXPORT_COLLECTION", "PID"); - + // HFJ_RES_VER_PROV version.startSectionWithMessage("Processing bulkExportCollectionFile: HFJ_RES_VER_PROV"); Builder.BuilderAddTableByColumns resVerProv = version.addTableByColumns("HFJ_RES_VER_PROV", "RES_VER_PID"); resVerProv.addColumn("RES_VER_PID").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.LONG); @@ -149,7 +148,6 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { .unique(true) .withColumns("VALUESET_PID", "VALUESET_ORDER"); - // Account for RESTYPE_LEN column increasing from 30 to 35 version.onTable("HFJ_RESOURCE").modifyColumn("RES_TYPE").nonNullable().withType(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 35); version.onTable("HFJ_HISTORY_TAG").modifyColumn("RES_TYPE").nonNullable().withType(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 35); @@ -165,8 +163,9 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { version.startSectionWithMessage("Processing table: TRM_VALUESET_C_DESIGNATION"); version.onTable("TRM_VALUESET_C_DESIGNATION").modifyColumn("VAL").nonNullable().withType(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 2000); + // TermConceptProperty version.startSectionWithMessage("Processing table: TRM_CONCEPT_PROPERTY"); - version.onTable("TRM_CONCEPT_PROPERTY").addColumn("PROP_VAL_LOB").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.CLOB); + version.onTable("TRM_CONCEPT_PROPERTY").addColumn("PROP_VAL_LOB").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.BLOB); } protected void init400() { diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/JsonParserDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/JsonParserDstu3Test.java index 2a9e8f42798..f6c411a272a 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/JsonParserDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/JsonParserDstu3Test.java @@ -319,6 +319,29 @@ public class JsonParserDstu3Test { } + /** + * See #402 + */ + @Test + public void testEncodeCompositionDoesntOverwriteNarrative() { + FhirContext ctx = FhirContext.forDstu3(); + ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); + + Composition composition = new Composition(); + composition.getText().setDivAsString("
root
"); + composition.addSection().getText().setDivAsString("
section0
"); + composition.addSection().getText().setDivAsString("
section1
"); + + String output = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(composition); + ourLog.info(output); + + assertThat(output, containsString("
root
")); + assertThat(output, containsString("
section0
")); + assertThat(output, containsString("
section1
")); + + } + + @Test public void testEncodeAndParseMetaProfileAndTags() { Patient p = new Patient(); diff --git a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java index d44704e9365..8f49131707a 100644 --- a/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java +++ b/hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/parser/XmlParserDstu3Test.java @@ -1070,6 +1070,28 @@ public class XmlParserDstu3Test { assertEquals("grandparent", gp.getName()); } + /** + * See #402 + */ + @Test + public void testEncodeCompositionDoesntOverwriteNarrative() { + FhirContext ctx = FhirContext.forDstu3(); + ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator()); + + Composition composition = new Composition(); + composition.getText().setDivAsString("
root
"); + composition.addSection().getText().setDivAsString("
section0
"); + composition.addSection().getText().setDivAsString("
section1
"); + + String output = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(composition); + ourLog.info(output); + + assertThat(output, containsString("
root
")); + assertThat(output, containsString("
section0
")); + assertThat(output, containsString("
section1
")); + + } + /** * See #326 */ diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/JsonParserR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/JsonParserR4Test.java index f3d4897a10a..cf9a68e5f4a 100644 --- a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/JsonParserR4Test.java +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/JsonParserR4Test.java @@ -447,6 +447,34 @@ public class JsonParserR4Test { assertEquals("535", ((StringType) houseNumberExt.getValue()).getValue()); } + + private Composition createComposition(String sectionText) { + Composition c = new Composition(); + Narrative compositionText = new Narrative().setStatus(Narrative.NarrativeStatus.GENERATED); + compositionText.setDivAsString("Composition"); + Narrative compositionSectionText = new Narrative().setStatus(Narrative.NarrativeStatus.GENERATED); + compositionSectionText.setDivAsString(sectionText); + c.setText(compositionText); + c.addSection().setText(compositionSectionText); + return c; + } + + /** + * See #402 (however JSON is fine) + */ + @Test + public void testEncodingTextSection() { + + String sectionText = "sectionText"; + Composition composition = createComposition(sectionText); + + String encoded = ourCtx.newJsonParser().encodeResourceToString(composition); + ourLog.info(encoded); + + int idx = encoded.indexOf(sectionText); + assertNotEquals(-1, idx); + } + /** * 2019-09-19 - Pre #1489 diff --git a/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/XmlParserR4Test.java b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/XmlParserR4Test.java new file mode 100644 index 00000000000..cf97110174f --- /dev/null +++ b/hapi-fhir-structures-r4/src/test/java/ca/uhn/fhir/parser/XmlParserR4Test.java @@ -0,0 +1,45 @@ +package ca.uhn.fhir.parser; + +import static org.junit.Assert.assertNotEquals; + +import org.hl7.fhir.r4.model.Composition; +import org.hl7.fhir.r4.model.Narrative; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ca.uhn.fhir.context.FhirContext; + +public class XmlParserR4Test { + private static final Logger ourLog = LoggerFactory.getLogger(XmlParserR4Test.class); + private static FhirContext ourCtx = FhirContext.forR4(); + + + private Composition createComposition(String sectionText) { + Composition c = new Composition(); + Narrative compositionText = new Narrative().setStatus(Narrative.NarrativeStatus.GENERATED); + compositionText.setDivAsString("Composition"); + Narrative compositionSectionText = new Narrative().setStatus(Narrative.NarrativeStatus.GENERATED); + compositionSectionText.setDivAsString(sectionText); + c.setText(compositionText); + c.addSection().setText(compositionSectionText); + return c; + } + + /** + * See #402 section.text is overwritten by composition.text + */ + @Test + public void testEncodingTextSection() { + + String sectionText = "sectionText"; + Composition composition = createComposition(sectionText); + + String encoded = ourCtx.newXmlParser().encodeResourceToString(composition); + ourLog.info(encoded); + + int idx = encoded.indexOf(sectionText); + assertNotEquals(-1, idx); + } + +} diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-head.html b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-head.html index 6b43eeb5e7c..501fb23344f 100644 --- a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-head.html +++ b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-head.html @@ -20,7 +20,7 @@ - + diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/js/RestfulTester.js b/hapi-fhir-testpage-overlay/src/main/webapp/js/RestfulTester.js index 97ca8de63ab..e850cf544f1 100644 --- a/hapi-fhir-testpage-overlay/src/main/webapp/js/RestfulTester.js +++ b/hapi-fhir-testpage-overlay/src/main/webapp/js/RestfulTester.js @@ -331,8 +331,8 @@ function addSearchControlDate(theSearchParamName, theContainerRowNum, theRowNum, ) ); input.datetimepicker({ - pickTime: false, - showToday: true + format: "YYYY-MM-DD", + showTodayButton: true }); // Set up the qualifier dropdown after we've initialized the datepicker, since it // overrides all addon buttons while it inits.. @@ -547,4 +547,4 @@ $( document ).ready(function() { if (conformance) { addSearchParamRow(); } -}); \ No newline at end of file +}); diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/js/moment-with-locales.min.js b/hapi-fhir-testpage-overlay/src/main/webapp/js/moment-with-locales.min.js new file mode 100644 index 00000000000..7e7fc7a126a --- /dev/null +++ b/hapi-fhir-testpage-overlay/src/main/webapp/js/moment-with-locales.min.js @@ -0,0 +1,6 @@ +//! moment-with-locales.js +//! version : 2.24.0 +//! authors : Tim Wood, Iskren Chernev, Moment.js contributors +//! license : MIT +//! momentjs.com +!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a():"function"==typeof define&&define.amd?define(a):e.moment=a()}(this,function(){"use strict";var e,n;function l(){return e.apply(null,arguments)}function _(e){return e instanceof Array||"[object Array]"===Object.prototype.toString.call(e)}function i(e){return null!=e&&"[object Object]"===Object.prototype.toString.call(e)}function o(e){return void 0===e}function m(e){return"number"==typeof e||"[object Number]"===Object.prototype.toString.call(e)}function u(e){return e instanceof Date||"[object Date]"===Object.prototype.toString.call(e)}function M(e,a){var t,s=[];for(t=0;t>>0,s=0;sTe(e)?(d=e+1,_-Te(e)):(d=e,_),{year:d,dayOfYear:r}}function Ce(e,a,t){var s,n,d=Ne(e.year(),a,t),r=Math.floor((e.dayOfYear()-d-1)/7)+1;return r<1?s=r+Ie(n=e.year()-1,a,t):r>Ie(e.year(),a,t)?(s=r-Ie(e.year(),a,t),n=e.year()+1):(n=e.year(),s=r),{week:s,year:n}}function Ie(e,a,t){var s=Ne(e,a,t),n=Ne(e+1,a,t);return(Te(e)-s+n)/7}C("w",["ww",2],"wo","week"),C("W",["WW",2],"Wo","isoWeek"),O("week","w"),O("isoWeek","W"),E("week",5),E("isoWeek",5),ie("w",B),ie("ww",B,V),ie("W",B),ie("WW",B,V),Me(["w","ww","W","WW"],function(e,a,t,s){a[s.substr(0,1)]=g(e)});function Ue(e,a){return e.slice(a,7).concat(e.slice(0,a))}C("d",0,"do","day"),C("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),C("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),C("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),C("e",0,0,"weekday"),C("E",0,0,"isoWeekday"),O("day","d"),O("weekday","e"),O("isoWeekday","E"),E("day",11),E("weekday",11),E("isoWeekday",11),ie("d",B),ie("e",B),ie("E",B),ie("dd",function(e,a){return a.weekdaysMinRegex(e)}),ie("ddd",function(e,a){return a.weekdaysShortRegex(e)}),ie("dddd",function(e,a){return a.weekdaysRegex(e)}),Me(["dd","ddd","dddd"],function(e,a,t,s){var n=t._locale.weekdaysParse(e,s,t._strict);null!=n?a.d=n:Y(t).invalidWeekday=e}),Me(["d","e","E"],function(e,a,t,s){a[s]=g(e)});var Ge="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_");var Ve="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_");var Ke="Su_Mo_Tu_We_Th_Fr_Sa".split("_");var Ze=re;var $e=re;var Be=re;function qe(){function e(e,a){return a.length-e.length}var a,t,s,n,d,r=[],_=[],i=[],o=[];for(a=0;a<7;a++)t=c([2e3,1]).day(a),s=this.weekdaysMin(t,""),n=this.weekdaysShort(t,""),d=this.weekdays(t,""),r.push(s),_.push(n),i.push(d),o.push(s),o.push(n),o.push(d);for(r.sort(e),_.sort(e),i.sort(e),o.sort(e),a=0;a<7;a++)_[a]=me(_[a]),i[a]=me(i[a]),o[a]=me(o[a]);this._weekdaysRegex=new RegExp("^("+o.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+_.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+r.join("|")+")","i")}function Qe(){return this.hours()%12||12}function Xe(e,a){C(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),a)})}function ea(e,a){return a._meridiemParse}C("H",["HH",2],0,"hour"),C("h",["hh",2],0,Qe),C("k",["kk",2],0,function(){return this.hours()||24}),C("hmm",0,0,function(){return""+Qe.apply(this)+F(this.minutes(),2)}),C("hmmss",0,0,function(){return""+Qe.apply(this)+F(this.minutes(),2)+F(this.seconds(),2)}),C("Hmm",0,0,function(){return""+this.hours()+F(this.minutes(),2)}),C("Hmmss",0,0,function(){return""+this.hours()+F(this.minutes(),2)+F(this.seconds(),2)}),Xe("a",!0),Xe("A",!1),O("hour","h"),E("hour",13),ie("a",ea),ie("A",ea),ie("H",B),ie("h",B),ie("k",B),ie("HH",B,V),ie("hh",B,V),ie("kk",B,V),ie("hmm",q),ie("hmmss",Q),ie("Hmm",q),ie("Hmmss",Q),le(["H","HH"],Ye),le(["k","kk"],function(e,a,t){var s=g(e);a[Ye]=24===s?0:s}),le(["a","A"],function(e,a,t){t._isPm=t._locale.isPM(e),t._meridiem=e}),le(["h","hh"],function(e,a,t){a[Ye]=g(e),Y(t).bigHour=!0}),le("hmm",function(e,a,t){var s=e.length-2;a[Ye]=g(e.substr(0,s)),a[ye]=g(e.substr(s)),Y(t).bigHour=!0}),le("hmmss",function(e,a,t){var s=e.length-4,n=e.length-2;a[Ye]=g(e.substr(0,s)),a[ye]=g(e.substr(s,2)),a[fe]=g(e.substr(n)),Y(t).bigHour=!0}),le("Hmm",function(e,a,t){var s=e.length-2;a[Ye]=g(e.substr(0,s)),a[ye]=g(e.substr(s))}),le("Hmmss",function(e,a,t){var s=e.length-4,n=e.length-2;a[Ye]=g(e.substr(0,s)),a[ye]=g(e.substr(s,2)),a[fe]=g(e.substr(n))});var aa,ta=Se("Hours",!0),sa={calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},longDateFormat:{LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},invalidDate:"Invalid date",ordinal:"%d",dayOfMonthOrdinalParse:/\d{1,2}/,relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},months:Oe,monthsShort:Pe,week:{dow:0,doy:6},weekdays:Ge,weekdaysMin:Ke,weekdaysShort:Ve,meridiemParse:/[ap]\.?m?\.?/i},na={},da={};function ra(e){return e?e.toLowerCase().replace("_","-"):e}function _a(e){var a=null;if(!na[e]&&"undefined"!=typeof module&&module&&module.exports)try{a=aa._abbr,require("./locale/"+e),ia(a)}catch(e){}return na[e]}function ia(e,a){var t;return e&&((t=o(a)?ma(e):oa(e,a))?aa=t:"undefined"!=typeof console&&console.warn&&console.warn("Locale "+e+" not found. Did you forget to load it?")),aa._abbr}function oa(e,a){if(null===a)return delete na[e],null;var t,s=sa;if(a.abbr=e,null!=na[e])S("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),s=na[e]._config;else if(null!=a.parentLocale)if(null!=na[a.parentLocale])s=na[a.parentLocale]._config;else{if(null==(t=_a(a.parentLocale)))return da[a.parentLocale]||(da[a.parentLocale]=[]),da[a.parentLocale].push({name:e,config:a}),null;s=t._config}return na[e]=new j(b(s,a)),da[e]&&da[e].forEach(function(e){oa(e.name,e.config)}),ia(e),na[e]}function ma(e){var a;if(e&&e._locale&&e._locale._abbr&&(e=e._locale._abbr),!e)return aa;if(!_(e)){if(a=_a(e))return a;e=[e]}return function(e){for(var a,t,s,n,d=0;d=a&&r(n,t,!0)>=a-1)break;a--}d++}return aa}(e)}function ua(e){var a,t=e._a;return t&&-2===Y(e).overflow&&(a=t[Le]<0||11je(t[he],t[Le])?ce:t[Ye]<0||24Ie(t,d,r)?Y(e)._overflowWeeks=!0:null!=i?Y(e)._overflowWeekday=!0:(_=Re(t,s,n,d,r),e._a[he]=_.year,e._dayOfYear=_.dayOfYear)}(e),null!=e._dayOfYear&&(d=la(e._a[he],s[he]),(e._dayOfYear>Te(d)||0===e._dayOfYear)&&(Y(e)._overflowDayOfYear=!0),t=Je(d,0,e._dayOfYear),e._a[Le]=t.getUTCMonth(),e._a[ce]=t.getUTCDate()),a=0;a<3&&null==e._a[a];++a)e._a[a]=r[a]=s[a];for(;a<7;a++)e._a[a]=r[a]=null==e._a[a]?2===a?1:0:e._a[a];24===e._a[Ye]&&0===e._a[ye]&&0===e._a[fe]&&0===e._a[ke]&&(e._nextDay=!0,e._a[Ye]=0),e._d=(e._useUTC?Je:function(e,a,t,s,n,d,r){var _;return e<100&&0<=e?(_=new Date(e+400,a,t,s,n,d,r),isFinite(_.getFullYear())&&_.setFullYear(e)):_=new Date(e,a,t,s,n,d,r),_}).apply(null,r),n=e._useUTC?e._d.getUTCDay():e._d.getDay(),null!=e._tzm&&e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm),e._nextDay&&(e._a[Ye]=24),e._w&&void 0!==e._w.d&&e._w.d!==n&&(Y(e).weekdayMismatch=!0)}}var ha=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,La=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,ca=/Z|[+-]\d\d(?::?\d\d)?/,Ya=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],ya=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],fa=/^\/?Date\((\-?\d+)/i;function ka(e){var a,t,s,n,d,r,_=e._i,i=ha.exec(_)||La.exec(_);if(i){for(Y(e).iso=!0,a=0,t=Ya.length;at.valueOf():t.valueOf()this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},Mt.isLocal=function(){return!!this.isValid()&&!this._isUTC},Mt.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},Mt.isUtc=Ra,Mt.isUTC=Ra,Mt.zoneAbbr=function(){return this._isUTC?"UTC":""},Mt.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},Mt.dates=t("dates accessor is deprecated. Use date instead.",_t),Mt.months=t("months accessor is deprecated. Use month instead",Ae),Mt.years=t("years accessor is deprecated. Use year instead",ve),Mt.zone=t("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,a){return null!=e?("string"!=typeof e&&(e=-e),this.utcOffset(e,a),this):-this.utcOffset()}),Mt.isDSTShifted=t("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){if(!o(this._isDSTShifted))return this._isDSTShifted;var e={};if(k(e,this),(e=va(e))._a){var a=e._isUTC?c(e._a):Ha(e._a);this._isDSTShifted=this.isValid()&&0a?Math.ceil(a):Math.floor(a)}function l(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.lengthd;d++)(c&&a[d]!==b[d]||!c&&t(a[d])!==t(b[d]))&&g++;return g+f}function q(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=Zb[a]||$b[b]||b}return a}function r(a){var b,c,d={};for(c in a)a.hasOwnProperty(c)&&(b=q(c),b&&(d[b]=a[c]));return d}function s(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}ib[b]=function(e,f){var g,h,i=ib.fn._lang[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=ib().utc().set(d,a);return i.call(ib.fn._lang,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function t(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function u(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function v(a,b,c){return $(ib([a,11,31+b-c]),b,c).week}function w(a){return x(a)?366:365}function x(a){return a%4===0&&a%100!==0||a%400===0}function y(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[pb]<0||a._a[pb]>11?pb:a._a[qb]<1||a._a[qb]>u(a._a[ob],a._a[pb])?qb:a._a[rb]<0||a._a[rb]>23?rb:a._a[sb]<0||a._a[sb]>59?sb:a._a[tb]<0||a._a[tb]>59?tb:a._a[ub]<0||a._a[ub]>999?ub:-1,a._pf._overflowDayOfYear&&(ob>b||b>qb)&&(b=qb),a._pf.overflow=b)}function z(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!a._pf.empty&&!a._pf.invalidMonth&&!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length)),a._isValid}function A(a){return a?a.toLowerCase().replace("_","-"):a}function B(a,b){return b._isUTC?ib(a).zone(b._offset||0):ib(a).local()}function C(a,b){return b.abbr=a,vb[a]||(vb[a]=new f),vb[a].set(b),vb[a]}function D(a){delete vb[a]}function E(a){var b,c,d,e,f=0,g=function(a){if(!vb[a]&&xb)try{require("./lang/"+a)}catch(b){}return vb[a]};if(!a)return ib.fn._lang;if(!n(a)){if(c=g(a))return c;a=[a]}for(;f0;){if(c=g(e.slice(0,b).join("-")))return c;if(d&&d.length>=b&&p(e,d,!0)>=b-1)break;b--}f++}return ib.fn._lang}function F(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function G(a){var b,c,d=a.match(Bb);for(b=0,c=d.length;c>b;b++)d[b]=cc[d[b]]?cc[d[b]]:F(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function H(a,b){return a.isValid()?(b=I(b,a.lang()),_b[b]||(_b[b]=G(b)),_b[b](a)):a.lang().invalidDate()}function I(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(Cb.lastIndex=0;d>=0&&Cb.test(a);)a=a.replace(Cb,c),Cb.lastIndex=0,d-=1;return a}function J(a,b){var c,d=b._strict;switch(a){case"Q":return Nb;case"DDDD":return Pb;case"YYYY":case"GGGG":case"gggg":return d?Qb:Fb;case"Y":case"G":case"g":return Sb;case"YYYYYY":case"YYYYY":case"GGGGG":case"ggggg":return d?Rb:Gb;case"S":if(d)return Nb;case"SS":if(d)return Ob;case"SSS":if(d)return Pb;case"DDD":return Eb;case"MMM":case"MMMM":case"dd":case"ddd":case"dddd":return Ib;case"a":case"A":return E(b._l)._meridiemParse;case"X":return Lb;case"Z":case"ZZ":return Jb;case"T":return Kb;case"SSSS":return Hb;case"MM":case"DD":case"YY":case"GG":case"gg":case"HH":case"hh":case"mm":case"ss":case"ww":case"WW":return d?Ob:Db;case"M":case"D":case"d":case"H":case"h":case"m":case"s":case"w":case"W":case"e":case"E":return Db;case"Do":return Mb;default:return c=new RegExp(R(Q(a.replace("\\","")),"i"))}}function K(a){a=a||"";var b=a.match(Jb)||[],c=b[b.length-1]||[],d=(c+"").match(Xb)||["-",0,0],e=+(60*d[1])+t(d[2]);return"+"===d[0]?-e:e}function L(a,b,c){var d,e=c._a;switch(a){case"Q":null!=b&&(e[pb]=3*(t(b)-1));break;case"M":case"MM":null!=b&&(e[pb]=t(b)-1);break;case"MMM":case"MMMM":d=E(c._l).monthsParse(b),null!=d?e[pb]=d:c._pf.invalidMonth=b;break;case"D":case"DD":null!=b&&(e[qb]=t(b));break;case"Do":null!=b&&(e[qb]=t(parseInt(b,10)));break;case"DDD":case"DDDD":null!=b&&(c._dayOfYear=t(b));break;case"YY":e[ob]=ib.parseTwoDigitYear(b);break;case"YYYY":case"YYYYY":case"YYYYYY":e[ob]=t(b);break;case"a":case"A":c._isPm=E(c._l).isPM(b);break;case"H":case"HH":case"h":case"hh":e[rb]=t(b);break;case"m":case"mm":e[sb]=t(b);break;case"s":case"ss":e[tb]=t(b);break;case"S":case"SS":case"SSS":case"SSSS":e[ub]=t(1e3*("0."+b));break;case"X":c._d=new Date(1e3*parseFloat(b));break;case"Z":case"ZZ":c._useUTC=!0,c._tzm=K(b);break;case"w":case"ww":case"W":case"WW":case"d":case"dd":case"ddd":case"dddd":case"e":case"E":a=a.substr(0,1);case"gg":case"gggg":case"GG":case"GGGG":case"GGGGG":a=a.substr(0,2),b&&(c._w=c._w||{},c._w[a]=b)}}function M(a){var b,c,d,e,f,g,h,i,j,k,l=[];if(!a._d){for(d=O(a),a._w&&null==a._a[qb]&&null==a._a[pb]&&(f=function(b){var c=parseInt(b,10);return b?b.length<3?c>68?1900+c:2e3+c:c:null==a._a[ob]?ib().weekYear():a._a[ob]},g=a._w,null!=g.GG||null!=g.W||null!=g.E?h=_(f(g.GG),g.W||1,g.E,4,1):(i=E(a._l),j=null!=g.d?X(g.d,i):null!=g.e?parseInt(g.e,10)+i._week.dow:0,k=parseInt(g.w,10)||1,null!=g.d&&jw(e)&&(a._pf._overflowDayOfYear=!0),c=W(e,0,a._dayOfYear),a._a[pb]=c.getUTCMonth(),a._a[qb]=c.getUTCDate()),b=0;3>b&&null==a._a[b];++b)a._a[b]=l[b]=d[b];for(;7>b;b++)a._a[b]=l[b]=null==a._a[b]?2===b?1:0:a._a[b];l[rb]+=t((a._tzm||0)/60),l[sb]+=t((a._tzm||0)%60),a._d=(a._useUTC?W:V).apply(null,l)}}function N(a){var b;a._d||(b=r(a._i),a._a=[b.year,b.month,b.day,b.hour,b.minute,b.second,b.millisecond],M(a))}function O(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function P(a){a._a=[],a._pf.empty=!0;var b,c,d,e,f,g=E(a._l),h=""+a._i,i=h.length,j=0;for(d=I(a._f,g).match(Bb)||[],b=0;b0&&a._pf.unusedInput.push(f),h=h.slice(h.indexOf(c)+c.length),j+=c.length),cc[e]?(c?a._pf.empty=!1:a._pf.unusedTokens.push(e),L(e,c,a)):a._strict&&!c&&a._pf.unusedTokens.push(e);a._pf.charsLeftOver=i-j,h.length>0&&a._pf.unusedInput.push(h),a._isPm&&a._a[rb]<12&&(a._a[rb]+=12),a._isPm===!1&&12===a._a[rb]&&(a._a[rb]=0),M(a),y(a)}function Q(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e})}function R(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function S(a){var c,d,e,f,g;if(0===a._f.length)return a._pf.invalidFormat=!0,void(a._d=new Date(0/0));for(f=0;fg)&&(e=g,d=c));i(a,d||c)}function T(a){var b,c,d=a._i,e=Tb.exec(d);if(e){for(a._pf.iso=!0,b=0,c=Vb.length;c>b;b++)if(Vb[b][1].exec(d)){a._f=Vb[b][0]+(e[6]||" ");break}for(b=0,c=Wb.length;c>b;b++)if(Wb[b][1].exec(d)){a._f+=Wb[b][0];break}d.match(Jb)&&(a._f+="Z"),P(a)}else ib.createFromInputFallback(a)}function U(b){var c=b._i,d=yb.exec(c);c===a?b._d=new Date:d?b._d=new Date(+d[1]):"string"==typeof c?T(b):n(c)?(b._a=c.slice(0),M(b)):o(c)?b._d=new Date(+c):"object"==typeof c?N(b):"number"==typeof c?b._d=new Date(c):ib.createFromInputFallback(b)}function V(a,b,c,d,e,f,g){var h=new Date(a,b,c,d,e,f,g);return 1970>a&&h.setFullYear(a),h}function W(a){var b=new Date(Date.UTC.apply(null,arguments));return 1970>a&&b.setUTCFullYear(a),b}function X(a,b){if("string"==typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!=typeof a)return null}else a=parseInt(a,10);return a}function Y(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function Z(a,b,c){var d=nb(Math.abs(a)/1e3),e=nb(d/60),f=nb(e/60),g=nb(f/24),h=nb(g/365),i=45>d&&["s",d]||1===e&&["m"]||45>e&&["mm",e]||1===f&&["h"]||22>f&&["hh",f]||1===g&&["d"]||25>=g&&["dd",g]||45>=g&&["M"]||345>g&&["MM",nb(g/30)]||1===h&&["y"]||["yy",h];return i[2]=b,i[3]=a>0,i[4]=c,Y.apply({},i)}function $(a,b,c){var d,e=c-b,f=c-a.day();return f>e&&(f-=7),e-7>f&&(f+=7),d=ib(a).add("d",f),{week:Math.ceil(d.dayOfYear()/7),year:d.year()}}function _(a,b,c,d,e){var f,g,h=W(a,0,1).getUTCDay();return c=null!=c?c:e,f=e-h+(h>d?7:0)-(e>h?7:0),g=7*(b-1)+(c-e)+f+1,{year:g>0?a:a-1,dayOfYear:g>0?g:w(a-1)+g}}function ab(b){var c=b._i,d=b._f;return null===c||d===a&&""===c?ib.invalid({nullInput:!0}):("string"==typeof c&&(b._i=c=E().preparse(c)),ib.isMoment(c)?(b=j(c),b._d=new Date(+c._d)):d?n(d)?S(b):P(b):U(b),new g(b))}function bb(a,b){var c;return"string"==typeof b&&(b=a.lang().monthsParse(b),"number"!=typeof b)?a:(c=Math.min(a.date(),u(a.year(),b)),a._d["set"+(a._isUTC?"UTC":"")+"Month"](b,c),a)}function cb(a,b){return a._d["get"+(a._isUTC?"UTC":"")+b]()}function db(a,b,c){return"Month"===b?bb(a,c):a._d["set"+(a._isUTC?"UTC":"")+b](c)}function eb(a,b){return function(c){return null!=c?(db(this,a,c),ib.updateOffset(this,b),this):cb(this,a)}}function fb(a){ib.duration.fn[a]=function(){return this._data[a]}}function gb(a,b){ib.duration.fn["as"+a]=function(){return+this/b}}function hb(a){"undefined"==typeof ender&&(jb=mb.moment,mb.moment=a?c("Accessing Moment through the global scope is deprecated, and will be removed in an upcoming release.",ib):ib)}for(var ib,jb,kb,lb="2.6.0",mb="undefined"!=typeof global?global:this,nb=Math.round,ob=0,pb=1,qb=2,rb=3,sb=4,tb=5,ub=6,vb={},wb={_isAMomentObject:null,_i:null,_f:null,_l:null,_strict:null,_isUTC:null,_offset:null,_pf:null,_lang:null},xb="undefined"!=typeof module&&module.exports,yb=/^\/?Date\((\-?\d+)/i,zb=/(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/,Ab=/^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/,Bb=/(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g,Cb=/(\[[^\[]*\])|(\\)?(LT|LL?L?L?|l{1,4})/g,Db=/\d\d?/,Eb=/\d{1,3}/,Fb=/\d{1,4}/,Gb=/[+\-]?\d{1,6}/,Hb=/\d+/,Ib=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,Jb=/Z|[\+\-]\d\d:?\d\d/gi,Kb=/T/i,Lb=/[\+\-]?\d+(\.\d{1,3})?/,Mb=/\d{1,2}/,Nb=/\d/,Ob=/\d\d/,Pb=/\d{3}/,Qb=/\d{4}/,Rb=/[+-]?\d{6}/,Sb=/[+-]?\d+/,Tb=/^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ub="YYYY-MM-DDTHH:mm:ssZ",Vb=[["YYYYYY-MM-DD",/[+-]\d{6}-\d{2}-\d{2}/],["YYYY-MM-DD",/\d{4}-\d{2}-\d{2}/],["GGGG-[W]WW-E",/\d{4}-W\d{2}-\d/],["GGGG-[W]WW",/\d{4}-W\d{2}/],["YYYY-DDD",/\d{4}-\d{3}/]],Wb=[["HH:mm:ss.SSSS",/(T| )\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss",/(T| )\d\d:\d\d:\d\d/],["HH:mm",/(T| )\d\d:\d\d/],["HH",/(T| )\d\d/]],Xb=/([\+\-]|\d\d)/gi,Yb=("Date|Hours|Minutes|Seconds|Milliseconds".split("|"),{Milliseconds:1,Seconds:1e3,Minutes:6e4,Hours:36e5,Days:864e5,Months:2592e6,Years:31536e6}),Zb={ms:"millisecond",s:"second",m:"minute",h:"hour",d:"day",D:"date",w:"week",W:"isoWeek",M:"month",Q:"quarter",y:"year",DDD:"dayOfYear",e:"weekday",E:"isoWeekday",gg:"weekYear",GG:"isoWeekYear"},$b={dayofyear:"dayOfYear",isoweekday:"isoWeekday",isoweek:"isoWeek",weekyear:"weekYear",isoweekyear:"isoWeekYear"},_b={},ac="DDD w W M D d".split(" "),bc="M D H h m s w W".split(" "),cc={M:function(){return this.month()+1},MMM:function(a){return this.lang().monthsShort(this,a)},MMMM:function(a){return this.lang().months(this,a)},D:function(){return this.date()},DDD:function(){return this.dayOfYear()},d:function(){return this.day()},dd:function(a){return this.lang().weekdaysMin(this,a)},ddd:function(a){return this.lang().weekdaysShort(this,a)},dddd:function(a){return this.lang().weekdays(this,a)},w:function(){return this.week()},W:function(){return this.isoWeek()},YY:function(){return l(this.year()%100,2)},YYYY:function(){return l(this.year(),4)},YYYYY:function(){return l(this.year(),5)},YYYYYY:function(){var a=this.year(),b=a>=0?"+":"-";return b+l(Math.abs(a),6)},gg:function(){return l(this.weekYear()%100,2)},gggg:function(){return l(this.weekYear(),4)},ggggg:function(){return l(this.weekYear(),5)},GG:function(){return l(this.isoWeekYear()%100,2)},GGGG:function(){return l(this.isoWeekYear(),4)},GGGGG:function(){return l(this.isoWeekYear(),5)},e:function(){return this.weekday()},E:function(){return this.isoWeekday()},a:function(){return this.lang().meridiem(this.hours(),this.minutes(),!0)},A:function(){return this.lang().meridiem(this.hours(),this.minutes(),!1)},H:function(){return this.hours()},h:function(){return this.hours()%12||12},m:function(){return this.minutes()},s:function(){return this.seconds()},S:function(){return t(this.milliseconds()/100)},SS:function(){return l(t(this.milliseconds()/10),2)},SSS:function(){return l(this.milliseconds(),3)},SSSS:function(){return l(this.milliseconds(),3)},Z:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+l(t(a/60),2)+":"+l(t(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";return 0>a&&(a=-a,b="-"),b+l(t(a/60),2)+l(t(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},dc=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];ac.length;)kb=ac.pop(),cc[kb+"o"]=e(cc[kb],kb);for(;bc.length;)kb=bc.pop(),cc[kb+kb]=d(cc[kb],2);for(cc.DDDD=d(cc.DDD,3),i(f.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"==typeof b?this[c]=b:this["_"+c]=b},_months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),months:function(a){return this._months[a.month()]},_monthsShort:"Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c,d;for(this._monthsParse||(this._monthsParse=[]),b=0;12>b;b++)if(this._monthsParse[b]||(c=ib.utc([2e3,b]),d="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=new RegExp(d.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su_Mo_Tu_We_Th_Fr_Sa".split("_"),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c,d;for(this._weekdaysParse||(this._weekdaysParse=[]),b=0;7>b;b++)if(this._weekdaysParse[b]||(c=ib([2e3,1]).day(b),d="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,""),this._weekdaysParse[b]=new RegExp(d.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];return!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b),b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"},_calendar:{sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},calendar:function(a,b){var c=this._calendar[a];return"function"==typeof c?c.apply(b):c},_relativeTime:{future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},relativeTime:function(a,b,c,d){var e=this._relativeTime[c];return"function"==typeof e?e(a,b,c,d):e.replace(/%d/i,a)},pastFuture:function(a,b){var c=this._relativeTime[a>0?"future":"past"];return"function"==typeof c?c(b):c.replace(/%s/i,b)},ordinal:function(a){return this._ordinal.replace("%d",a)},_ordinal:"%d",preparse:function(a){return a},postformat:function(a){return a},week:function(a){return $(a,this._week.dow,this._week.doy).week},_week:{dow:0,doy:6},_invalidDate:"Invalid date",invalidDate:function(){return this._invalidDate}}),ib=function(c,d,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._i=c,g._f=d,g._l=e,g._strict=f,g._isUTC=!1,g._pf=b(),ab(g)},ib.suppressDeprecationWarnings=!1,ib.createFromInputFallback=c("moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.",function(a){a._d=new Date(a._i)}),ib.utc=function(c,d,e,f){var g;return"boolean"==typeof e&&(f=e,e=a),g={},g._isAMomentObject=!0,g._useUTC=!0,g._isUTC=!0,g._l=e,g._i=c,g._f=d,g._strict=f,g._pf=b(),ab(g).utc()},ib.unix=function(a){return ib(1e3*a)},ib.duration=function(a,b){var c,d,e,f=a,g=null;return ib.isDuration(a)?f={ms:a._milliseconds,d:a._days,M:a._months}:"number"==typeof a?(f={},b?f[b]=a:f.milliseconds=a):(g=zb.exec(a))?(c="-"===g[1]?-1:1,f={y:0,d:t(g[qb])*c,h:t(g[rb])*c,m:t(g[sb])*c,s:t(g[tb])*c,ms:t(g[ub])*c}):(g=Ab.exec(a))&&(c="-"===g[1]?-1:1,e=function(a){var b=a&&parseFloat(a.replace(",","."));return(isNaN(b)?0:b)*c},f={y:e(g[2]),M:e(g[3]),d:e(g[4]),h:e(g[5]),m:e(g[6]),s:e(g[7]),w:e(g[8])}),d=new h(f),ib.isDuration(a)&&a.hasOwnProperty("_lang")&&(d._lang=a._lang),d},ib.version=lb,ib.defaultFormat=Ub,ib.momentProperties=wb,ib.updateOffset=function(){},ib.lang=function(a,b){var c;return a?(b?C(A(a),b):null===b?(D(a),a="en"):vb[a]||E(a),c=ib.duration.fn._lang=ib.fn._lang=E(a),c._abbr):ib.fn._lang._abbr},ib.langData=function(a){return a&&a._lang&&a._lang._abbr&&(a=a._lang._abbr),E(a)},ib.isMoment=function(a){return a instanceof g||null!=a&&a.hasOwnProperty("_isAMomentObject")},ib.isDuration=function(a){return a instanceof h},kb=dc.length-1;kb>=0;--kb)s(dc[kb]);ib.normalizeUnits=function(a){return q(a)},ib.invalid=function(a){var b=ib.utc(0/0);return null!=a?i(b._pf,a):b._pf.userInvalidated=!0,b},ib.parseZone=function(){return ib.apply(null,arguments).parseZone()},ib.parseTwoDigitYear=function(a){return t(a)+(t(a)>68?1900:2e3)},i(ib.fn=g.prototype,{clone:function(){return ib(this)},valueOf:function(){return+this._d+6e4*(this._offset||0)},unix:function(){return Math.floor(+this/1e3)},toString:function(){return this.clone().lang("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")},toDate:function(){return this._offset?new Date(+this):this._d},toISOString:function(){var a=ib(this).utc();return 00:!1},parsingFlags:function(){return i({},this._pf)},invalidAt:function(){return this._pf.overflow},utc:function(){return this.zone(0)},local:function(){return this.zone(0),this._isUTC=!1,this},format:function(a){var b=H(this,a||ib.defaultFormat);return this.lang().postformat(b)},add:function(a,b){var c;return c="string"==typeof a?ib.duration(+b,a):ib.duration(a,b),m(this,c,1),this},subtract:function(a,b){var c;return c="string"==typeof a?ib.duration(+b,a):ib.duration(a,b),m(this,c,-1),this},diff:function(a,b,c){var d,e,f=B(a,this),g=6e4*(this.zone()-f.zone());return b=q(b),"year"===b||"month"===b?(d=432e5*(this.daysInMonth()+f.daysInMonth()),e=12*(this.year()-f.year())+(this.month()-f.month()),e+=(this-ib(this).startOf("month")-(f-ib(f).startOf("month")))/d,e-=6e4*(this.zone()-ib(this).startOf("month").zone()-(f.zone()-ib(f).startOf("month").zone()))/d,"year"===b&&(e/=12)):(d=this-f,e="second"===b?d/1e3:"minute"===b?d/6e4:"hour"===b?d/36e5:"day"===b?(d-g)/864e5:"week"===b?(d-g)/6048e5:d),c?e:k(e)},from:function(a,b){return ib.duration(this.diff(a)).lang(this.lang()._abbr).humanize(!b)},fromNow:function(a){return this.from(ib(),a)},calendar:function(){var a=B(ib(),this).startOf("day"),b=this.diff(a,"days",!0),c=-6>b?"sameElse":-1>b?"lastWeek":0>b?"lastDay":1>b?"sameDay":2>b?"nextDay":7>b?"nextWeek":"sameElse";return this.format(this.lang().calendar(c,this))},isLeapYear:function(){return x(this.year())},isDST:function(){return this.zone()+ib(a).startOf(b)},isBefore:function(a,b){return b="undefined"!=typeof b?b:"millisecond",+this.clone().startOf(b)<+ib(a).startOf(b)},isSame:function(a,b){return b=b||"ms",+this.clone().startOf(b)===+B(a,this).startOf(b)},min:function(a){return a=ib.apply(null,arguments),this>a?this:a},max:function(a){return a=ib.apply(null,arguments),a>this?this:a},zone:function(a,b){var c=this._offset||0;return null==a?this._isUTC?c:this._d.getTimezoneOffset():("string"==typeof a&&(a=K(a)),Math.abs(a)<16&&(a=60*a),this._offset=a,this._isUTC=!0,c!==a&&(!b||this._changeInProgress?m(this,ib.duration(c-a,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,ib.updateOffset(this,!0),this._changeInProgress=null)),this)},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){return this._tzm?this.zone(this._tzm):"string"==typeof this._i&&this.zone(this._i),this},hasAlignedHourOffset:function(a){return a=a?ib(a).zone():0,(this.zone()-a)%60===0},daysInMonth:function(){return u(this.year(),this.month())},dayOfYear:function(a){var b=nb((ib(this).startOf("day")-ib(this).startOf("year"))/864e5)+1;return null==a?b:this.add("d",a-b)},quarter:function(a){return null==a?Math.ceil((this.month()+1)/3):this.month(3*(a-1)+this.month()%3)},weekYear:function(a){var b=$(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==a?b:this.add("y",a-b)},isoWeekYear:function(a){var b=$(this,1,4).year;return null==a?b:this.add("y",a-b)},week:function(a){var b=this.lang().week(this);return null==a?b:this.add("d",7*(a-b))},isoWeek:function(a){var b=$(this,1,4).week;return null==a?b:this.add("d",7*(a-b))},weekday:function(a){var b=(this.day()+7-this.lang()._week.dow)%7;return null==a?b:this.add("d",a-b)},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},isoWeeksInYear:function(){return v(this.year(),1,4)},weeksInYear:function(){var a=this._lang._week;return v(this.year(),a.dow,a.doy)},get:function(a){return a=q(a),this[a]()},set:function(a,b){return a=q(a),"function"==typeof this[a]&&this[a](b),this},lang:function(b){return b===a?this._lang:(this._lang=E(b),this)}}),ib.fn.millisecond=ib.fn.milliseconds=eb("Milliseconds",!1),ib.fn.second=ib.fn.seconds=eb("Seconds",!1),ib.fn.minute=ib.fn.minutes=eb("Minutes",!1),ib.fn.hour=ib.fn.hours=eb("Hours",!0),ib.fn.date=eb("Date",!0),ib.fn.dates=c("dates accessor is deprecated. Use date instead.",eb("Date",!0)),ib.fn.year=eb("FullYear",!0),ib.fn.years=c("years accessor is deprecated. Use year instead.",eb("FullYear",!0)),ib.fn.days=ib.fn.day,ib.fn.months=ib.fn.month,ib.fn.weeks=ib.fn.week,ib.fn.isoWeeks=ib.fn.isoWeek,ib.fn.quarters=ib.fn.quarter,ib.fn.toJSON=ib.fn.toISOString,i(ib.duration.fn=h.prototype,{_bubble:function(){var a,b,c,d,e=this._milliseconds,f=this._days,g=this._months,h=this._data;h.milliseconds=e%1e3,a=k(e/1e3),h.seconds=a%60,b=k(a/60),h.minutes=b%60,c=k(b/60),h.hours=c%24,f+=k(c/24),h.days=f%30,g+=k(f/30),h.months=g%12,d=k(g/12),h.years=d},weeks:function(){return k(this.days()/7)},valueOf:function(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*t(this._months/12)},humanize:function(a){var b=+this,c=Z(b,!a,this.lang());return a&&(c=this.lang().pastFuture(b,c)),this.lang().postformat(c)},add:function(a,b){var c=ib.duration(a,b);return this._milliseconds+=c._milliseconds,this._days+=c._days,this._months+=c._months,this._bubble(),this},subtract:function(a,b){var c=ib.duration(a,b);return this._milliseconds-=c._milliseconds,this._days-=c._days,this._months-=c._months,this._bubble(),this},get:function(a){return a=q(a),this[a.toLowerCase()+"s"]()},as:function(a){return a=q(a),this["as"+a.charAt(0).toUpperCase()+a.slice(1)+"s"]()},lang:ib.fn.lang,toIsoString:function(){var a=Math.abs(this.years()),b=Math.abs(this.months()),c=Math.abs(this.days()),d=Math.abs(this.hours()),e=Math.abs(this.minutes()),f=Math.abs(this.seconds()+this.milliseconds()/1e3);return this.asSeconds()?(this.asSeconds()<0?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||f?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(f?f+"S":""):"P0D"}});for(kb in Yb)Yb.hasOwnProperty(kb)&&(gb(kb,Yb[kb]),fb(kb.toLowerCase()));gb("Weeks",6048e5),ib.duration.fn.asMonths=function(){return(+this-31536e6*this.years())/2592e6+12*this.years()},ib.lang("en",{ordinal:function(a){var b=a%10,c=1===t(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),xb?module.exports=ib:"function"==typeof define&&define.amd?(define("moment",function(a,b,c){return c.config&&c.config()&&c.config().noGlobal===!0&&(mb.moment=jb),ib}),hb(!0)):hb()}).call(this); \ No newline at end of file diff --git a/pom.xml b/pom.xml index b52a7737715..132e6257162 100755 --- a/pom.xml +++ b/pom.xml @@ -552,6 +552,9 @@ dmap David Maplesden + + jaferkhan + diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1d86c3b8817..450c6c75460 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -287,6 +287,15 @@ conditional creates can now be authorized even if they are happening inside a FHIR transaction. + + When encoding a Composition resource in XML, the section narrative blocks were incorrectly + replaced by the main resource narrative. Thanks to Mirjam Baltus for reporting! + + + AN issue with date pickers not working in the hapi-fhir-testpage-overlay + project has been fixed. Thanks to GitHub user @jaferkhan for the pull + request! +