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