diff --git a/src/Hl7.Fhir.Base/Introspection/ModelInspector.cs b/src/Hl7.Fhir.Base/Introspection/ModelInspector.cs index 0c0c54ffd9..cbb08dae64 100644 --- a/src/Hl7.Fhir.Base/Introspection/ModelInspector.cs +++ b/src/Hl7.Fhir.Base/Introspection/ModelInspector.cs @@ -295,8 +295,7 @@ private void extractBackbonesFromClasses(IEnumerable classTypes) public Type? GetTypeForFhirType(string name) => FindClassMapping(name) is { } mapping ? mapping.NativeType : null; - public bool IsBindable(string type) => FindClassMapping(type) is { } mapping && mapping.IsBindable || - type == "CodeableReference"; + public bool IsBindable(string type) => FindClassMapping(type) is { } mapping && mapping.IsBindable; public bool IsConformanceResource(string name) => GetTypeForFhirType(name) is { } type && IsConformanceResource(type); diff --git a/src/Hl7.Fhir.R4B/Model/CodeableReference.cs b/src/Hl7.Fhir.Base/Model/CodeableReference.cs similarity index 100% rename from src/Hl7.Fhir.R4B/Model/CodeableReference.cs rename to src/Hl7.Fhir.Base/Model/CodeableReference.cs diff --git a/src/Hl7.Fhir.R5/Model/Generated/CodeableReference.cs b/src/Hl7.Fhir.Base/Model/Generated/CodeableReference.cs similarity index 100% rename from src/Hl7.Fhir.R5/Model/Generated/CodeableReference.cs rename to src/Hl7.Fhir.Base/Model/Generated/CodeableReference.cs diff --git a/src/Hl7.Fhir.Base/Model/Generated/_GeneratorLog.cs b/src/Hl7.Fhir.Base/Model/Generated/_GeneratorLog.cs index 494d61f818..d98c693841 100644 --- a/src/Hl7.Fhir.Base/Model/Generated/_GeneratorLog.cs +++ b/src/Hl7.Fhir.Base/Model/Generated/_GeneratorLog.cs @@ -302,6 +302,7 @@ // BackboneElement.cs // BackboneType.cs // CodeableConcept.cs +// CodeableReference.cs // Coding.cs // ContactDetail.cs // ContactPoint.cs diff --git a/src/Hl7.Fhir.ElementModel.R4B.Tests/ParseExtensionsTests.cs b/src/Hl7.Fhir.ElementModel.R4B.Tests/ParseExtensionsTests.cs index d55be1c822..9e027fda75 100644 --- a/src/Hl7.Fhir.ElementModel.R4B.Tests/ParseExtensionsTests.cs +++ b/src/Hl7.Fhir.ElementModel.R4B.Tests/ParseExtensionsTests.cs @@ -1,7 +1,6 @@ using FluentAssertions; using Hl7.Fhir.ElementModel; using Hl7.Fhir.Model; -using Hl7.Fhir.Specification.Terminology; using System.Collections.Generic; using Xunit; diff --git a/src/Hl7.Fhir.R4B/Model/Generated/CodeableReference.cs b/src/Hl7.Fhir.R4B/Model/Generated/CodeableReference.cs deleted file mode 100644 index c637ef5a15..0000000000 --- a/src/Hl7.Fhir.R4B/Model/Generated/CodeableReference.cs +++ /dev/null @@ -1,178 +0,0 @@ -// -// Contents of: hl7.fhir.r4b.core version: 4.3.0 - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.Serialization; -using Hl7.Fhir.Introspection; -using Hl7.Fhir.Serialization; -using Hl7.Fhir.Specification; -using Hl7.Fhir.Utility; -using Hl7.Fhir.Validation; - -/* - Copyright (c) 2011+, 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 -{ - /// - /// Reference to a resource or a concept - /// - [Serializable] - [DataContract] - [FhirType("CodeableReference","http://hl7.org/fhir/StructureDefinition/CodeableReference")] - public partial class CodeableReference : Hl7.Fhir.Model.DataType - { - /// - /// FHIR Type Name - /// - public override string TypeName { get { return "CodeableReference"; } } - - /// - /// Reference to a concept (by class) - /// - [FhirElement("concept", InSummary=true, Order=30)] - [DataMember] - public Hl7.Fhir.Model.CodeableConcept Concept - { - get { return _Concept; } - set { _Concept = value; OnPropertyChanged("Concept"); } - } - - private Hl7.Fhir.Model.CodeableConcept _Concept; - - /// - /// Reference to a resource (by instance) - /// - [FhirElement("reference", InSummary=true, Order=40)] - [DataMember] - public Hl7.Fhir.Model.ResourceReference Reference - { - get { return _Reference; } - set { _Reference = value; OnPropertyChanged("Reference"); } - } - - private Hl7.Fhir.Model.ResourceReference _Reference; - - public override IDeepCopyable CopyTo(IDeepCopyable other) - { - var dest = other as CodeableReference; - - if (dest == null) - { - throw new ArgumentException("Can only copy to an object of the same type", "other"); - } - - base.CopyTo(dest); - if(Concept != null) dest.Concept = (Hl7.Fhir.Model.CodeableConcept)Concept.DeepCopy(); - if(Reference != null) dest.Reference = (Hl7.Fhir.Model.ResourceReference)Reference.DeepCopy(); - return dest; - } - - public override IDeepCopyable DeepCopy() - { - return CopyTo(new CodeableReference()); - } - - /// - public override bool Matches(IDeepComparable other) - { - var otherT = other as CodeableReference; - if(otherT == null) return false; - - if(!base.Matches(otherT)) return false; - if( !DeepComparable.Matches(Concept, otherT.Concept)) return false; - if( !DeepComparable.Matches(Reference, otherT.Reference)) return false; - - return true; - } - - public override bool IsExactly(IDeepComparable other) - { - var otherT = other as CodeableReference; - if(otherT == null) return false; - - if(!base.IsExactly(otherT)) return false; - if( !DeepComparable.IsExactly(Concept, otherT.Concept)) return false; - if( !DeepComparable.IsExactly(Reference, otherT.Reference)) return false; - - return true; - } - - [IgnoreDataMember] - public override IEnumerable Children - { - get - { - foreach (var item in base.Children) yield return item; - if (Concept != null) yield return Concept; - if (Reference != null) yield return Reference; - } - } - - [IgnoreDataMember] - public override IEnumerable NamedChildren - { - get - { - foreach (var item in base.NamedChildren) yield return item; - if (Concept != null) yield return new ElementValue("concept", Concept); - if (Reference != null) yield return new ElementValue("reference", Reference); - } - } - - protected override bool TryGetValue(string key, out object value) - { - switch (key) - { - case "concept": - value = Concept; - return Concept is not null; - case "reference": - value = Reference; - return Reference is not null; - default: - return base.TryGetValue(key, out value); - } - - } - - protected override IEnumerable> GetElementPairs() - { - foreach (var kvp in base.GetElementPairs()) yield return kvp; - if (Concept is not null) yield return new KeyValuePair("concept",Concept); - if (Reference is not null) yield return new KeyValuePair("reference",Reference); - } - - } - -} - -// end of file diff --git a/src/Hl7.Fhir.R4B/Model/Generated/_GeneratorLog.cs b/src/Hl7.Fhir.R4B/Model/Generated/_GeneratorLog.cs index 8399c5f74a..b90095b1ce 100644 --- a/src/Hl7.Fhir.R4B/Model/Generated/_GeneratorLog.cs +++ b/src/Hl7.Fhir.R4B/Model/Generated/_GeneratorLog.cs @@ -283,7 +283,6 @@ // Address.cs // Age.cs // Annotation.cs -// CodeableReference.cs // Contributor.cs // Count.cs // DataRequirement.cs diff --git a/src/Hl7.Fhir.R5/Model/CodeableReference.cs b/src/Hl7.Fhir.R5/Model/CodeableReference.cs deleted file mode 100644 index 5cd8b15f2c..0000000000 --- a/src/Hl7.Fhir.R5/Model/CodeableReference.cs +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2024, 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 - */ - -#nullable enable -using Hl7.Fhir.Introspection; - -namespace Hl7.Fhir.Model -{ - [Bindable(true)] - public partial class CodeableReference - { - } -} \ No newline at end of file diff --git a/src/Hl7.Fhir.R5/Model/Generated/_GeneratorLog.cs b/src/Hl7.Fhir.R5/Model/Generated/_GeneratorLog.cs index e877fee87f..b4b0434254 100644 --- a/src/Hl7.Fhir.R5/Model/Generated/_GeneratorLog.cs +++ b/src/Hl7.Fhir.R5/Model/Generated/_GeneratorLog.cs @@ -308,7 +308,6 @@ // Age.cs // Annotation.cs // Availability.cs -// CodeableReference.cs // Contributor.cs // Count.cs // DataRequirement.cs diff --git a/src/Hl7.Fhir.Support.Tests/Introspection/ModelInspectorTest.cs b/src/Hl7.Fhir.Support.Tests/Introspection/ModelInspectorTest.cs index c6f0d90766..f6f40fa26d 100644 --- a/src/Hl7.Fhir.Support.Tests/Introspection/ModelInspectorTest.cs +++ b/src/Hl7.Fhir.Support.Tests/Introspection/ModelInspectorTest.cs @@ -6,6 +6,7 @@ * available at https://raw.githubusercontent.com/FirelyTeam/firely-net-sdk/master/LICENSE */ +using FluentAssertions; using System.Reflection; using Microsoft.VisualStudio.TestTools.UnitTesting; using Hl7.Fhir.Model; @@ -37,6 +38,18 @@ public void TestResourceNameResolving() Assert.IsNull(noway); } + [TestMethod] + public void TestIsBindable() + { + ModelInspector.Base.IsBindable("string").Should().BeTrue(); + ModelInspector.Base.IsBindable("uri").Should().BeTrue(); + ModelInspector.Base.IsBindable("Quantity").Should().BeTrue(); + ModelInspector.Base.IsBindable("Extension").Should().BeTrue(); + ModelInspector.Base.IsBindable("Coding").Should().BeTrue(); + ModelInspector.Base.IsBindable("CodeableConcept").Should().BeTrue(); + ModelInspector.Base.IsBindable("CodeableReference").Should().BeTrue(); + ModelInspector.Base.IsBindable("integer").Should().BeFalse(); + } [TestMethod] public void TestAssemblyInspection()