/// <summary> /// Deserialize JSON into a FHIR AdverseEvent#Causality /// </summary> public static void DeserializeJson(this AdverseEvent.CausalityComponent 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($"AdverseEvent.CausalityComponent >>> AdverseEvent#Causality.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"AdverseEvent.CausalityComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR AdverseEvent#Causality /// </summary> public static void DeserializeJsonProperty(this AdverseEvent.CausalityComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "assessment": current.Assessment = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Assessment).DeserializeJson(ref reader, options); break; case "productRelatedness": if (reader.TokenType == JsonTokenType.Null) { current.ProductRelatednessElement = new FhirString(); reader.Skip(); } else { current.ProductRelatednessElement = new FhirString(reader.GetString()); } break; case "_productRelatedness": if (current.ProductRelatednessElement == null) { current.ProductRelatednessElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.ProductRelatednessElement).DeserializeJson(ref reader, options); break; case "author": current.Author = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Author).DeserializeJson(ref reader, options); break; case "method": current.Method = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Method).DeserializeJson(ref reader, options); break; // Complex: causality, Export: CausalityComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR AdverseEvent#Causality into JSON /// </summary> public static void SerializeJson(this AdverseEvent.CausalityComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: AdverseEvent#Causality, Export: CausalityComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); if (current.Assessment != null) { writer.WritePropertyName("assessment"); current.Assessment.SerializeJson(writer, options); } if (current.ProductRelatednessElement != null) { if (!string.IsNullOrEmpty(current.ProductRelatednessElement.Value)) { writer.WriteString("productRelatedness", current.ProductRelatednessElement.Value); } if (current.ProductRelatednessElement.HasExtensions() || (!string.IsNullOrEmpty(current.ProductRelatednessElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_productRelatedness", false, current.ProductRelatednessElement.Extension, current.ProductRelatednessElement.ElementId); } } if (current.Author != null) { writer.WritePropertyName("author"); current.Author.SerializeJson(writer, options); } if (current.Method != null) { writer.WritePropertyName("method"); current.Method.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }