/// <summary> /// Deserialize JSON into a FHIR BiologicallyDerivedProduct#Storage /// </summary> public static void DeserializeJson(this BiologicallyDerivedProduct.StorageComponent 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($"BiologicallyDerivedProduct.StorageComponent >>> BiologicallyDerivedProduct#Storage.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"BiologicallyDerivedProduct.StorageComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR BiologicallyDerivedProduct#Storage into JSON /// </summary> public static void SerializeJson(this BiologicallyDerivedProduct.StorageComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: BiologicallyDerivedProduct#Storage, Export: StorageComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); 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.TemperatureElement != null) { if (current.TemperatureElement.Value != null) { writer.WriteNumber("temperature", (decimal)current.TemperatureElement.Value); } if (current.TemperatureElement.HasExtensions() || (!string.IsNullOrEmpty(current.TemperatureElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_temperature", false, current.TemperatureElement.Extension, current.TemperatureElement.ElementId); } } if (current.ScaleElement != null) { if (current.ScaleElement.Value != null) { writer.WriteString("scale", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.ScaleElement.Value)); } if (current.ScaleElement.HasExtensions() || (!string.IsNullOrEmpty(current.ScaleElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_scale", false, current.ScaleElement.Extension, current.ScaleElement.ElementId); } } if (current.Duration != null) { writer.WritePropertyName("duration"); current.Duration.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR BiologicallyDerivedProduct#Storage /// </summary> public static void DeserializeJsonProperty(this BiologicallyDerivedProduct.StorageComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { 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 "temperature": if (reader.TokenType == JsonTokenType.Null) { current.TemperatureElement = new FhirDecimal(); reader.Skip(); } else { current.TemperatureElement = new FhirDecimal(reader.GetDecimal()); } break; case "_temperature": if (current.TemperatureElement == null) { current.TemperatureElement = new FhirDecimal(); } ((Hl7.Fhir.Model.Element)current.TemperatureElement).DeserializeJson(ref reader, options); break; case "scale": if (reader.TokenType == JsonTokenType.Null) { current.ScaleElement = new Code <Hl7.Fhir.Model.BiologicallyDerivedProduct.BiologicallyDerivedProductStorageScale>(); reader.Skip(); } else { current.ScaleElement = new Code <Hl7.Fhir.Model.BiologicallyDerivedProduct.BiologicallyDerivedProductStorageScale>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.BiologicallyDerivedProduct.BiologicallyDerivedProductStorageScale>(reader.GetString())); } break; case "_scale": if (current.ScaleElement == null) { current.ScaleElement = new Code <Hl7.Fhir.Model.BiologicallyDerivedProduct.BiologicallyDerivedProductStorageScale>(); } ((Hl7.Fhir.Model.Element)current.ScaleElement).DeserializeJson(ref reader, options); break; case "duration": current.Duration = new Hl7.Fhir.Model.Period(); ((Hl7.Fhir.Model.Period)current.Duration).DeserializeJson(ref reader, options); break; // Complex: storage, Export: StorageComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }