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

            throw new JsonException($"MedicinalProductPackaged: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Exemple #2
0
        /// <summary>
        /// Serialize a FHIR MedicinalProductPackaged into JSON
        /// </summary>
        public static void SerializeJson(this MedicinalProductPackaged current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            writer.WriteString("resourceType", "MedicinalProductPackaged");
            // Complex: MedicinalProductPackaged, Export: MedicinalProductPackaged, Base: DomainResource (DomainResource)
            ((Hl7.Fhir.Model.DomainResource)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.Subject != null) && (current.Subject.Count != 0))
            {
                writer.WritePropertyName("subject");
                writer.WriteStartArray();
                foreach (ResourceReference val in current.Subject)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (current.DescriptionElement != null)
            {
                if (!string.IsNullOrEmpty(current.DescriptionElement.Value))
                {
                    writer.WriteString("description", current.DescriptionElement.Value);
                }
                if (current.DescriptionElement.HasExtensions() || (!string.IsNullOrEmpty(current.DescriptionElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_description", false, current.DescriptionElement.Extension, current.DescriptionElement.ElementId);
                }
            }

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

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

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

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

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

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

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

                current.Subject = new List <ResourceReference>();

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

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

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

            case "description":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.DescriptionElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.DescriptionElement = new FhirString(reader.GetString());
                }
                break;

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

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

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

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

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

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

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

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

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

                current.Manufacturer = new List <ResourceReference>();

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

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

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

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

                current.BatchIdentifier = new List <MedicinalProductPackaged.BatchIdentifierComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.MedicinalProductPackaged.BatchIdentifierComponent v_BatchIdentifier = new Hl7.Fhir.Model.MedicinalProductPackaged.BatchIdentifierComponent();
                    v_BatchIdentifier.DeserializeJson(ref reader, options);
                    current.BatchIdentifier.Add(v_BatchIdentifier);

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

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

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

                current.PackageItem = new List <MedicinalProductPackaged.PackageItemComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.MedicinalProductPackaged.PackageItemComponent v_PackageItem = new Hl7.Fhir.Model.MedicinalProductPackaged.PackageItemComponent();
                    v_PackageItem.DeserializeJson(ref reader, options);
                    current.PackageItem.Add(v_PackageItem);

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

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

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