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

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

            writer.WritePropertyName("code");
            current.Code.SerializeJson(writer, options);

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

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

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

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

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

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

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deserialize JSON into a FHIR MedicinalProductPharmaceutical#RouteOfAdministration
        /// </summary>
        public static void DeserializeJsonProperty(this MedicinalProductPharmaceutical.RouteOfAdministrationComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options);
                break;

            case "firstDose":
                current.FirstDose = new Hl7.Fhir.Model.Quantity();
                ((Hl7.Fhir.Model.Quantity)current.FirstDose).DeserializeJson(ref reader, options);
                break;

            case "maxSingleDose":
                current.MaxSingleDose = new Hl7.Fhir.Model.Quantity();
                ((Hl7.Fhir.Model.Quantity)current.MaxSingleDose).DeserializeJson(ref reader, options);
                break;

            case "maxDosePerDay":
                current.MaxDosePerDay = new Hl7.Fhir.Model.Quantity();
                ((Hl7.Fhir.Model.Quantity)current.MaxDosePerDay).DeserializeJson(ref reader, options);
                break;

            case "maxDosePerTreatmentPeriod":
                current.MaxDosePerTreatmentPeriod = new Hl7.Fhir.Model.Ratio();
                ((Hl7.Fhir.Model.Ratio)current.MaxDosePerTreatmentPeriod).DeserializeJson(ref reader, options);
                break;

            case "maxTreatmentPeriod":
                current.MaxTreatmentPeriod = new Hl7.Fhir.Model.Duration();
                ((Hl7.Fhir.Model.Duration)current.MaxTreatmentPeriod).DeserializeJson(ref reader, options);
                break;

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

                current.TargetSpecies = new List <MedicinalProductPharmaceutical.TargetSpeciesComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.MedicinalProductPharmaceutical.TargetSpeciesComponent v_TargetSpecies = new Hl7.Fhir.Model.MedicinalProductPharmaceutical.TargetSpeciesComponent();
                    v_TargetSpecies.DeserializeJson(ref reader, options);
                    current.TargetSpecies.Add(v_TargetSpecies);

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

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

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