Esempio n. 1
0
        /// <summary>
        /// Deserialize JSON into a FHIR ProductShelfLife
        /// </summary>
        public static void DeserializeJson(this ProductShelfLife 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($"ProductShelfLife >>> ProductShelfLife.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
                    }
                    reader.Read();
                    current.DeserializeJsonProperty(ref reader, options, propertyName);
                }
            }

            throw new JsonException($"ProductShelfLife: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}");
        }
Esempio n. 2
0
 public static ProductShelfLifeDto FromModel(ProductShelfLife model)
 {
     return(new ProductShelfLifeDto()
     {
         ProductId = model.ProductId,
         StockEntryId = model.StockEntryId,
         StartDate = model.StartDate,
         EndDate = model.EndDate,
     });
 }
Esempio n. 3
0
        /// <summary>
        /// Deserialize JSON into a FHIR ProductShelfLife
        /// </summary>
        public static void DeserializeJsonProperty(this ProductShelfLife 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 "type":
                current.Type = new Hl7.Fhir.Model.CodeableConcept();
                ((Hl7.Fhir.Model.CodeableConcept)current.Type).DeserializeJson(ref reader, options);
                break;

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

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

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

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

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

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

            // Complex: ProductShelfLife, Export: ProductShelfLife, Base: BackboneElement
            default:
                ((Hl7.Fhir.Model.BackboneType)current).DeserializeJsonProperty(ref reader, options, propertyName);
                break;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Serialize a FHIR ProductShelfLife into JSON
        /// </summary>
        public static void SerializeJson(this ProductShelfLife current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            // Complex: ProductShelfLife, Export: ProductShelfLife, Base: BackboneElement (BackboneType)
            ((Hl7.Fhir.Model.BackboneType)current).SerializeJson(writer, options, false);

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

            writer.WritePropertyName("type");
            current.Type.SerializeJson(writer, options);

            writer.WritePropertyName("period");
            current.Period.SerializeJson(writer, options);

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

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