/// <summary> /// Deserialize JSON into a FHIR DataRequirement#CodeFilter /// </summary> public static void DeserializeJson(this DataRequirement.CodeFilterComponent 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($"DataRequirement.CodeFilterComponent >>> DataRequirement#CodeFilter.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"DataRequirement.CodeFilterComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR DataRequirement#CodeFilter /// </summary> public static void DeserializeJsonProperty(this DataRequirement.CodeFilterComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "path": if (reader.TokenType == JsonTokenType.Null) { current.PathElement = new FhirString(); reader.Skip(); } else { current.PathElement = new FhirString(reader.GetString()); } break; case "_path": if (current.PathElement == null) { current.PathElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.PathElement).DeserializeJson(ref reader, options); break; case "searchParam": if (reader.TokenType == JsonTokenType.Null) { current.SearchParamElement = new FhirString(); reader.Skip(); } else { current.SearchParamElement = new FhirString(reader.GetString()); } break; case "_searchParam": if (current.SearchParamElement == null) { current.SearchParamElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.SearchParamElement).DeserializeJson(ref reader, options); break; case "valueSet": if (reader.TokenType == JsonTokenType.Null) { current.ValueSetElement = new Canonical(); reader.Skip(); } else { current.ValueSetElement = new Canonical(reader.GetString()); } break; case "_valueSet": if (current.ValueSetElement == null) { current.ValueSetElement = new Canonical(); } ((Hl7.Fhir.Model.Element)current.ValueSetElement).DeserializeJson(ref reader, options); break; case "code": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"CodeFilterComponent error reading 'code' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Code = new List <Coding>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Coding v_Code = new Hl7.Fhir.Model.Coding(); v_Code.DeserializeJson(ref reader, options); current.Code.Add(v_Code); if (!reader.Read()) { throw new JsonException($"CodeFilterComponent error reading 'code' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Code.Count == 0) { current.Code = null; } break; // Complex: codeFilter, Export: CodeFilterComponent, Base: Element default: ((Hl7.Fhir.Model.Element)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR DataRequirement#CodeFilter into JSON /// </summary> public static void SerializeJson(this DataRequirement.CodeFilterComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: DataRequirement#CodeFilter, Export: CodeFilterComponent, Base: Element (Element) ((Hl7.Fhir.Model.Element)current).SerializeJson(writer, options, false); if (current.PathElement != null) { if (!string.IsNullOrEmpty(current.PathElement.Value)) { writer.WriteString("path", current.PathElement.Value); } if (current.PathElement.HasExtensions() || (!string.IsNullOrEmpty(current.PathElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_path", false, current.PathElement.Extension, current.PathElement.ElementId); } } if (current.SearchParamElement != null) { if (!string.IsNullOrEmpty(current.SearchParamElement.Value)) { writer.WriteString("searchParam", current.SearchParamElement.Value); } if (current.SearchParamElement.HasExtensions() || (!string.IsNullOrEmpty(current.SearchParamElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_searchParam", false, current.SearchParamElement.Extension, current.SearchParamElement.ElementId); } } if (current.ValueSetElement != null) { if (!string.IsNullOrEmpty(current.ValueSetElement.Value)) { writer.WriteString("valueSet", current.ValueSetElement.Value); } if (current.ValueSetElement.HasExtensions() || (!string.IsNullOrEmpty(current.ValueSetElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_valueSet", false, current.ValueSetElement.Extension, current.ValueSetElement.ElementId); } } if ((current.Code != null) && (current.Code.Count != 0)) { writer.WritePropertyName("code"); writer.WriteStartArray(); foreach (Coding val in current.Code) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }