public void WhenAddressTransformedToHealthVault_ThenValueEqual()
        {
            string[] lines       = { "1", "Microsoft Way" };
            var      fhirAddress = new Hl7.Fhir.Model.Address
            {
                Type       = Hl7.Fhir.Model.Address.AddressType.Postal,
                Text       = "John's Postal Address",
                Line       = lines.ToList(),
                City       = "Redmond",
                District   = "King County",
                State      = "WA",
                Country    = "US",
                PostalCode = "98052"
            };

            var hvAddress = fhirAddress.ToHealthVault();

            Assert.IsNotNull(hvAddress);
            Assert.AreEqual(hvAddress.Description, fhirAddress.Text);
            Assert.AreEqual(fhirAddress.Line.Count(), hvAddress.Street.Count());
            Assert.AreEqual(fhirAddress.City, hvAddress.City);
            Assert.AreEqual(fhirAddress.PostalCode, hvAddress.PostalCode);
            Assert.AreEqual(fhirAddress.State, hvAddress.State);
            Assert.AreEqual(fhirAddress.Country, hvAddress.Country);
            Assert.AreEqual(fhirAddress.District, hvAddress.County);
        }
Exemple #2
0
        public static ItemTypes.Address ToHealthVault(this Hl7.Fhir.Model.Address address)
        {
            if ((string.IsNullOrEmpty(address.City)) || (string.IsNullOrWhiteSpace(address.Line.ToString())) || (string.IsNullOrWhiteSpace(address.PostalCode)) ||
                (string.IsNullOrWhiteSpace(address.Country)))
            {
                return(null);
            }

            var hvAddress = new ItemTypes.Address();

            foreach (var line in address.Line)
            {
                hvAddress.Street.Add(line);
            }

            hvAddress.City       = address.City;
            hvAddress.State      = address.State;
            hvAddress.County     = address.District;
            hvAddress.PostalCode = address.PostalCode;
            if (!string.IsNullOrEmpty(address.Country))
            {
                hvAddress.Country = address.Country;
            }

            hvAddress.Description = address.Text;
            hvAddress.IsPrimary   = address.GetBoolExtension(HealthVaultExtensions.IsPrimary);
            return(hvAddress);
        }
Exemple #3
0
        /// <summary>
        /// Returns list of all Address elements
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        private List <Expression> ToExpressions(FhirModel.Address element)
        {
            if (element == null)
            {
                return(null);
            }

            var values = new List <Expression>();

            values.Add(element.City != null ? new StringValue(element.City) : null);
            values.Add(element.Country != null ? new StringValue(element.Country) : null);
            values.AddRange(element.Line != null ? element.Line.Select(line => new StringValue(line)) : null);
            values.Add(element.State != null ? new StringValue(element.State) : null);
            values.Add(element.Text != null ? new StringValue(element.Text) : null);
            values.Add(element.Use.HasValue ? new StringValue(_fhirModel.GetLiteralForEnum(element.Use.Value)) : null);
            values.Add(element.PostalCode != null ? new StringValue(element.PostalCode) : null);

            return(values.Where(v => v != null).ToList());
        }
Exemple #4
0
        /// <summary>
        /// Generates a HL7 Patient class
        /// </summary>
        /// <param name="patientNumber"></param>
        /// <param name="practitioner"></param>
        /// <param name="state"></param>
        /// <param name="district"></param>
        /// <param name="postalCode"></param>
        /// <returns></returns>
        public HL7.Patient GeneratePatient(int patientNumber, int practitioner, string state, string district, string postalCode)
        {
            HL7.Patient genPat = new HL7.Patient();

            //give an id
            genPat.Id = patientNumber.ToString();

            ////give a name
            HL7.HumanName hName = new HL7.HumanName();
            hName.FamilyElement.Add(new HL7.FhirString("TESTLAST"));
            hName.GivenElement.Add(new HL7.FhirString("TESTFIRST"));
            genPat.Name.Add(hName);

            //add a care provider so we can filter for doctor facing app
            HL7.ResourceReference practRef = new HL7.ResourceReference();
            practRef.ReferenceElement = new HL7.FhirString("Practitioner/" + practitioner);
            genPat.CareProvider.Add(practRef);

            //give an address
            HL7.Address address = new HL7.Address();
            address.Use = HL7.Address.AddressUse.Home;
            address.LineElement.Add(new HL7.FhirString("123 Fake Street"));
            address.City       = "FAKETOWN";
            address.District   = district;
            address.State      = state;
            address.PostalCode = postalCode;
            genPat.Address.Add(address);

            //give a gender
            genPat.Gender = (rand.NextDouble() < .5) ? HL7.AdministrativeGender.Female : HL7.AdministrativeGender.Male;

            //give a DOB
            //randomly generate based on age range 0 - 17
            int      years = Convert.ToInt32(Math.Round(16 * rand.NextDouble())) + 1;
            int      days  = Convert.ToInt32(Math.Round(364 * rand.NextDouble()));
            DateTime dob   = new DateTime(2016 - years, 01, 01).AddDays(days);

            HL7.Date hl7DOB = new HL7.Date(dob.ToShortDateString());
            genPat.BirthDateElement = hl7DOB;

            return(genPat);
        }
        internal static Hl7.Fhir.Model.Address ToFhirInternal(ItemTypes.Address hvAddress)
        {
            var address = new Hl7.Fhir.Model.Address
            {
                Text       = hvAddress.Description,
                Line       = hvAddress.Street,
                City       = hvAddress.City,
                PostalCode = hvAddress.PostalCode,
                District   = hvAddress.County,
                State      = hvAddress.State,
                Country    = hvAddress.Country,
            };

            if (hvAddress.IsPrimary.HasValue && hvAddress.IsPrimary.Value)
            {
                address.AddExtension(HealthVaultExtensions.IsPrimary, new FhirBoolean(true));
            }

            return(address);
        }
        /// <summary>
        /// Parse Address
        /// </summary>
        public static Hl7.Fhir.Model.Address ParseAddress(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Address existingInstance = null)
        {
            Hl7.Fhir.Model.Address result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Address();
            string currentElementName     = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "extension"))
                    {
                        result.Extension.Add(ExtensionParser.ParseExtension(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element use
                else if (atName == "use")
                {
                    result.UseElement = CodeParser.ParseCode <Hl7.Fhir.Model.Address.AddressUse>(reader, errors);
                }

                // Parse element text
                else if (atName == "text")
                {
                    result.TextElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element line
                else if (atName == "line")
                {
                    result.LineElement = new List <Hl7.Fhir.Model.FhirString>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "line"))
                    {
                        result.LineElement.Add(FhirStringParser.ParseFhirString(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element city
                else if (atName == "city")
                {
                    result.CityElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element state
                else if (atName == "state")
                {
                    result.StateElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element zip
                else if (atName == "zip")
                {
                    result.ZipElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element country
                else if (atName == "country")
                {
                    result.CountryElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element period
                else if (atName == "period")
                {
                    result.Period = PeriodParser.ParsePeriod(reader, errors);
                }

                else
                {
                    errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                    reader.SkipSubElementsFor(currentElementName);
                    result = null;
                }
            }

            reader.LeaveElement();
            return(result);
        }
 public void Write(Definition definition, Address address)
 {
     Write(definition, address.City);
     Write(definition, address.Country);
     Write(definition, address.Line); // ienumerable
     Write(definition, address.State);
     Write(definition, address.Text);
     Write(definition, address.Use.ToString());
     Write(definition, address.PostalCode);
 }
Exemple #8
0
        public static void SerializeAddress(Hl7.Fhir.Model.Address value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartComplexContent();

            // Serialize element _id
            if (value.LocalIdElement != null)
            {
                writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute);
            }

            // Serialize element extension
            if (value.Extension != null && !summary && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element use
            if (value.UseElement != null)
            {
                writer.WriteStartElement("use");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.Address.AddressUse>(value.UseElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element text
            if (value.TextElement != null)
            {
                writer.WriteStartElement("text");
                FhirStringSerializer.SerializeFhirString(value.TextElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element line
            if (value.LineElement != null && value.LineElement.Count > 0)
            {
                writer.WriteStartArrayElement("line");
                foreach (var item in value.LineElement)
                {
                    writer.WriteStartArrayMember("line");
                    FhirStringSerializer.SerializeFhirString(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element city
            if (value.CityElement != null)
            {
                writer.WriteStartElement("city");
                FhirStringSerializer.SerializeFhirString(value.CityElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element state
            if (value.StateElement != null)
            {
                writer.WriteStartElement("state");
                FhirStringSerializer.SerializeFhirString(value.StateElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element zip
            if (value.ZipElement != null)
            {
                writer.WriteStartElement("zip");
                FhirStringSerializer.SerializeFhirString(value.ZipElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element country
            if (value.CountryElement != null)
            {
                writer.WriteStartElement("country");
                FhirStringSerializer.SerializeFhirString(value.CountryElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element period
            if (value.Period != null)
            {
                writer.WriteStartElement("period");
                PeriodSerializer.SerializePeriod(value.Period, writer, summary);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
        }
Exemple #9
0
 public void Collect(Definition definition, Address address)
 {
     Write(definition, address.City);
     Write(definition, address.Country);
     Write(definition, address.Line); // ienumerable
     Write(definition, address.State);
     Write(definition, address.Text);
     Write(definition, address.Use.ToString());
     Write(definition, address.Zip);
 }
Exemple #10
0
        public void AddressMapTest()
        {
            var input = new Address();
            input.City = "Amsterdam";
            input.Country = "Netherlands";
            input.Line = new List<string> { "Bruggebouw", "Bos en lommerplein 280" };
            input.PostalCode = "1055 RW";

            var result = sut.Map(input);

            Assert.AreEqual(5, result.Count()); //2 line elements + city, country and postalcode.
            foreach (var res in result)
            {
                Assert.IsInstanceOfType(res, typeof(StringValue));
            }
            Assert.AreEqual(1, result.Where(r => (r as StringValue).Value == "Bruggebouw").Count());
            Assert.AreEqual(1, result.Where(r => (r as StringValue).Value == "Bos en lommerplein 280").Count());
            Assert.AreEqual(1, result.Where(r => (r as StringValue).Value == "Netherlands").Count());
            Assert.AreEqual(1, result.Where(r => (r as StringValue).Value == "Amsterdam").Count());
            Assert.AreEqual(1, result.Where(r => (r as StringValue).Value == "1055 RW").Count());
        }
        /// <summary>
        /// Deserialize JSON into a FHIR Organization
        /// </summary>
        public static void DeserializeJsonProperty(this Organization current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Organization 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($"Organization 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 "active":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ActiveElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.ActiveElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

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

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

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

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

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

                if (current.Type.Count == 0)
                {
                    current.Type = null;
                }
                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 "alias":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Organization error reading 'alias' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                }

                current.AliasElement = new List <FhirString>();

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

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

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

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

                int i_alias = 0;

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

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

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

                current.Telecom = new List <ContactPoint>();

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

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

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

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

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

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

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

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

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

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

                current.Contact = new List <Organization.ContactComponent>();

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

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

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

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

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

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

            // Complex: Organization, Export: Organization, Base: DomainResource
            default:
                ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Exemple #12
0
        /// <summary>
        /// Deserialize JSON into a FHIR Practitioner
        /// </summary>
        public static void DeserializeJsonProperty(this Practitioner current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"Practitioner 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($"Practitioner 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 "active":
                if (reader.TokenType == JsonTokenType.Null)
                {
                    current.ActiveElement = new FhirBoolean();
                    reader.Skip();
                }
                else
                {
                    current.ActiveElement = new FhirBoolean(reader.GetBoolean());
                }
                break;

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

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

                current.Name = new List <HumanName>();

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

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

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

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

                current.Telecom = new List <ContactPoint>();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                current.Qualification = new List <Practitioner.QualificationComponent>();

                while (reader.TokenType != JsonTokenType.EndArray)
                {
                    Hl7.Fhir.Model.Practitioner.QualificationComponent v_Qualification = new Hl7.Fhir.Model.Practitioner.QualificationComponent();
                    v_Qualification.DeserializeJson(ref reader, options);
                    current.Qualification.Add(v_Qualification);

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

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

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

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

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

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

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

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