コード例 #1
0
ファイル: Condition.cs プロジェクト: microsoft/fhir-codegen
        /// <summary>
        /// Deserialize JSON into a FHIR Condition#Stage
        /// </summary>
        public static void DeserializeJson(this Condition.StageComponent 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($"Condition.StageComponent >>> Condition#Stage.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"Condition.StageComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
コード例 #2
0
ファイル: Condition.cs プロジェクト: microsoft/fhir-codegen
        /// <summary>
        /// Deserialize JSON into a FHIR Condition#Stage
        /// </summary>
        public static void DeserializeJsonProperty(this Condition.StageComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "summary":
                current.Summary = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Summary).DeserializeJson(ref reader, options);
                break;

            case "assessment":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"StageComponent error reading 'assessment' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Assessment = new List <ResourceReference>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ResourceReference v_Assessment = new Hl7.Fhir.Model.ResourceReference();
                    v_Assessment.DeserializeJson(ref reader, options);
                    current.Assessment.Add(v_Assessment);

                    if (!reader.Read())
                    {
                        throw new JsonException($"StageComponent error reading 'assessment' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Assessment.Count == 0)
                {
                    current.Assessment = null;
                }
                break;

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

            // Complex: stage, Export: StageComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
コード例 #3
0
ファイル: Condition.cs プロジェクト: microsoft/fhir-codegen
        /// <summary>
        /// Serialize a FHIR Condition#Stage into JSON
        /// </summary>
        public static void SerializeJson(this Condition.StageComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Condition#Stage, Export: StageComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

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

            if ((current.Assessment != null) && (current.Assessment.Count != 0))
            {
                writer.WritePropertyName("assessment");
                writer.WriteStartArray();
                foreach (ResourceReference val in current.Assessment)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

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

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