コード例 #1
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as MedicinalProductPackaged;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (Subject != null)
            {
                dest.Subject = new List <Hl7.Fhir.Model.ResourceReference>(Subject.DeepCopy());
            }
            if (DescriptionElement != null)
            {
                dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
            }
            if (LegalStatusOfSupply != null)
            {
                dest.LegalStatusOfSupply = (Hl7.Fhir.Model.CodeableConcept)LegalStatusOfSupply.DeepCopy();
            }
            if (MarketingStatus != null)
            {
                dest.MarketingStatus = new List <Hl7.Fhir.Model.MarketingStatus>(MarketingStatus.DeepCopy());
            }
            if (MarketingAuthorization != null)
            {
                dest.MarketingAuthorization = (Hl7.Fhir.Model.ResourceReference)MarketingAuthorization.DeepCopy();
            }
            if (Manufacturer != null)
            {
                dest.Manufacturer = new List <Hl7.Fhir.Model.ResourceReference>(Manufacturer.DeepCopy());
            }
            if (BatchIdentifier != null)
            {
                dest.BatchIdentifier = new List <Hl7.Fhir.Model.MedicinalProductPackaged.BatchIdentifierComponent>(BatchIdentifier.DeepCopy());
            }
            if (PackageItem != null)
            {
                dest.PackageItem = new List <Hl7.Fhir.Model.MedicinalProductPackaged.PackageItemComponent>(PackageItem.DeepCopy());
            }
            return(dest);
        }
コード例 #2
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;
            }
        }