Пример #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR Person#Link
        /// </summary>
        public static void DeserializeJson(this Person.LinkComponent 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($"Person.LinkComponent >>> Person#Link.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"Person.LinkComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Пример #2
0
        /// <summary>
        /// Deserialize JSON into a FHIR Person#Link
        /// </summary>
        public static void DeserializeJsonProperty(this Person.LinkComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "target":
                current.Target = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Target).DeserializeJson(ref reader, options);
                break;

            case "assurance":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.AssuranceElement = new Code <Hl7.Fhir.Model.Person.IdentityAssuranceLevel>();
                    reader.Skip();
                }
                else
                {
                    current.AssuranceElement = new Code <Hl7.Fhir.Model.Person.IdentityAssuranceLevel>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.Person.IdentityAssuranceLevel>(reader.GetString()));
                }
                break;

            case "_assurance":
                if (current.AssuranceElement == null)
                {
                    current.AssuranceElement = new Code <Hl7.Fhir.Model.Person.IdentityAssuranceLevel>();
                }
                ((Hl7.Fhir.Model.Element)current.AssuranceElement).DeserializeJson(ref reader, options);
                break;

            // Complex: link, Export: LinkComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Пример #3
0
        /// <summary>
        /// Serialize a FHIR Person#Link into JSON
        /// </summary>
        public static void SerializeJson(this Person.LinkComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Person#Link, Export: LinkComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

            writer.WritePropertyName("target");
            current.Target.SerializeJson(writer, options);

            if (current.AssuranceElement != null)
            {
                if (current.AssuranceElement.Value != null)
                {
                    writer.WriteString("assurance", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.AssuranceElement.Value));
                }
                if (current.AssuranceElement.HasExtensions() || (!string.IsNullOrEmpty(current.AssuranceElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_assurance", false, current.AssuranceElement.Extension, current.AssuranceElement.ElementId);
                }
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }