Skip to content

Commit

Permalink
First draft of this PR, all unit tests run.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoutkramer committed Nov 26, 2024
1 parent f4884be commit 37cf815
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 175 deletions.
4 changes: 2 additions & 2 deletions src/Hl7.Fhir.Base/Model/Generated/Attachment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public Hl7.Fhir.Model.PrimitiveType UrlElement
[IgnoreDataMember]
public string UrlUri
{
get { return UrlElement != null ? ((Hl7.Fhir.Model.FhirUri)UrlElement).Value : null; }
get { return UrlElement != null ? ((IValue<string>)UrlElement).Value : null; }
set
{
if (value == null)
Expand All @@ -198,7 +198,7 @@ public string UrlUri
[IgnoreDataMember]
public string Url
{
get { return UrlElement != null ? ((Hl7.Fhir.Model.FhirUrl)UrlElement).Value : null; }
get { return UrlElement != null ? ((IValue<string>)UrlElement).Value : null; }
set
{
if (value == null)
Expand Down
4 changes: 2 additions & 2 deletions src/Hl7.Fhir.Base/Model/Generated/Bundle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ public Hl7.Fhir.Model.PrimitiveType RelationElement
[IgnoreDataMember]
public string RelationString
{
get { return RelationElement != null ? ((Hl7.Fhir.Model.FhirString)RelationElement).Value : null; }
get { return RelationElement != null ? ((IValue<string>)RelationElement).Value : null; }
set
{
if (value == null)
Expand All @@ -997,7 +997,7 @@ public string RelationString
[IgnoreDataMember]
public string Relation
{
get { return RelationElement != null ? ((Hl7.Fhir.Model.Code)RelationElement).Value : null; }
get { return RelationElement != null ? ((IValue<string>)RelationElement).Value : null; }
set
{
if (value == null)
Expand Down
12 changes: 0 additions & 12 deletions src/Hl7.Fhir.Base/Serialization/BaseFhirJsonPocoDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -782,18 +782,6 @@ string typeName()
bool isInteger64()
=> fhirType == typeof(Integer64);
}

// Validation is now done using POCO validation, so have removed it here.
// Keep code around in case I make my mind up before publication.
//static (object?, FhirJsonException?) readEnum(ref Utf8JsonReader reader, Type enumType)
//{
// var contents = reader.GetString()!;
// var enumValue = EnumUtility.ParseLiteral(contents, enumType);

// return enumValue is not null
// ? (contents, null)
// : (contents, ERR.CODED_VALUE_NOT_IN_ENUM.With(ref reader, contents, EnumUtility.GetName(enumType)));
//}
}

private static (object?, FhirJsonException) unexpectedToken(ref Utf8JsonReader reader, string instancePath, string? value, string expected, string actual) =>
Expand Down
18 changes: 10 additions & 8 deletions src/Hl7.Fhir.Base/Serialization/FhirJsonException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ public class FhirJsonException : ExtendedCodedException
public const string RESOURCE_TYPE_NOT_A_RESOURCE_CODE = "JSON117";
public const string UNKNOWN_PROPERTY_FOUND_CODE = "JSON118";

[Obsolete("This issue is no longer raised as it is now allowed to use `resourceType` as the name of an element.")]
public const string RESOURCETYPE_UNEXPECTED_CODE = "JSON119";
//[Obsolete("This issue is no longer raised as it is now allowed to use `resourceType` as the name of an element.")]
//public const string RESOURCETYPE_UNEXPECTED_CODE = "JSON119";
public const string OBJECTS_CANNOT_BE_EMPTY_CODE = "JSON120";
public const string ARRAYS_CANNOT_BE_EMPTY_CODE = "JSON121";
public const string LONG_CANNOT_BE_PARSED_CODE = "JSON122";
public const string LONG_INCORRECT_FORMAT_CODE = "JSON123";

[Obsolete("According to the latest updates of the Json format, primitive arrays of different sizes are no longer considered an error.")]
public const string PRIMITIVE_ARRAYS_INCOMPAT_SIZE_CODE = "JSON122";
//[Obsolete("According to the latest updates of the Json format, primitive arrays of different sizes are no longer considered an error.")]
//public const string PRIMITIVE_ARRAYS_INCOMPAT_SIZE_CODE = "JSON122";

public const string PRIMITIVE_ARRAYS_ONLY_NULL_CODE = "JSON125";

// Cannot happen anymore since 6.0 since the simple values Element.id and Extension.url are gone.
//public const string INCOMPATIBLE_SIMPLE_VALUE_CODE = "JSON126";
public const string PROPERTY_MAY_NOT_BE_EMPTY_CODE = "JSON127";

Expand Down Expand Up @@ -107,8 +109,8 @@ public class FhirJsonException : ExtendedCodedException

// The serialization contained a superfluous 'resourceType' property, but we have read all data anyway.
// Note, this is no longer considered an error, since there are Resources using an element named "resourceType" (Subscription.filterBy for example).
[Obsolete("This issue is no longer raised as it is now allowed to use `resourceType` as the name of an element.")]
internal static FhirJsonException RESOURCETYPE_UNEXPECTED(ref Utf8JsonReader reader, string instancePath) => Initialize(ref reader, instancePath, RESOURCETYPE_UNEXPECTED_CODE, "The 'resourceType' property should only be used in resources.", OO_Sev.Warning, OO_Typ.Structure);
//[Obsolete("This issue is no longer raised as it is now allowed to use `resourceType` as the name of an element.")]
//internal static FhirJsonException RESOURCETYPE_UNEXPECTED(ref Utf8JsonReader reader, string instancePath) => Initialize(ref reader, instancePath, RESOURCETYPE_UNEXPECTED_CODE, "The 'resourceType' property should only be used in resources.", OO_Sev.Warning, OO_Typ.Structure);

// Empty objects and arrays can be ignored without discarding data
internal static FhirJsonException OBJECTS_CANNOT_BE_EMPTY(ref Utf8JsonReader reader, string instancePath) => Initialize(ref reader, instancePath, OBJECTS_CANNOT_BE_EMPTY_CODE, "An object needs to have at least one property.", OO_Sev.Warning, OO_Typ.Structure);
Expand Down Expand Up @@ -137,10 +139,10 @@ public class FhirJsonException : ExtendedCodedException
LONG_INCORRECT_FORMAT_CODE,
EXPECTED_START_OF_ARRAY_CODE,
USE_OF_UNDERSCORE_ILLEGAL_CODE,
RESOURCETYPE_UNEXPECTED_CODE,
// RESOURCETYPE_UNEXPECTED_CODE,
OBJECTS_CANNOT_BE_EMPTY_CODE,
ARRAYS_CANNOT_BE_EMPTY_CODE,
PRIMITIVE_ARRAYS_INCOMPAT_SIZE_CODE,
// PRIMITIVE_ARRAYS_INCOMPAT_SIZE_CODE,
PRIMITIVE_ARRAYS_ONLY_NULL_CODE,
PROPERTY_MAY_NOT_BE_EMPTY_CODE,
DUPLICATE_ARRAY_CODE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ public Hl7.Fhir.Model.PrimitiveType DescriptionElement
[IgnoreDataMember]
public string DescriptionString
{
get { return DescriptionElement != null ? ((Hl7.Fhir.Model.FhirString)DescriptionElement).Value : null; }
get { return DescriptionElement != null ? ((IValue<string>)DescriptionElement).Value : null; }
set
{
if (value == null)
Expand All @@ -620,7 +620,7 @@ public string DescriptionString
[IgnoreDataMember]
public string Description
{
get { return DescriptionElement != null ? ((Hl7.Fhir.Model.Markdown)DescriptionElement).Value : null; }
get { return DescriptionElement != null ? ((IValue<string>)DescriptionElement).Value : null; }
set
{
if (value == null)
Expand Down
12 changes: 6 additions & 6 deletions src/Hl7.Fhir.Conformance/Model/Generated/ElementDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1431,7 +1431,7 @@ public Hl7.Fhir.Model.PrimitiveType RequirementsElement
[IgnoreDataMember]
public string RequirementsString
{
get { return RequirementsElement != null ? ((Hl7.Fhir.Model.FhirString)RequirementsElement).Value : null; }
get { return RequirementsElement != null ? ((IValue<string>)RequirementsElement).Value : null; }
set
{
if (value == null)
Expand All @@ -1449,7 +1449,7 @@ public string RequirementsString
[IgnoreDataMember]
public string Requirements
{
get { return RequirementsElement != null ? ((Hl7.Fhir.Model.Markdown)RequirementsElement).Value : null; }
get { return RequirementsElement != null ? ((IValue<string>)RequirementsElement).Value : null; }
set
{
if (value == null)
Expand Down Expand Up @@ -1879,7 +1879,7 @@ public Hl7.Fhir.Model.PrimitiveType DescriptionElement
[IgnoreDataMember]
public string DescriptionString
{
get { return DescriptionElement != null ? ((Hl7.Fhir.Model.FhirString)DescriptionElement).Value : null; }
get { return DescriptionElement != null ? ((IValue<string>)DescriptionElement).Value : null; }
set
{
if (value == null)
Expand All @@ -1897,7 +1897,7 @@ public string DescriptionString
[IgnoreDataMember]
public string Description
{
get { return DescriptionElement != null ? ((Hl7.Fhir.Model.Markdown)DescriptionElement).Value : null; }
get { return DescriptionElement != null ? ((IValue<string>)DescriptionElement).Value : null; }
set
{
if (value == null)
Expand Down Expand Up @@ -2533,7 +2533,7 @@ public Hl7.Fhir.Model.PrimitiveType CommentElement
[IgnoreDataMember]
public string CommentString
{
get { return CommentElement != null ? ((Hl7.Fhir.Model.FhirString)CommentElement).Value : null; }
get { return CommentElement != null ? ((IValue<string>)CommentElement).Value : null; }
set
{
if (value == null)
Expand All @@ -2551,7 +2551,7 @@ public string CommentString
[IgnoreDataMember]
public string Comment
{
get { return CommentElement != null ? ((Hl7.Fhir.Model.Markdown)CommentElement).Value : null; }
get { return CommentElement != null ? ((IValue<string>)CommentElement).Value : null; }
set
{
if (value == null)
Expand Down
37 changes: 7 additions & 30 deletions src/Hl7.Fhir.STU3/Model/Generated/CapabilityStatement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -640,54 +640,31 @@ public partial class ImplementationComponent : Hl7.Fhir.Model.BackboneElement
/// <summary>
/// Describes this specific instance.
/// </summary>
/// <remarks>
/// The type of this element has changed over time. Make sure to use Hl7.Fhir.Model.FhirString in STU3, R4 and R4B, Hl7.Fhir.Model.Markdown starting from R5.
/// </remarks>
[FhirElement("description", InSummary=true, Order=40)]
[DeclaredType(Type = typeof(Hl7.Fhir.Model.FhirString), Since = FhirRelease.STU3)]
[DeclaredType(Type = typeof(Hl7.Fhir.Model.Markdown), Since = FhirRelease.R5)]
[Cardinality(Min=1,Max=1)]
[DataMember]
public Hl7.Fhir.Model.PrimitiveType DescriptionElement
public Hl7.Fhir.Model.FhirString DescriptionElement
{
get { return _DescriptionElement; }
set { _DescriptionElement = value; OnPropertyChanged("DescriptionElement"); }
}

private Hl7.Fhir.Model.PrimitiveType _DescriptionElement;

/// <summary>
/// Describes this specific instance. Use this property in STU3, R4 and R4B.
/// </summary>
/// <remarks>This uses the native .NET datatype, rather than the FHIR equivalent</remarks>
[IgnoreDataMember]
public string DescriptionString
{
get { return DescriptionElement != null ? ((Hl7.Fhir.Model.FhirString)DescriptionElement).Value : null; }
set
{
if (value == null)
DescriptionElement = null;
else
DescriptionElement = new Hl7.Fhir.Model.FhirString(value);
OnPropertyChanged("DescriptionString");
}
}
private Hl7.Fhir.Model.FhirString _DescriptionElement;

/// <summary>
/// Describes this specific instance. Use this property starting from R5.
/// Describes this specific instance
/// </summary>
/// <remarks>This uses the native .NET datatype, rather than the FHIR equivalent</remarks>
[IgnoreDataMember]
public string Description
{
get { return DescriptionElement != null ? ((Hl7.Fhir.Model.Markdown)DescriptionElement).Value : null; }
get { return DescriptionElement != null ? DescriptionElement.Value : null; }
set
{
if (value == null)
DescriptionElement = null;
else
DescriptionElement = new Hl7.Fhir.Model.Markdown(value);
DescriptionElement = new Hl7.Fhir.Model.FhirString(value);
OnPropertyChanged("Description");
}
}
Expand Down Expand Up @@ -733,7 +710,7 @@ public override IDeepCopyable CopyTo(IDeepCopyable other)
}

base.CopyTo(dest);
if(DescriptionElement != null) dest.DescriptionElement = (Hl7.Fhir.Model.PrimitiveType)DescriptionElement.DeepCopy();
if(DescriptionElement != null) dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
if(UrlElement != null) dest.UrlElement = (Hl7.Fhir.Model.FhirUri)UrlElement.DeepCopy();
return dest;
}
Expand Down Expand Up @@ -789,7 +766,7 @@ internal protected override Base SetValue(string key, object value)
switch (key)
{
case "description":
DescriptionElement = (Hl7.Fhir.Model.PrimitiveType)value;
DescriptionElement = (Hl7.Fhir.Model.FhirString)value;
return this;
case "url":
UrlElement = (Hl7.Fhir.Model.FhirUri)value;
Expand Down
Loading

0 comments on commit 37cf815

Please sign in to comment.