Exemplo n.º 1
0
        /// <summary>
        /// Deserialize JSON into a FHIR DetectedIssue#Mitigation
        /// </summary>
        public static void DeserializeJson(this DetectedIssue.MitigationComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options)
        {
            string propertyName;

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    return;
                }

                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    propertyName = reader.GetString();
                    if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug)
                    {
                        Console.WriteLine($"DetectedIssue.MitigationComponent >>> DetectedIssue#Mitigation.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"DetectedIssue.MitigationComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Serialize a FHIR DetectedIssue#Mitigation into JSON
        /// </summary>
        public static void SerializeJson(this DetectedIssue.MitigationComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: DetectedIssue#Mitigation, Export: MitigationComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("action");
            current.Action.SerializeJson(writer, options);

            if (current.DateElement != null)
            {
                if (!string.IsNullOrEmpty(current.DateElement.Value))
                {
                    writer.WriteString("date", current.DateElement.Value);
                }
                if (current.DateElement.HasExtensions() || (!string.IsNullOrEmpty(current.DateElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_date", false, current.DateElement.Extension, current.DateElement.ElementId);
                }
            }

            if (current.Author != null)
            {
                writer.WritePropertyName("author");
                current.Author.SerializeJson(writer, options);
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deserialize JSON into a FHIR DetectedIssue#Mitigation
        /// </summary>
        public static void DeserializeJsonProperty(this DetectedIssue.MitigationComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "action":
                current.Action = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Action).DeserializeJson(ref reader, options);
                break;

            case "date":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.DateElement = new FhirDateTime();
                    reader.Skip();
                }
                else
                {
                    current.DateElement = new FhirDateTime(reader.GetString());
                }
                break;

            case "_date":
                if (current.DateElement == null)
                {
                    current.DateElement = new FhirDateTime();
                }
                ((Hl7.Fhir.Model.Element)current.DateElement).DeserializeJson(ref reader, options);
                break;

            case "author":
                current.Author = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Author).DeserializeJson(ref reader, options);
                break;

            // Complex: mitigation, Export: MitigationComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }