/// <summary> /// Deserialize JSON into a FHIR BiologicallyDerivedProduct#Processing /// </summary> public static void DeserializeJson(this BiologicallyDerivedProduct.ProcessingComponent 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.ProcessingComponent >>> BiologicallyDerivedProduct#Processing.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"BiologicallyDerivedProduct.ProcessingComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR BiologicallyDerivedProduct#Processing /// </summary> public static void DeserializeJsonProperty(this BiologicallyDerivedProduct.ProcessingComponent 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 "procedure": current.Procedure = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Procedure).DeserializeJson(ref reader, options); break; case "additive": current.Additive = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Additive).DeserializeJson(ref reader, options); break; case "timeDateTime": if (reader.TokenType == JsonTokenType.Null) { current.Time = new FhirDateTime(); reader.Skip(); } else { current.Time = new FhirDateTime(reader.GetString()); } break; case "_timeDateTime": if (current.Time == null) { current.Time = new FhirDateTime(); } ((Hl7.Fhir.Model.Element)current.Time).DeserializeJson(ref reader, options); break; case "timePeriod": current.Time = new Hl7.Fhir.Model.Period(); ((Hl7.Fhir.Model.Period)current.Time).DeserializeJson(ref reader, options); break; // Complex: processing, Export: ProcessingComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR BiologicallyDerivedProduct#Processing into JSON /// </summary> public static void SerializeJson(this BiologicallyDerivedProduct.ProcessingComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: BiologicallyDerivedProduct#Processing, Export: ProcessingComponent, 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.Procedure != null) { writer.WritePropertyName("procedure"); current.Procedure.SerializeJson(writer, options); } if (current.Additive != null) { writer.WritePropertyName("additive"); current.Additive.SerializeJson(writer, options); } if (current.Time != null) { switch (current.Time) { case FhirDateTime v_FhirDateTime: if (v_FhirDateTime != null) { if (!string.IsNullOrEmpty(v_FhirDateTime.Value)) { writer.WriteString("timeDateTime", v_FhirDateTime.Value); } if (v_FhirDateTime.HasExtensions() || (!string.IsNullOrEmpty(v_FhirDateTime.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_timeDateTime", false, v_FhirDateTime.Extension, v_FhirDateTime.ElementId); } } break; case Period v_Period: writer.WritePropertyName("timePeriod"); v_Period.SerializeJson(writer, options); break; } } if (includeStartObject) { writer.WriteEndObject(); } }