/// <summary> /// Deserialize JSON into a FHIR MedicinalProductIngredient#Strength /// </summary> public static void DeserializeJson(this MedicinalProductIngredient.StrengthComponent 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.StrengthComponent >>> MedicinalProductIngredient#Strength.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"MedicinalProductIngredient.StrengthComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR MedicinalProductIngredient#Strength /// </summary> public static void DeserializeJsonProperty(this MedicinalProductIngredient.StrengthComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "presentation": current.Presentation = new Hl7.Fhir.Model.Ratio(); ((Hl7.Fhir.Model.Ratio)current.Presentation).DeserializeJson(ref reader, options); break; case "presentationLowLimit": current.PresentationLowLimit = new Hl7.Fhir.Model.Ratio(); ((Hl7.Fhir.Model.Ratio)current.PresentationLowLimit).DeserializeJson(ref reader, options); break; case "concentration": current.Concentration = new Hl7.Fhir.Model.Ratio(); ((Hl7.Fhir.Model.Ratio)current.Concentration).DeserializeJson(ref reader, options); break; case "concentrationLowLimit": current.ConcentrationLowLimit = new Hl7.Fhir.Model.Ratio(); ((Hl7.Fhir.Model.Ratio)current.ConcentrationLowLimit).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($"StrengthComponent 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($"StrengthComponent 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; case "referenceStrength": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"StrengthComponent error reading 'referenceStrength' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.ReferenceStrength = new List <MedicinalProductIngredient.ReferenceStrengthComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.MedicinalProductIngredient.ReferenceStrengthComponent v_ReferenceStrength = new Hl7.Fhir.Model.MedicinalProductIngredient.ReferenceStrengthComponent(); v_ReferenceStrength.DeserializeJson(ref reader, options); current.ReferenceStrength.Add(v_ReferenceStrength); if (!reader.Read()) { throw new JsonException($"StrengthComponent error reading 'referenceStrength' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.ReferenceStrength.Count == 0) { current.ReferenceStrength = null; } break; // Complex: strength, Export: StrengthComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR MedicinalProductIngredient#Strength into JSON /// </summary> public static void SerializeJson(this MedicinalProductIngredient.StrengthComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: MedicinalProductIngredient#Strength, Export: StrengthComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); writer.WritePropertyName("presentation"); current.Presentation.SerializeJson(writer, options); if (current.PresentationLowLimit != null) { writer.WritePropertyName("presentationLowLimit"); current.PresentationLowLimit.SerializeJson(writer, options); } if (current.Concentration != null) { writer.WritePropertyName("concentration"); current.Concentration.SerializeJson(writer, options); } if (current.ConcentrationLowLimit != null) { writer.WritePropertyName("concentrationLowLimit"); current.ConcentrationLowLimit.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 ((current.ReferenceStrength != null) && (current.ReferenceStrength.Count != 0)) { writer.WritePropertyName("referenceStrength"); writer.WriteStartArray(); foreach (MedicinalProductIngredient.ReferenceStrengthComponent val in current.ReferenceStrength) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }