コード例 #1
0
        /// <summary>
        /// Deserialize JSON into a FHIR ClinicalImpression#Investigation
        /// </summary>
        public static void DeserializeJson(this ClinicalImpression.InvestigationComponent 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($"ClinicalImpression.InvestigationComponent >>> ClinicalImpression#Investigation.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"ClinicalImpression.InvestigationComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
コード例 #2
0
        /// <summary>
        /// Serialize a FHIR ClinicalImpression#Investigation into JSON
        /// </summary>
        public static void SerializeJson(this ClinicalImpression.InvestigationComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Component: ClinicalImpression#Investigation, Export: InvestigationComponent, Base: BackboneElement (BackboneElement)
            ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false);

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

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

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }
コード例 #3
0
        /// <summary>
        /// Deserialize JSON into a FHIR ClinicalImpression#Investigation
        /// </summary>
        public static void DeserializeJsonProperty(this ClinicalImpression.InvestigationComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName)
        {
            switch (propertyName)
            {
            case "code":
                current.Code = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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