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

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

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

            writer.WritePropertyName("strength");
            current.Strength.SerializeJson(writer, options);

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

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

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

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Beispiel #3
0
        /// <summary>
        /// Deserialize JSON into a FHIR MedicinalProductIngredient#ReferenceStrength
        /// </summary>
        public static void DeserializeJsonProperty(this MedicinalProductIngredient.ReferenceStrengthComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "substance":
                current.Substance = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Substance).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

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

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