/// <summary> /// Deserialize JSON into a FHIR DocumentManifest /// </summary> public static void DeserializeJson(this DocumentManifest 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($"DocumentManifest >>> DocumentManifest.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"DocumentManifest: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR DocumentManifest into JSON /// </summary> public static void SerializeJson(this DocumentManifest current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } writer.WriteString("resourceType", "DocumentManifest"); // Complex: DocumentManifest, Export: DocumentManifest, Base: DomainResource (DomainResource) ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false); if (current.MasterIdentifier != null) { writer.WritePropertyName("masterIdentifier"); current.MasterIdentifier.SerializeJson(writer, options); } if ((current.Identifier != null) && (current.Identifier.Count != 0)) { writer.WritePropertyName("identifier"); writer.WriteStartArray(); foreach (Identifier val in current.Identifier) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } writer.WriteString("status", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StatusElement.Value)); if (current.Type != null) { writer.WritePropertyName("type"); current.Type.SerializeJson(writer, options); } if (current.Subject != null) { writer.WritePropertyName("subject"); current.Subject.SerializeJson(writer, options); } if (current.CreatedElement != null) { if (!string.IsNullOrEmpty(current.CreatedElement.Value)) { writer.WriteString("created", current.CreatedElement.Value); } if (current.CreatedElement.HasExtensions() || (!string.IsNullOrEmpty(current.CreatedElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_created", false, current.CreatedElement.Extension, current.CreatedElement.ElementId); } } if ((current.Author != null) && (current.Author.Count != 0)) { writer.WritePropertyName("author"); writer.WriteStartArray(); foreach (ResourceReference val in current.Author) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Recipient != null) && (current.Recipient.Count != 0)) { writer.WritePropertyName("recipient"); writer.WriteStartArray(); foreach (ResourceReference val in current.Recipient) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (current.SourceElement != null) { if (!string.IsNullOrEmpty(current.SourceElement.Value)) { writer.WriteString("source", current.SourceElement.Value); } if (current.SourceElement.HasExtensions() || (!string.IsNullOrEmpty(current.SourceElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_source", false, current.SourceElement.Extension, current.SourceElement.ElementId); } } if (current.DescriptionElement != null) { if (!string.IsNullOrEmpty(current.DescriptionElement.Value)) { writer.WriteString("description", current.DescriptionElement.Value); } if (current.DescriptionElement.HasExtensions() || (!string.IsNullOrEmpty(current.DescriptionElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_description", false, current.DescriptionElement.Extension, current.DescriptionElement.ElementId); } } if ((current.Content != null) && (current.Content.Count != 0)) { writer.WritePropertyName("content"); writer.WriteStartArray(); foreach (ResourceReference val in current.Content) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Related != null) && (current.Related.Count != 0)) { writer.WritePropertyName("related"); writer.WriteStartArray(); foreach (DocumentManifest.RelatedComponent val in current.Related) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR DocumentManifest /// </summary> public static void DeserializeJsonProperty(this DocumentManifest current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "masterIdentifier": current.MasterIdentifier = new Hl7.Fhir.Model.Identifier(); ((Hl7.Fhir.Model.Identifier)current.MasterIdentifier).DeserializeJson(ref reader, options); break; case "identifier": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"DocumentManifest error reading 'identifier' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Identifier = new List <Identifier>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Identifier v_Identifier = new Hl7.Fhir.Model.Identifier(); v_Identifier.DeserializeJson(ref reader, options); current.Identifier.Add(v_Identifier); if (!reader.Read()) { throw new JsonException($"DocumentManifest error reading 'identifier' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Identifier.Count == 0) { current.Identifier = null; } break; case "status": if (reader.TokenType == JsonTokenType.Null) { current.StatusElement = new Code <Hl7.Fhir.Model.DocumentReferenceStatus>(); reader.Skip(); } else { current.StatusElement = new Code <Hl7.Fhir.Model.DocumentReferenceStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.DocumentReferenceStatus>(reader.GetString())); } break; case "_status": if (current.StatusElement == null) { current.StatusElement = new Code <Hl7.Fhir.Model.DocumentReferenceStatus>(); } ((Hl7.Fhir.Model.Element)current.StatusElement).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 "subject": current.Subject = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Subject).DeserializeJson(ref reader, options); break; case "created": if (reader.TokenType == JsonTokenType.Null) { current.CreatedElement = new FhirDateTime(); reader.Skip(); } else { current.CreatedElement = new FhirDateTime(reader.GetString()); } break; case "_created": if (current.CreatedElement == null) { current.CreatedElement = new FhirDateTime(); } ((Hl7.Fhir.Model.Element)current.CreatedElement).DeserializeJson(ref reader, options); break; case "author": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"DocumentManifest error reading 'author' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Author = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Author = new Hl7.Fhir.Model.ResourceReference(); v_Author.DeserializeJson(ref reader, options); current.Author.Add(v_Author); if (!reader.Read()) { throw new JsonException($"DocumentManifest error reading 'author' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Author.Count == 0) { current.Author = null; } break; case "recipient": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"DocumentManifest error reading 'recipient' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Recipient = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Recipient = new Hl7.Fhir.Model.ResourceReference(); v_Recipient.DeserializeJson(ref reader, options); current.Recipient.Add(v_Recipient); if (!reader.Read()) { throw new JsonException($"DocumentManifest error reading 'recipient' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Recipient.Count == 0) { current.Recipient = null; } break; case "source": if (reader.TokenType == JsonTokenType.Null) { current.SourceElement = new FhirUri(); reader.Skip(); } else { current.SourceElement = new FhirUri(reader.GetString()); } break; case "_source": if (current.SourceElement == null) { current.SourceElement = new FhirUri(); } ((Hl7.Fhir.Model.Element)current.SourceElement).DeserializeJson(ref reader, options); break; case "description": if (reader.TokenType == JsonTokenType.Null) { current.DescriptionElement = new FhirString(); reader.Skip(); } else { current.DescriptionElement = new FhirString(reader.GetString()); } break; case "_description": if (current.DescriptionElement == null) { current.DescriptionElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.DescriptionElement).DeserializeJson(ref reader, options); break; case "content": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"DocumentManifest error reading 'content' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Content = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Content = new Hl7.Fhir.Model.ResourceReference(); v_Content.DeserializeJson(ref reader, options); current.Content.Add(v_Content); if (!reader.Read()) { throw new JsonException($"DocumentManifest error reading 'content' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Content.Count == 0) { current.Content = null; } break; case "related": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"DocumentManifest error reading 'related' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Related = new List <DocumentManifest.RelatedComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.DocumentManifest.RelatedComponent v_Related = new Hl7.Fhir.Model.DocumentManifest.RelatedComponent(); v_Related.DeserializeJson(ref reader, options); current.Related.Add(v_Related); if (!reader.Read()) { throw new JsonException($"DocumentManifest error reading 'related' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Related.Count == 0) { current.Related = null; } break; // Complex: DocumentManifest, Export: DocumentManifest, Base: DomainResource default: ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }