Ejemplo n.º 1
0
        /// <summary>
        /// Deserialize JSON into a FHIR CodeableConcept
        /// </summary>
        public static void DeserializeJsonProperty(this CodeableConcept current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "coding":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"CodeableConcept error reading 'coding' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Coding = new List <Coding>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Coding v_Coding = new Hl7.Fhir.Model.Coding();
                    v_Coding.DeserializeJson(ref reader, options);
                    current.Coding.Add(v_Coding);

                    if (!reader.Read())
                    {
                        throw new JsonException($"CodeableConcept error reading 'coding' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Coding.Count == 0)
                {
                    current.Coding = null;
                }
                break;

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

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

            // Complex: CodeableConcept, Export: CodeableConcept, Base: Element
            default:
                ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deserialize JSON into a FHIR DataRequirement#CodeFilter
        /// </summary>
        public static void DeserializeJsonProperty(this DataRequirement.CodeFilterComponent 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 "valueSet":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ValueSetElement = new Canonical();
                    reader.Skip();
                }
                else
                {
                    current.ValueSetElement = new Canonical(reader.GetString());
                }
                break;

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

            case "code":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"CodeFilterComponent error reading 'code' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Code = new List <Coding>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Coding v_Code = new Hl7.Fhir.Model.Coding();
                    v_Code.DeserializeJson(ref reader, options);
                    current.Code.Add(v_Code);

                    if (!reader.Read())
                    {
                        throw new JsonException($"CodeFilterComponent error reading 'code' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Code.Count == 0)
                {
                    current.Code = null;
                }
                break;

            // Complex: codeFilter, Export: CodeFilterComponent, Base: Element
            default:
                ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deserialize JSON into a FHIR Meta
        /// </summary>
        public static void DeserializeJsonProperty(this Meta current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "versionId":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.VersionIdElement = new Id();
                    reader.Skip();
                }
                else
                {
                    current.VersionIdElement = new Id(reader.GetString());
                }
                break;

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

            case "lastUpdated":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.LastUpdatedElement = new Instant();
                    reader.Skip();
                }
                else
                {
                    current.LastUpdatedElement = new Instant(DateTimeOffset.Parse(reader.GetString()));
                }
                break;

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

            case "source":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.SourceElement = new FhirUri();
                    reader.Skip();
                }
                else
                {
                    current.SourceElement = new FhirUri(reader.GetString());
                }
                break;

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

            case "profile":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Meta error reading 'profile' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.ProfileElement = new List <FhirUri>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        current.ProfileElement.Add(new FhirUri());
                        reader.Skip();
                    }
                    else
                    {
                        current.ProfileElement.Add(new FhirUri(reader.GetString()));
                    }

                    if (!reader.Read())
                    {
                        throw new JsonException($"Meta error reading 'profile' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.ProfileElement.Count == 0)
                {
                    current.ProfileElement = null;
                }
                break;

            case "_profile":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Meta error reading 'profile' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                int i_profile = 0;

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    if (i_profile >= current.ProfileElement.Count)
                    {
                        current.ProfileElement.Add(new FhirUri());
                    }
                    if (reader.TokenType == JsonTokenType.Null)
                    {
                        reader.Skip();
                    }
                    else
                    {
                        ((Hl7.Fhir.Model.Element)current.ProfileElement[i_profile++]).DeserializeJson(ref reader, options);
                    }

                    if (!reader.Read())
                    {
                        throw new JsonException($"Meta error reading 'profile' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }
                break;

            case "security":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Meta error reading 'security' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Security = new List <Coding>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Coding v_Security = new Hl7.Fhir.Model.Coding();
                    v_Security.DeserializeJson(ref reader, options);
                    current.Security.Add(v_Security);

                    if (!reader.Read())
                    {
                        throw new JsonException($"Meta error reading 'security' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Security.Count == 0)
                {
                    current.Security = null;
                }
                break;

            case "tag":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Meta error reading 'tag' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Tag = new List <Coding>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Coding v_Tag = new Hl7.Fhir.Model.Coding();
                    v_Tag.DeserializeJson(ref reader, options);
                    current.Tag.Add(v_Tag);

                    if (!reader.Read())
                    {
                        throw new JsonException($"Meta error reading 'tag' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    if (reader.TokenType == JsonTokenType.EndObject)
                    {
                        reader.Read();
                    }
                }

                if (current.Tag.Count == 0)
                {
                    current.Tag = null;
                }
                break;

            // Complex: Meta, Export: Meta, Base: Element
            default:
                ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }