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

            throw new JsonException($"EpisodeOfCare.StatusHistoryComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
        /// <summary>
        /// Deserialize JSON into a FHIR EpisodeOfCare#StatusHistory
        /// </summary>
        public static void DeserializeJsonProperty(this EpisodeOfCare.StatusHistoryComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "status":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatus>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatus>(reader.GetString()));
                }
                break;

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.EpisodeOfCare.EpisodeOfCareStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options);
                break;

            case "period":
                current.Period = new Hl7.Fhir.Model.Period();
                ((Hl7.Fhir.Model.Period)current.Period).DeserializeJson(ref reader, options);
                break;

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

            writer.WriteString("status", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StatusElement.Value));

            writer.WritePropertyName("period");
            current.Period.SerializeJson(writer, options);

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