/// <summary> /// Deserialize JSON into a FHIR Medication#Batch /// </summary> public static void DeserializeJson(this Medication.BatchComponent 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($"Medication.BatchComponent >>> Medication#Batch.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"Medication.BatchComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR Medication#Batch /// </summary> public static void DeserializeJsonProperty(this Medication.BatchComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "lotNumber": if (reader.TokenType == JsonTokenType.Null) { current.LotNumberElement = new FhirString(); reader.Skip(); } else { current.LotNumberElement = new FhirString(reader.GetString()); } break; case "_lotNumber": if (current.LotNumberElement == null) { current.LotNumberElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.LotNumberElement).DeserializeJson(ref reader, options); break; case "expirationDate": if (reader.TokenType == JsonTokenType.Null) { current.ExpirationDateElement = new FhirDateTime(); reader.Skip(); } else { current.ExpirationDateElement = new FhirDateTime(reader.GetString()); } break; case "_expirationDate": if (current.ExpirationDateElement == null) { current.ExpirationDateElement = new FhirDateTime(); } ((Hl7.Fhir.Model.Element)current.ExpirationDateElement).DeserializeJson(ref reader, options); break; // Complex: batch, Export: BatchComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR Medication#Batch into JSON /// </summary> public static void SerializeJson(this Medication.BatchComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: Medication#Batch, Export: BatchComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); if (current.LotNumberElement != null) { if (!string.IsNullOrEmpty(current.LotNumberElement.Value)) { writer.WriteString("lotNumber", current.LotNumberElement.Value); } if (current.LotNumberElement.HasExtensions() || (!string.IsNullOrEmpty(current.LotNumberElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_lotNumber", false, current.LotNumberElement.Extension, current.LotNumberElement.ElementId); } } if (current.ExpirationDateElement != null) { if (!string.IsNullOrEmpty(current.ExpirationDateElement.Value)) { writer.WriteString("expirationDate", current.ExpirationDateElement.Value); } if (current.ExpirationDateElement.HasExtensions() || (!string.IsNullOrEmpty(current.ExpirationDateElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_expirationDate", false, current.ExpirationDateElement.Extension, current.ExpirationDateElement.ElementId); } } if (includeStartObject) { writer.WriteEndObject(); } }