From c40e360a51c8235ea19de466e12fb839edb26fff Mon Sep 17 00:00:00 2001 From: Ewout Kramer Date: Fri, 17 Jan 2025 17:12:12 +0100 Subject: [PATCH] Implemented IToSystemPrimitive on all applicable FHIR Primitives. --- src/Benchmarks/DateTimeBenchmark.cs | 6 +- .../CompatibilitySuppressions.xml | 560 ++++++++++++++++++ src/Hl7.Fhir.Base/ElementModel/Types/Any.cs | 2 +- .../ElementModel/Types/Boolean.cs | 2 +- ...qlConvertible.cs => IToSystemPrimitive.cs} | 11 +- .../ElementModel/Types/Quantity.cs | 2 +- .../FhirPath/Functions/ConversionOperators.cs | 59 +- src/Hl7.Fhir.Base/Model/Canonical.cs | 216 +++---- src/Hl7.Fhir.Base/Model/Code.cs | 13 +- src/Hl7.Fhir.Base/Model/CodeOfT.cs | 6 +- src/Hl7.Fhir.Base/Model/CodeableConcept.cs | 16 +- src/Hl7.Fhir.Base/Model/CodeableReference.cs | 42 +- src/Hl7.Fhir.Base/Model/Coding.cs | 15 +- src/Hl7.Fhir.Base/Model/Date.cs | 28 +- src/Hl7.Fhir.Base/Model/FhirBoolean.cs | 27 +- src/Hl7.Fhir.Base/Model/FhirDateTime.cs | 24 +- src/Hl7.Fhir.Base/Model/FhirDecimal.cs | 27 +- src/Hl7.Fhir.Base/Model/FhirString.cs | 11 +- src/Hl7.Fhir.Base/Model/FhirUri.cs | 13 +- src/Hl7.Fhir.Base/Model/FhirUrl.cs | 48 +- src/Hl7.Fhir.Base/Model/Instant.cs | 65 +- src/Hl7.Fhir.Base/Model/Integer.cs | 26 +- src/Hl7.Fhir.Base/Model/Integer64.cs | 26 +- src/Hl7.Fhir.Base/Model/Markdown.cs | 31 +- src/Hl7.Fhir.Base/Model/Oid.cs | 38 +- src/Hl7.Fhir.Base/Model/PositiveInt.cs | 26 +- src/Hl7.Fhir.Base/Model/Quantity.cs | 29 +- src/Hl7.Fhir.Base/Model/Time.cs | 23 +- src/Hl7.Fhir.Base/Model/UnsignedInt.cs | 26 +- src/Hl7.Fhir.Base/Model/Uuid.cs | 52 +- .../Model/DateTests.cs | 6 +- .../Model/DateTimeTests.cs | 10 +- .../Model/TimeTests.cs | 8 +- 33 files changed, 1128 insertions(+), 366 deletions(-) rename src/Hl7.Fhir.Base/ElementModel/Types/{ICqlConvertible.cs => IToSystemPrimitive.cs} (68%) diff --git a/src/Benchmarks/DateTimeBenchmark.cs b/src/Benchmarks/DateTimeBenchmark.cs index 7eb86dff16..a1483ec136 100644 --- a/src/Benchmarks/DateTimeBenchmark.cs +++ b/src/Benchmarks/DateTimeBenchmark.cs @@ -10,10 +10,10 @@ public class DateTimeBenchmarks public void BenchmarkSetup() { _dateTimeInstance = new FhirDateTime(DATETIME); - _ = _dateTimeInstance.TryToDateTime(out var _); // trigger initial compile of regex + _ = _dateTimeInstance.TryToSystemDateTime(out var _); // trigger initial compile of regex _dateInstance = new Date(DATE); - _ = _dateInstance.TryToDate(out var _); // trigger initial compile of regex + _ = _dateInstance.TryToSystemDate(out var _); // trigger initial compile of regex } private const string DATETIME = "2023-07-11T13:00:00"; @@ -59,4 +59,4 @@ public DateTimeOffset DateToDTO_Cached() return result; } } -} +} \ No newline at end of file diff --git a/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml b/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml index 362003322f..f6d525cfc1 100644 --- a/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml +++ b/src/Hl7.Fhir.Base/CompatibilitySuppressions.xml @@ -15,6 +15,13 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0001 + T:Hl7.Fhir.ElementModel.Types.ICqlConvertible + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0001 T:Hl7.Fhir.ElementModel.Types.MetricConfiguration @@ -43,6 +50,13 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0001 + T:Hl7.Fhir.Model.ElementValue + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0001 T:Hl7.Fhir.Model.IDeepComparable @@ -134,6 +148,55 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0001 + T:Hl7.Fhir.Utility.Fail + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0001 + T:Hl7.Fhir.Utility.Fail`1 + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0001 + T:Hl7.Fhir.Utility.IFailed + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0001 + T:Hl7.Fhir.Utility.Ok + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0001 + T:Hl7.Fhir.Utility.Ok`1 + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0001 + T:Hl7.Fhir.Utility.Result + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0001 + T:Hl7.Fhir.Utility.Result`1 + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0002 F:Hl7.Fhir.ElementModel.ScopedNode.Parent @@ -141,6 +204,13 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0002 + F:Hl7.Fhir.ElementModel.Types.Any.ArgNullException + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0002 F:Hl7.Fhir.Model.Resource.SyncLock @@ -253,6 +323,188 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Any.CannotCastTo``1(Hl7.Fhir.ElementModel.Types.Any) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Any.NotSameTypeComparison(System.Object,System.Object) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Any.Parse(System.String,System.Type) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Any.propagateNull``1(System.Object,System.Func{``0}) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Any.TryParse(System.String,System.Type,System.Object@) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Code.op_Implicit(Hl7.Fhir.ElementModel.Types.Code)~Hl7.Fhir.ElementModel.Types.Concept + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Date.TryCompareTo(Hl7.Fhir.ElementModel.Types.Any) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Date.TryEquals(Hl7.Fhir.ElementModel.Types.Any) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.DateTime.TryCompareTo(Hl7.Fhir.ElementModel.Types.Any) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.DateTime.TryEquals(Hl7.Fhir.ElementModel.Types.Any) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Decimal.op_Explicit(Hl7.Fhir.ElementModel.Types.Decimal)~Hl7.Fhir.ElementModel.Types.String + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Integer.op_Implicit(Hl7.Fhir.ElementModel.Types.Integer)~Hl7.Fhir.ElementModel.Types.Decimal + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Integer.op_Implicit(Hl7.Fhir.ElementModel.Types.Integer)~Hl7.Fhir.ElementModel.Types.Long + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Integer.op_Implicit(Hl7.Fhir.ElementModel.Types.Integer)~Hl7.Fhir.ElementModel.Types.Quantity + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Long.op_Implicit(Hl7.Fhir.ElementModel.Types.Long)~Hl7.Fhir.ElementModel.Types.Decimal + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Long.op_Implicit(Hl7.Fhir.ElementModel.Types.Long)~Hl7.Fhir.ElementModel.Types.Quantity + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Quantity.op_Addition(Hl7.Fhir.ElementModel.Types.Quantity,Hl7.Fhir.ElementModel.Types.Quantity) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Quantity.op_Division(Hl7.Fhir.ElementModel.Types.Quantity,Hl7.Fhir.ElementModel.Types.Quantity) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Quantity.op_Multiply(Hl7.Fhir.ElementModel.Types.Quantity,Hl7.Fhir.ElementModel.Types.Quantity) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Quantity.op_Subtraction(Hl7.Fhir.ElementModel.Types.Quantity,Hl7.Fhir.ElementModel.Types.Quantity) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Quantity.TryCompareTo(Hl7.Fhir.ElementModel.Types.Any,Hl7.Fhir.ElementModel.Types.QuantityComparison) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Quantity.TryCompareTo(Hl7.Fhir.ElementModel.Types.Any) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Quantity.TryEquals(Hl7.Fhir.ElementModel.Types.Any,Hl7.Fhir.ElementModel.Types.QuantityComparison) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.String.#ctor + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Time.TryCompareTo(Hl7.Fhir.ElementModel.Types.Any) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.ElementModel.Types.Time.TryEquals(Hl7.Fhir.ElementModel.Types.Any) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0002 M:Hl7.Fhir.FhirPath.ElementNavFhirExtensions.HasValue(Hl7.Fhir.ElementModel.ITypedElement) @@ -421,6 +673,55 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0002 + M:Hl7.Fhir.Model.Date.op_Equality(Hl7.Fhir.Model.Date,Hl7.Fhir.Model.Date) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Date.op_GreaterThan(Hl7.Fhir.Model.Date,Hl7.Fhir.Model.Date) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Date.op_GreaterThanOrEqual(Hl7.Fhir.Model.Date,Hl7.Fhir.Model.Date) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Date.op_Inequality(Hl7.Fhir.Model.Date,Hl7.Fhir.Model.Date) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Date.op_LessThan(Hl7.Fhir.Model.Date,Hl7.Fhir.Model.Date) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Date.op_LessThanOrEqual(Hl7.Fhir.Model.Date,Hl7.Fhir.Model.Date) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Date.ToDate + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0002 M:Hl7.Fhir.Model.Date.ToDateTimeOffset @@ -428,6 +729,111 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0002 + M:Hl7.Fhir.Model.Date.TryToDate(Hl7.Fhir.ElementModel.Types.Date@) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.FhirDateTime.op_Equality(Hl7.Fhir.Model.FhirDateTime,Hl7.Fhir.Model.FhirDateTime) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.FhirDateTime.op_GreaterThan(Hl7.Fhir.Model.FhirDateTime,Hl7.Fhir.Model.FhirDateTime) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.FhirDateTime.op_GreaterThanOrEqual(Hl7.Fhir.Model.FhirDateTime,Hl7.Fhir.Model.FhirDateTime) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.FhirDateTime.op_Inequality(Hl7.Fhir.Model.FhirDateTime,Hl7.Fhir.Model.FhirDateTime) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.FhirDateTime.op_LessThan(Hl7.Fhir.Model.FhirDateTime,Hl7.Fhir.Model.FhirDateTime) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.FhirDateTime.op_LessThanOrEqual(Hl7.Fhir.Model.FhirDateTime,Hl7.Fhir.Model.FhirDateTime) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.FhirDateTime.ToDateTime + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.FhirDateTime.TryToDateTime(Hl7.Fhir.ElementModel.Types.DateTime@) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Instant.op_Equality(Hl7.Fhir.Model.Instant,Hl7.Fhir.Model.Instant) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Instant.op_GreaterThan(Hl7.Fhir.Model.Instant,Hl7.Fhir.Model.Instant) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Instant.op_GreaterThanOrEqual(Hl7.Fhir.Model.Instant,Hl7.Fhir.Model.Instant) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Instant.op_Inequality(Hl7.Fhir.Model.Instant,Hl7.Fhir.Model.Instant) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Instant.op_LessThan(Hl7.Fhir.Model.Instant,Hl7.Fhir.Model.Instant) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Instant.op_LessThanOrEqual(Hl7.Fhir.Model.Instant,Hl7.Fhir.Model.Instant) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0002 M:Hl7.Fhir.Model.Meta.get_ProfileElement @@ -442,6 +848,13 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0002 + M:Hl7.Fhir.Model.Quantity.ToQuantity + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0002 M:Hl7.Fhir.Model.Resource.get_HasVersionId @@ -449,6 +862,62 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0002 + M:Hl7.Fhir.Model.Time.op_Equality(Hl7.Fhir.Model.Time,Hl7.Fhir.Model.Time) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Time.op_GreaterThan(Hl7.Fhir.Model.Time,Hl7.Fhir.Model.Time) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Time.op_GreaterThanOrEqual(Hl7.Fhir.Model.Time,Hl7.Fhir.Model.Time) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Time.op_Inequality(Hl7.Fhir.Model.Time,Hl7.Fhir.Model.Time) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Time.op_LessThan(Hl7.Fhir.Model.Time,Hl7.Fhir.Model.Time) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Time.op_LessThanOrEqual(Hl7.Fhir.Model.Time,Hl7.Fhir.Model.Time) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Time.ToTime + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0002 + M:Hl7.Fhir.Model.Time.TryToTime(Hl7.Fhir.ElementModel.Types.Time@) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0002 M:Hl7.Fhir.Serialization.BaseFhirJsonPocoDeserializer.#ctor(Hl7.Fhir.Introspection.ModelInspector,Hl7.Fhir.Serialization.FhirJsonPocoDeserializerSettings) @@ -1058,6 +1527,13 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0005 + M:Hl7.Fhir.ElementModel.Types.Any.TryConvertTo(System.Type,Hl7.Fhir.ElementModel.Types.Any@) + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0006 M:Hl7.Fhir.ElementModel.ITypedElement.Children(System.String) @@ -1114,6 +1590,90 @@ lib/net8.0/Hl7.Fhir.Base.dll true + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Boolean + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Code + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Concept + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Date + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.DateTime + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Decimal + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Integer + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Long + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Quantity + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Ratio + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.String + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + + + CP0008 + T:Hl7.Fhir.ElementModel.Types.Time + lib/net8.0/Hl7.Fhir.Base.dll + lib/net8.0/Hl7.Fhir.Base.dll + true + CP0008 T:Hl7.Fhir.Model.Attachment diff --git a/src/Hl7.Fhir.Base/ElementModel/Types/Any.cs b/src/Hl7.Fhir.Base/ElementModel/Types/Any.cs index 436df86b1f..596c3f6c59 100644 --- a/src/Hl7.Fhir.Base/ElementModel/Types/Any.cs +++ b/src/Hl7.Fhir.Base/ElementModel/Types/Any.cs @@ -17,7 +17,7 @@ namespace Hl7.Fhir.ElementModel.Types; /// /// The base class for all CQL/FhirPath types. /// -public abstract class Any : ICqlConvertible +public abstract class Any { /// /// Returns the concrete subclass of Any that is used to represent the diff --git a/src/Hl7.Fhir.Base/ElementModel/Types/Boolean.cs b/src/Hl7.Fhir.Base/ElementModel/Types/Boolean.cs index cf4d8fe828..126ceb34e6 100644 --- a/src/Hl7.Fhir.Base/ElementModel/Types/Boolean.cs +++ b/src/Hl7.Fhir.Base/ElementModel/Types/Boolean.cs @@ -13,7 +13,7 @@ namespace Hl7.Fhir.ElementModel.Types; -public class Boolean(bool value) : Any, ICqlEquatable, ICqlConvertible +public class Boolean(bool value) : Any, ICqlEquatable { public static Boolean True = new(true); public static Boolean False = new(false); diff --git a/src/Hl7.Fhir.Base/ElementModel/Types/ICqlConvertible.cs b/src/Hl7.Fhir.Base/ElementModel/Types/IToSystemPrimitive.cs similarity index 68% rename from src/Hl7.Fhir.Base/ElementModel/Types/ICqlConvertible.cs rename to src/Hl7.Fhir.Base/ElementModel/Types/IToSystemPrimitive.cs index c9aa581d8c..966b205b18 100644 --- a/src/Hl7.Fhir.Base/ElementModel/Types/ICqlConvertible.cs +++ b/src/Hl7.Fhir.Base/ElementModel/Types/IToSystemPrimitive.cs @@ -12,20 +12,23 @@ namespace Hl7.Fhir.ElementModel.Types; -public interface ICqlConvertible +/// +/// An interface to convert a model POCO into a CQL/FhirPath type. +/// +public interface IToSystemPrimitive { /// /// Tries to convert this object into a CQL/FhirPath type. /// - /// The subclass of Any to convert to. /// If succesful, the converted object, otherwise null. - bool TryConvertTo(Type to, [NotNullWhen(true)] out Any? result); + /// true if this model object has a CQL equivalent and the conversion succeeded, otherwise false. + bool TryConvertToSystemType([NotNullWhen(true)] out Any? result); } public static class CqlConvertible { - public static bool TryConvertTo(this ICqlConvertible source, [NotNullWhen(true)] out T? result) where T : Any + public static bool TryConvertTo(this Any source, [NotNullWhen(true)] out T? result) where T : Any { var success = source.TryConvertTo(typeof(T), out var any) && any is T; diff --git a/src/Hl7.Fhir.Base/ElementModel/Types/Quantity.cs b/src/Hl7.Fhir.Base/ElementModel/Types/Quantity.cs index 6c97ca4ba7..73ff2af33c 100644 --- a/src/Hl7.Fhir.Base/ElementModel/Types/Quantity.cs +++ b/src/Hl7.Fhir.Base/ElementModel/Types/Quantity.cs @@ -16,7 +16,7 @@ namespace Hl7.Fhir.ElementModel.Types; public class Quantity(decimal value, string? unit, QuantityUnitSystem system) - : Any, IComparable, ICqlEquatable, ICqlOrderable, ICqlConvertible + : Any, IComparable, ICqlEquatable, ICqlOrderable { public const string UCUM = "http://unitsofmeasure.org"; public const string UCUM_UNIT = "1"; diff --git a/src/Hl7.Fhir.Base/FhirPath/Functions/ConversionOperators.cs b/src/Hl7.Fhir.Base/FhirPath/Functions/ConversionOperators.cs index ac73d5ba9c..9f8c81b7ec 100644 --- a/src/Hl7.Fhir.Base/FhirPath/Functions/ConversionOperators.cs +++ b/src/Hl7.Fhir.Base/FhirPath/Functions/ConversionOperators.cs @@ -22,11 +22,8 @@ internal static class ConversionOperators /// /// /// - public static bool? ToBoolean(this Any focus) - { - if (focus is not ICqlConvertible c) return null; - return c.TryConvertTo(out var result) ? result.Value : null; - } + public static bool? ToBoolean(this Any focus) => + focus.TryConvertTo(out var result) ? result.Value : null; /// /// FhirPath convertsToBoolean() function @@ -41,11 +38,7 @@ internal static class ConversionOperators /// /// /// - public static int? ToInteger(this Any focus) - { - if (focus is not ICqlConvertible c) return null; - return c.TryConvertTo(out var result) ? result.Value : null; - } + public static int? ToInteger(this Any focus) => focus.TryConvertTo(out var result) ? result.Value : null; /// /// FhirPath convertsToInteger() function. @@ -60,11 +53,8 @@ internal static class ConversionOperators /// /// /// - public static decimal? ToDecimal(this Any focus) - { - if (focus is not ICqlConvertible c) return null; - return c.TryConvertTo(out var result) ? result.Value : null; - } + public static decimal? ToDecimal(this Any focus) => + focus.TryConvertTo(out var result) ? result.Value : null; /// /// FhirPath convertsToDecimal() function. @@ -79,11 +69,7 @@ internal static class ConversionOperators /// /// /// - public static long? ToLong(this Any focus) - { - if (focus is not ICqlConvertible c) return null; - return c.TryConvertTo(out var result) ? result.Value : null; - } + public static long? ToLong(this Any focus) => focus.TryConvertTo(out var result) ? result.Value : null; /// @@ -99,11 +85,7 @@ internal static class ConversionOperators /// /// /// - public static P.Quantity? ToQuantity(this Any focus) - { - if (focus is not ICqlConvertible c) return null; - return c.TryConvertTo(out var result) ? result : null; - } + public static P.Quantity? ToQuantity(this Any focus) => focus.TryConvertTo(out var result) ? result : null; /// /// FhirPath convertsToQuantity() function. @@ -118,11 +100,8 @@ internal static class ConversionOperators /// /// /// - public static string? ToStringRepresentation(this Any focus) - { - if (focus is not ICqlConvertible c) return null; - return c.TryConvertTo(out var result) ? result.Value : null; - } + public static string? ToStringRepresentation(this Any focus) => + focus.TryConvertTo(out var result) ? result.Value : null; /// /// FhirPath convertsToString() function. @@ -136,11 +115,7 @@ internal static class ConversionOperators /// /// /// - public static P.Date? ToDate(this Any focus) - { - if (focus is not ICqlConvertible c) return null; - return c.TryConvertTo(out var result) ? result : null; - } + public static P.Date? ToDate(this Any focus) => focus.TryConvertTo(out var result) ? result : null; /// @@ -156,11 +131,7 @@ internal static class ConversionOperators /// /// /// - public static P.DateTime? ToDateTime(this Any focus) - { - if (focus is not ICqlConvertible c) return null; - return c.TryConvertTo(out var result) ? result : null; - } + public static P.DateTime? ToDateTime(this Any focus) => focus.TryConvertTo(out var result) ? result : null; /// @@ -175,13 +146,7 @@ internal static class ConversionOperators /// /// /// - public static P.Time? ToTime(this Any focus) - { - if (focus is not ICqlConvertible c) return null; - return c.TryConvertTo