/// <summary> /// Deserialize JSON into a FHIR MedicinalProductIndication /// </summary> public static void DeserializeJson(this MedicinalProductIndication 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($"MedicinalProductIndication >>> MedicinalProductIndication.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"MedicinalProductIndication: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Serialize a FHIR MedicinalProductIndication into JSON /// </summary> public static void SerializeJson(this MedicinalProductIndication current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } writer.WriteString("resourceType", "MedicinalProductIndication"); // Complex: MedicinalProductIndication, Export: MedicinalProductIndication, 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.DiseaseSymptomProcedure != null) { writer.WritePropertyName("diseaseSymptomProcedure"); current.DiseaseSymptomProcedure.SerializeJson(writer, options); } if (current.DiseaseStatus != null) { writer.WritePropertyName("diseaseStatus"); current.DiseaseStatus.SerializeJson(writer, options); } if ((current.Comorbidity != null) && (current.Comorbidity.Count != 0)) { writer.WritePropertyName("comorbidity"); writer.WriteStartArray(); foreach (CodeableConcept val in current.Comorbidity) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (current.IntendedEffect != null) { writer.WritePropertyName("intendedEffect"); current.IntendedEffect.SerializeJson(writer, options); } if (current.Duration != null) { writer.WritePropertyName("duration"); current.Duration.SerializeJson(writer, options); } if ((current.OtherTherapy != null) && (current.OtherTherapy.Count != 0)) { writer.WritePropertyName("otherTherapy"); writer.WriteStartArray(); foreach (MedicinalProductIndication.OtherTherapyComponent val in current.OtherTherapy) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.UndesirableEffect != null) && (current.UndesirableEffect.Count != 0)) { writer.WritePropertyName("undesirableEffect"); writer.WriteStartArray(); foreach (ResourceReference val in current.UndesirableEffect) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } 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 MedicinalProductIndication /// </summary> public static void DeserializeJsonProperty(this MedicinalProductIndication current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "subject": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductIndication 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($"MedicinalProductIndication 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 "diseaseSymptomProcedure": current.DiseaseSymptomProcedure = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.DiseaseSymptomProcedure).DeserializeJson(ref reader, options); break; case "diseaseStatus": current.DiseaseStatus = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.DiseaseStatus).DeserializeJson(ref reader, options); break; case "comorbidity": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductIndication error reading 'comorbidity' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Comorbidity = new List <CodeableConcept>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.CodeableConcept v_Comorbidity = new Hl7.Fhir.Model.CodeableConcept(); v_Comorbidity.DeserializeJson(ref reader, options); current.Comorbidity.Add(v_Comorbidity); if (!reader.Read()) { throw new JsonException($"MedicinalProductIndication error reading 'comorbidity' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Comorbidity.Count == 0) { current.Comorbidity = null; } break; case "intendedEffect": current.IntendedEffect = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.IntendedEffect).DeserializeJson(ref reader, options); break; case "duration": current.Duration = new Hl7.Fhir.Model.Quantity(); ((Hl7.Fhir.Model.Quantity)current.Duration).DeserializeJson(ref reader, options); break; case "otherTherapy": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductIndication error reading 'otherTherapy' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.OtherTherapy = new List <MedicinalProductIndication.OtherTherapyComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.MedicinalProductIndication.OtherTherapyComponent v_OtherTherapy = new Hl7.Fhir.Model.MedicinalProductIndication.OtherTherapyComponent(); v_OtherTherapy.DeserializeJson(ref reader, options); current.OtherTherapy.Add(v_OtherTherapy); if (!reader.Read()) { throw new JsonException($"MedicinalProductIndication error reading 'otherTherapy' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.OtherTherapy.Count == 0) { current.OtherTherapy = null; } break; case "undesirableEffect": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductIndication error reading 'undesirableEffect' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.UndesirableEffect = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_UndesirableEffect = new Hl7.Fhir.Model.ResourceReference(); v_UndesirableEffect.DeserializeJson(ref reader, options); current.UndesirableEffect.Add(v_UndesirableEffect); if (!reader.Read()) { throw new JsonException($"MedicinalProductIndication error reading 'undesirableEffect' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.UndesirableEffect.Count == 0) { current.UndesirableEffect = null; } break; case "population": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"MedicinalProductIndication 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($"MedicinalProductIndication 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: MedicinalProductIndication, Export: MedicinalProductIndication, Base: DomainResource default: ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }