Пример #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR Practitioner#Qualification
        /// </summary>
        public static void DeserializeJson(this Practitioner.QualificationComponent 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($"Practitioner.QualificationComponent >>> Practitioner#Qualification.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"Practitioner.QualificationComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Пример #2
0
        /// <summary>
        /// Deserialize JSON into a FHIR Practitioner#Qualification
        /// </summary>
        public static void DeserializeJsonProperty(this Practitioner.QualificationComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "identifier":
                if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read()))
                {
                    throw new JsonException($"QualificationComponent 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($"QualificationComponent 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 "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options);
                break;

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

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

            // Complex: qualification, Export: QualificationComponent, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
        internal static Practitioner ToFhirInternal(PersonItem person)
        {
            var practitioner = new Practitioner();

            HumanName fhirName = person.Name.ToFhir();

            practitioner.Name = new System.Collections.Generic.List <HumanName> {
                fhirName
            };

            if (!string.IsNullOrEmpty(person.Organization))
            {
                practitioner.SetStringExtension(HealthVaultExtensions.Organization, person.Organization);
            }

            if (!string.IsNullOrEmpty(person.ProfessionalTraining))
            {
                var qualificationComponent = new Practitioner.QualificationComponent
                {
                    Code = new CodeableConcept
                    {
                        Text = person.ProfessionalTraining
                    }
                };
                practitioner.Qualification = new System.Collections.Generic.List <Practitioner.QualificationComponent>
                {
                    qualificationComponent
                };
            }

            if (!string.IsNullOrEmpty(person.PersonId))
            {
                practitioner.Identifier = new System.Collections.Generic.List <Identifier>
                {
                    new Identifier
                    {
                        Value = person.PersonId
                    }
                };
            }

            if (person.ContactInformation != null)
            {
                practitioner.Address.AddRange(
                    person.ContactInformation.Address.Select(address => address.ToFhir()));
                practitioner.Telecom.AddRange(
                    person.ContactInformation.Phone.Select(phone => phone.ToFhir()));
                practitioner.Telecom.AddRange(
                    person.ContactInformation.Email.Select(email => email.ToFhir()));
            }

            return(practitioner);
        }
Пример #4
0
        /// <summary>
        /// Serialize a FHIR Practitioner#Qualification into JSON
        /// </summary>
        public static void SerializeJson(this Practitioner.QualificationComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: Practitioner#Qualification, Export: QualificationComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)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();
            }

            writer.WritePropertyName("code");
            current.Code.SerializeJson(writer, options);

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

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

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }