/// <summary> /// Deserialize JSON into a FHIR MedicinalProductAuthorization#Procedure /// </summary> public static void DeserializeJson(this MedicinalProductAuthorization.ProcedureComponent 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($"MedicinalProductAuthorization.ProcedureComponent >>> MedicinalProductAuthorization#Procedure.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"MedicinalProductAuthorization.ProcedureComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR MedicinalProductAuthorization#Procedure into JSON /// </summary> public static void SerializeJson(this MedicinalProductAuthorization.ProcedureComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: MedicinalProductAuthorization#Procedure, Export: ProcedureComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); if (current.Identifier != null) { writer.WritePropertyName("identifier"); current.Identifier.SerializeJson(writer, options); } writer.WritePropertyName("type"); current.Type.SerializeJson(writer, options); if (current.Date != null) { switch (current.Date) { case Period v_Period: writer.WritePropertyName("datePeriod"); v_Period.SerializeJson(writer, options); break; case FhirDateTime v_FhirDateTime: if (v_FhirDateTime != null) { if (!string.IsNullOrEmpty(v_FhirDateTime.Value)) { writer.WriteString("dateDateTime", v_FhirDateTime.Value); } if (v_FhirDateTime.HasExtensions() || (!string.IsNullOrEmpty(v_FhirDateTime.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_dateDateTime", false, v_FhirDateTime.Extension, v_FhirDateTime.ElementId); } } break; } } if ((current.Application != null) && (current.Application.Count != 0)) { writer.WritePropertyName("application"); writer.WriteStartArray(); foreach (MedicinalProductAuthorization.ProcedureComponent val in current.Application) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR MedicinalProductAuthorization#Procedure /// </summary> public static void DeserializeJsonProperty(this MedicinalProductAuthorization.ProcedureComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "identifier": current.Identifier = new Hl7.Fhir.Model.Identifier(); ((Hl7.Fhir.Model.Identifier)current.Identifier).DeserializeJson(ref reader, options); break; case "type": current.Type = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Type).DeserializeJson(ref reader, options); break; case "datePeriod": current.Date = new Hl7.Fhir.Model.Period(); ((Hl7.Fhir.Model.Period)current.Date).DeserializeJson(ref reader, options); break; case "dateDateTime": if (reader.TokenType == JsonTokenType.Null) { current.Date = new FhirDateTime(); reader.Skip(); } else { current.Date = new FhirDateTime(reader.GetString()); } break; case "_dateDateTime": if (current.Date == null) { current.Date = new FhirDateTime(); } ((Hl7.Fhir.Model.Element)current.Date).DeserializeJson(ref reader, options); break; case "application": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"ProcedureComponent error reading 'application' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Application = new List <MedicinalProductAuthorization.ProcedureComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.MedicinalProductAuthorization.ProcedureComponent v_Application = new Hl7.Fhir.Model.MedicinalProductAuthorization.ProcedureComponent(); v_Application.DeserializeJson(ref reader, options); current.Application.Add(v_Application); if (!reader.Read()) { throw new JsonException($"ProcedureComponent error reading 'application' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Application.Count == 0) { current.Application = null; } break; // Complex: procedure, Export: ProcedureComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }