/// <summary> /// Deserialize JSON into a FHIR MedicinalProductIngredient#SpecifiedSubstance /// </summary> public static void DeserializeJson(this MedicinalProductIngredient.SpecifiedSubstanceComponent 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($"MedicinalProductIngredient.SpecifiedSubstanceComponent >>> MedicinalProductIngredient#SpecifiedSubstance.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"MedicinalProductIngredient.SpecifiedSubstanceComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR MedicinalProductIngredient#SpecifiedSubstance /// </summary> public static void DeserializeJsonProperty(this MedicinalProductIngredient.SpecifiedSubstanceComponent 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 "group": current.Group = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Group).DeserializeJson(ref reader, options); break; case "confidentiality": current.Confidentiality = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Confidentiality).DeserializeJson(ref reader, options); break; case "strength": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"SpecifiedSubstanceComponent error reading 'strength' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Strength = new List <MedicinalProductIngredient.StrengthComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.MedicinalProductIngredient.StrengthComponent v_Strength = new Hl7.Fhir.Model.MedicinalProductIngredient.StrengthComponent(); v_Strength.DeserializeJson(ref reader, options); current.Strength.Add(v_Strength); if (!reader.Read()) { throw new JsonException($"SpecifiedSubstanceComponent error reading 'strength' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Strength.Count == 0) { current.Strength = null; } break; // Complex: specifiedSubstance, Export: SpecifiedSubstanceComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR MedicinalProductIngredient#SpecifiedSubstance into JSON /// </summary> public static void SerializeJson(this MedicinalProductIngredient.SpecifiedSubstanceComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: MedicinalProductIngredient#SpecifiedSubstance, Export: SpecifiedSubstanceComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); writer.WritePropertyName("code"); current.Code.SerializeJson(writer, options); writer.WritePropertyName("group"); current.Group.SerializeJson(writer, options); if (current.Confidentiality != null) { writer.WritePropertyName("confidentiality"); current.Confidentiality.SerializeJson(writer, options); } if ((current.Strength != null) && (current.Strength.Count != 0)) { writer.WritePropertyName("strength"); writer.WriteStartArray(); foreach (MedicinalProductIngredient.StrengthComponent val in current.Strength) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }