/// <summary> /// Deserialize JSON into a FHIR MedicinalProductManufactured /// </summary> public static void DeserializeJson(this MedicinalProductManufactured 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($"MedicinalProductManufactured >>> MedicinalProductManufactured.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"MedicinalProductManufactured: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR MedicinalProductManufactured into JSON /// </summary> public static void SerializeJson(this MedicinalProductManufactured current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } writer.WriteString("resourceType", "MedicinalProductManufactured"); // Complex: MedicinalProductManufactured, Export: MedicinalProductManufactured, Base: DomainResource (DomainResource) ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false); writer.WritePropertyName("manufacturedDoseForm"); current.ManufacturedDoseForm.SerializeJson(writer, options); if (current.UnitOfPresentation != null) { writer.WritePropertyName("unitOfPresentation"); current.UnitOfPresentation.SerializeJson(writer, options); } writer.WritePropertyName("quantity"); current.Quantity.SerializeJson(writer, options); if ((current.Manufacturer != null) && (current.Manufacturer.Count != 0)) { writer.WritePropertyName("manufacturer"); writer.WriteStartArray(); foreach (ResourceReference val in current.Manufacturer) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Ingredient != null) && (current.Ingredient.Count != 0)) { writer.WritePropertyName("ingredient"); writer.WriteStartArray(); foreach (ResourceReference val in current.Ingredient) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (current.PhysicalCharacteristics != null) { writer.WritePropertyName("physicalCharacteristics"); current.PhysicalCharacteristics.SerializeJson(writer, options); } if ((current.OtherCharacteristics != null) && (current.OtherCharacteristics.Count != 0)) { writer.WritePropertyName("otherCharacteristics"); writer.WriteStartArray(); foreach (CodeableConcept val in current.OtherCharacteristics) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR MedicinalProductManufactured /// </summary> public static void DeserializeJsonProperty(this MedicinalProductManufactured current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "manufacturedDoseForm": current.ManufacturedDoseForm = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.ManufacturedDoseForm).DeserializeJson(ref reader, options); break; case "unitOfPresentation": current.UnitOfPresentation = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.UnitOfPresentation).DeserializeJson(ref reader, options); break; case "quantity": current.Quantity = new Hl7.Fhir.Model.Quantity(); ((Hl7.Fhir.Model.Quantity)current.Quantity).DeserializeJson(ref reader, options); break; case "manufacturer": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductManufactured error reading 'manufacturer' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Manufacturer = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Manufacturer = new Hl7.Fhir.Model.ResourceReference(); v_Manufacturer.DeserializeJson(ref reader, options); current.Manufacturer.Add(v_Manufacturer); if (!reader.Read()) { throw new JsonException($"MedicinalProductManufactured error reading 'manufacturer' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Manufacturer.Count == 0) { current.Manufacturer = null; } break; case "ingredient": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductManufactured error reading 'ingredient' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Ingredient = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Ingredient = new Hl7.Fhir.Model.ResourceReference(); v_Ingredient.DeserializeJson(ref reader, options); current.Ingredient.Add(v_Ingredient); if (!reader.Read()) { throw new JsonException($"MedicinalProductManufactured error reading 'ingredient' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Ingredient.Count == 0) { current.Ingredient = null; } break; case "physicalCharacteristics": current.PhysicalCharacteristics = new Hl7.Fhir.Model.ProdCharacteristic(); ((Hl7.Fhir.Model.ProdCharacteristic)current.PhysicalCharacteristics).DeserializeJson(ref reader, options); break; case "otherCharacteristics": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductManufactured error reading 'otherCharacteristics' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.OtherCharacteristics = new List <CodeableConcept>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.CodeableConcept v_OtherCharacteristics = new Hl7.Fhir.Model.CodeableConcept(); v_OtherCharacteristics.DeserializeJson(ref reader, options); current.OtherCharacteristics.Add(v_OtherCharacteristics); if (!reader.Read()) { throw new JsonException($"MedicinalProductManufactured error reading 'otherCharacteristics' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.OtherCharacteristics.Count == 0) { current.OtherCharacteristics = null; } break; // Complex: MedicinalProductManufactured, Export: MedicinalProductManufactured, Base: DomainResource default: ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }