Beispiel #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR ResearchStudy#Objective
        /// </summary>
        public static void DeserializeJson(this ResearchStudy.ObjectiveComponent 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($"ResearchStudy.ObjectiveComponent >>> ResearchStudy#Objective.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"ResearchStudy.ObjectiveComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Beispiel #2
0
        /// <summary>
        /// Deserialize JSON into a FHIR ResearchStudy#Objective
        /// </summary>
        public static void DeserializeJsonProperty(this ResearchStudy.ObjectiveComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "name":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.NameElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.NameElement = new FhirString(reader.GetString());
                }
                break;

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

            case "type":
                current.Type = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Type).DeserializeJson(ref reader, options);
                break;

            // Complex: objective, Export: ObjectiveComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Serialize a FHIR ResearchStudy#Objective into JSON
        /// </summary>
        public static void SerializeJson(this ResearchStudy.ObjectiveComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: ResearchStudy#Objective, Export: ObjectiveComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

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

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

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }