Exemplo n.º 1
0
        /// <summary>
        /// Deserialize JSON into a FHIR NamingSystem
        /// </summary>
        public static void DeserializeJsonProperty(this NamingSystem current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "name":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.NameElement = new FhirString();
                    reader.Skip();
                }
                else
                {
                    current.NameElement = new FhirString(reader.GetString());
                }
                break;

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

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

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.PublicationStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options);
                break;

            case "kind":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.KindElement = new Code <Hl7.Fhir.Model.NamingSystem.NamingSystemType>();
                    reader.Skip();
                }
                else
                {
                    current.KindElement = new Code <Hl7.Fhir.Model.NamingSystem.NamingSystemType>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.NamingSystem.NamingSystemType>(reader.GetString()));
                }
                break;

            case "_kind":
                if (current.KindElement == null)
                {
                    current.KindElement = new Code <Hl7.Fhir.Model.NamingSystem.NamingSystemType>();
                }
                ((Hl7.Fhir.Model.Element)current.KindElement).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

                current.Contact = new List <ContactDetail>();

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

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

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

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

            case "_responsible":
                if (current.ResponsibleElement == null)
                {
                    current.ResponsibleElement = new FhirString();
                }
                ((Hl7.Fhir.Model.Element)current.ResponsibleElement).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 "description":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Description = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.Description = new Markdown(reader.GetString());
                }
                break;

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

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

                current.UseContext = new List <UsageContext>();

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

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

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

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

                current.Jurisdiction = new List <CodeableConcept>();

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

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

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

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

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

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

                current.UniqueId = new List <NamingSystem.UniqueIdComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.NamingSystem.UniqueIdComponent v_UniqueId = new Hl7.Fhir.Model.NamingSystem.UniqueIdComponent();
                    v_UniqueId.DeserializeJson(ref reader, options);
                    current.UniqueId.Add(v_UniqueId);

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

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

            // Complex: NamingSystem, Export: NamingSystem, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Deserialize JSON into a FHIR Library
        /// </summary>
        public static void DeserializeJsonProperty(this Library current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "url":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.UrlElement = new FhirUri();
                    reader.Skip();
                }
                else
                {
                    current.UrlElement = new FhirUri(reader.GetString());
                }
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.PublicationStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options);
                break;

            case "experimental":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ExperimentalElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.ExperimentalElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

            case "_experimental":
                if (current.ExperimentalElement == null)
                {
                    current.ExperimentalElement = new FhirBoolean();
                }
                ((Hl7.Fhir.Model.Element)current.ExperimentalElement).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 "subjectCodeableConcept":
                current.Subject = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Subject).DeserializeJson(ref reader, options);
                break;

            case "subjectReference":
                current.Subject = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Subject).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

                current.Contact = new List <ContactDetail>();

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

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

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

            case "description":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Description = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.Description = new Markdown(reader.GetString());
                }
                break;

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

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

                current.UseContext = new List <UsageContext>();

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

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

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

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

                current.Jurisdiction = new List <CodeableConcept>();

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

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

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

            case "purpose":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Purpose = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.Purpose = new Markdown(reader.GetString());
                }
                break;

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

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

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

            case "copyright":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Copyright = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.Copyright = new Markdown(reader.GetString());
                }
                break;

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

            case "approvalDate":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ApprovalDateElement = new Date();
                    reader.Skip();
                }
                else
                {
                    current.ApprovalDateElement = new Date(reader.GetString());
                }
                break;

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

            case "lastReviewDate":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.LastReviewDateElement = new Date();
                    reader.Skip();
                }
                else
                {
                    current.LastReviewDateElement = new Date(reader.GetString());
                }
                break;

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

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

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

                current.Topic = new List <CodeableConcept>();

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

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

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

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

                current.Author = new List <ContactDetail>();

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

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

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

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

                current.Editor = new List <ContactDetail>();

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

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

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

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

                current.Reviewer = new List <ContactDetail>();

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

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

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

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

                current.Endorser = new List <ContactDetail>();

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

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

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

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

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

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

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

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

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

                current.Parameter = new List <ParameterDefinition>();

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

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

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

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

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

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

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

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

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

                current.Content = new List <Attachment>();

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

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

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

            // Complex: Library, Export: Library, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deserialize JSON into a FHIR CompartmentDefinition
        /// </summary>
        public static void DeserializeJsonProperty(this CompartmentDefinition current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "url":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.UrlElement = new FhirUri();
                    reader.Skip();
                }
                else
                {
                    current.UrlElement = new FhirUri(reader.GetString());
                }
                break;

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

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

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

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

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

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

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.PublicationStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options);
                break;

            case "experimental":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ExperimentalElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.ExperimentalElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

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

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

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

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

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

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

                current.Contact = new List <ContactDetail>();

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

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

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

            case "description":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Description = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.Description = new Markdown(reader.GetString());
                }
                break;

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

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

                current.UseContext = new List <UsageContext>();

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

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

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

            case "purpose":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Purpose = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.Purpose = new Markdown(reader.GetString());
                }
                break;

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

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

            case "_code":
                if (current.CodeElement == null)
                {
                    current.CodeElement = new Code <Hl7.Fhir.Model.CompartmentType>();
                }
                ((Hl7.Fhir.Model.Element)current.CodeElement).DeserializeJson(ref reader, options);
                break;

            case "search":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.SearchElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.SearchElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

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

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

                current.Resource = new List <CompartmentDefinition.ResourceComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.CompartmentDefinition.ResourceComponent v_Resource = new Hl7.Fhir.Model.CompartmentDefinition.ResourceComponent();
                    v_Resource.DeserializeJson(ref reader, options);
                    current.Resource.Add(v_Resource);

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

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

            // Complex: CompartmentDefinition, Export: CompartmentDefinition, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Deserialize JSON into a FHIR Contributor
        /// </summary>
        public static void DeserializeJsonProperty(this Contributor current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "type":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.TypeElement = new Code <Hl7.Fhir.Model.Contributor.ContributorType>();
                    reader.Skip();
                }
                else
                {
                    current.TypeElement = new Code <Hl7.Fhir.Model.Contributor.ContributorType>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.Contributor.ContributorType>(reader.GetString()));
                }
                break;

            case "_type":
                if (current.TypeElement == null)
                {
                    current.TypeElement = new Code <Hl7.Fhir.Model.Contributor.ContributorType>();
                }
                ((Hl7.Fhir.Model.Element)current.TypeElement).DeserializeJson(ref reader, options);
                break;

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

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

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

                current.Contact = new List <ContactDetail>();

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

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

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

            // Complex: Contributor, Export: Contributor, Base: Element
            default:
                ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Deserialize JSON into a FHIR ResearchStudy
        /// </summary>
        public static void DeserializeJsonProperty(this ResearchStudy current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"ResearchStudy error reading 'identifier' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

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

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

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

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

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

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

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

                current.Protocol = new List <ResourceReference>();

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

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

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

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

                current.PartOf = new List <ResourceReference>();

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

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

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

            case "status":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.ResearchStudy.ResearchStudyStatus>();
                    reader.Skip();
                }
                else
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.ResearchStudy.ResearchStudyStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.ResearchStudy.ResearchStudyStatus>(reader.GetString()));
                }
                break;

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.ResearchStudy.ResearchStudyStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options);
                break;

            case "primaryPurposeType":
                current.PrimaryPurposeType = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.PrimaryPurposeType).DeserializeJson(ref reader, options);
                break;

            case "phase":
                current.Phase = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Phase).DeserializeJson(ref reader, options);
                break;

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

                current.Category = new List <CodeableConcept>();

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

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

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

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

                current.Focus = new List <CodeableConcept>();

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

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

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

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

                current.Condition = new List <CodeableConcept>();

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

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

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

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

                current.Contact = new List <ContactDetail>();

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

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

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

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

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

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

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

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

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

                current.Keyword = new List <CodeableConcept>();

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

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

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

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

                current.Location = new List <CodeableConcept>();

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

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

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

            case "description":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.Description = new Markdown();
                    reader.Skip();
                }
                else
                {
                    current.Description = new Markdown(reader.GetString());
                }
                break;

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

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

                current.Enrollment = new List <ResourceReference>();

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

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

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

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

            case "sponsor":
                current.Sponsor = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Sponsor).DeserializeJson(ref reader, options);
                break;

            case "principalInvestigator":
                current.PrincipalInvestigator = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.PrincipalInvestigator).DeserializeJson(ref reader, options);
                break;

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

                current.Site = new List <ResourceReference>();

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

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

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

            case "reasonStopped":
                current.ReasonStopped = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.ReasonStopped).DeserializeJson(ref reader, options);
                break;

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

                current.Note = new List <Annotation>();

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

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

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

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

                current.Arm = new List <ResearchStudy.ArmComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ResearchStudy.ArmComponent v_Arm = new Hl7.Fhir.Model.ResearchStudy.ArmComponent();
                    v_Arm.DeserializeJson(ref reader, options);
                    current.Arm.Add(v_Arm);

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

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

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

                current.Objective = new List <ResearchStudy.ObjectiveComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.ResearchStudy.ObjectiveComponent v_Objective = new Hl7.Fhir.Model.ResearchStudy.ObjectiveComponent();
                    v_Objective.DeserializeJson(ref reader, options);
                    current.Objective.Add(v_Objective);

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

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

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