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

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

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

            if ((current.Stratum != null) && (current.Stratum.Count != 0))
            {
                writer.WritePropertyName("stratum");
                writer.WriteStartArray();
                foreach (MeasureReport.StratifierGroupComponent val in current.Stratum)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
コード例 #3
0
        /// <summary>
        /// Deserialize JSON into a FHIR MeasureReport#Stratifier
        /// </summary>
        public static void DeserializeJsonProperty(this MeasureReport.StratifierComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "code":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"StratifierComponent error reading 'code' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Code = new List <CodeableConcept>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.CodeableConcept v_Code = new Hl7.Fhir.Model.CodeableConcept();
                    v_Code.DeserializeJson(ref reader, options);
                    current.Code.Add(v_Code);

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

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

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

                current.Stratum = new List <MeasureReport.StratifierGroupComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.MeasureReport.StratifierGroupComponent v_Stratum = new Hl7.Fhir.Model.MeasureReport.StratifierGroupComponent();
                    v_Stratum.DeserializeJson(ref reader, options);
                    current.Stratum.Add(v_Stratum);

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

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

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