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

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

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

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

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

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

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

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

                current.Identifier = new List <Identifier>();

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

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

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

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

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

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

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

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

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

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

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

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