Exemple #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR Composition
        /// </summary>
        public static void DeserializeJsonProperty(this Composition current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                current.Identifier = new Hl7.Fhir.Model.Identifier();
                ((Hl7.Fhir.Model.Identifier)current.Identifier).DeserializeJson(ref reader, options);
                break;

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

            case "_status":
                if (current.StatusElement == null)
                {
                    current.StatusElement = new Code <Hl7.Fhir.Model.CompositionStatus>();
                }
                ((Hl7.Fhir.Model.Element)current.StatusElement).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 "category":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Composition 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($"Composition 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 "subject":
                current.Subject = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Subject).DeserializeJson(ref reader, options);
                break;

            case "encounter":
                current.Encounter = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Encounter).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 "author":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Composition error reading 'author' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

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

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

                    if (!reader.Read())
                    {
                        throw new JsonException($"Composition 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 "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 "confidentiality":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ConfidentialityElement = new Code <Hl7.Fhir.Model.Composition.v3_ConfidentialityClassification>();
                    reader.Skip();
                }
                else
                {
                    current.ConfidentialityElement = new Code <Hl7.Fhir.Model.Composition.v3_ConfidentialityClassification>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.Composition.v3_ConfidentialityClassification>(reader.GetString()));
                }
                break;

            case "_confidentiality":
                if (current.ConfidentialityElement == null)
                {
                    current.ConfidentialityElement = new Code <Hl7.Fhir.Model.Composition.v3_ConfidentialityClassification>();
                }
                ((Hl7.Fhir.Model.Element)current.ConfidentialityElement).DeserializeJson(ref reader, options);
                break;

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

                current.Attester = new List <Composition.AttesterComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Composition.AttesterComponent v_Attester = new Hl7.Fhir.Model.Composition.AttesterComponent();
                    v_Attester.DeserializeJson(ref reader, options);
                    current.Attester.Add(v_Attester);

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

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

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

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

                current.RelatesTo = new List <Composition.RelatesToComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Composition.RelatesToComponent v_RelatesTo = new Hl7.Fhir.Model.Composition.RelatesToComponent();
                    v_RelatesTo.DeserializeJson(ref reader, options);
                    current.RelatesTo.Add(v_RelatesTo);

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

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

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

                current.Event = new List <Composition.EventComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Composition.EventComponent v_Event = new Hl7.Fhir.Model.Composition.EventComponent();
                    v_Event.DeserializeJson(ref reader, options);
                    current.Event.Add(v_Event);

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

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

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

                current.Section = new List <Composition.SectionComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Composition.SectionComponent v_Section = new Hl7.Fhir.Model.Composition.SectionComponent();
                    v_Section.DeserializeJson(ref reader, options);
                    current.Section.Add(v_Section);

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

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

            // Complex: Composition, Export: Composition, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemple #2
0
        /// <summary>
        /// Deserialize JSON into a FHIR Composition#Section
        /// </summary>
        public static void DeserializeJsonProperty(this Composition.SectionComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            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 "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options);
                break;

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

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

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

                    if (!reader.Read())
                    {
                        throw new JsonException($"SectionComponent 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 "focus":
                current.Focus = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Focus).DeserializeJson(ref reader, options);
                break;

            case "text":
                current.Text = new Hl7.Fhir.Model.Narrative();
                ((Hl7.Fhir.Model.Narrative)current.Text).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

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

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

                current.Section = new List <Composition.SectionComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Composition.SectionComponent v_Section = new Hl7.Fhir.Model.Composition.SectionComponent();
                    v_Section.DeserializeJson(ref reader, options);
                    current.Section.Add(v_Section);

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

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

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