public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as ResearchSubject; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (Identifier != null) { dest.Identifier = (Hl7.Fhir.Model.Identifier)Identifier.DeepCopy(); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.ResearchSubject.ResearchSubjectStatus>)StatusElement.DeepCopy(); } if (Period != null) { dest.Period = (Hl7.Fhir.Model.Period)Period.DeepCopy(); } if (Study != null) { dest.Study = (Hl7.Fhir.Model.ResourceReference)Study.DeepCopy(); } if (Individual != null) { dest.Individual = (Hl7.Fhir.Model.ResourceReference)Individual.DeepCopy(); } if (AssignedArmElement != null) { dest.AssignedArmElement = (Hl7.Fhir.Model.FhirString)AssignedArmElement.DeepCopy(); } if (ActualArmElement != null) { dest.ActualArmElement = (Hl7.Fhir.Model.FhirString)ActualArmElement.DeepCopy(); } if (Consent != null) { dest.Consent = (Hl7.Fhir.Model.ResourceReference)Consent.DeepCopy(); } return(dest); }
public static void SerializeStudy(Hl7.Fhir.Model.Study value, IFhirWriter writer) { writer.WriteStartRootObject("Study"); writer.WriteStartComplexContent(); // Serialize element extension if (value.Extension != null && value.Extension.Count > 0) { writer.WriteStartArrayElement("extension"); foreach (var item in value.Extension) { writer.WriteStartArrayMember("extension"); ExtensionSerializer.SerializeExtension(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element language if (value.Language != null) { writer.WriteStartElement("language"); CodeSerializer.SerializeCode(value.Language, writer); writer.WriteEndElement(); } // Serialize element text if (value.Text != null) { writer.WriteStartElement("text"); NarrativeSerializer.SerializeNarrative(value.Text, writer); writer.WriteEndElement(); } // Serialize element contained if (value.Contained != null && value.Contained.Count > 0) { writer.WriteStartArrayElement("contained"); foreach (var item in value.Contained) { writer.WriteStartArrayMember("contained"); FhirSerializer.SerializeResource(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element _id if (value.LocalId != null) { writer.WriteStartElement("_id"); IdSerializer.SerializeId(value.LocalId, writer); writer.WriteEndElement(); } // Serialize element identifier if (value.Identifier != null && value.Identifier.Count > 0) { writer.WriteStartArrayElement("identifier"); foreach (var item in value.Identifier) { writer.WriteStartArrayMember("identifier"); IdentifierSerializer.SerializeIdentifier(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element sponsor if (value.Sponsor != null) { writer.WriteStartElement("sponsor"); FhirStringSerializer.SerializeFhirString(value.Sponsor, writer); writer.WriteEndElement(); } // Serialize element title if (value.Title != null) { writer.WriteStartElement("title"); FhirStringSerializer.SerializeFhirString(value.Title, writer); writer.WriteEndElement(); } // Serialize element description if (value.Description != null) { writer.WriteStartElement("description"); FhirStringSerializer.SerializeFhirString(value.Description, writer); writer.WriteEndElement(); } // Serialize element type if (value.Type != null) { writer.WriteStartElement("type"); CodeableConceptSerializer.SerializeCodeableConcept(value.Type, writer); writer.WriteEndElement(); } // Serialize element condition if (value.Condition != null && value.Condition.Count > 0) { writer.WriteStartArrayElement("condition"); foreach (var item in value.Condition) { writer.WriteStartArrayMember("condition"); CodeableConceptSerializer.SerializeCodeableConcept(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element treatment if (value.Treatment != null && value.Treatment.Count > 0) { writer.WriteStartArrayElement("treatment"); foreach (var item in value.Treatment) { writer.WriteStartArrayMember("treatment"); StudySerializer.SerializeStudyTreatmentComponent(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element controlType if (value.ControlType != null && value.ControlType.Count > 0) { writer.WriteStartArrayElement("controlType"); foreach (var item in value.ControlType) { writer.WriteStartArrayMember("controlType"); CodeableConceptSerializer.SerializeCodeableConcept(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element objective if (value.Objective != null && value.Objective.Count > 0) { writer.WriteStartArrayElement("objective"); foreach (var item in value.Objective) { writer.WriteStartArrayMember("objective"); FhirStringSerializer.SerializeFhirString(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element outcomeMeasure if (value.OutcomeMeasure != null && value.OutcomeMeasure.Count > 0) { writer.WriteStartArrayElement("outcomeMeasure"); foreach (var item in value.OutcomeMeasure) { writer.WriteStartArrayMember("outcomeMeasure"); FhirStringSerializer.SerializeFhirString(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element eligibility if (value.Eligibility != null && value.Eligibility.Count > 0) { writer.WriteStartArrayElement("eligibility"); foreach (var item in value.Eligibility) { writer.WriteStartArrayMember("eligibility"); ResourceReferenceSerializer.SerializeResourceReference(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element period if (value.Period != null) { writer.WriteStartElement("period"); PeriodSerializer.SerializePeriod(value.Period, writer); writer.WriteEndElement(); } // Serialize element duration if (value.Duration != null) { writer.WriteStartElement("duration"); QuantitySerializer.SerializeQuantity(value.Duration, writer); writer.WriteEndElement(); } // Serialize element plannedEnrollment if (value.PlannedEnrollment != null) { writer.WriteStartElement("plannedEnrollment"); IntegerSerializer.SerializeInteger(value.PlannedEnrollment, writer); writer.WriteEndElement(); } // Serialize element intervention if (value.Intervention != null) { writer.WriteStartElement("intervention"); StudySerializer.SerializeStudyInterventionComponent(value.Intervention, writer); writer.WriteEndElement(); } // Serialize element protocol if (value.Protocol != null && value.Protocol.Count > 0) { writer.WriteStartArrayElement("protocol"); foreach (var item in value.Protocol) { writer.WriteStartArrayMember("protocol"); ResourceReferenceSerializer.SerializeResourceReference(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element dataStructure if (value.DataStructure != null) { writer.WriteStartElement("dataStructure"); ResourceReferenceSerializer.SerializeResourceReference(value.DataStructure, writer); writer.WriteEndElement(); } // Serialize element data if (value.Data != null && value.Data.Count > 0) { writer.WriteStartArrayElement("data"); foreach (var item in value.Data) { writer.WriteStartArrayMember("data"); ResourceReferenceSerializer.SerializeResourceReference(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } writer.WriteEndComplexContent(); writer.WriteEndRootObject(); }
/// <summary> /// Parse Study /// </summary> public static Hl7.Fhir.Model.Study ParseStudy(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Study existingInstance = null) { Hl7.Fhir.Model.Study result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Study(); try { string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { // Parse element extension if (ParserUtils.IsAtFhirElement(reader, "extension")) { result.Extension = new List <Hl7.Fhir.Model.Extension>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "extension")) { result.Extension.Add(ExtensionParser.ParseExtension(reader, errors)); } reader.LeaveArray(); } // Parse element language else if (ParserUtils.IsAtFhirElement(reader, "language")) { result.Language = CodeParser.ParseCode(reader, errors); } // Parse element text else if (ParserUtils.IsAtFhirElement(reader, "text")) { result.Text = NarrativeParser.ParseNarrative(reader, errors); } // Parse element contained else if (ParserUtils.IsAtFhirElement(reader, "contained")) { result.Contained = new List <Hl7.Fhir.Model.Resource>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "contained")) { result.Contained.Add(ParserUtils.ParseContainedResource(reader, errors)); } reader.LeaveArray(); } // Parse element _id else if (ParserUtils.IsAtFhirElement(reader, "_id")) { result.LocalId = Id.Parse(reader.ReadPrimitiveContents("id")); } // Parse element identifier else if (ParserUtils.IsAtFhirElement(reader, "identifier")) { result.Identifier = new List <Hl7.Fhir.Model.Identifier>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "identifier")) { result.Identifier.Add(IdentifierParser.ParseIdentifier(reader, errors)); } reader.LeaveArray(); } // Parse element sponsor else if (ParserUtils.IsAtFhirElement(reader, "sponsor")) { result.Sponsor = FhirStringParser.ParseFhirString(reader, errors); } // Parse element title else if (ParserUtils.IsAtFhirElement(reader, "title")) { result.Title = FhirStringParser.ParseFhirString(reader, errors); } // Parse element description else if (ParserUtils.IsAtFhirElement(reader, "description")) { result.Description = FhirStringParser.ParseFhirString(reader, errors); } // Parse element type else if (ParserUtils.IsAtFhirElement(reader, "type")) { result.Type = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element condition else if (ParserUtils.IsAtFhirElement(reader, "condition")) { result.Condition = new List <Hl7.Fhir.Model.CodeableConcept>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "condition")) { result.Condition.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors)); } reader.LeaveArray(); } // Parse element treatment else if (ParserUtils.IsAtFhirElement(reader, "treatment")) { result.Treatment = new List <Hl7.Fhir.Model.Study.StudyTreatmentComponent>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "treatment")) { result.Treatment.Add(StudyParser.ParseStudyTreatmentComponent(reader, errors)); } reader.LeaveArray(); } // Parse element controlType else if (ParserUtils.IsAtFhirElement(reader, "controlType")) { result.ControlType = new List <Hl7.Fhir.Model.CodeableConcept>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "controlType")) { result.ControlType.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors)); } reader.LeaveArray(); } // Parse element objective else if (ParserUtils.IsAtFhirElement(reader, "objective")) { result.Objective = new List <Hl7.Fhir.Model.FhirString>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "objective")) { result.Objective.Add(FhirStringParser.ParseFhirString(reader, errors)); } reader.LeaveArray(); } // Parse element outcomeMeasure else if (ParserUtils.IsAtFhirElement(reader, "outcomeMeasure")) { result.OutcomeMeasure = new List <Hl7.Fhir.Model.FhirString>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "outcomeMeasure")) { result.OutcomeMeasure.Add(FhirStringParser.ParseFhirString(reader, errors)); } reader.LeaveArray(); } // Parse element eligibility else if (ParserUtils.IsAtFhirElement(reader, "eligibility")) { result.Eligibility = new List <Hl7.Fhir.Model.ResourceReference>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "eligibility")) { result.Eligibility.Add(ResourceReferenceParser.ParseResourceReference(reader, errors)); } reader.LeaveArray(); } // Parse element period else if (ParserUtils.IsAtFhirElement(reader, "period")) { result.Period = PeriodParser.ParsePeriod(reader, errors); } // Parse element duration else if (ParserUtils.IsAtFhirElement(reader, "duration")) { result.Duration = DurationParser.ParseDuration(reader, errors); } // Parse element plannedEnrollment else if (ParserUtils.IsAtFhirElement(reader, "plannedEnrollment")) { result.PlannedEnrollment = IntegerParser.ParseInteger(reader, errors); } // Parse element intervention else if (ParserUtils.IsAtFhirElement(reader, "intervention")) { result.Intervention = StudyParser.ParseStudyInterventionComponent(reader, errors); } // Parse element protocol else if (ParserUtils.IsAtFhirElement(reader, "protocol")) { result.Protocol = new List <Hl7.Fhir.Model.ResourceReference>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "protocol")) { result.Protocol.Add(ResourceReferenceParser.ParseResourceReference(reader, errors)); } reader.LeaveArray(); } // Parse element dataStructure else if (ParserUtils.IsAtFhirElement(reader, "dataStructure")) { result.DataStructure = ResourceReferenceParser.ParseResourceReference(reader, errors); } // Parse element data else if (ParserUtils.IsAtFhirElement(reader, "data")) { result.Data = new List <Hl7.Fhir.Model.ResourceReference>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "data")) { result.Data.Add(ResourceReferenceParser.ParseResourceReference(reader, errors)); } reader.LeaveArray(); } else { errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader); reader.SkipSubElementsFor(currentElementName); result = null; } } reader.LeaveElement(); } catch (Exception ex) { errors.Add(ex.Message, reader); } return(result); }