/// <summary> /// Deserialize JSON into a FHIR MedicinalProductContraindication#OtherTherapy /// </summary> public static void DeserializeJson(this MedicinalProductContraindication.OtherTherapyComponent 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($"MedicinalProductContraindication.OtherTherapyComponent >>> MedicinalProductContraindication#OtherTherapy.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"MedicinalProductContraindication.OtherTherapyComponent: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
/// <summary> /// Deserialize JSON into a FHIR MedicinalProductContraindication#OtherTherapy /// </summary> public static void DeserializeJsonProperty(this MedicinalProductContraindication.OtherTherapyComponent current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "therapyRelationshipType": current.TherapyRelationshipType = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.TherapyRelationshipType).DeserializeJson(ref reader, options); break; case "medicationCodeableConcept": current.Medication = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Medication).DeserializeJson(ref reader, options); break; case "medicationReference": current.Medication = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Medication).DeserializeJson(ref reader, options); break; // Complex: otherTherapy, Export: OtherTherapyComponent, Base: BackboneElement default: ((Hl7.Fhir.Model.BackboneElement)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Serialize a FHIR MedicinalProductContraindication#OtherTherapy into JSON /// </summary> public static void SerializeJson(this MedicinalProductContraindication.OtherTherapyComponent current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } // Component: MedicinalProductContraindication#OtherTherapy, Export: OtherTherapyComponent, Base: BackboneElement (BackboneElement) ((Hl7.Fhir.Model.BackboneElement)current).SerializeJson(writer, options, false); writer.WritePropertyName("therapyRelationshipType"); current.TherapyRelationshipType.SerializeJson(writer, options); if (current.Medication != null) { switch (current.Medication) { case CodeableConcept v_CodeableConcept: writer.WritePropertyName("medicationCodeableConcept"); v_CodeableConcept.SerializeJson(writer, options); break; case ResourceReference v_ResourceReference: writer.WritePropertyName("medicationReference"); v_ResourceReference.SerializeJson(writer, options); break; } } if (includeStartObject) { writer.WriteEndObject(); } }