/// <summary> /// Deserialize JSON into a FHIR MedicinalProductUndesirableEffect /// </summary> public static void DeserializeJson(this MedicinalProductUndesirableEffect 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($"MedicinalProductUndesirableEffect >>> MedicinalProductUndesirableEffect.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"MedicinalProductUndesirableEffect: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR MedicinalProductUndesirableEffect into JSON /// </summary> public static void SerializeJson(this MedicinalProductUndesirableEffect current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } writer.WriteString("resourceType", "MedicinalProductUndesirableEffect"); // Complex: MedicinalProductUndesirableEffect, Export: MedicinalProductUndesirableEffect, Base: DomainResource (DomainResource) ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false); if ((current.Subject != null) && (current.Subject.Count != 0)) { writer.WritePropertyName("subject"); writer.WriteStartArray(); foreach (ResourceReference val in current.Subject) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (current.SymptomConditionEffect != null) { writer.WritePropertyName("symptomConditionEffect"); current.SymptomConditionEffect.SerializeJson(writer, options); } if (current.Classification != null) { writer.WritePropertyName("classification"); current.Classification.SerializeJson(writer, options); } if (current.FrequencyOfOccurrence != null) { writer.WritePropertyName("frequencyOfOccurrence"); current.FrequencyOfOccurrence.SerializeJson(writer, options); } if ((current.Population != null) && (current.Population.Count != 0)) { writer.WritePropertyName("population"); writer.WriteStartArray(); foreach (Population val in current.Population) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR MedicinalProductUndesirableEffect /// </summary> public static void DeserializeJsonProperty(this MedicinalProductUndesirableEffect current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "subject": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductUndesirableEffect error reading 'subject' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Subject = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Subject = new Hl7.Fhir.Model.ResourceReference(); v_Subject.DeserializeJson(ref reader, options); current.Subject.Add(v_Subject); if (!reader.Read()) { throw new JsonException($"MedicinalProductUndesirableEffect error reading 'subject' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Subject.Count == 0) { current.Subject = null; } break; case "symptomConditionEffect": current.SymptomConditionEffect = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.SymptomConditionEffect).DeserializeJson(ref reader, options); break; case "classification": current.Classification = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Classification).DeserializeJson(ref reader, options); break; case "frequencyOfOccurrence": current.FrequencyOfOccurrence = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.FrequencyOfOccurrence).DeserializeJson(ref reader, options); break; case "population": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductUndesirableEffect error reading 'population' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Population = new List <Population>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Population v_Population = new Hl7.Fhir.Model.Population(); v_Population.DeserializeJson(ref reader, options); current.Population.Add(v_Population); if (!reader.Read()) { throw new JsonException($"MedicinalProductUndesirableEffect error reading 'population' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Population.Count == 0) { current.Population = null; } break; // Complex: MedicinalProductUndesirableEffect, Export: MedicinalProductUndesirableEffect, Base: DomainResource default: ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }