diff --git a/src/Hl7.Fhir.Specification.Tests/Source/ArtifactSummaryTests.cs b/src/Hl7.Fhir.Specification.Tests/Source/ArtifactSummaryTests.cs
index 2b99cfabcd..d709c82b3a 100644
--- a/src/Hl7.Fhir.Specification.Tests/Source/ArtifactSummaryTests.cs
+++ b/src/Hl7.Fhir.Specification.Tests/Source/ArtifactSummaryTests.cs
@@ -121,6 +121,11 @@ public void TestProfilesTypesJson()
Assert.AreEqual(StructureDefinition.StructureDefinitionKind.Datatype.GetLiteral(), summary.GetStructureDefinitionKind());
// If this is a constraining StructDef, then Base should also be specified
Assert.IsTrue(summary.GetStructureDefinitionConstrainedType() == null || summary.GetStructureDefinitionBase() != null);
+
+ // [WMR 20180725] Also harvest root element definition text
+ // [WMR 20180801] Disabled; included version of profiles-types.json does NOT contain definitions...
+ // var rootDefinition = summary.GetStructureDefinitionRootDefinition();
+ // Assert.IsNotNull(rootDefinition);
}
}
@@ -166,6 +171,10 @@ public void TestProfilesResourcesXml()
// [WMR 20171218] Maturity Level extension
Assert.IsNotNull(summary.GetStructureDefinitionMaturityLevel());
+
+ // [WMR 20180725] Also harvest root element definition text
+ var rootDefinition = summary.GetStructureDefinitionRootDefinition();
+ Assert.IsNotNull(rootDefinition);
}
}
diff --git a/src/Hl7.Fhir.Specification/Specification/Source/Summary/ArtifactSummaryHarvesters.cs b/src/Hl7.Fhir.Specification/Specification/Source/Summary/ArtifactSummaryHarvesters.cs
index 6ecb790436..897cebade3 100644
--- a/src/Hl7.Fhir.Specification/Specification/Source/Summary/ArtifactSummaryHarvesters.cs
+++ b/src/Hl7.Fhir.Specification/Specification/Source/Summary/ArtifactSummaryHarvesters.cs
@@ -33,13 +33,13 @@ namespace Hl7.Fhir.Specification.Source
///
public static class ArtifactSummaryProperties
{
- public const string OriginKey = "Origin";
- public const string FileSizeKey = "Size";
- public const string LastModifiedKey = "LastModified";
- public const string SerializationFormatKey = "Format";
- public const string PositionKey = "Position";
- public const string TypeNameKey = "TypeName";
- public const string ResourceUriKey = "Uri";
+ public static readonly string OriginKey = "Origin";
+ public static readonly string FileSizeKey = "Size";
+ public static readonly string LastModifiedKey = "LastModified";
+ public static readonly string SerializationFormatKey = "Format";
+ public static readonly string PositionKey = "Position";
+ public static readonly string TypeNameKey = "TypeName";
+ public static readonly string ResourceUriKey = "Uri";
/// Try to retrieve the property value for the specified key.
/// An artifact summary property bag.
@@ -233,6 +233,8 @@ public static class StructureDefinitionSummaryProperties
public static readonly string FmmExtensionUrl = @"http://hl7.org/fhir/StructureDefinition/structuredefinition-fmm";
public static readonly string MaturityLevelKey = "StructureDefinition.maturityLevel";
+ public static readonly string RootDefinitionKey = "StructureDefinition.rootDefinition";
+
/// Determines if the specified instance represents summary information about a resource.
public static bool IsStructureDefinitionSummary(this IArtifactSummaryPropertyBag properties)
=> properties.GetTypeName() == StructureDefinitionTypeName;
@@ -255,6 +257,21 @@ public static bool Harvest(IElementNavigator nav, ArtifactSummaryPropertyBag pro
nav.HarvestValue(properties, ConstrainedTypeKey, "constrainedType");
nav.HarvestValue(properties, ContextTypeKey, "contextType");
nav.HarvestValue(properties, BaseKey, "base");
+
+ // [WMR 20180725] Also harvest definition property from (first) root element in snapshot/differential
+ // HL7 FHIR website displays this text as introduction on top of each resource/datatype page
+ if ((nav.Find("snapshot") || nav.Find("differential")))
+ {
+ if (nav.MoveToFirstChild("element") && Navigation.ElementDefinitionNavigator.IsRootPath(nav.Name))
+ {
+ var childNav = nav.Clone();
+ if (childNav.MoveToFirstChild())
+ {
+ childNav.HarvestValue(properties, RootDefinitionKey, "definition");
+ }
+ }
+ }
+
}
return true;
}
@@ -302,6 +319,14 @@ public static string GetStructureDefinitionBase(this IArtifactSummaryPropertyBag
///
public static string GetStructureDefinitionMaturityLevel(this IArtifactSummaryPropertyBag properties)
=> properties.GetValueOrDefault(MaturityLevelKey);
+ /// Get the value of the root element definition from the specified artifact summary property bag, if available.
+ ///
+ /// Returns the definition text of the root element.
+ /// Only applies to summaries of resources.
+ ///
+ public static string GetStructureDefinitionRootDefinition(this IArtifactSummaryPropertyBag properties)
+ => properties.GetValueOrDefault(RootDefinitionKey);
+
}
/// For harvesting specific summary information from a resource.