Example #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR FamilyMemberHistory
        /// </summary>
        public static void DeserializeJson(this FamilyMemberHistory current, ref Utf8JsonReader reader, JsonSerializerOptions options)
        {
            string propertyName;

            while (reader.Read())
            {
                if (reader.TokenType == JsonTokenType.EndObject)
                {
                    return;
                }

                if (reader.TokenType == JsonTokenType.PropertyName)
                {
                    propertyName = reader.GetString();
                    if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug)
                    {
                        Console.WriteLine($"FamilyMemberHistory >>> FamilyMemberHistory.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"FamilyMemberHistory: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Example #2
0
        /// <summary>
        /// Serialize a FHIR FamilyMemberHistory into JSON
        /// </summary>
        public static void SerializeJson(this FamilyMemberHistory current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            writer.WriteString("resourceType", "FamilyMemberHistory");
            // Complex: FamilyMemberHistory, Export: FamilyMemberHistory, Base: DomainResource (DomainResource)
            ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false);

            if ((current.Identifier != null) && (current.Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();
                foreach (Identifier val in current.Identifier)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.InstantiatesCanonicalElement != null) && (current.InstantiatesCanonicalElement.Count != 0))
            {
                int valueCount     = 0;
                int extensionCount = 0;
                foreach (Canonical val in current.InstantiatesCanonicalElement)
                {
                    if (!string.IsNullOrEmpty(val.Value))
                    {
                        valueCount++;
                    }
                    if (val.HasExtensions())
                    {
                        extensionCount++;
                    }
                }

                if (valueCount > 0)
                {
                    writer.WritePropertyName("instantiatesCanonical");
                    writer.WriteStartArray();
                    foreach (Canonical val in current.InstantiatesCanonicalElement)
                    {
                        if (string.IsNullOrEmpty(val.Value))
                        {
                            writer.WriteNullValue();
                        }
                        else
                        {
                            writer.WriteStringValue(val.Value);
                        }
                    }

                    writer.WriteEndArray();
                }

                if (extensionCount > 0)
                {
                    writer.WritePropertyName("_instantiatesCanonical");
                    writer.WriteStartArray();
                    foreach (Canonical val in current.InstantiatesCanonicalElement)
                    {
                        if (val.HasExtensions() || (!string.IsNullOrEmpty(val.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, string.Empty, true, val.Extension, val.ElementId);
                        }
                        else
                        {
                            writer.WriteNullValue();
                        }
                    }

                    writer.WriteEndArray();
                }
            }

            if ((current.InstantiatesUriElement != null) && (current.InstantiatesUriElement.Count != 0))
            {
                int valueCount     = 0;
                int extensionCount = 0;
                foreach (FhirUri val in current.InstantiatesUriElement)
                {
                    if (!string.IsNullOrEmpty(val.Value))
                    {
                        valueCount++;
                    }
                    if (val.HasExtensions())
                    {
                        extensionCount++;
                    }
                }

                if (valueCount > 0)
                {
                    writer.WritePropertyName("instantiatesUri");
                    writer.WriteStartArray();
                    foreach (FhirUri val in current.InstantiatesUriElement)
                    {
                        if (string.IsNullOrEmpty(val.Value))
                        {
                            writer.WriteNullValue();
                        }
                        else
                        {
                            writer.WriteStringValue(val.Value);
                        }
                    }

                    writer.WriteEndArray();
                }

                if (extensionCount > 0)
                {
                    writer.WritePropertyName("_instantiatesUri");
                    writer.WriteStartArray();
                    foreach (FhirUri val in current.InstantiatesUriElement)
                    {
                        if (val.HasExtensions() || (!string.IsNullOrEmpty(val.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, string.Empty, true, val.Extension, val.ElementId);
                        }
                        else
                        {
                            writer.WriteNullValue();
                        }
                    }

                    writer.WriteEndArray();
                }
            }

            writer.WriteString("status", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StatusElement.Value));

            if (current.DataAbsentReason != null)
            {
                writer.WritePropertyName("dataAbsentReason");
                current.DataAbsentReason.SerializeJson(writer, options);
            }

            writer.WritePropertyName("patient");
            current.Patient.SerializeJson(writer, options);

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

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

            writer.WritePropertyName("relationship");
            current.Relationship.SerializeJson(writer, options);

            if (current.Sex != null)
            {
                writer.WritePropertyName("sex");
                current.Sex.SerializeJson(writer, options);
            }

            if (current.Born != null)
            {
                switch (current.Born)
                {
                case Period v_Period:
                    writer.WritePropertyName("bornPeriod");
                    v_Period.SerializeJson(writer, options);
                    break;

                case Date v_Date:
                    if (v_Date != null)
                    {
                        if (!string.IsNullOrEmpty(v_Date.Value))
                        {
                            writer.WriteString("bornDate", v_Date.Value);
                        }
                        if (v_Date.HasExtensions() || (!string.IsNullOrEmpty(v_Date.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_bornDate", false, v_Date.Extension, v_Date.ElementId);
                        }
                    }
                    break;

                case FhirString v_FhirString:
                    if (v_FhirString != null)
                    {
                        if (!string.IsNullOrEmpty(v_FhirString.Value))
                        {
                            writer.WriteString("bornString", v_FhirString.Value);
                        }
                        if (v_FhirString.HasExtensions() || (!string.IsNullOrEmpty(v_FhirString.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_bornString", false, v_FhirString.Extension, v_FhirString.ElementId);
                        }
                    }
                    break;
                }
            }
            if (current.Age != null)
            {
                switch (current.Age)
                {
                case Age v_Age:
                    writer.WritePropertyName("ageAge");
                    v_Age.SerializeJson(writer, options);
                    break;

                case Range v_Range:
                    writer.WritePropertyName("ageRange");
                    v_Range.SerializeJson(writer, options);
                    break;

                case FhirString v_FhirString:
                    if (v_FhirString != null)
                    {
                        if (!string.IsNullOrEmpty(v_FhirString.Value))
                        {
                            writer.WriteString("ageString", v_FhirString.Value);
                        }
                        if (v_FhirString.HasExtensions() || (!string.IsNullOrEmpty(v_FhirString.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_ageString", false, v_FhirString.Extension, v_FhirString.ElementId);
                        }
                    }
                    break;
                }
            }
            if (current.EstimatedAgeElement != null)
            {
                if (current.EstimatedAgeElement.Value != null)
                {
                    writer.WriteBoolean("estimatedAge", (bool)current.EstimatedAgeElement.Value);
                }
                if (current.EstimatedAgeElement.HasExtensions() || (!string.IsNullOrEmpty(current.EstimatedAgeElement.ElementId)))
                {
                    JsonStreamUtilities.SerializeExtensionList(writer, options, "_estimatedAge", false, current.EstimatedAgeElement.Extension, current.EstimatedAgeElement.ElementId);
                }
            }

            if (current.Deceased != null)
            {
                switch (current.Deceased)
                {
                case FhirBoolean v_FhirBoolean:
                    if (v_FhirBoolean != null)
                    {
                        if (v_FhirBoolean.Value != null)
                        {
                            writer.WriteBoolean("deceasedBoolean", (bool)v_FhirBoolean.Value);
                        }
                        if (v_FhirBoolean.HasExtensions() || (!string.IsNullOrEmpty(v_FhirBoolean.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_deceasedBoolean", false, v_FhirBoolean.Extension, v_FhirBoolean.ElementId);
                        }
                    }
                    break;

                case Age v_Age:
                    writer.WritePropertyName("deceasedAge");
                    v_Age.SerializeJson(writer, options);
                    break;

                case Range v_Range:
                    writer.WritePropertyName("deceasedRange");
                    v_Range.SerializeJson(writer, options);
                    break;

                case Date v_Date:
                    if (v_Date != null)
                    {
                        if (!string.IsNullOrEmpty(v_Date.Value))
                        {
                            writer.WriteString("deceasedDate", v_Date.Value);
                        }
                        if (v_Date.HasExtensions() || (!string.IsNullOrEmpty(v_Date.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_deceasedDate", false, v_Date.Extension, v_Date.ElementId);
                        }
                    }
                    break;

                case FhirString v_FhirString:
                    if (v_FhirString != null)
                    {
                        if (!string.IsNullOrEmpty(v_FhirString.Value))
                        {
                            writer.WriteString("deceasedString", v_FhirString.Value);
                        }
                        if (v_FhirString.HasExtensions() || (!string.IsNullOrEmpty(v_FhirString.ElementId)))
                        {
                            JsonStreamUtilities.SerializeExtensionList(writer, options, "_deceasedString", false, v_FhirString.Extension, v_FhirString.ElementId);
                        }
                    }
                    break;
                }
            }
            if ((current.ReasonCode != null) && (current.ReasonCode.Count != 0))
            {
                writer.WritePropertyName("reasonCode");
                writer.WriteStartArray();
                foreach (CodeableConcept val in current.ReasonCode)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.ReasonReference != null) && (current.ReasonReference.Count != 0))
            {
                writer.WritePropertyName("reasonReference");
                writer.WriteStartArray();
                foreach (ResourceReference val in current.ReasonReference)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.Note != null) && (current.Note.Count != 0))
            {
                writer.WritePropertyName("note");
                writer.WriteStartArray();
                foreach (Annotation val in current.Note)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if ((current.Condition != null) && (current.Condition.Count != 0))
            {
                writer.WritePropertyName("condition");
                writer.WriteStartArray();
                foreach (FamilyMemberHistory.ConditionComponent val in current.Condition)
                {
                    val.SerializeJson(writer, options, true);
                }
                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
Example #3
0
        /// <summary>
        /// Deserialize JSON into a FHIR FamilyMemberHistory
        /// </summary>
        public static void DeserializeJsonProperty(this FamilyMemberHistory current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"FamilyMemberHistory 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($"FamilyMemberHistory 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 "instantiatesCanonical":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"FamilyMemberHistory error reading 'instantiatesCanonical' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.InstantiatesCanonicalElement = new List <Canonical>();

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

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

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

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

                int i_instantiatesCanonical = 0;

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

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

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

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

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

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

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

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

                int i_instantiatesUri = 0;

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

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

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

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

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

            case "patient":
                current.Patient = new Hl7.Fhir.Model.ResourceReference();
                ((Hl7.Fhir.Model.ResourceReference)current.Patient).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 "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 "relationship":
                current.Relationship = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Relationship).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

            case "ageRange":
                current.Age = new Hl7.Fhir.Model.Range();
                ((Hl7.Fhir.Model.Range)current.Age).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

            case "deceasedAge":
                current.Deceased = new Hl7.Fhir.Model.Age();
                ((Hl7.Fhir.Model.Age)current.Deceased).DeserializeJson(ref reader, options);
                break;

            case "deceasedRange":
                current.Deceased = new Hl7.Fhir.Model.Range();
                ((Hl7.Fhir.Model.Range)current.Deceased).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            case "note":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"FamilyMemberHistory 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($"FamilyMemberHistory 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 "condition":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"FamilyMemberHistory error reading 'condition' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.Condition = new List <FamilyMemberHistory.ConditionComponent>();

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

                    if (!reader.Read())
                    {
                        throw new JsonException($"FamilyMemberHistory 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;

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