// <auto-generated />
// Built from: hl7.fhir.r5.core version: 4.6.0
  // Option: "NAMESPACE" = "fhirCsR5"

using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using fhirCsR5.Serialization;

namespace fhirCsR5.Models
{
  /// <summary>
  /// Evidence variable such as population, exposure, or outcome.
  /// </summary>
  [JsonConverter(typeof(fhirCsR5.Serialization.JsonStreamComponentConverter<EvidenceVariableDefinition>))]
  public class EvidenceVariableDefinition : BackboneElement,  IFhirJsonSerializable {
    /// <summary>
    /// A text description or summary of the variable.
    /// </summary>
    public string Description { get; set; }
    /// <summary>
    /// Extension container element for Description
    /// </summary>
    public Element _Description { get; set; }
    /// <summary>
    /// Indication of quality of match between intended variable to actual variable.
    /// </summary>
    public CodeableConcept DirectnessMatch { get; set; }
    /// <summary>
    /// Definition of the intended variable related to the Evidence.
    /// </summary>
    public Reference Intended { get; set; }
    /// <summary>
    /// Footnotes and/or explanatory notes.
    /// </summary>
    public List<Annotation> Note { get; set; }
    /// <summary>
    /// Definition of the actual variable related to the statistic(s).
    /// </summary>
    public Reference Observed { get; set; }
    /// <summary>
    /// population | subpopulation | exposure | referenceExposure | measuredVariable | confounder.
    /// </summary>
    public CodeableConcept VariableRole { get; set; }
    /// <summary>
    /// Serialize to a JSON object
    /// </summary>
    public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
    {
      if (includeStartObject)
      {
        writer.WriteStartObject();
      }
      ((fhirCsR5.Models.BackboneElement)this).SerializeJson(writer, options, false);

      if (!string.IsNullOrEmpty(Description))
      {
        writer.WriteString("description", (string)Description!);
      }

      if (_Description != null)
      {
        writer.WritePropertyName("_description");
        _Description.SerializeJson(writer, options);
      }

      if ((Note != null) && (Note.Count != 0))
      {
        writer.WritePropertyName("note");
        writer.WriteStartArray();

        foreach (Annotation valNote in Note)
        {
          valNote.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (VariableRole != null)
      {
        writer.WritePropertyName("variableRole");
        VariableRole.SerializeJson(writer, options);
      }

      if (Observed != null)
      {
        writer.WritePropertyName("observed");
        Observed.SerializeJson(writer, options);
      }

      if (Intended != null)
      {
        writer.WritePropertyName("intended");
        Intended.SerializeJson(writer, options);
      }

      if (DirectnessMatch != null)
      {
        writer.WritePropertyName("directnessMatch");
        DirectnessMatch.SerializeJson(writer, options);
      }

      if (includeStartObject)
      {
        writer.WriteEndObject();
      }
    }
    /// <summary>
    /// Deserialize a JSON property
    /// </summary>
    public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
    {
      switch (propertyName)
      {
        case "description":
          Description = reader.GetString();
          break;

        case "_description":
          _Description = new fhirCsR5.Models.Element();
          _Description.DeserializeJson(ref reader, options);
          break;

        case "directnessMatch":
          DirectnessMatch = new fhirCsR5.Models.CodeableConcept();
          DirectnessMatch.DeserializeJson(ref reader, options);
          break;

        case "intended":
          Intended = new fhirCsR5.Models.Reference();
          Intended.DeserializeJson(ref reader, options);
          break;

        case "note":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Note = new List<Annotation>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Annotation objNote = new fhirCsR5.Models.Annotation();
            objNote.DeserializeJson(ref reader, options);
            Note.Add(objNote);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Note.Count == 0)
          {
            Note = null;
          }

          break;

        case "observed":
          Observed = new fhirCsR5.Models.Reference();
          Observed.DeserializeJson(ref reader, options);
          break;

        case "variableRole":
          VariableRole = new fhirCsR5.Models.CodeableConcept();
          VariableRole.DeserializeJson(ref reader, options);
          break;

        default:
          ((fhirCsR5.Models.BackboneElement)this).DeserializeJsonProperty(ref reader, options, propertyName);
          break;
      }
    }

    /// <summary>
    /// Deserialize a JSON object
    /// </summary>
    public new void DeserializeJson(ref Utf8JsonReader reader, JsonSerializerOptions options)
    {
      string propertyName;

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

        if (reader.TokenType == JsonTokenType.PropertyName)
        {
          propertyName = reader.GetString();
          reader.Read();
          this.DeserializeJsonProperty(ref reader, options, propertyName);
        }
      }

      throw new JsonException();
    }
  }
  /// <summary>
  /// Number of samples in the statistic.
  /// </summary>
  [JsonConverter(typeof(fhirCsR5.Serialization.JsonStreamComponentConverter<EvidenceStatisticSampleSize>))]
  public class EvidenceStatisticSampleSize : BackboneElement,  IFhirJsonSerializable {
    /// <summary>
    /// Human-readable summary of population sample size.
    /// </summary>
    public string Description { get; set; }
    /// <summary>
    /// Extension container element for Description
    /// </summary>
    public Element _Description { get; set; }
    /// <summary>
    /// Number of participants with known results for measured variables.
    /// </summary>
    public uint? KnownDataCount { get; set; }
    /// <summary>
    /// Footnote or explanatory note about the sample size.
    /// </summary>
    public List<Annotation> Note { get; set; }
    /// <summary>
    /// A human-readable string to clarify or explain concepts about the sample size.
    /// </summary>
    public uint? NumberOfParticipants { get; set; }
    /// <summary>
    /// Number of participants in the population.
    /// </summary>
    public uint? NumberOfStudies { get; set; }
    /// <summary>
    /// Serialize to a JSON object
    /// </summary>
    public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
    {
      if (includeStartObject)
      {
        writer.WriteStartObject();
      }
      ((fhirCsR5.Models.BackboneElement)this).SerializeJson(writer, options, false);

      if (!string.IsNullOrEmpty(Description))
      {
        writer.WriteString("description", (string)Description!);
      }

      if (_Description != null)
      {
        writer.WritePropertyName("_description");
        _Description.SerializeJson(writer, options);
      }

      if ((Note != null) && (Note.Count != 0))
      {
        writer.WritePropertyName("note");
        writer.WriteStartArray();

        foreach (Annotation valNote in Note)
        {
          valNote.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (NumberOfStudies != null)
      {
        writer.WriteNumber("numberOfStudies", (uint)NumberOfStudies!);
      }

      if (NumberOfParticipants != null)
      {
        writer.WriteNumber("numberOfParticipants", (uint)NumberOfParticipants!);
      }

      if (KnownDataCount != null)
      {
        writer.WriteNumber("knownDataCount", (uint)KnownDataCount!);
      }

      if (includeStartObject)
      {
        writer.WriteEndObject();
      }
    }
    /// <summary>
    /// Deserialize a JSON property
    /// </summary>
    public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
    {
      switch (propertyName)
      {
        case "description":
          Description = reader.GetString();
          break;

        case "_description":
          _Description = new fhirCsR5.Models.Element();
          _Description.DeserializeJson(ref reader, options);
          break;

        case "knownDataCount":
          KnownDataCount = reader.GetUInt32();
          break;

        case "note":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Note = new List<Annotation>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Annotation objNote = new fhirCsR5.Models.Annotation();
            objNote.DeserializeJson(ref reader, options);
            Note.Add(objNote);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Note.Count == 0)
          {
            Note = null;
          }

          break;

        case "numberOfParticipants":
          NumberOfParticipants = reader.GetUInt32();
          break;

        case "numberOfStudies":
          NumberOfStudies = reader.GetUInt32();
          break;

        default:
          ((fhirCsR5.Models.BackboneElement)this).DeserializeJsonProperty(ref reader, options, propertyName);
          break;
      }
    }

    /// <summary>
    /// Deserialize a JSON object
    /// </summary>
    public new void DeserializeJson(ref Utf8JsonReader reader, JsonSerializerOptions options)
    {
      string propertyName;

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

        if (reader.TokenType == JsonTokenType.PropertyName)
        {
          propertyName = reader.GetString();
          reader.Read();
          this.DeserializeJsonProperty(ref reader, options, propertyName);
        }
      }

      throw new JsonException();
    }
  }
  /// <summary>
  /// A nested attribute estimate; which is the attribute estimate of an attribute estimate
  /// </summary>
  [JsonConverter(typeof(fhirCsR5.Serialization.JsonStreamComponentConverter<EvidenceStatisticAttributeEstimateAttributeEstimate>))]
  public class EvidenceStatisticAttributeEstimateAttributeEstimate : BackboneElement,  IFhirJsonSerializable {
    /// <summary>
    /// Human-readable summary of the estimate.
    /// </summary>
    public string Description { get; set; }
    /// <summary>
    /// Extension container element for Description
    /// </summary>
    public Element _Description { get; set; }
    /// <summary>
    /// Use 95 for a 95% confidence interval.
    /// </summary>
    public decimal? Level { get; set; }
    /// <summary>
    /// Extension container element for Level
    /// </summary>
    public Element _Level { get; set; }
    /// <summary>
    /// Footnote or explanatory note about the estimate.
    /// </summary>
    public List<Annotation> Note { get; set; }
    /// <summary>
    /// Often the pvalue
    /// </summary>
    public Quantity Quantity { get; set; }
    /// <summary>
    /// Lower bound of confidence interval.
    /// </summary>
    public Range Range { get; set; }
    /// <summary>
    /// The type of attribute estimate, eg confidence interval or p value.
    /// </summary>
    public CodeableConcept Type { get; set; }
    /// <summary>
    /// Serialize to a JSON object
    /// </summary>
    public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
    {
      if (includeStartObject)
      {
        writer.WriteStartObject();
      }
      ((fhirCsR5.Models.BackboneElement)this).SerializeJson(writer, options, false);

      if (!string.IsNullOrEmpty(Description))
      {
        writer.WriteString("description", (string)Description!);
      }

      if (_Description != null)
      {
        writer.WritePropertyName("_description");
        _Description.SerializeJson(writer, options);
      }

      if ((Note != null) && (Note.Count != 0))
      {
        writer.WritePropertyName("note");
        writer.WriteStartArray();

        foreach (Annotation valNote in Note)
        {
          valNote.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

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

      if (Quantity != null)
      {
        writer.WritePropertyName("quantity");
        Quantity.SerializeJson(writer, options);
      }

      if (Level != null)
      {
        writer.WriteNumber("level", (decimal)Level!);
      }

      if (_Level != null)
      {
        writer.WritePropertyName("_level");
        _Level.SerializeJson(writer, options);
      }

      if (Range != null)
      {
        writer.WritePropertyName("range");
        Range.SerializeJson(writer, options);
      }

      if (includeStartObject)
      {
        writer.WriteEndObject();
      }
    }
    /// <summary>
    /// Deserialize a JSON property
    /// </summary>
    public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
    {
      switch (propertyName)
      {
        case "description":
          Description = reader.GetString();
          break;

        case "_description":
          _Description = new fhirCsR5.Models.Element();
          _Description.DeserializeJson(ref reader, options);
          break;

        case "level":
          Level = reader.GetDecimal();
          break;

        case "_level":
          _Level = new fhirCsR5.Models.Element();
          _Level.DeserializeJson(ref reader, options);
          break;

        case "note":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Note = new List<Annotation>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Annotation objNote = new fhirCsR5.Models.Annotation();
            objNote.DeserializeJson(ref reader, options);
            Note.Add(objNote);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Note.Count == 0)
          {
            Note = null;
          }

          break;

        case "quantity":
          Quantity = new fhirCsR5.Models.Quantity();
          Quantity.DeserializeJson(ref reader, options);
          break;

        case "range":
          Range = new fhirCsR5.Models.Range();
          Range.DeserializeJson(ref reader, options);
          break;

        case "type":
          Type = new fhirCsR5.Models.CodeableConcept();
          Type.DeserializeJson(ref reader, options);
          break;

        default:
          ((fhirCsR5.Models.BackboneElement)this).DeserializeJsonProperty(ref reader, options, propertyName);
          break;
      }
    }

    /// <summary>
    /// Deserialize a JSON object
    /// </summary>
    public new void DeserializeJson(ref Utf8JsonReader reader, JsonSerializerOptions options)
    {
      string propertyName;

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

        if (reader.TokenType == JsonTokenType.PropertyName)
        {
          propertyName = reader.GetString();
          reader.Read();
          this.DeserializeJsonProperty(ref reader, options, propertyName);
        }
      }

      throw new JsonException();
    }
  }
  /// <summary>
  /// A statistical attribute of the statistic such as a measure of heterogeneity.
  /// </summary>
  [JsonConverter(typeof(fhirCsR5.Serialization.JsonStreamComponentConverter<EvidenceStatisticAttributeEstimate>))]
  public class EvidenceStatisticAttributeEstimate : BackboneElement,  IFhirJsonSerializable {
    /// <summary>
    /// A nested attribute estimate; which is the attribute estimate of an attribute estimate
    /// </summary>
    public List<EvidenceStatisticAttributeEstimateAttributeEstimate> AttributeEstimate { get; set; }
    /// <summary>
    /// Human-readable summary of the estimate.
    /// </summary>
    public string Description { get; set; }
    /// <summary>
    /// Extension container element for Description
    /// </summary>
    public Element _Description { get; set; }
    /// <summary>
    /// Use 95 for a 95% confidence interval.
    /// </summary>
    public decimal? Level { get; set; }
    /// <summary>
    /// Extension container element for Level
    /// </summary>
    public Element _Level { get; set; }
    /// <summary>
    /// Footnote or explanatory note about the estimate.
    /// </summary>
    public List<Annotation> Note { get; set; }
    /// <summary>
    /// Often the p value
    /// </summary>
    public Quantity Quantity { get; set; }
    /// <summary>
    /// Lower bound of confidence interval.
    /// </summary>
    public Range Range { get; set; }
    /// <summary>
    /// The type of attribute estimate, eg confidence interval or p value.
    /// </summary>
    public CodeableConcept Type { get; set; }
    /// <summary>
    /// Serialize to a JSON object
    /// </summary>
    public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
    {
      if (includeStartObject)
      {
        writer.WriteStartObject();
      }
      ((fhirCsR5.Models.BackboneElement)this).SerializeJson(writer, options, false);

      if (!string.IsNullOrEmpty(Description))
      {
        writer.WriteString("description", (string)Description!);
      }

      if (_Description != null)
      {
        writer.WritePropertyName("_description");
        _Description.SerializeJson(writer, options);
      }

      if ((Note != null) && (Note.Count != 0))
      {
        writer.WritePropertyName("note");
        writer.WriteStartArray();

        foreach (Annotation valNote in Note)
        {
          valNote.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

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

      if (Quantity != null)
      {
        writer.WritePropertyName("quantity");
        Quantity.SerializeJson(writer, options);
      }

      if (Level != null)
      {
        writer.WriteNumber("level", (decimal)Level!);
      }

      if (_Level != null)
      {
        writer.WritePropertyName("_level");
        _Level.SerializeJson(writer, options);
      }

      if (Range != null)
      {
        writer.WritePropertyName("range");
        Range.SerializeJson(writer, options);
      }

      if ((AttributeEstimate != null) && (AttributeEstimate.Count != 0))
      {
        writer.WritePropertyName("attributeEstimate");
        writer.WriteStartArray();

        foreach (EvidenceStatisticAttributeEstimateAttributeEstimate valAttributeEstimate in AttributeEstimate)
        {
          valAttributeEstimate.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (includeStartObject)
      {
        writer.WriteEndObject();
      }
    }
    /// <summary>
    /// Deserialize a JSON property
    /// </summary>
    public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
    {
      switch (propertyName)
      {
        case "attributeEstimate":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          AttributeEstimate = new List<EvidenceStatisticAttributeEstimateAttributeEstimate>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.EvidenceStatisticAttributeEstimateAttributeEstimate objAttributeEstimate = new fhirCsR5.Models.EvidenceStatisticAttributeEstimateAttributeEstimate();
            objAttributeEstimate.DeserializeJson(ref reader, options);
            AttributeEstimate.Add(objAttributeEstimate);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (AttributeEstimate.Count == 0)
          {
            AttributeEstimate = null;
          }

          break;

        case "description":
          Description = reader.GetString();
          break;

        case "_description":
          _Description = new fhirCsR5.Models.Element();
          _Description.DeserializeJson(ref reader, options);
          break;

        case "level":
          Level = reader.GetDecimal();
          break;

        case "_level":
          _Level = new fhirCsR5.Models.Element();
          _Level.DeserializeJson(ref reader, options);
          break;

        case "note":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Note = new List<Annotation>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Annotation objNote = new fhirCsR5.Models.Annotation();
            objNote.DeserializeJson(ref reader, options);
            Note.Add(objNote);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Note.Count == 0)
          {
            Note = null;
          }

          break;

        case "quantity":
          Quantity = new fhirCsR5.Models.Quantity();
          Quantity.DeserializeJson(ref reader, options);
          break;

        case "range":
          Range = new fhirCsR5.Models.Range();
          Range.DeserializeJson(ref reader, options);
          break;

        case "type":
          Type = new fhirCsR5.Models.CodeableConcept();
          Type.DeserializeJson(ref reader, options);
          break;

        default:
          ((fhirCsR5.Models.BackboneElement)this).DeserializeJsonProperty(ref reader, options, propertyName);
          break;
      }
    }

    /// <summary>
    /// Deserialize a JSON object
    /// </summary>
    public new void DeserializeJson(ref Utf8JsonReader reader, JsonSerializerOptions options)
    {
      string propertyName;

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

        if (reader.TokenType == JsonTokenType.PropertyName)
        {
          propertyName = reader.GetString();
          reader.Read();
          this.DeserializeJsonProperty(ref reader, options, propertyName);
        }
      }

      throw new JsonException();
    }
  }
  /// <summary>
  /// A variable adjusted for in the adjusted analysis.
  /// </summary>
  [JsonConverter(typeof(fhirCsR5.Serialization.JsonStreamComponentConverter<EvidenceStatisticModelCharacteristicVariable>))]
  public class EvidenceStatisticModelCharacteristicVariable : BackboneElement,  IFhirJsonSerializable {
    /// <summary>
    /// How the variable is classified for use in adjusted analysis.
    /// </summary>
    public string Handling { get; set; }
    /// <summary>
    /// Extension container element for Handling
    /// </summary>
    public Element _Handling { get; set; }
    /// <summary>
    /// Description for grouping of ordinal or polychotomous variables.
    /// </summary>
    public List<CodeableConcept> ValueCategory { get; set; }
    /// <summary>
    /// Discrete value for grouping of ordinal or polychotomous variables.
    /// </summary>
    public List<Quantity> ValueQuantity { get; set; }
    /// <summary>
    /// Range of values for grouping of ordinal or polychotomous variables.
    /// </summary>
    public List<Range> ValueRange { get; set; }
    /// <summary>
    /// Description of the variable.
    /// </summary>
    public Reference VariableDefinition { get; set; }
    /// <summary>
    /// Serialize to a JSON object
    /// </summary>
    public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
    {
      if (includeStartObject)
      {
        writer.WriteStartObject();
      }
      ((fhirCsR5.Models.BackboneElement)this).SerializeJson(writer, options, false);

      if (VariableDefinition != null)
      {
        writer.WritePropertyName("variableDefinition");
        VariableDefinition.SerializeJson(writer, options);
      }

      if (!string.IsNullOrEmpty(Handling))
      {
        writer.WriteString("handling", (string)Handling!);
      }

      if (_Handling != null)
      {
        writer.WritePropertyName("_handling");
        _Handling.SerializeJson(writer, options);
      }

      if ((ValueCategory != null) && (ValueCategory.Count != 0))
      {
        writer.WritePropertyName("valueCategory");
        writer.WriteStartArray();

        foreach (CodeableConcept valValueCategory in ValueCategory)
        {
          valValueCategory.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((ValueQuantity != null) && (ValueQuantity.Count != 0))
      {
        writer.WritePropertyName("valueQuantity");
        writer.WriteStartArray();

        foreach (Quantity valValueQuantity in ValueQuantity)
        {
          valValueQuantity.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((ValueRange != null) && (ValueRange.Count != 0))
      {
        writer.WritePropertyName("valueRange");
        writer.WriteStartArray();

        foreach (Range valValueRange in ValueRange)
        {
          valValueRange.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (includeStartObject)
      {
        writer.WriteEndObject();
      }
    }
    /// <summary>
    /// Deserialize a JSON property
    /// </summary>
    public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
    {
      switch (propertyName)
      {
        case "handling":
          Handling = reader.GetString();
          break;

        case "_handling":
          _Handling = new fhirCsR5.Models.Element();
          _Handling.DeserializeJson(ref reader, options);
          break;

        case "valueCategory":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          ValueCategory = new List<CodeableConcept>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.CodeableConcept objValueCategory = new fhirCsR5.Models.CodeableConcept();
            objValueCategory.DeserializeJson(ref reader, options);
            ValueCategory.Add(objValueCategory);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (ValueCategory.Count == 0)
          {
            ValueCategory = null;
          }

          break;

        case "valueQuantity":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          ValueQuantity = new List<Quantity>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Quantity objValueQuantity = new fhirCsR5.Models.Quantity();
            objValueQuantity.DeserializeJson(ref reader, options);
            ValueQuantity.Add(objValueQuantity);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (ValueQuantity.Count == 0)
          {
            ValueQuantity = null;
          }

          break;

        case "valueRange":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          ValueRange = new List<Range>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Range objValueRange = new fhirCsR5.Models.Range();
            objValueRange.DeserializeJson(ref reader, options);
            ValueRange.Add(objValueRange);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (ValueRange.Count == 0)
          {
            ValueRange = null;
          }

          break;

        case "variableDefinition":
          VariableDefinition = new fhirCsR5.Models.Reference();
          VariableDefinition.DeserializeJson(ref reader, options);
          break;

        default:
          ((fhirCsR5.Models.BackboneElement)this).DeserializeJsonProperty(ref reader, options, propertyName);
          break;
      }
    }

    /// <summary>
    /// Deserialize a JSON object
    /// </summary>
    public new void DeserializeJson(ref Utf8JsonReader reader, JsonSerializerOptions options)
    {
      string propertyName;

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

        if (reader.TokenType == JsonTokenType.PropertyName)
        {
          propertyName = reader.GetString();
          reader.Read();
          this.DeserializeJsonProperty(ref reader, options, propertyName);
        }
      }

      throw new JsonException();
    }
  }
  /// <summary>
  /// Code Values for the Evidence.statistic.modelCharacteristic.variable.handling field
  /// </summary>
  public static class EvidenceStatisticModelCharacteristicVariableHandlingCodes {
    public const string CONTINUOUS = "continuous";
    public const string DICHOTOMOUS = "dichotomous";
    public const string ORDINAL = "ordinal";
    public const string POLYCHOTOMOUS = "polychotomous";
  }
  /// <summary>
  /// A component of the method to generate the statistic.
  /// </summary>
  [JsonConverter(typeof(fhirCsR5.Serialization.JsonStreamComponentConverter<EvidenceStatisticModelCharacteristic>))]
  public class EvidenceStatisticModelCharacteristic : BackboneElement,  IFhirJsonSerializable {
    /// <summary>
    /// Description of a component of the method to generate the statistic.
    /// </summary>
    public CodeableConcept Code { get; set; }
    /// <summary>
    /// Further specification of the quantified value of the component of the method to generate the statistic.
    /// </summary>
    public Quantity Value { get; set; }
    /// <summary>
    /// A variable adjusted for in the adjusted analysis.
    /// </summary>
    public List<EvidenceStatisticModelCharacteristicVariable> Variable { get; set; }
    /// <summary>
    /// Serialize to a JSON object
    /// </summary>
    public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
    {
      if (includeStartObject)
      {
        writer.WriteStartObject();
      }
      ((fhirCsR5.Models.BackboneElement)this).SerializeJson(writer, options, false);

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

      if (Value != null)
      {
        writer.WritePropertyName("value");
        Value.SerializeJson(writer, options);
      }

      if ((Variable != null) && (Variable.Count != 0))
      {
        writer.WritePropertyName("variable");
        writer.WriteStartArray();

        foreach (EvidenceStatisticModelCharacteristicVariable valVariable in Variable)
        {
          valVariable.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (includeStartObject)
      {
        writer.WriteEndObject();
      }
    }
    /// <summary>
    /// Deserialize a JSON property
    /// </summary>
    public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
    {
      switch (propertyName)
      {
        case "code":
          Code = new fhirCsR5.Models.CodeableConcept();
          Code.DeserializeJson(ref reader, options);
          break;

        case "value":
          Value = new fhirCsR5.Models.Quantity();
          Value.DeserializeJson(ref reader, options);
          break;

        case "variable":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Variable = new List<EvidenceStatisticModelCharacteristicVariable>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.EvidenceStatisticModelCharacteristicVariable objVariable = new fhirCsR5.Models.EvidenceStatisticModelCharacteristicVariable();
            objVariable.DeserializeJson(ref reader, options);
            Variable.Add(objVariable);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Variable.Count == 0)
          {
            Variable = null;
          }

          break;

        default:
          ((fhirCsR5.Models.BackboneElement)this).DeserializeJsonProperty(ref reader, options, propertyName);
          break;
      }
    }

    /// <summary>
    /// Deserialize a JSON object
    /// </summary>
    public new void DeserializeJson(ref Utf8JsonReader reader, JsonSerializerOptions options)
    {
      string propertyName;

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

        if (reader.TokenType == JsonTokenType.PropertyName)
        {
          propertyName = reader.GetString();
          reader.Read();
          this.DeserializeJsonProperty(ref reader, options, propertyName);
        }
      }

      throw new JsonException();
    }
  }
  /// <summary>
  /// Values and parameters for a single statistic.
  /// </summary>
  [JsonConverter(typeof(fhirCsR5.Serialization.JsonStreamComponentConverter<EvidenceStatistic>))]
  public class EvidenceStatistic : BackboneElement,  IFhirJsonSerializable {
    /// <summary>
    /// A statistical attribute of the statistic such as a measure of heterogeneity.
    /// </summary>
    public List<EvidenceStatisticAttributeEstimate> AttributeEstimate { get; set; }
    /// <summary>
    /// Simple strings can be used for descriptive purposes. Exact matching to EvidenceVariable.category.name for the Evidence.variableDefinition[variableRole=measuredVariable].observed=Reference(EvidenceVariable) could facilitate validation within datasets.
    /// </summary>
    public CodeableConcept Category { get; set; }
    /// <summary>
    /// A description of the content value of the statistic.
    /// </summary>
    public string Description { get; set; }
    /// <summary>
    /// Extension container element for Description
    /// </summary>
    public Element _Description { get; set; }
    /// <summary>
    /// A component of the method to generate the statistic.
    /// </summary>
    public List<EvidenceStatisticModelCharacteristic> ModelCharacteristic { get; set; }
    /// <summary>
    /// Footnotes and/or explanatory notes.
    /// </summary>
    public List<Annotation> Note { get; set; }
    /// <summary>
    /// When the number affected is the statistic, use Evidence.statistic.quantity and set Evidence.statistic.type.coding.code=C25463 and Evidence.statistic.type.coding.display=Count. When the statistic is a Proportion, use Evidence.statistic.numberAffected and enter an integer as the value. When the statistic is an Event Rate (where individual participants may have 2 or more events), use Evidence.statistic.numberAffected to record the number of participants with events rather than the total number of events.
    /// </summary>
    public uint? NumberAffected { get; set; }
    /// <summary>
    /// When the number of events is the statistic, use Evidence.statistic.quantity and set Evidence.statistic.type.coding.code=C25463 and Evidence.statistic.type.coding.display=Count. When the statistic is an Event Rate (where individual participants may have 2 or more events), use Evidence.statistic.numberOfEvents to record the total number of events rather than the number of participants with events.
    /// </summary>
    public uint? NumberOfEvents { get; set; }
    /// <summary>
    /// Statistic value.
    /// </summary>
    public Quantity Quantity { get; set; }
    /// <summary>
    /// Number of samples in the statistic.
    /// </summary>
    public EvidenceStatisticSampleSize SampleSize { get; set; }
    /// <summary>
    /// Type of statistic, eg relative risk.
    /// </summary>
    public CodeableConcept StatisticType { get; set; }
    /// <summary>
    /// Serialize to a JSON object
    /// </summary>
    public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
    {
      if (includeStartObject)
      {
        writer.WriteStartObject();
      }
      ((fhirCsR5.Models.BackboneElement)this).SerializeJson(writer, options, false);

      if (!string.IsNullOrEmpty(Description))
      {
        writer.WriteString("description", (string)Description!);
      }

      if (_Description != null)
      {
        writer.WritePropertyName("_description");
        _Description.SerializeJson(writer, options);
      }

      if ((Note != null) && (Note.Count != 0))
      {
        writer.WritePropertyName("note");
        writer.WriteStartArray();

        foreach (Annotation valNote in Note)
        {
          valNote.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (StatisticType != null)
      {
        writer.WritePropertyName("statisticType");
        StatisticType.SerializeJson(writer, options);
      }

      if (Category != null)
      {
        writer.WritePropertyName("category");
        Category.SerializeJson(writer, options);
      }

      if (Quantity != null)
      {
        writer.WritePropertyName("quantity");
        Quantity.SerializeJson(writer, options);
      }

      if (NumberOfEvents != null)
      {
        writer.WriteNumber("numberOfEvents", (uint)NumberOfEvents!);
      }

      if (NumberAffected != null)
      {
        writer.WriteNumber("numberAffected", (uint)NumberAffected!);
      }

      if (SampleSize != null)
      {
        writer.WritePropertyName("sampleSize");
        SampleSize.SerializeJson(writer, options);
      }

      if ((AttributeEstimate != null) && (AttributeEstimate.Count != 0))
      {
        writer.WritePropertyName("attributeEstimate");
        writer.WriteStartArray();

        foreach (EvidenceStatisticAttributeEstimate valAttributeEstimate in AttributeEstimate)
        {
          valAttributeEstimate.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((ModelCharacteristic != null) && (ModelCharacteristic.Count != 0))
      {
        writer.WritePropertyName("modelCharacteristic");
        writer.WriteStartArray();

        foreach (EvidenceStatisticModelCharacteristic valModelCharacteristic in ModelCharacteristic)
        {
          valModelCharacteristic.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (includeStartObject)
      {
        writer.WriteEndObject();
      }
    }
    /// <summary>
    /// Deserialize a JSON property
    /// </summary>
    public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
    {
      switch (propertyName)
      {
        case "attributeEstimate":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          AttributeEstimate = new List<EvidenceStatisticAttributeEstimate>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.EvidenceStatisticAttributeEstimate objAttributeEstimate = new fhirCsR5.Models.EvidenceStatisticAttributeEstimate();
            objAttributeEstimate.DeserializeJson(ref reader, options);
            AttributeEstimate.Add(objAttributeEstimate);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (AttributeEstimate.Count == 0)
          {
            AttributeEstimate = null;
          }

          break;

        case "category":
          Category = new fhirCsR5.Models.CodeableConcept();
          Category.DeserializeJson(ref reader, options);
          break;

        case "description":
          Description = reader.GetString();
          break;

        case "_description":
          _Description = new fhirCsR5.Models.Element();
          _Description.DeserializeJson(ref reader, options);
          break;

        case "modelCharacteristic":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          ModelCharacteristic = new List<EvidenceStatisticModelCharacteristic>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.EvidenceStatisticModelCharacteristic objModelCharacteristic = new fhirCsR5.Models.EvidenceStatisticModelCharacteristic();
            objModelCharacteristic.DeserializeJson(ref reader, options);
            ModelCharacteristic.Add(objModelCharacteristic);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (ModelCharacteristic.Count == 0)
          {
            ModelCharacteristic = null;
          }

          break;

        case "note":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Note = new List<Annotation>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Annotation objNote = new fhirCsR5.Models.Annotation();
            objNote.DeserializeJson(ref reader, options);
            Note.Add(objNote);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Note.Count == 0)
          {
            Note = null;
          }

          break;

        case "numberAffected":
          NumberAffected = reader.GetUInt32();
          break;

        case "numberOfEvents":
          NumberOfEvents = reader.GetUInt32();
          break;

        case "quantity":
          Quantity = new fhirCsR5.Models.Quantity();
          Quantity.DeserializeJson(ref reader, options);
          break;

        case "sampleSize":
          SampleSize = new fhirCsR5.Models.EvidenceStatisticSampleSize();
          SampleSize.DeserializeJson(ref reader, options);
          break;

        case "statisticType":
          StatisticType = new fhirCsR5.Models.CodeableConcept();
          StatisticType.DeserializeJson(ref reader, options);
          break;

        default:
          ((fhirCsR5.Models.BackboneElement)this).DeserializeJsonProperty(ref reader, options, propertyName);
          break;
      }
    }

    /// <summary>
    /// Deserialize a JSON object
    /// </summary>
    public new void DeserializeJson(ref Utf8JsonReader reader, JsonSerializerOptions options)
    {
      string propertyName;

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

        if (reader.TokenType == JsonTokenType.PropertyName)
        {
          propertyName = reader.GetString();
          reader.Read();
          this.DeserializeJsonProperty(ref reader, options, propertyName);
        }
      }

      throw new JsonException();
    }
  }
  /// <summary>
  /// Assessment of certainty, confidence in the estimates, or quality of the evidence.
  /// </summary>
  [JsonConverter(typeof(fhirCsR5.Serialization.JsonStreamComponentConverter<EvidenceCertainty>))]
  public class EvidenceCertainty : BackboneElement,  IFhirJsonSerializable {
    /// <summary>
    /// Textual description of certainty.
    /// </summary>
    public string Description { get; set; }
    /// <summary>
    /// Extension container element for Description
    /// </summary>
    public Element _Description { get; set; }
    /// <summary>
    /// Footnotes and/or explanatory notes.
    /// </summary>
    public List<Annotation> Note { get; set; }
    /// <summary>
    /// Individual or group who did the rating.
    /// </summary>
    public string Rater { get; set; }
    /// <summary>
    /// Extension container element for Rater
    /// </summary>
    public Element _Rater { get; set; }
    /// <summary>
    /// Assessment or judgement of the aspect.
    /// </summary>
    public CodeableConcept Rating { get; set; }
    /// <summary>
    /// A domain or subdomain of certainty.
    /// </summary>
    public List<EvidenceCertainty> Subcomponent { get; set; }
    /// <summary>
    /// Aspect of certainty being rated.
    /// </summary>
    public CodeableConcept Type { get; set; }
    /// <summary>
    /// Serialize to a JSON object
    /// </summary>
    public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
    {
      if (includeStartObject)
      {
        writer.WriteStartObject();
      }
      ((fhirCsR5.Models.BackboneElement)this).SerializeJson(writer, options, false);

      if (!string.IsNullOrEmpty(Description))
      {
        writer.WriteString("description", (string)Description!);
      }

      if (_Description != null)
      {
        writer.WritePropertyName("_description");
        _Description.SerializeJson(writer, options);
      }

      if ((Note != null) && (Note.Count != 0))
      {
        writer.WritePropertyName("note");
        writer.WriteStartArray();

        foreach (Annotation valNote in Note)
        {
          valNote.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

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

      if (Rating != null)
      {
        writer.WritePropertyName("rating");
        Rating.SerializeJson(writer, options);
      }

      if (!string.IsNullOrEmpty(Rater))
      {
        writer.WriteString("rater", (string)Rater!);
      }

      if (_Rater != null)
      {
        writer.WritePropertyName("_rater");
        _Rater.SerializeJson(writer, options);
      }

      if ((Subcomponent != null) && (Subcomponent.Count != 0))
      {
        writer.WritePropertyName("subcomponent");
        writer.WriteStartArray();

        foreach (EvidenceCertainty valSubcomponent in Subcomponent)
        {
          valSubcomponent.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (includeStartObject)
      {
        writer.WriteEndObject();
      }
    }
    /// <summary>
    /// Deserialize a JSON property
    /// </summary>
    public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
    {
      switch (propertyName)
      {
        case "description":
          Description = reader.GetString();
          break;

        case "_description":
          _Description = new fhirCsR5.Models.Element();
          _Description.DeserializeJson(ref reader, options);
          break;

        case "note":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Note = new List<Annotation>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Annotation objNote = new fhirCsR5.Models.Annotation();
            objNote.DeserializeJson(ref reader, options);
            Note.Add(objNote);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Note.Count == 0)
          {
            Note = null;
          }

          break;

        case "rater":
          Rater = reader.GetString();
          break;

        case "_rater":
          _Rater = new fhirCsR5.Models.Element();
          _Rater.DeserializeJson(ref reader, options);
          break;

        case "rating":
          Rating = new fhirCsR5.Models.CodeableConcept();
          Rating.DeserializeJson(ref reader, options);
          break;

        case "subcomponent":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Subcomponent = new List<EvidenceCertainty>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.EvidenceCertainty objSubcomponent = new fhirCsR5.Models.EvidenceCertainty();
            objSubcomponent.DeserializeJson(ref reader, options);
            Subcomponent.Add(objSubcomponent);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Subcomponent.Count == 0)
          {
            Subcomponent = null;
          }

          break;

        case "type":
          Type = new fhirCsR5.Models.CodeableConcept();
          Type.DeserializeJson(ref reader, options);
          break;

        default:
          ((fhirCsR5.Models.BackboneElement)this).DeserializeJsonProperty(ref reader, options, propertyName);
          break;
      }
    }

    /// <summary>
    /// Deserialize a JSON object
    /// </summary>
    public new void DeserializeJson(ref Utf8JsonReader reader, JsonSerializerOptions options)
    {
      string propertyName;

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

        if (reader.TokenType == JsonTokenType.PropertyName)
        {
          propertyName = reader.GetString();
          reader.Read();
          this.DeserializeJsonProperty(ref reader, options, propertyName);
        }
      }

      throw new JsonException();
    }
  }
  /// <summary>
  /// The Evidence Resource provides a machine-interpretable expression of an evidence concept including the evidence variables (eg population, exposures/interventions, comparators, outcomes, measured variables, confounding variables), the statistics, and the certainty of this evidence.
  /// </summary>
  [JsonConverter(typeof(fhirCsR5.Serialization.JsonStreamComponentConverter<Evidence>))]
  public class Evidence : DomainResource,  IFhirJsonSerializable {
    /// <summary>
    /// Resource Type Name
    /// </summary>
    public override string ResourceType => "Evidence";
    /// <summary>
    /// The 'date' element may be more recent than the approval date because of minor changes or editorial corrections.
    /// </summary>
    public string ApprovalDate { get; set; }
    /// <summary>
    /// Extension container element for ApprovalDate
    /// </summary>
    public Element _ApprovalDate { get; set; }
    /// <summary>
    /// Declarative description of the Evidence.
    /// </summary>
    public string Assertion { get; set; }
    /// <summary>
    /// Extension container element for Assertion
    /// </summary>
    public Element _Assertion { get; set; }
    /// <summary>
    /// Extensions to ContactDetail include: contactReference, contactAddress, and contributionTime (Details at: http://build.fhir.org/clinicalreasoning-module.html).
    /// </summary>
    public List<ContactDetail> Author { get; set; }
    /// <summary>
    /// Assessment of certainty, confidence in the estimates, or quality of the evidence.
    /// </summary>
    public List<EvidenceCertainty> Certainty { get; set; }
    /// <summary>
    /// Citation Resource or display of suggested citation for this evidence.
    /// </summary>
    public Reference CiteAsReference { get; set; }
    /// <summary>
    /// Citation Resource or display of suggested citation for this evidence.
    /// </summary>
    public string CiteAsMarkdown { get; set; }
    /// <summary>
    /// Extension container element for CiteAsMarkdown
    /// </summary>
    public Element _CiteAsMarkdown { get; set; }
    /// <summary>
    /// Extensions to ContactDetail include: contactReference, contactAddress, and contributionTime (Details at: http://build.fhir.org/clinicalreasoning-module.html).
    /// </summary>
    public List<ContactDetail> Contact { get; set; }
    /// <summary>
    /// Note that this is not the same as the resource last-modified-date, since the resource may be a secondary representation of the summary. Additional specific dates may be added as extensions or be found by consulting Provenances associated with past versions of the resource.
    /// </summary>
    public string Date { get; set; }
    /// <summary>
    /// Extension container element for Date
    /// </summary>
    public Element _Date { get; set; }
    /// <summary>
    /// This description can be used to capture details such as why the evidence was built, comments about misuse, instructions for clinical use and interpretation, literature references, examples from the paper world, etc. It is not a rendering of the evidence as conveyed in the 'text' field of the resource itself. This item SHOULD be populated unless the information is available from context (e.g. the language of the evidence is presumed to be the predominant language in the place the evidence was created).
    /// </summary>
    public string Description { get; set; }
    /// <summary>
    /// Extension container element for Description
    /// </summary>
    public Element _Description { get; set; }
    /// <summary>
    /// Extensions to ContactDetail include: contactReference, contactAddress, and contributionTime (Details at: http://build.fhir.org/clinicalreasoning-module.html).
    /// </summary>
    public List<ContactDetail> Editor { get; set; }
    /// <summary>
    /// Extensions to ContactDetail include: contactReference, contactAddress, and contributionTime (Details at: http://build.fhir.org/clinicalreasoning-module.html).
    /// </summary>
    public List<ContactDetail> Endorser { get; set; }
    /// <summary>
    /// Typically, this is used for identifiers that can go in an HL7 V3 II (instance identifier) data type, and can then identify this summary outside of FHIR, where it is not possible to use the logical URI.
    /// </summary>
    public List<Identifier> Identifier { get; set; }
    /// <summary>
    /// If specified, this date follows the original approval date.
    /// </summary>
    public string LastReviewDate { get; set; }
    /// <summary>
    /// Extension container element for LastReviewDate
    /// </summary>
    public Element _LastReviewDate { get; set; }
    /// <summary>
    /// Footnotes and/or explanatory notes.
    /// </summary>
    public List<Annotation> Note { get; set; }
    /// <summary>
    /// Usually an organization but may be an individual. The publisher (or steward) of the evidence is the organization or individual primarily responsible for the maintenance and upkeep of the evidence. This is not necessarily the same individual or organization that developed and initially authored the content. The publisher is the primary point of contact for questions or issues with the evidence. This item SHOULD be populated unless the information is available from context.
    /// </summary>
    public string Publisher { get; set; }
    /// <summary>
    /// Extension container element for Publisher
    /// </summary>
    public Element _Publisher { get; set; }
    /// <summary>
    /// Link or citation to artifact associated with the summary.
    /// </summary>
    public List<RelatedArtifact> RelatedArtifact { get; set; }
    /// <summary>
    /// Extensions to ContactDetail include: contactReference, contactAddress, and contributionTime (Details at: http://build.fhir.org/clinicalreasoning-module.html).
    /// </summary>
    public List<ContactDetail> Reviewer { get; set; }
    /// <summary>
    /// Values and parameters for a single statistic.
    /// </summary>
    public List<EvidenceStatistic> Statistic { get; set; }
    /// <summary>
    /// Allows filtering of summarys s that are appropriate for use versus not.
    /// </summary>
    public string Status { get; set; }
    /// <summary>
    /// Extension container element for Status
    /// </summary>
    public Element _Status { get; set; }
    /// <summary>
    /// The type of study that produced this evidence.
    /// </summary>
    public CodeableConcept StudyType { get; set; }
    /// <summary>
    /// The method to combine studies.
    /// </summary>
    public CodeableConcept SynthesisType { get; set; }
    /// <summary>
    /// In some cases, the resource can no longer be found at the stated url, but the url itself cannot change. Implementations can use the meta.source element to indicate where the current master source of the resource can be found.
    /// </summary>
    public string Title { get; set; }
    /// <summary>
    /// Extension container element for Title
    /// </summary>
    public Element _Title { get; set; }
    /// <summary>
    /// Can be a urn:uuid: or a urn:oid: but real http: addresses are preferred. Multiple instances may share the same URL if they have a distinct version.
    /// </summary>
    public string Url { get; set; }
    /// <summary>
    /// Extension container element for Url
    /// </summary>
    public Element _Url { get; set; }
    /// <summary>
    /// When multiple useContexts are specified, there is no expectation that all or any of the contexts apply.
    /// </summary>
    public List<UsageContext> UseContext { get; set; }
    /// <summary>
    /// Evidence variable such as population, exposure, or outcome.
    /// </summary>
    public List<EvidenceVariableDefinition> VariableDefinition { get; set; }
    /// <summary>
    /// The determination of when to create a new version of a resource (same url, new version) vs. defining a new artifact is up to the author. Considerations for making this decision are found in Technical and Business Versions.
    /// </summary>
    public string Version { get; set; }
    /// <summary>
    /// Extension container element for Version
    /// </summary>
    public Element _Version { get; set; }
    /// <summary>
    /// Serialize to a JSON object
    /// </summary>
    public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
    {
      if (includeStartObject)
      {
        writer.WriteStartObject();
      }
      if (!string.IsNullOrEmpty(ResourceType))
      {
        writer.WriteString("resourceType", (string)ResourceType!);
      }


      ((fhirCsR5.Models.DomainResource)this).SerializeJson(writer, options, false);

      if (!string.IsNullOrEmpty(Url))
      {
        writer.WriteString("url", (string)Url!);
      }

      if (_Url != null)
      {
        writer.WritePropertyName("_url");
        _Url.SerializeJson(writer, options);
      }

      if ((Identifier != null) && (Identifier.Count != 0))
      {
        writer.WritePropertyName("identifier");
        writer.WriteStartArray();

        foreach (Identifier valIdentifier in Identifier)
        {
          valIdentifier.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (!string.IsNullOrEmpty(Version))
      {
        writer.WriteString("version", (string)Version!);
      }

      if (_Version != null)
      {
        writer.WritePropertyName("_version");
        _Version.SerializeJson(writer, options);
      }

      if (!string.IsNullOrEmpty(Title))
      {
        writer.WriteString("title", (string)Title!);
      }

      if (_Title != null)
      {
        writer.WritePropertyName("_title");
        _Title.SerializeJson(writer, options);
      }

      if (CiteAsReference != null)
      {
        writer.WritePropertyName("citeAsReference");
        CiteAsReference.SerializeJson(writer, options);
      }

      if (!string.IsNullOrEmpty(CiteAsMarkdown))
      {
        writer.WriteString("citeAsMarkdown", (string)CiteAsMarkdown!);
      }

      if (_CiteAsMarkdown != null)
      {
        writer.WritePropertyName("_citeAsMarkdown");
        _CiteAsMarkdown.SerializeJson(writer, options);
      }

      if (!string.IsNullOrEmpty(Status))
      {
        writer.WriteString("status", (string)Status!);
      }

      if (_Status != null)
      {
        writer.WritePropertyName("_status");
        _Status.SerializeJson(writer, options);
      }

      if (!string.IsNullOrEmpty(Date))
      {
        writer.WriteString("date", (string)Date!);
      }

      if (_Date != null)
      {
        writer.WritePropertyName("_date");
        _Date.SerializeJson(writer, options);
      }

      if ((UseContext != null) && (UseContext.Count != 0))
      {
        writer.WritePropertyName("useContext");
        writer.WriteStartArray();

        foreach (UsageContext valUseContext in UseContext)
        {
          valUseContext.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (!string.IsNullOrEmpty(ApprovalDate))
      {
        writer.WriteString("approvalDate", (string)ApprovalDate!);
      }

      if (_ApprovalDate != null)
      {
        writer.WritePropertyName("_approvalDate");
        _ApprovalDate.SerializeJson(writer, options);
      }

      if (!string.IsNullOrEmpty(LastReviewDate))
      {
        writer.WriteString("lastReviewDate", (string)LastReviewDate!);
      }

      if (_LastReviewDate != null)
      {
        writer.WritePropertyName("_lastReviewDate");
        _LastReviewDate.SerializeJson(writer, options);
      }

      if (!string.IsNullOrEmpty(Publisher))
      {
        writer.WriteString("publisher", (string)Publisher!);
      }

      if (_Publisher != null)
      {
        writer.WritePropertyName("_publisher");
        _Publisher.SerializeJson(writer, options);
      }

      if ((Contact != null) && (Contact.Count != 0))
      {
        writer.WritePropertyName("contact");
        writer.WriteStartArray();

        foreach (ContactDetail valContact in Contact)
        {
          valContact.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((Author != null) && (Author.Count != 0))
      {
        writer.WritePropertyName("author");
        writer.WriteStartArray();

        foreach (ContactDetail valAuthor in Author)
        {
          valAuthor.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((Editor != null) && (Editor.Count != 0))
      {
        writer.WritePropertyName("editor");
        writer.WriteStartArray();

        foreach (ContactDetail valEditor in Editor)
        {
          valEditor.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((Reviewer != null) && (Reviewer.Count != 0))
      {
        writer.WritePropertyName("reviewer");
        writer.WriteStartArray();

        foreach (ContactDetail valReviewer in Reviewer)
        {
          valReviewer.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((Endorser != null) && (Endorser.Count != 0))
      {
        writer.WritePropertyName("endorser");
        writer.WriteStartArray();

        foreach (ContactDetail valEndorser in Endorser)
        {
          valEndorser.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((RelatedArtifact != null) && (RelatedArtifact.Count != 0))
      {
        writer.WritePropertyName("relatedArtifact");
        writer.WriteStartArray();

        foreach (RelatedArtifact valRelatedArtifact in RelatedArtifact)
        {
          valRelatedArtifact.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (!string.IsNullOrEmpty(Description))
      {
        writer.WriteString("description", (string)Description!);
      }

      if (_Description != null)
      {
        writer.WritePropertyName("_description");
        _Description.SerializeJson(writer, options);
      }

      if (!string.IsNullOrEmpty(Assertion))
      {
        writer.WriteString("assertion", (string)Assertion!);
      }

      if (_Assertion != null)
      {
        writer.WritePropertyName("_assertion");
        _Assertion.SerializeJson(writer, options);
      }

      if ((Note != null) && (Note.Count != 0))
      {
        writer.WritePropertyName("note");
        writer.WriteStartArray();

        foreach (Annotation valNote in Note)
        {
          valNote.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((VariableDefinition != null) && (VariableDefinition.Count != 0))
      {
        writer.WritePropertyName("variableDefinition");
        writer.WriteStartArray();

        foreach (EvidenceVariableDefinition valVariableDefinition in VariableDefinition)
        {
          valVariableDefinition.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (SynthesisType != null)
      {
        writer.WritePropertyName("synthesisType");
        SynthesisType.SerializeJson(writer, options);
      }

      if (StudyType != null)
      {
        writer.WritePropertyName("studyType");
        StudyType.SerializeJson(writer, options);
      }

      if ((Statistic != null) && (Statistic.Count != 0))
      {
        writer.WritePropertyName("statistic");
        writer.WriteStartArray();

        foreach (EvidenceStatistic valStatistic in Statistic)
        {
          valStatistic.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if ((Certainty != null) && (Certainty.Count != 0))
      {
        writer.WritePropertyName("certainty");
        writer.WriteStartArray();

        foreach (EvidenceCertainty valCertainty in Certainty)
        {
          valCertainty.SerializeJson(writer, options, true);
        }

        writer.WriteEndArray();
      }

      if (includeStartObject)
      {
        writer.WriteEndObject();
      }
    }
    /// <summary>
    /// Deserialize a JSON property
    /// </summary>
    public new void DeserializeJsonProperty(ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
    {
      switch (propertyName)
      {
        case "approvalDate":
          ApprovalDate = reader.GetString();
          break;

        case "_approvalDate":
          _ApprovalDate = new fhirCsR5.Models.Element();
          _ApprovalDate.DeserializeJson(ref reader, options);
          break;

        case "assertion":
          Assertion = reader.GetString();
          break;

        case "_assertion":
          _Assertion = new fhirCsR5.Models.Element();
          _Assertion.DeserializeJson(ref reader, options);
          break;

        case "author":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Author = new List<ContactDetail>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.ContactDetail objAuthor = new fhirCsR5.Models.ContactDetail();
            objAuthor.DeserializeJson(ref reader, options);
            Author.Add(objAuthor);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Author.Count == 0)
          {
            Author = null;
          }

          break;

        case "certainty":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Certainty = new List<EvidenceCertainty>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.EvidenceCertainty objCertainty = new fhirCsR5.Models.EvidenceCertainty();
            objCertainty.DeserializeJson(ref reader, options);
            Certainty.Add(objCertainty);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Certainty.Count == 0)
          {
            Certainty = null;
          }

          break;

        case "citeAsReference":
          CiteAsReference = new fhirCsR5.Models.Reference();
          CiteAsReference.DeserializeJson(ref reader, options);
          break;

        case "citeAsMarkdown":
          CiteAsMarkdown = reader.GetString();
          break;

        case "_citeAsMarkdown":
          _CiteAsMarkdown = new fhirCsR5.Models.Element();
          _CiteAsMarkdown.DeserializeJson(ref reader, options);
          break;

        case "contact":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Contact = new List<ContactDetail>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.ContactDetail objContact = new fhirCsR5.Models.ContactDetail();
            objContact.DeserializeJson(ref reader, options);
            Contact.Add(objContact);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Contact.Count == 0)
          {
            Contact = null;
          }

          break;

        case "date":
          Date = reader.GetString();
          break;

        case "_date":
          _Date = new fhirCsR5.Models.Element();
          _Date.DeserializeJson(ref reader, options);
          break;

        case "description":
          Description = reader.GetString();
          break;

        case "_description":
          _Description = new fhirCsR5.Models.Element();
          _Description.DeserializeJson(ref reader, options);
          break;

        case "editor":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Editor = new List<ContactDetail>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.ContactDetail objEditor = new fhirCsR5.Models.ContactDetail();
            objEditor.DeserializeJson(ref reader, options);
            Editor.Add(objEditor);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Editor.Count == 0)
          {
            Editor = null;
          }

          break;

        case "endorser":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Endorser = new List<ContactDetail>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.ContactDetail objEndorser = new fhirCsR5.Models.ContactDetail();
            objEndorser.DeserializeJson(ref reader, options);
            Endorser.Add(objEndorser);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Endorser.Count == 0)
          {
            Endorser = null;
          }

          break;

        case "identifier":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Identifier = new List<Identifier>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Identifier objIdentifier = new fhirCsR5.Models.Identifier();
            objIdentifier.DeserializeJson(ref reader, options);
            Identifier.Add(objIdentifier);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Identifier.Count == 0)
          {
            Identifier = null;
          }

          break;

        case "lastReviewDate":
          LastReviewDate = reader.GetString();
          break;

        case "_lastReviewDate":
          _LastReviewDate = new fhirCsR5.Models.Element();
          _LastReviewDate.DeserializeJson(ref reader, options);
          break;

        case "note":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Note = new List<Annotation>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.Annotation objNote = new fhirCsR5.Models.Annotation();
            objNote.DeserializeJson(ref reader, options);
            Note.Add(objNote);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Note.Count == 0)
          {
            Note = null;
          }

          break;

        case "publisher":
          Publisher = reader.GetString();
          break;

        case "_publisher":
          _Publisher = new fhirCsR5.Models.Element();
          _Publisher.DeserializeJson(ref reader, options);
          break;

        case "relatedArtifact":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          RelatedArtifact = new List<RelatedArtifact>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.RelatedArtifact objRelatedArtifact = new fhirCsR5.Models.RelatedArtifact();
            objRelatedArtifact.DeserializeJson(ref reader, options);
            RelatedArtifact.Add(objRelatedArtifact);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (RelatedArtifact.Count == 0)
          {
            RelatedArtifact = null;
          }

          break;

        case "reviewer":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Reviewer = new List<ContactDetail>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.ContactDetail objReviewer = new fhirCsR5.Models.ContactDetail();
            objReviewer.DeserializeJson(ref reader, options);
            Reviewer.Add(objReviewer);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Reviewer.Count == 0)
          {
            Reviewer = null;
          }

          break;

        case "statistic":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          Statistic = new List<EvidenceStatistic>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.EvidenceStatistic objStatistic = new fhirCsR5.Models.EvidenceStatistic();
            objStatistic.DeserializeJson(ref reader, options);
            Statistic.Add(objStatistic);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (Statistic.Count == 0)
          {
            Statistic = null;
          }

          break;

        case "status":
          Status = reader.GetString();
          break;

        case "_status":
          _Status = new fhirCsR5.Models.Element();
          _Status.DeserializeJson(ref reader, options);
          break;

        case "studyType":
          StudyType = new fhirCsR5.Models.CodeableConcept();
          StudyType.DeserializeJson(ref reader, options);
          break;

        case "synthesisType":
          SynthesisType = new fhirCsR5.Models.CodeableConcept();
          SynthesisType.DeserializeJson(ref reader, options);
          break;

        case "title":
          Title = reader.GetString();
          break;

        case "_title":
          _Title = new fhirCsR5.Models.Element();
          _Title.DeserializeJson(ref reader, options);
          break;

        case "url":
          Url = reader.GetString();
          break;

        case "_url":
          _Url = new fhirCsR5.Models.Element();
          _Url.DeserializeJson(ref reader, options);
          break;

        case "useContext":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          UseContext = new List<UsageContext>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.UsageContext objUseContext = new fhirCsR5.Models.UsageContext();
            objUseContext.DeserializeJson(ref reader, options);
            UseContext.Add(objUseContext);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (UseContext.Count == 0)
          {
            UseContext = null;
          }

          break;

        case "variableDefinition":
          if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
          {
            throw new JsonException();
          }

          VariableDefinition = new List<EvidenceVariableDefinition>();

          while (reader.TokenType != JsonTokenType.EndArray)
          {
            fhirCsR5.Models.EvidenceVariableDefinition objVariableDefinition = new fhirCsR5.Models.EvidenceVariableDefinition();
            objVariableDefinition.DeserializeJson(ref reader, options);
            VariableDefinition.Add(objVariableDefinition);

            if (!reader.Read())
            {
              throw new JsonException();
            }
          }

          if (VariableDefinition.Count == 0)
          {
            VariableDefinition = null;
          }

          break;

        case "version":
          Version = reader.GetString();
          break;

        case "_version":
          _Version = new fhirCsR5.Models.Element();
          _Version.DeserializeJson(ref reader, options);
          break;

        default:
          ((fhirCsR5.Models.DomainResource)this).DeserializeJsonProperty(ref reader, options, propertyName);
          break;
      }
    }

    /// <summary>
    /// Deserialize a JSON object
    /// </summary>
    public new void DeserializeJson(ref Utf8JsonReader reader, JsonSerializerOptions options)
    {
      string propertyName;

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

        if (reader.TokenType == JsonTokenType.PropertyName)
        {
          propertyName = reader.GetString();
          reader.Read();
          this.DeserializeJsonProperty(ref reader, options, propertyName);
        }
      }

      throw new JsonException();
    }
  }
  /// <summary>
  /// Code Values for the Evidence.status field
  /// </summary>
  public static class EvidenceStatusCodes {
    public const string DRAFT = "draft";
    public const string ACTIVE = "active";
    public const string RETIRED = "retired";
    public const string UNKNOWN = "unknown";
  }
}
