/// <summary> /// Deserialize JSON into a FHIR Appointment#Participant /// </summary> public static void DeserializeJson(this Appointment.ParticipantComponent 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($"Appointment.ParticipantComponent >>> Appointment#Participant.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"Appointment.ParticipantComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR Appointment#Participant into JSON /// </summary> public static void SerializeJson(this Appointment.ParticipantComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: Appointment#Participant, Export: ParticipantComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); if ((current.Type != null) && (current.Type.Count != 0)) { writer.WritePropertyName("type"); writer.WriteStartArray(); foreach (CodeableConcept val in current.Type) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (current.Actor != null) { writer.WritePropertyName("actor"); current.Actor.SerializeJson(writer, options); } if (current.RequiredElement != null) { if (current.RequiredElement.Value != null) { writer.WriteString("required", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.RequiredElement.Value)); } if (current.RequiredElement.HasExtensions() || (!string.IsNullOrEmpty(current.RequiredElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_required", false, current.RequiredElement.Extension, current.RequiredElement.ElementId); } } writer.WriteString("status", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StatusElement.Value)); if (current.Period != null) { writer.WritePropertyName("period"); current.Period.SerializeJson(writer, options); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR Appointment#Participant /// </summary> public static void DeserializeJsonProperty(this Appointment.ParticipantComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "type": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"ParticipantComponent error reading 'type' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Type = new List <CodeableConcept>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.CodeableConcept v_Type = new Hl7.Fhir.Model.CodeableConcept(); v_Type.DeserializeJson(ref reader, options); current.Type.Add(v_Type); if (!reader.Read()) { throw new JsonException($"ParticipantComponent error reading 'type' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Type.Count == 0) { current.Type = null; } break; case "actor": current.Actor = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Actor).DeserializeJson(ref reader, options); break; case "required": if (reader.TokenType == JsonTokenType.Null) { current.RequiredElement = new Code <Hl7.Fhir.Model.Appointment.ParticipantRequired>(); reader.Skip(); } else { current.RequiredElement = new Code <Hl7.Fhir.Model.Appointment.ParticipantRequired>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.Appointment.ParticipantRequired>(reader.GetString())); } break; case "_required": if (current.RequiredElement == null) { current.RequiredElement = new Code <Hl7.Fhir.Model.Appointment.ParticipantRequired>(); } ((Hl7.Fhir.Model.Element)current.RequiredElement).DeserializeJson(ref reader, options); break; case "status": if (reader.TokenType == JsonTokenType.Null) { current.StatusElement = new Code <Hl7.Fhir.Model.ParticipationStatus>(); reader.Skip(); } else { current.StatusElement = new Code <Hl7.Fhir.Model.ParticipationStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.ParticipationStatus>(reader.GetString())); } break; case "_status": if (current.StatusElement == null) { current.StatusElement = new Code <Hl7.Fhir.Model.ParticipationStatus>(); } ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options); break; case "period": current.Period = new Hl7.Fhir.Model.Period(); ((Hl7.Fhir.Model.Period)current.Period).DeserializeJson(ref reader, options); break; // Complex: participant, Export: ParticipantComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }