/// <summary> /// Deserialize JSON into a FHIR DocumentReference#RelatesTo /// </summary> public static void DeserializeJson(this DocumentReference.RelatesToComponent 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($"DocumentReference.RelatesToComponent >>> DocumentReference#RelatesTo.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"DocumentReference.RelatesToComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR DocumentReference#RelatesTo /// </summary> public static void DeserializeJsonProperty(this DocumentReference.RelatesToComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "code": if (reader.TokenType == JsonTokenType.Null) { current.CodeElement = new Code <Hl7.Fhir.Model.DocumentRelationshipType>(); reader.Skip(); } else { current.CodeElement = new Code <Hl7.Fhir.Model.DocumentRelationshipType>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.DocumentRelationshipType>(reader.GetString())); } break; case "_code": if (current.CodeElement == null) { current.CodeElement = new Code <Hl7.Fhir.Model.DocumentRelationshipType>(); } ((Hl7.Fhir.Model.Element)current.CodeElement).DeserializeJson(ref reader, options); break; case "target": current.Target = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Target).DeserializeJson(ref reader, options); break; // Complex: relatesTo, Export: RelatesToComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR DocumentReference#RelatesTo into JSON /// </summary> public static void SerializeJson(this DocumentReference.RelatesToComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: DocumentReference#RelatesTo, Export: RelatesToComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); writer.WriteString("code", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.CodeElement.Value)); writer.WritePropertyName("target"); current.Target.SerializeJson(writer, options); if (includeStartObject) { writer.WriteEndObject(); } }