diff --git a/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml b/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
index adf8dfa26c..362003322f 100644
--- a/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
+++ b/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml
@@ -29,6 +29,13 @@
lib/net8.0/Hl7.Fhir.Base.dll
true
+
+ CP0001
+ T:Hl7.Fhir.Introspection.BindableAttribute
+ lib/net8.0/Hl7.Fhir.Base.dll
+ lib/net8.0/Hl7.Fhir.Base.dll
+ true
+
CP0001
T:Hl7.Fhir.Model.DeepComparable
@@ -43,6 +50,13 @@
lib/net8.0/Hl7.Fhir.Base.dll
true
+
+ CP0001
+ T:Hl7.Fhir.Model.ISystemAndCode
+ lib/net8.0/Hl7.Fhir.Base.dll
+ lib/net8.0/Hl7.Fhir.Base.dll
+ true
+
CP0001
T:Hl7.Fhir.Serialization.BaseFhirSerializer
diff --git a/src/Hl7.Fhir.Base/Introspection/BindableAttribute.cs b/src/Hl7.Fhir.Base/Introspection/BindableAttribute.cs
deleted file mode 100644
index 628245834e..0000000000
--- a/src/Hl7.Fhir.Base/Introspection/BindableAttribute.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- Copyright (c) 2011-2013, HL7, Inc.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of HL7 nor the names of its contributors may be used to
- endorse or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-
-*/
-
-using System;
-
-#nullable enable
-
-namespace Hl7.Fhir.Introspection
-{
- ///
- /// This attribute is applied to classes that represent bindable types.
- ///
- [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
- public sealed class BindableAttribute : VersionedAttribute
- {
- public BindableAttribute(bool isBindable)
- {
- IsBindable = isBindable;
- }
-
- public bool IsBindable { get; }
- }
-}
-
-#nullable restore
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Introspection/ClassMapping.cs b/src/Hl7.Fhir.Base/Introspection/ClassMapping.cs
index bb18ed7a4c..36af880864 100644
--- a/src/Hl7.Fhir.Base/Introspection/ClassMapping.cs
+++ b/src/Hl7.Fhir.Base/Introspection/ClassMapping.cs
@@ -86,7 +86,7 @@ public static bool TryCreate(Type type, [NotNullWhen(true)]out ClassMapping? res
}
// Now continue with the normal algorithm, types adorned with the [FhirTypeAttribute]
- if (GetAttribute(type.GetTypeInfo(), release) is not { } typeAttribute) return false;
+ if (GetAttribute(type, release) is not { } typeAttribute) return false;
result = new ClassMapping(collectTypeName(typeAttribute, type), type, release)
{
@@ -96,9 +96,9 @@ public static bool TryCreate(Type type, [NotNullWhen(true)]out ClassMapping? res
type.GenericTypeArguments[0] : null,
IsFhirPrimitive = typeof(PrimitiveType).IsAssignableFrom(type),
IsBackboneType = typeAttribute.IsBackboneType,
- IsBindable = GetAttribute(type.GetTypeInfo(), release)?.IsBindable ?? false,
+ IsBindable = typeof(ICoded).IsAssignableFrom(type),
Canonical = typeAttribute.Canonical,
- ValidationAttributes = GetAttributes(type.GetTypeInfo(), release).ToArray(),
+ ValidationAttributes = GetAttributes(type, release).ToArray(),
};
return true;
diff --git a/src/Hl7.Fhir.Base/Model/Code.cs b/src/Hl7.Fhir.Base/Model/Code.cs
index 27557a372b..d6c3e2b0c0 100644
--- a/src/Hl7.Fhir.Base/Model/Code.cs
+++ b/src/Hl7.Fhir.Base/Model/Code.cs
@@ -30,24 +30,22 @@ POSSIBILITY OF SUCH DAMAGE.
#nullable enable
-using Hl7.Fhir.Introspection;
+using System.Collections.Generic;
using System.Text.RegularExpressions;
-namespace Hl7.Fhir.Model
+namespace Hl7.Fhir.Model;
+
+public partial class Code : ICoded
{
- [Bindable(true)]
- public partial class Code
- {
- ///
- /// Creates a from an instance of a .
- ///
- public virtual ElementModel.Types.Code ToSystemCode() => new(system: null, code: Value, display: null, version: null);
+ ///
+ /// Creates a from an instance of a .
+ ///
+ public virtual ElementModel.Types.Code ToSystemCode() => new(system: null, code: Value, display: null, version: null);
- ///
- /// Checks whether the given literal is correctly formatted.
- ///
- public static bool IsValidValue(string value) => Regex.IsMatch(value, "^" + PATTERN + "$", RegexOptions.Singleline);
- }
-}
+ ///
+ /// Checks whether the given literal is correctly formatted.
+ ///
+ public static bool IsValidValue(string value) => Regex.IsMatch(value, "^" + PATTERN + "$", RegexOptions.Singleline);
-#nullable restore
\ No newline at end of file
+ public virtual IEnumerable ToCodings() => [new(system: null, code: Value)];
+}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Model/CodeOfT.cs b/src/Hl7.Fhir.Base/Model/CodeOfT.cs
index ec0040ab06..421efaf090 100644
--- a/src/Hl7.Fhir.Base/Model/CodeOfT.cs
+++ b/src/Hl7.Fhir.Base/Model/CodeOfT.cs
@@ -28,6 +28,7 @@ POSSIBILITY OF SUCH DAMAGE.
*/
+#nullable enable
using Hl7.Fhir.Introspection;
using Hl7.Fhir.Specification;
@@ -40,81 +41,76 @@ POSSIBILITY OF SUCH DAMAGE.
using COVE = Hl7.Fhir.Validation.CodedValidationException;
using S = Hl7.Fhir.ElementModel.Types;
-namespace Hl7.Fhir.Model
+namespace Hl7.Fhir.Model;
+
+///
+/// A that has a limited set of values and which can therefore
+/// be represented as an enumerated type.
+///
+[Serializable]
+[FhirType("codeOfT")]
+[DataContract]
+[System.Diagnostics.DebuggerDisplay(@"\{Value={Value}}")]
+public class Code : Code, INullableValue where T : struct, Enum
{
- ///
- /// A that has a limited set of values and which can therefore
- /// be represented as an enumerated type.
- ///
- [Serializable]
- [FhirType("codeOfT")]
- [DataContract]
- [System.Diagnostics.DebuggerDisplay(@"\{Value={Value}}")]
- public class Code : Code, INullableValue, ISystemAndCode where T : struct, Enum
+ static Code()
{
- static Code()
- {
- if (!typeof(T).IsEnum())
- throw new ArgumentException("T must be an enumerated type");
- }
+ if (!typeof(T).IsEnum())
+ throw new ArgumentException("T must be an enumerated type");
+ }
- public override string TypeName => "code";
+ public override string TypeName => "code";
- public Code() : this(null) { }
+ public Code() : this(null) { }
- public Code(T? value)
- {
- Value = value;
- }
+ public Code(T? value)
+ {
+ Value = value;
+ }
- // Primitive value of element
- [FhirElement("value", IsPrimitiveValue = true, XmlSerialization = XmlRepresentation.XmlAttr, InSummary = true, Order = 30)]
- [DataMember]
- new public T? Value
+ // Primitive value of element
+ [FhirElement("value", IsPrimitiveValue = true, XmlSerialization = XmlRepresentation.XmlAttr, InSummary = true, Order = 30)]
+ [DataMember]
+ new public T? Value
+ {
+ get => TryParseObjectValue(out var value)
+ ? value
+ : throw new InvalidCastException($"Value '{ObjectValue}' cannot be cast to a member of enumeration {typeof(T).Name}.");
+ set
{
- get => TryParseObjectValue(out var value)
- ? value
- : throw new InvalidCastException($"Value '{ObjectValue}' cannot be cast to a member of enumeration {typeof(T).Name}.");
- set
- {
- ObjectValue = value?.GetLiteral();
- OnPropertyChanged("Value");
- }
+ ObjectValue = value?.GetLiteral();
+ OnPropertyChanged("Value");
}
+ }
+
+ internal bool TryParseObjectValue(out T? value)
+ {
+ value = default;
- internal bool TryParseObjectValue(out T? value)
+ if (ObjectValue is string s && EnumUtility.ParseLiteral(s) is { } parsed)
{
- value = default;
-
- if (ObjectValue is string s && EnumUtility.ParseLiteral(s) is { } parsed)
- {
- value = parsed;
- return true;
- }
- else return ObjectValue is null;
+ value = parsed;
+ return true;
}
+ else return ObjectValue is null;
+ }
- string ISystemAndCode.System => Value?.GetSystem();
+ public override IEnumerable ToCodings() => [new(Value?.GetSystem(), Value?.GetLiteral())];
- string ISystemAndCode.Code => Value?.GetLiteral();
+ public override S.Code ToSystemCode() =>
+ new(Value?.GetSystem(),
+ Value?.GetLiteral() ?? throw new InvalidOperationException("Code must have a value in order to be useable to construct a System.Code."),
+ display: null,
+ version: null);
- public override S.Code ToSystemCode() =>
- new(Value?.GetSystem(),
- Value?.GetLiteral() ?? throw new InvalidOperationException("Code must have a value in order to be useable to construct a System.Code."),
- display: null,
- version: null);
+ public override IEnumerable Validate(ValidationContext validationContext)
+ {
+ var baseResults = base.Validate(validationContext);
- public override IEnumerable Validate(ValidationContext validationContext)
- {
- var baseResults = base.Validate(validationContext);
-
- if (TryParseObjectValue(out _))
- return baseResults;
- else
- {
- var result = COVE.INVALID_CODED_VALUE(validationContext, ObjectValue, EnumUtility.GetName()).AsResult(validationContext);
- return baseResults.Append(result);
- }
- }
+ if (TryParseObjectValue(out _))
+ return baseResults;
+
+ var result = COVE.INVALID_CODED_VALUE(validationContext, ObjectValue, EnumUtility.GetName()).AsResult(validationContext);
+ return baseResults.Append(result);
}
}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Model/CodeableConcept.cs b/src/Hl7.Fhir.Base/Model/CodeableConcept.cs
index 5b563384fa..df253a1242 100644
--- a/src/Hl7.Fhir.Base/Model/CodeableConcept.cs
+++ b/src/Hl7.Fhir.Base/Model/CodeableConcept.cs
@@ -28,20 +28,21 @@ POSSIBILITY OF SUCH DAMAGE.
*/
-using Hl7.Fhir.Introspection;
+#nullable enable
+
+using System.Collections.Generic;
using System.Linq;
using S = Hl7.Fhir.ElementModel.Types;
+namespace Hl7.Fhir.Model;
-namespace Hl7.Fhir.Model
+public partial class CodeableConcept : ICoded
{
- [Bindable(true)]
- public partial class CodeableConcept
+ public S.Concept ToSystemConcept()
{
- public S.Concept ToSystemConcept()
- {
- var codes = Coding.Select(c => c.ToSystemCode());
- return new S.Concept(codes, display: Text);
- }
+ var codes = Coding.Select(c => c.ToSystemCode());
+ return new S.Concept(codes, display: Text);
}
-}
+
+ public IEnumerable ToCodings() => Coding;
+}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Model/CodeableReference.cs b/src/Hl7.Fhir.Base/Model/CodeableReference.cs
index 418afd4e17..f217d8742f 100644
--- a/src/Hl7.Fhir.Base/Model/CodeableReference.cs
+++ b/src/Hl7.Fhir.Base/Model/CodeableReference.cs
@@ -7,26 +7,27 @@
*/
#nullable enable
-using Hl7.Fhir.Introspection;
-namespace Hl7.Fhir.Model
+using System.Collections.Generic;
+
+namespace Hl7.Fhir.Model;
+
+public partial class CodeableReference : ICoded
{
- [Bindable(true)]
- public partial class CodeableReference
+ public CodeableReference()
{
- public CodeableReference()
- {
- // Nothing
- }
+ // Nothing
+ }
- public CodeableReference(CodeableConcept concept)
- {
- Concept = concept;
- }
+ public CodeableReference(CodeableConcept concept)
+ {
+ Concept = concept;
+ }
- public CodeableReference(ResourceReference reference)
- {
- Reference = reference;
- }
+ public CodeableReference(ResourceReference reference)
+ {
+ Reference = reference;
}
+
+ public IEnumerable ToCodings() => Concept?.ToCodings() ?? [];
}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Model/Coding.cs b/src/Hl7.Fhir.Base/Model/Coding.cs
index 2e52ba31aa..003651b3b7 100644
--- a/src/Hl7.Fhir.Base/Model/Coding.cs
+++ b/src/Hl7.Fhir.Base/Model/Coding.cs
@@ -1,82 +1,80 @@
/*
Copyright (c) 2011+, HL7, Inc.
All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
+
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
+
+ * Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- * Neither the name of HL7 nor the names of its contributors may be used to
- endorse or promote products derived from this software without specific
+ * Neither the name of HL7 nor the names of its contributors may be used to
+ endorse or promote products derived from this software without specific
prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
*/
-using Hl7.Fhir.Introspection;
+#nullable enable
+
+using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using S = Hl7.Fhir.ElementModel.Types;
+namespace Hl7.Fhir.Model;
-namespace Hl7.Fhir.Model
+[DebuggerDisplay(@"\{{DebuggerDisplay,nq}}")]
+public partial class Coding: ICoded
{
-
-
- [DebuggerDisplay(@"\{{DebuggerDisplay,nq}}")]
- [Bindable(true)]
- public partial class Coding
+ public Coding()
{
- public Coding()
- {
-
- }
+ // Nothing
+ }
- public Coding(string system, string code)
- {
- this.System = system;
- this.Code = code;
- }
+ public Coding(string? system, string? code)
+ {
+ this.System = system;
+ this.Code = code;
+ }
- public Coding(string system, string code, string display)
- {
- this.System = system;
- this.Code = code;
- this.Display = display;
- }
+ public Coding(string? system, string? code, string? display)
+ {
+ this.System = system;
+ this.Code = code;
+ this.Display = display;
+ }
- [DebuggerBrowsable(DebuggerBrowsableState.Never)]
- public string DebuggerDisplay
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ public string DebuggerDisplay
+ {
+ get
{
- get
- {
- StringBuilder sb = new StringBuilder();
- if (!string.IsNullOrEmpty(this.Code))
- sb.AppendFormat(" Code=\"{0}\"", Code);
- if (!string.IsNullOrEmpty(this.Display))
- sb.AppendFormat(" Display=\"{0}\"", Display);
- if (!string.IsNullOrEmpty(this.System))
- sb.AppendFormat(" System=\"{0}\"", System);
+ var sb = new StringBuilder();
+ if (!string.IsNullOrEmpty(this.Code))
+ sb.Append($" Code=\"{Code}\"");
+ if (!string.IsNullOrEmpty(this.Display))
+ sb.Append($" Display=\"{Display}\"");
+ if (!string.IsNullOrEmpty(this.System))
+ sb.Append($" System=\"{System}\"");
- return sb.ToString();
- }
+ return sb.ToString();
}
-
- public S.Code ToSystemCode() => new S.Code(System, Code, Display, Version);
}
-}
+
+ public S.Code ToSystemCode() => new(System, Code, Display, Version);
+ public IEnumerable ToCodings() => [this];
+}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Model/Extension.cs b/src/Hl7.Fhir.Base/Model/Extension.cs
index 801f932518..601cfbdd2f 100644
--- a/src/Hl7.Fhir.Base/Model/Extension.cs
+++ b/src/Hl7.Fhir.Base/Model/Extension.cs
@@ -31,14 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
#nullable enable
-using Hl7.Fhir.Introspection;
-using Hl7.Fhir.Specification;
-using Hl7.Fhir.Validation;
-using System;
using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Runtime.Serialization;
-using SystemPrimitive = Hl7.Fhir.ElementModel.Types;
namespace Hl7.Fhir.Model;
@@ -46,8 +39,7 @@ namespace Hl7.Fhir.Model;
/// Optional Extensions Element
///
[System.Diagnostics.DebuggerDisplay(@"\{Value={Value} Url={_url}}")]
-[Bindable(true)]
-public partial class Extension
+public partial class Extension : ICoded
{
public Extension()
{
@@ -58,4 +50,10 @@ public Extension(string url, DataType value)
this.Url = url;
this.Value = value;
}
+
+ public IEnumerable ToCodings() => Value switch
+ {
+ ICoded coded => coded.ToCodings(),
+ _ => []
+ };
}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Model/FhirString.cs b/src/Hl7.Fhir.Base/Model/FhirString.cs
index 1a53f15ff3..283970c2cb 100644
--- a/src/Hl7.Fhir.Base/Model/FhirString.cs
+++ b/src/Hl7.Fhir.Base/Model/FhirString.cs
@@ -29,20 +29,19 @@ POSSIBILITY OF SUCH DAMAGE.
#nullable enable
-using Hl7.Fhir.Introspection;
+using System.Collections.Generic;
-namespace Hl7.Fhir.Model
+namespace Hl7.Fhir.Model;
+
+public partial class FhirString : ICoded
{
- [Bindable(true)]
- public partial class FhirString
- {
- ///
- /// Checks whether the given literal is correctly formatted.
- ///
- public static bool IsValidValue(string value) => value.Length is <= 1024 * 1024 and > 0; // Note that strings SHALL NOT exceed 1MB in size.
+ ///
+ /// Checks whether the given literal is correctly formatted.
+ ///
+ public static bool IsValidValue(string value) => value.Length is <= 1024 * 1024 and > 0; // Note that strings SHALL NOT exceed 1MB in size.
- // We do not match against the pattern since that is more expensive
- }
-}
+ // We do not match against the pattern since that is more expensive
+
-#nullable restore
\ No newline at end of file
+ public IEnumerable ToCodings() => [new(null, Value)];
+}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Model/FhirUri.cs b/src/Hl7.Fhir.Base/Model/FhirUri.cs
index 5d1d3d28d1..8ac999ad8d 100644
--- a/src/Hl7.Fhir.Base/Model/FhirUri.cs
+++ b/src/Hl7.Fhir.Base/Model/FhirUri.cs
@@ -29,50 +29,49 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#nullable enable
-using Hl7.Fhir.Introspection;
+
using System;
+using System.Collections.Generic;
+
+namespace Hl7.Fhir.Model;
-namespace Hl7.Fhir.Model
+public partial class FhirUri : ICoded
{
- [Bindable(true)]
- public partial class FhirUri
+ public FhirUri(Uri uri)
{
- public FhirUri(Uri uri)
+ Value = uri.OriginalString;
+ }
+
+ ///
+ /// Checks whether the given literal is correctly formatted.
+ ///
+ /// Due to the way we use Urls in FHIR, some "valid" FHIR urls are
+ /// actually no valid according to
+ public static bool IsValidValue(string value)
+ {
+ Uri uri;
+
+ try
{
- Value = uri.OriginalString;
+ uri = new Uri(value, UriKind.RelativeOrAbsolute);
+ }
+ catch
+ {
+ return false;
}
- ///
- /// Checks whether the given literal is correctly formatted.
- ///
- /// Due to the way we use Urls in FHIR, some "valid" FHIR urls are
- /// actually no valid according to
- public static bool IsValidValue(string value)
+ if (uri.IsAbsoluteUri)
{
- Uri uri;
+ var uris = uri.ToString();
- try
- {
- uri = new Uri(value, UriKind.RelativeOrAbsolute);
- }
- catch
- {
+ if (uris.StartsWith("urn:oid:") && !Oid.IsValidValue(uris))
+ return false;
+ else if (uris.StartsWith("urn:uuid:") && !Uuid.IsValidValue(uris))
return false;
- }
-
- if (uri.IsAbsoluteUri)
- {
- var uris = uri.ToString();
-
- if (uris.StartsWith("urn:oid:") && !Oid.IsValidValue(uris))
- return false;
- else if (uris.StartsWith("urn:uuid:") && !Uuid.IsValidValue(uris))
- return false;
- }
-
- return true;
}
+
+ return true;
}
-}
-#nullable restore
\ No newline at end of file
+ public IEnumerable ToCodings() => [new(null, Value)];
+}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Model/Generated/Attachment.cs b/src/Hl7.Fhir.Base/Model/Generated/Attachment.cs
index 41c6164ddb..cd90a09215 100644
--- a/src/Hl7.Fhir.Base/Model/Generated/Attachment.cs
+++ b/src/Hl7.Fhir.Base/Model/Generated/Attachment.cs
@@ -209,7 +209,7 @@ public string Url
if (value == null)
UrlElement = null;
else
- UrlElement = new Hl7.Fhir.Model.FhirUri(value);
+ UrlElement = new Hl7.Fhir.Model.FhirUrl(value);
OnPropertyChanged("Url");
}
}
diff --git a/src/Hl7.Fhir.Base/Model/ICoded.cs b/src/Hl7.Fhir.Base/Model/ICoded.cs
index afbf0f3587..bee07a9fd6 100644
--- a/src/Hl7.Fhir.Base/Model/ICoded.cs
+++ b/src/Hl7.Fhir.Base/Model/ICoded.cs
@@ -12,55 +12,44 @@
using System.Collections.Generic;
using System.Linq;
-namespace Hl7.Fhir.Model
+namespace Hl7.Fhir.Model;
+
+///
+/// Maps a FHIR datatype to a (list of) Coding, according to https://hl7.org/fhir/terminologies.html#4.1
+///
+public interface ICoded
{
- ///
- /// Marks a resource that is coded.
- ///
- public interface ICoded
- {
- IEnumerable ToCodings();
- }
+ IEnumerable ToCodings();
+}
+
+///
+/// Represents a resource that can be coded.
+///
+/// The type that is used to codify the resource, usually a (list of) or .
+/// This interface is primarily used in the context of CQL, where every resource is assigned an element that represents that
+/// element as a code.
+public interface ICoded : ICoded
+{
+ T Code { get; set; }
+}
+
+///
+/// Helper methods for working with coded types.
+///
+public static class CodedExtensions
+{
///
- /// Represents a resource that can be coded.
+ /// Maps a list of FHIR datatypes to a list of .
///
- /// The type that is used to codify the resource, usually a (list of) or .
- public interface ICoded : ICoded
- {
- T Code { get; set; }
- }
-
+ public static IEnumerable ToCodings(this IEnumerable? dts) => dts?.SelectMany(dt => dt.ToCodings()) ?? [];
///
- /// Helper methods for working with coded types.
+ /// Maps a FHIR datatype to a (list of) Coding, according to https://hl7.org/fhir/terminologies.html#4.1
///
- public static class CodedExtensions
+ public static IEnumerable ToCodings(this DataType? dt) => dt switch
{
- ///
- /// Maps a list of FHIR datatypes to a list of . See for more details.
- ///
- /// When the datatype is not bindeable, and thus not convertable to a Coding.
- public static IEnumerable ToCodings(this IEnumerable? dts) => dts?.SelectMany(dt => dt.ToCodings()) ?? [];
-
- ///
- /// Maps a FHIR datatype to a (list of) Coding, according to https://hl7.org/fhir/terminologies.html#4.1
- ///
- /// When the datatype is not bindeable, and thus not convertable to a Coding.
- public static IEnumerable ToCodings(this DataType? dt) => dt switch
- {
- null => Enumerable.Empty(),
- ISystemAndCode sac => new[] { new Coding(sac.System, sac.Code) },
- Code co => new[] { new Coding(null, co.Value) },
- Coding cd => new[] { cd },
- CodeableConcept cc => cc.Coding ?? Enumerable.Empty(),
- Quantity q => new[] { new Coding(q.System, q.Code) },
- FhirString fs => new[] { new Coding(null, fs.Value) },
- FhirUri u => new[] { new Coding(null, u.Value) },
- CodeableReference { Concept: {} crc } => crc.Coding ?? Enumerable.Empty(),
- _ => []
- };
- }
-}
-
-#nullable restore
\ No newline at end of file
+ ICoded c => c.ToCodings(),
+ _ => []
+ };
+}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Base/Model/ISystemAndCode.cs b/src/Hl7.Fhir.Base/Model/ISystemAndCode.cs
deleted file mode 100644
index c00f63b3bd..0000000000
--- a/src/Hl7.Fhir.Base/Model/ISystemAndCode.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- Copyright (c) 2011-2012, HL7, Inc
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of HL7 nor the names of its contributors may be used to
- endorse or promote products derived from this software without specific
- prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- POSSIBILITY OF SUCH DAMAGE.
-
-
-*/
-
-namespace Hl7.Fhir.Model
-{
- ///
- /// Provides a way to access the system and code from a Code<T> derived class, without having to mess
- /// about with the generic types/additional nasty reflection
- ///
- public interface ISystemAndCode
- {
- string System { get; }
- string Code { get; }
- }
-}
diff --git a/src/Hl7.Fhir.Base/Model/Quantity.cs b/src/Hl7.Fhir.Base/Model/Quantity.cs
index 5413c76cc0..234b90accd 100644
--- a/src/Hl7.Fhir.Base/Model/Quantity.cs
+++ b/src/Hl7.Fhir.Base/Model/Quantity.cs
@@ -1,53 +1,55 @@
/*
Copyright (c) 2011-2012, HL7, Inc
All rights reserved.
-
- Redistribution and use in source and binary forms, with or without modification,
+
+ Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice, this
+
+ * Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- * Neither the name of HL7 nor the names of its contributors may be used to
- endorse or promote products derived from this software without specific
+ * Neither the name of HL7 nor the names of its contributors may be used to
+ endorse or promote products derived from this software without specific
prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
-
+
*/
-using Hl7.Fhir.Introspection;
+#nullable enable
+
using Hl7.Fhir.Utility;
+using System.Collections.Generic;
using P = Hl7.Fhir.ElementModel.Types;
-namespace Hl7.Fhir.Model
+namespace Hl7.Fhir.Model;
+
+public partial class Quantity : ICoded
{
- [Bindable(true)]
- public partial class Quantity
+ public P.Quantity? ToQuantity()
{
- public P.Quantity ToQuantity()
+ if (Value != null)
{
- if (Value != null)
- {
- if (Comparator != null)
- throw Error.NotSupported("Cannot convert a Quantity with a comparator to a FhirPath Quantity");
-
- return new P.Quantity(Value.Value, Code);
- }
- else
- return null;
+ if (Comparator != null)
+ throw Error.NotSupported("Cannot convert a Quantity with a comparator to a FhirPath Quantity");
+
+ return new P.Quantity(Value.Value, Code);
}
+ else
+ return null;
}
-}
+
+ public IEnumerable ToCodings() => [new(System, Code)];
+}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.STU3.Tests/Model/CodeEnumTests.cs b/src/Hl7.Fhir.STU3.Tests/Model/CodeEnumTests.cs
deleted file mode 100644
index 527d382a47..0000000000
--- a/src/Hl7.Fhir.STU3.Tests/Model/CodeEnumTests.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2014, Firely (info@fire.ly) and contributors
- * See the file CONTRIBUTORS for details.
- *
- * This file is licensed under the BSD 3-Clause license
- * available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE
- */
-
-using Hl7.Fhir.Model;
-using Hl7.Fhir.Utility;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-
-namespace Hl7.Fhir.Tests.Model
-{
- [TestClass]
- public class CodeEnumTests
- {
- [TestMethod]
- public void SetValueUpdatesRawValue()
- {
- var c = new Code();
- Assert.IsNull(c.ObjectValue);
- Assert.IsNull(c.Value);
-
- c = new Code(AdministrativeGender.Female);
- Assert.AreEqual("female", c.ObjectValue);
- Assert.AreEqual(AdministrativeGender.Female, c.Value);
-
- c.Value = AdministrativeGender.Unknown;
- Assert.AreEqual("unknown", c.ObjectValue);
- Assert.AreEqual(AdministrativeGender.Unknown, c.Value);
- }
-
-
- [TestMethod]
- public void SetRawValueUpdatesValue()
- {
- var c = new Code(AdministrativeGender.Female);
- c.ObjectValue = "male";
- Assert.AreEqual(AdministrativeGender.Male, c.Value);
-
- c.ObjectValue = "maleX";
- Assert.ThrowsException(() => c.Value);
-
- c.Value = AdministrativeGender.Other;
- Assert.AreEqual("other", c.ObjectValue);
-
- c.ObjectValue = null;
- Assert.IsNull(c.Value);
- }
-
- [TestMethod]
- public void TestISystemAndCode()
- {
- var c = new Code(AdministrativeGender.Female) as ISystemAndCode;
-
- Assert.AreEqual("female", c.Code);
- Assert.AreEqual("http://hl7.org/fhir/administrative-gender", c.System);
-
- c = new Code(TestEnum.IHaveNoSystem) as ISystemAndCode;
- Assert.AreEqual("IHaveNoSystem", c.Code);
- Assert.IsNull(c.System);
- }
-
- [FhirEnumeration("TestEnum")]
- private enum TestEnum
- {
- IHaveNoSystem = 4
- }
- }
-}
diff --git a/src/Hl7.Fhir.Shared.Tests/Hl7.Fhir.Shared.Tests.projitems b/src/Hl7.Fhir.Shared.Tests/Hl7.Fhir.Shared.Tests.projitems
index 6a511db278..9ee3b36921 100644
--- a/src/Hl7.Fhir.Shared.Tests/Hl7.Fhir.Shared.Tests.projitems
+++ b/src/Hl7.Fhir.Shared.Tests/Hl7.Fhir.Shared.Tests.projitems
@@ -11,14 +11,10 @@
-
-
-
-
diff --git a/src/Hl7.Fhir.Shared.Tests/Model/AnnotationTests.cs b/src/Hl7.Fhir.Shared.Tests/Model/AnnotationTests.cs
deleted file mode 100644
index ac3ac71575..0000000000
--- a/src/Hl7.Fhir.Shared.Tests/Model/AnnotationTests.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2014, Firely (info@fire.ly) and contributors
- * See the file CONTRIBUTORS for details.
- *
- * This file is licensed under the BSD 3-Clause license
- * available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE
- */
-
-using Hl7.Fhir.Model;
-using Hl7.Fhir.Rest;
-using Hl7.Fhir.Utility;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Hl7.Fhir.Tests.Model
-{
- [TestClass]
- public class AnnotationTests
- {
- internal class AnnotationData
- {
- public string Data;
- }
-
-
- [TestMethod]
- public void TestAddAnnotation()
- {
- FhirBoolean data = new FhirBoolean();
-
- Assert.IsNull(data.Annotation(typeof(AnnotationData)));
- data.AddAnnotation(new AnnotationData { Data = "hi!" });
- Assert.IsNotNull(data.Annotation(typeof(AnnotationData)));
- Assert.AreEqual("hi!", data.Annotation().Data);
- Assert.AreEqual(1, data.Annotations(typeof(AnnotationData)).Count());
-
- data.AddAnnotation(new AnnotationData { Data = "hi2!" });
-
- // Does not change original outcome (still the first)
- Assert.IsNotNull(data.Annotation(typeof(AnnotationData)));
- Assert.AreEqual("hi!", data.Annotation().Data);
-
- Assert.AreEqual(2, data.Annotations(typeof(AnnotationData)).Count());
- Assert.AreEqual("hi2!", data.Annotations().Skip(1).First().Data);
-
- data.AddAnnotation("Bare string");
-
- Assert.AreEqual(2, data.Annotations(typeof(AnnotationData)).Count());
- Assert.AreEqual("hi!", data.Annotation().Data);
-
- data.RemoveAnnotations();
- Assert.AreEqual(0, data.Annotations(typeof(AnnotationData)).Count());
-
- Assert.AreEqual("Bare string", data.Annotation());
- }
-
-
- [TestMethod]
- public void TestAnnotationsAreCloneable()
- {
- FhirBoolean data = new FhirBoolean(true);
-
- data.AddAnnotation(new AnnotationData { Data = "Hi!" });
-
- var copied = (FhirBoolean)data.DeepCopy();
-
- Assert.AreEqual("Hi!", copied.Annotation().Data);
- }
-
- [TestMethod]
- public void TestAnnotationsEnumType()
- {
- FhirBoolean data = new FhirBoolean(true);
-
- data.SetAnnotation(SummaryType.True);
-
- var copied = (FhirBoolean)data.DeepCopy();
-
- Assert.AreEqual(SummaryType.True, copied.Annotation());
-
- copied.SetAnnotation(SummaryType.Text);
- Assert.AreEqual(SummaryType.Text, copied.Annotation());
-
- Assert.IsTrue(copied.HasAnnotation());
-
- copied.RemoveAnnotations();
-
- Assert.IsFalse(copied.HasAnnotation());
- }
-
-
- [TestMethod]
- public void SetBaseUri()
- {
- // Indirect test of annotations
- Patient p = new Patient();
-
- p.ResourceBase = new Uri("http://nu.nl/");
- Assert.AreEqual("http://nu.nl/", p.ResourceBase.ToString());
- }
-
- ///
- /// Pre-generate testNumber of annotations.
- /// Set them on a single element in parallel.
- ///
- [TestMethod]
- public void SetAnnotationIsThreadSafe()
- {
- var testNumber = 10;
- var rnd = new Random();
- var annotations =
- Enumerable.Range(0, testNumber)
- .Select(i => new AnnotationData() { Data = rnd.Next(0, testNumber).ToString() })
- .ToArray();
- var element = new FhirBoolean();
- try
- {
- Parallel.For(0, testNumber, new ParallelOptions() { MaxDegreeOfParallelism = testNumber }, (i) =>
- {
- element.SetAnnotation(annotations[i]);
- }
- );
-
- }
- catch (Exception ex)
- {
- Assert.Fail($"AddAnnotation should not throw an exception, but it did: {ex.Message}");
- }
-
- Assert.AreEqual(1, element.Annotations(typeof(AnnotationData)).Count());
-
- }
- }
-}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Shared.Tests/Model/BundleExtensionsTest.cs b/src/Hl7.Fhir.Shared.Tests/Model/BundleExtensionsTest.cs
deleted file mode 100644
index 9110b7b0ad..0000000000
--- a/src/Hl7.Fhir.Shared.Tests/Model/BundleExtensionsTest.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2014, Firely (info@fire.ly) and contributors
- * See the file CONTRIBUTORS for details.
- *
- * This file is licensed under the BSD 3-Clause license
- * available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE
- */
-
-using Hl7.Fhir.Model;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Hl7.Fhir.Rest;
-
-namespace Hl7.Fhir.Tests.Model
-{
- [TestClass]
- public class BundleExtensionsTest
- {
- [TestMethod]
- public void TestFindEntry()
- {
- Bundle b = new Bundle();
- b.AddResourceEntry(new Patient { Id = "4" }, "http://some.org/fhir/Patient/4");
- b.AddResourceEntry(new Patient { Id = "5", Meta = new Meta { VersionId = "5" } }, "http://some.org/fhir/Patient/5");
- b.AddResourceEntry(new Patient { Id = "6" }, "http://some.org/fhir/Patient/8");
-
- Assert.AreEqual(1, b.FindEntry("http://some.org/fhir/Patient/4").Count());
- Assert.AreEqual(1, b.FindEntry("http://some.org/fhir/Patient/5").Count());
- Assert.AreEqual(0, b.FindEntry("http://some.org/fhir/Patient/6").Count());
- Assert.AreEqual(1, b.FindEntry("http://some.org/fhir/Patient/8").Count());
-
- Assert.AreEqual(1, b.FindEntry("http://some.org/fhir/Patient/5/_history/5").Count());
- Assert.AreEqual(0, b.FindEntry("http://some.org/fhir/Patient/5/_history/6").Count());
-
- Assert.AreEqual(1, b.FindEntry("https://some.org/fhir/Patient/4").Count());
- }
-
- [TestMethod]
- public void ResourceListFiltering()
- {
- var testBundle = new Bundle();
-
- testBundle.AddResourceEntry(new Patient { Id = "1234", Meta = new Meta { VersionId = "v2" } }, "http://nu.nl/fhir/Patient/1234");
- testBundle.AddResourceEntry(new Patient { Id = "1234", Meta = new Meta { VersionId = "v3" } }, "http://nu.nl/fhir/Patient/1234");
- testBundle.AddResourceEntry(new Patient { Id = "1234", Meta = new Meta { VersionId = "v4" } }, "http://nu.nl/fhir/Patient/1234")
- .Request = new Bundle.RequestComponent { Method = Bundle.HTTPVerb.DELETE } ;
-
- testBundle.AddResourceEntry(new Patient { Id = "5678" }, "http://server1.com/fhir/Patient/5678");
- testBundle.AddResourceEntry(new Patient { Id = "1.2.3.4.5" }, "urn:oid:1.2.3.4.5");
-
- var result = testBundle.FindEntry("http://nu.nl/fhir/Patient/1234");
- Assert.AreEqual(2, result.Count());
- result = testBundle.FindEntry("http://nu.nl/fhir/Patient/1234", includeDeleted: true);
- Assert.AreEqual(3, result.Count());
- result = testBundle.FindEntry("http://nu.nl/fhir/Patient/1234/_history/v3", includeDeleted: true);
- Assert.AreEqual(1, result.Count());
- result = testBundle.FindEntry(new Uri("http://server3.org/fhir/Patient/1234"));
- Assert.AreEqual(0, result.Count());
-
- result = testBundle.FindEntry(new Uri("http://server1.com/fhir/Patient/5678"));
- Assert.AreEqual(1, result.Count());
- result = testBundle.FindEntry(new Uri("http://server2.com/fhir/Patient/5678"));
- Assert.AreEqual(0, result.Count());
-
- result = testBundle.FindEntry(new Uri("urn:oid:1.2.3.4.5"));
- Assert.AreEqual(1, result.Count());
- }
-
- [TestMethod]
- public void AddSearchEntry()
- {
- var testBundle = new Bundle();
- testBundle.AddSearchEntry(new Patient { Id = "5678" }, "http://server1.com/fhir/Patient/5678", Bundle.SearchEntryMode.Match);
-
- var firstEntry = testBundle.FindEntry("http://server1.com/fhir/Patient/5678").First();
-
- Assert.AreEqual(Bundle.SearchEntryMode.Match, firstEntry.Search.Mode);
- Assert.AreEqual("5678", firstEntry.Resource.Id);
-
- testBundle.AddSearchEntry(
- new Patient { Id = "5679" },
- "http://server1.com/fhir/Patient/5679",
- Bundle.SearchEntryMode.Include,
- new decimal(0.1));
-
- var secondEntry = testBundle.FindEntry("http://server1.com/fhir/Patient/5679").First();
- Assert.AreEqual(Bundle.SearchEntryMode.Include, secondEntry.Search.Mode);
- Assert.AreEqual("5679", secondEntry.Resource.Id);
- Assert.AreEqual((Decimal)0.1, secondEntry.Search.Score);
-
- // Retest that the first one can still be located
- firstEntry = testBundle.FindEntry("http://server1.com/fhir/Patient/5678").First();
-
- Assert.AreEqual(Bundle.SearchEntryMode.Match, firstEntry.Search.Mode);
- Assert.AreEqual("5678", firstEntry.Resource.Id);
- }
- }
-}
diff --git a/src/Hl7.Fhir.STU3.Tests/Model/AnnotationTests.cs b/src/Hl7.Fhir.Support.Poco.Tests/Model/AnnotationTests.cs
similarity index 100%
rename from src/Hl7.Fhir.STU3.Tests/Model/AnnotationTests.cs
rename to src/Hl7.Fhir.Support.Poco.Tests/Model/AnnotationTests.cs
diff --git a/src/Hl7.Fhir.STU3.Tests/Model/BundleExtensionsTest.cs b/src/Hl7.Fhir.Support.Poco.Tests/Model/BundleExtensionsTest.cs
similarity index 100%
rename from src/Hl7.Fhir.STU3.Tests/Model/BundleExtensionsTest.cs
rename to src/Hl7.Fhir.Support.Poco.Tests/Model/BundleExtensionsTest.cs
diff --git a/src/Hl7.Fhir.Shared.Tests/Model/CodeEnumTests.cs b/src/Hl7.Fhir.Support.Poco.Tests/Model/CodeEnumTests.cs
similarity index 88%
rename from src/Hl7.Fhir.Shared.Tests/Model/CodeEnumTests.cs
rename to src/Hl7.Fhir.Support.Poco.Tests/Model/CodeEnumTests.cs
index 527d382a47..c2a2ad94dc 100644
--- a/src/Hl7.Fhir.Shared.Tests/Model/CodeEnumTests.cs
+++ b/src/Hl7.Fhir.Support.Poco.Tests/Model/CodeEnumTests.cs
@@ -51,15 +51,15 @@ public void SetRawValueUpdatesValue()
}
[TestMethod]
- public void TestISystemAndCode()
+ public void TestToSystemCode()
{
- var c = new Code(AdministrativeGender.Female) as ISystemAndCode;
+ var c = new Code(AdministrativeGender.Female).ToSystemCode();
- Assert.AreEqual("female", c.Code);
+ Assert.AreEqual("female", c.Value);
Assert.AreEqual("http://hl7.org/fhir/administrative-gender", c.System);
- c = new Code(TestEnum.IHaveNoSystem) as ISystemAndCode;
- Assert.AreEqual("IHaveNoSystem", c.Code);
+ c = new Code(TestEnum.IHaveNoSystem).ToSystemCode();
+ Assert.AreEqual("IHaveNoSystem", c.Value);
Assert.IsNull(c.System);
}
@@ -69,4 +69,4 @@ private enum TestEnum
IHaveNoSystem = 4
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Hl7.Fhir.Shared.Tests/Model/NullExtensionsTest.cs b/src/Hl7.Fhir.Support.Poco.Tests/Model/NullExtensionsTest.cs
similarity index 100%
rename from src/Hl7.Fhir.Shared.Tests/Model/NullExtensionsTest.cs
rename to src/Hl7.Fhir.Support.Poco.Tests/Model/NullExtensionsTest.cs
diff --git a/src/Hl7.Fhir.Support.Tests/Introspection/PropertyMappingTest.cs b/src/Hl7.Fhir.Support.Tests/Introspection/PropertyMappingTest.cs
index a810122474..0a65347f9c 100644
--- a/src/Hl7.Fhir.Support.Tests/Introspection/PropertyMappingTest.cs
+++ b/src/Hl7.Fhir.Support.Tests/Introspection/PropertyMappingTest.cs
@@ -11,6 +11,7 @@
using Hl7.Fhir.Model;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
+using System.Collections.Generic;
using System.Diagnostics;
namespace Hl7.Fhir.Tests.Introspection;
@@ -134,16 +135,13 @@ public class TypeWithCodeOfT
}
[FhirType("BindableClass")]
- [Bindable(true)]
- public class BindableClass
+ public class BindableClass : ICoded
{
+ public IEnumerable ToCodings() => throw new NotImplementedException();
}
[FhirType("NonBindableClass")]
- [Bindable(false)]
- public class NonBindableClass
- {
- }
+ public class NonBindableClass;
[TestMethod]
public void IsBindableTest()