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

            throw new JsonException($"MeasureReport.PopulationComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Example #2
0
        /// <summary>
        /// Deserialize JSON into a FHIR MeasureReport#Population
        /// </summary>
        public static void DeserializeJsonProperty(this MeasureReport.PopulationComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options);
                break;

            case "count":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.CountElement = new Integer();
                    reader.Skip();
                }
                else
                {
                    current.CountElement = new Integer(reader.GetInt32());
                }
                break;

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

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

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

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

            if (current.CountElement != null)
            {
                if (current.CountElement.Value != null)
                {
                    writer.WriteNumber("count", (int)current.CountElement.Value);
                }
                if (current.CountElement.HasExtensions() || (!string.IsNullOrEmpty(current.CountElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_count", false, current.CountElement.Extension, current.CountElement.ElementId);
                }
            }

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

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