Exemplo n.º 1
0
        /// <summary>
        /// Deserialize JSON into a FHIR DataRequirement#DateFilter
        /// </summary>
        public static void DeserializeJson(this DataRequirement.DateFilterComponent 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($"DataRequirement.DateFilterComponent >>> DataRequirement#DateFilter.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"DataRequirement.DateFilterComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deserialize JSON into a FHIR DataRequirement#DateFilter
        /// </summary>
        public static void DeserializeJsonProperty(this DataRequirement.DateFilterComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "path":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.PathElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.PathElement = new FhirString(reader.GetString());
                }
                break;

            case "_path":
                if (current.PathElement == null)
                {
                    current.PathElement = new FhirString();
                }
                ((Hl7.Fhir.Model.Element)current.PathElement).DeserializeJson(ref reader, options);
                break;

            case "searchParam":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.SearchParamElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.SearchParamElement = new FhirString(reader.GetString());
                }
                break;

            case "_searchParam":
                if (current.SearchParamElement == null)
                {
                    current.SearchParamElement = new FhirString();
                }
                ((Hl7.Fhir.Model.Element)current.SearchParamElement).DeserializeJson(ref reader, options);
                break;

            case "valueDateTime":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Value = new FhirDateTime();
                    reader.Skip();
                }
                else
                {
                    current.Value = new FhirDateTime(reader.GetString());
                }
                break;

            case "_valueDateTime":
                if (current.Value == null)
                {
                    current.Value = new FhirDateTime();
                }
                ((Hl7.Fhir.Model.Element)current.Value).DeserializeJson(ref reader, options);
                break;

            case "valuePeriod":
                current.Value = new Hl7.Fhir.Model.Period();
                ((Hl7.Fhir.Model.Period)current.Value).DeserializeJson(ref reader, options);
                break;

            case "valueDuration":
                current.Value = new Hl7.Fhir.Model.Duration();
                ((Hl7.Fhir.Model.Duration)current.Value).DeserializeJson(ref reader, options);
                break;

            // Complex: dateFilter, Export: DateFilterComponent, Base: Element
            default:
                ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Serialize a FHIR DataRequirement#DateFilter into JSON
        /// </summary>
        public static void SerializeJson(this DataRequirement.DateFilterComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: DataRequirement#DateFilter, Export: DateFilterComponent, Base: Element (Element)
            ((Hl7.Fhir.Model.Element)current).SerializeJson(writer, options, false);

            if (current.PathElement != null)
            {
                if (!string.IsNullOrEmpty(current.PathElement.Value))
                {
                    writer.WriteString("path", current.PathElement.Value);
                }
                if (current.PathElement.HasExtensions() || (!string.IsNullOrEmpty(current.PathElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_path", false, current.PathElement.Extension, current.PathElement.ElementId);
                }
            }

            if (current.SearchParamElement != null)
            {
                if (!string.IsNullOrEmpty(current.SearchParamElement.Value))
                {
                    writer.WriteString("searchParam", current.SearchParamElement.Value);
                }
                if (current.SearchParamElement.HasExtensions() || (!string.IsNullOrEmpty(current.SearchParamElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_searchParam", false, current.SearchParamElement.Extension, current.SearchParamElement.ElementId);
                }
            }

            if (current.Value != null)
            {
                switch (current.Value)
                {
                case FhirDateTime v_FhirDateTime:
                    if (v_FhirDateTime != null)
                    {
                        if (!string.IsNullOrEmpty(v_FhirDateTime.Value))
                        {
                            writer.WriteString("valueDateTime", v_FhirDateTime.Value);
                        }
                        if (v_FhirDateTime.HasExtensions() || (!string.IsNullOrEmpty(v_FhirDateTime.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_valueDateTime", false, v_FhirDateTime.Extension, v_FhirDateTime.ElementId);
                        }
                    }
                    break;

                case Period v_Period:
                    writer.WritePropertyName("valuePeriod");
                    v_Period.SerializeJson(writer, options);
                    break;

                case Duration v_Duration:
                    writer.WritePropertyName("valueDuration");
                    v_Duration.SerializeJson(writer, options);
                    break;
                }
            }
            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }