/// <summary> /// Deserialize JSON into a FHIR AdverseEvent#SuspectEntity /// </summary> public static void DeserializeJson(this AdverseEvent.SuspectEntityComponent 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.SuspectEntityComponent >>> AdverseEvent#SuspectEntity.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"AdverseEvent.SuspectEntityComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR AdverseEvent#SuspectEntity into JSON /// </summary> public static void SerializeJson(this AdverseEvent.SuspectEntityComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: AdverseEvent#SuspectEntity, Export: SuspectEntityComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); writer.WritePropertyName("instance"); current.Instance.SerializeJson(writer, options); if ((current.Causality != null) && (current.Causality.Count != 0)) { writer.WritePropertyName("causality"); writer.WriteStartArray(); foreach (AdverseEvent.CausalityComponent val in current.Causality) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR AdverseEvent#SuspectEntity /// </summary> public static void DeserializeJsonProperty(this AdverseEvent.SuspectEntityComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "instance": current.Instance = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Instance).DeserializeJson(ref reader, options); break; case "causality": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"SuspectEntityComponent error reading 'causality' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Causality = new List <AdverseEvent.CausalityComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.AdverseEvent.CausalityComponent v_Causality = new Hl7.Fhir.Model.AdverseEvent.CausalityComponent(); v_Causality.DeserializeJson(ref reader, options); current.Causality.Add(v_Causality); if (!reader.Read()) { throw new JsonException($"SuspectEntityComponent error reading 'causality' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Causality.Count == 0) { current.Causality = null; } break; // Complex: suspectEntity, Export: SuspectEntityComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }