Skip to content

Commit

Permalink
Fixes #2935.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoutkramer committed Dec 3, 2024
1 parent ca56c0b commit c5e4d28
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 82 deletions.
7 changes: 3 additions & 4 deletions src/Hl7.Fhir.Base/ElementModel/ScopedNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

using Hl7.Fhir.Model;
using Hl7.Fhir.Specification;
using Hl7.Fhir.Support.Poco;
using Hl7.Fhir.Utility;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -94,9 +93,9 @@ private ScopedNode(ScopedNode parentNode, ScopedNode? parentResource, ITypedElem
public NodeType Type => this switch
{
{ AtResource: true } when Current.Children("contained").Any() => NodeType.DomainResource | NodeType.Resource,
{ InstanceType: FhirTypeConstants.BUNDLE } => NodeType.Bundle | NodeType.Resource,
{ InstanceType: FhirTypeNames.BUNDLE } => NodeType.Bundle | NodeType.Resource,
{ AtResource: true } => NodeType.Resource,
{ InstanceType: FhirTypeConstants.REFERENCE or FhirTypeConstants.CANONICAL or FhirTypeConstants.CODEABLEREFERENCE } => NodeType.Reference,
{ InstanceType: FhirTypeNames.REFERENCE or FhirTypeNames.CANONICAL or FhirTypeNames.CODEABLEREFERENCE } => NodeType.Reference,
{ Value: not null } => NodeType.Primitive,
_ => 0
};
Expand Down Expand Up @@ -293,4 +292,4 @@ public IEnumerable<IScopedNode> Children(string? name = null) =>

public string ShortPath => Current is ElementNode en ? en.ShortPath : Current.Location;
}
}
}
17 changes: 8 additions & 9 deletions src/Hl7.Fhir.Base/ElementModel/TypedElementParseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/

using Hl7.Fhir.Model;
using Hl7.Fhir.Support.Poco;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -47,14 +46,14 @@ public static class TypedElementParseExtensions
{
return instance.InstanceType switch
{
FhirTypeConstants.CODE => instance.ParsePrimitiveInternal<Code>(),
FhirTypeConstants.STRING => new Code(instance.ParsePrimitiveInternal<FhirString>().Value),
FhirTypeConstants.URI => new Code(instance.ParsePrimitiveInternal<FhirUri>().Value),
FhirTypeConstants.CODING => instance.ParseCodingInternal(),
FhirTypeConstants.CODEABLE_CONCEPT => instance.ParseCodeableConceptInternal(),
FhirTypeConstants.QUANTITY => parseQuantity(),
FhirTypeConstants.EXTENSION => parseExtension(),
FhirTypeConstants.CODEABLEREFERENCE => parseCodeableReference(),
FhirTypeNames.CODE => instance.ParsePrimitiveInternal<Code>(),
FhirTypeNames.STRING => new Code(instance.ParsePrimitiveInternal<FhirString>().Value),
FhirTypeNames.URI => new Code(instance.ParsePrimitiveInternal<FhirUri>().Value),
FhirTypeNames.CODING => instance.ParseCodingInternal(),
FhirTypeNames.CODEABLE_CONCEPT => instance.ParseCodeableConceptInternal(),
FhirTypeNames.QUANTITY => parseQuantity(),
FhirTypeNames.EXTENSION => parseExtension(),
FhirTypeNames.CODEABLEREFERENCE => parseCodeableReference(),
_ => null,
};

Expand Down
52 changes: 0 additions & 52 deletions src/Hl7.Fhir.Base/Model/FhirTypeConstants.cs

This file was deleted.

67 changes: 50 additions & 17 deletions src/Hl7.Fhir.Base/Model/FhirTypeNames.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,53 @@
namespace Hl7.Fhir.Model
namespace Hl7.Fhir.Model;

internal static class FhirTypeNames
{
internal class FhirTypeNames
{
public const string PATIENT_NAME = "Patient";
public const string BINARY_NAME = "Binary";
public const string EXTENSION_NAME = "Extension";
public const string SIMPLEQUANTITY_NAME = "SimpleQuantity";
public const string STRUCTUREDEFINITION_NAME = "StructureDefinition";
public const string CONCEPTMAP_NAME = "ConceptMap";
public const string CODESYSTEM_NAME = "CodeSystem";
public const string NAMINGSYSTEM_NAME = "NamingSystem";
public const string DOMAINRESOURCE_NAME = "DomainResource";
public const string REFERENCE_NAME = "Reference";
public const string ELEMENT_NAME = "Element";
public const string STRING_NAME = "string";
public const string MARKDOWN_NAME = "markdown";
public const string BOOLEAN = "boolean";
public const string INTEGER = "integer";
public const string INTEGER64 = "integer64";
public const string UNSIGNED_INT = "unsignedInt";
public const string POSITIVE_INT = "positiveInt";
public const string TIME = "time";
public const string DATE = "date";
public const string INSTANT = "instant";
public const string DATE_TIME = "dateTime";
public const string DECIMAL = "decimal";
public const string STRING = "string";
public const string CODE = "code";
public const string ID = "id";
public const string URI = "uri";
public const string OID = "oid";
public const string UUID = "uuid";
public const string CANONICAL = "canonical";
public const string URL = "url";
public const string MARKDOWN = "markdown";
public const string BASE64_BINARY = "base64Binary";

// General-Purpose Data types
public const string CODING = "Coding";
public const string CODEABLE_CONCEPT = "CodeableConcept";
public const string QUANTITY = "Quantity";

// Special Purpose Data types
public const string EXTENSION = "Extension";
public const string REFERENCE = "Reference";
public const string CODEABLEREFERENCE = "CodeableReference";
public const string XHTML = "xhtml";

// Resource type
public const string BUNDLE = "Bundle";
public const string PATIENT_NAME = "Patient";
public const string BINARY_NAME = "Binary";
public const string EXTENSION_NAME = "Extension";
public const string SIMPLEQUANTITY_NAME = "SimpleQuantity";
public const string STRUCTUREDEFINITION_NAME = "StructureDefinition";
public const string CONCEPTMAP_NAME = "ConceptMap";
public const string CODESYSTEM_NAME = "CodeSystem";
public const string NAMINGSYSTEM_NAME = "NamingSystem";
public const string DOMAINRESOURCE_NAME = "DomainResource";
public const string REFERENCE_NAME = "Reference";
public const string ELEMENT_NAME = "Element";
public const string STRING_NAME = "string";
public const string MARKDOWN_NAME = "markdown";

}
}

0 comments on commit c5e4d28

Please sign in to comment.