/// <summary> /// Parse Problem /// </summary> public static Hl7.Fhir.Model.Problem ParseProblem(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Problem existingInstance = null) { Hl7.Fhir.Model.Problem result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Problem(); 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 subject else if (ParserUtils.IsAtFhirElement(reader, "subject")) { result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors); } // Parse element visit else if (ParserUtils.IsAtFhirElement(reader, "visit")) { result.Visit = ResourceReferenceParser.ParseResourceReference(reader, errors); } // Parse element asserter else if (ParserUtils.IsAtFhirElement(reader, "asserter")) { result.Asserter = ResourceReferenceParser.ParseResourceReference(reader, errors); } // Parse element dateAsserted else if (ParserUtils.IsAtFhirElement(reader, "dateAsserted")) { result.DateAsserted = DateParser.ParseDate(reader, errors); } // Parse element code else if (ParserUtils.IsAtFhirElement(reader, "code")) { result.Code = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element category else if (ParserUtils.IsAtFhirElement(reader, "category")) { result.Category = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element status else if (ParserUtils.IsAtFhirElement(reader, "status")) { result.Status = CodeParser.ParseCode <Hl7.Fhir.Model.Problem.ProblemStatus>(reader, errors); } // Parse element certainty else if (ParserUtils.IsAtFhirElement(reader, "certainty")) { result.Certainty = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element severity else if (ParserUtils.IsAtFhirElement(reader, "severity")) { result.Severity = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element onset else if (ParserUtils.IsAtFhirElement(reader, "onset", true)) { result.Onset = FhirParser.ParseElement(reader, errors); } // Parse element abatement else if (ParserUtils.IsAtFhirElement(reader, "abatement", true)) { result.Abatement = FhirParser.ParseElement(reader, errors); } // Parse element stage else if (ParserUtils.IsAtFhirElement(reader, "stage")) { result.Stage = ProblemParser.ParseProblemStageComponent(reader, errors); } // Parse element evidence else if (ParserUtils.IsAtFhirElement(reader, "evidence")) { result.Evidence = new List <Hl7.Fhir.Model.Problem.ProblemEvidenceComponent>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "evidence")) { result.Evidence.Add(ProblemParser.ParseProblemEvidenceComponent(reader, errors)); } reader.LeaveArray(); } // Parse element location else if (ParserUtils.IsAtFhirElement(reader, "location")) { result.Location = new List <Hl7.Fhir.Model.Problem.ProblemLocationComponent>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "location")) { result.Location.Add(ProblemParser.ParseProblemLocationComponent(reader, errors)); } reader.LeaveArray(); } // Parse element relatedItem else if (ParserUtils.IsAtFhirElement(reader, "relatedItem")) { result.RelatedItem = new List <Hl7.Fhir.Model.Problem.ProblemRelatedItemComponent>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "relatedItem")) { result.RelatedItem.Add(ProblemParser.ParseProblemRelatedItemComponent(reader, errors)); } reader.LeaveArray(); } // Parse element notes else if (ParserUtils.IsAtFhirElement(reader, "notes")) { result.Notes = FhirStringParser.ParseFhirString(reader, errors); } 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); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as ClinicalImpression; 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 = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.ClinicalImpression.ClinicalImpressionStatus>)StatusElement.DeepCopy(); } if (StatusReason != null) { dest.StatusReason = (Hl7.Fhir.Model.CodeableConcept)StatusReason.DeepCopy(); } if (Code != null) { dest.Code = (Hl7.Fhir.Model.CodeableConcept)Code.DeepCopy(); } if (DescriptionElement != null) { dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy(); } if (Subject != null) { dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy(); } if (Encounter != null) { dest.Encounter = (Hl7.Fhir.Model.ResourceReference)Encounter.DeepCopy(); } if (Effective != null) { dest.Effective = (Hl7.Fhir.Model.DataType)Effective.DeepCopy(); } if (DateElement != null) { dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy(); } if (Assessor != null) { dest.Assessor = (Hl7.Fhir.Model.ResourceReference)Assessor.DeepCopy(); } if (Previous != null) { dest.Previous = (Hl7.Fhir.Model.ResourceReference)Previous.DeepCopy(); } if (Problem != null) { dest.Problem = new List <Hl7.Fhir.Model.ResourceReference>(Problem.DeepCopy()); } if (Investigation != null) { dest.Investigation = new List <Hl7.Fhir.Model.ClinicalImpression.InvestigationComponent>(Investigation.DeepCopy()); } if (ProtocolElement != null) { dest.ProtocolElement = new List <Hl7.Fhir.Model.FhirUri>(ProtocolElement.DeepCopy()); } if (SummaryElement != null) { dest.SummaryElement = (Hl7.Fhir.Model.FhirString)SummaryElement.DeepCopy(); } if (Finding != null) { dest.Finding = new List <Hl7.Fhir.Model.ClinicalImpression.FindingComponent>(Finding.DeepCopy()); } if (PrognosisCodeableConcept != null) { dest.PrognosisCodeableConcept = new List <Hl7.Fhir.Model.CodeableConcept>(PrognosisCodeableConcept.DeepCopy()); } if (PrognosisReference != null) { dest.PrognosisReference = new List <Hl7.Fhir.Model.ResourceReference>(PrognosisReference.DeepCopy()); } if (SupportingInfo != null) { dest.SupportingInfo = new List <Hl7.Fhir.Model.ResourceReference>(SupportingInfo.DeepCopy()); } if (Note != null) { dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy()); } return(dest); }
public static void SerializeProblem(Hl7.Fhir.Model.Problem value, IFhirWriter writer) { writer.WriteStartRootObject("Problem"); 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 subject if (value.Subject != null) { writer.WriteStartElement("subject"); ResourceReferenceSerializer.SerializeResourceReference(value.Subject, writer); writer.WriteEndElement(); } // Serialize element visit if (value.Visit != null) { writer.WriteStartElement("visit"); ResourceReferenceSerializer.SerializeResourceReference(value.Visit, writer); writer.WriteEndElement(); } // Serialize element asserter if (value.Asserter != null) { writer.WriteStartElement("asserter"); ResourceReferenceSerializer.SerializeResourceReference(value.Asserter, writer); writer.WriteEndElement(); } // Serialize element dateAsserted if (value.DateAsserted != null) { writer.WriteStartElement("dateAsserted"); DateSerializer.SerializeDate(value.DateAsserted, writer); writer.WriteEndElement(); } // Serialize element code if (value.Code != null) { writer.WriteStartElement("code"); CodeableConceptSerializer.SerializeCodeableConcept(value.Code, writer); writer.WriteEndElement(); } // Serialize element category if (value.Category != null) { writer.WriteStartElement("category"); CodeableConceptSerializer.SerializeCodeableConcept(value.Category, writer); writer.WriteEndElement(); } // Serialize element status if (value.Status != null) { writer.WriteStartElement("status"); CodeSerializer.SerializeCode <Hl7.Fhir.Model.Problem.ProblemStatus>(value.Status, writer); writer.WriteEndElement(); } // Serialize element certainty if (value.Certainty != null) { writer.WriteStartElement("certainty"); CodeableConceptSerializer.SerializeCodeableConcept(value.Certainty, writer); writer.WriteEndElement(); } // Serialize element severity if (value.Severity != null) { writer.WriteStartElement("severity"); CodeableConceptSerializer.SerializeCodeableConcept(value.Severity, writer); writer.WriteEndElement(); } // Serialize element onset if (value.Onset != null) { writer.WriteStartElement(SerializationUtil.BuildPolymorphicName("onset", value.Onset.GetType())); FhirSerializer.SerializeElement(value.Onset, writer); writer.WriteEndElement(); } // Serialize element abatement if (value.Abatement != null) { writer.WriteStartElement(SerializationUtil.BuildPolymorphicName("abatement", value.Abatement.GetType())); FhirSerializer.SerializeElement(value.Abatement, writer); writer.WriteEndElement(); } // Serialize element stage if (value.Stage != null) { writer.WriteStartElement("stage"); ProblemSerializer.SerializeProblemStageComponent(value.Stage, writer); writer.WriteEndElement(); } // Serialize element evidence if (value.Evidence != null && value.Evidence.Count > 0) { writer.WriteStartArrayElement("evidence"); foreach (var item in value.Evidence) { writer.WriteStartArrayMember("evidence"); ProblemSerializer.SerializeProblemEvidenceComponent(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element location if (value.Location != null && value.Location.Count > 0) { writer.WriteStartArrayElement("location"); foreach (var item in value.Location) { writer.WriteStartArrayMember("location"); ProblemSerializer.SerializeProblemLocationComponent(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element relatedItem if (value.RelatedItem != null && value.RelatedItem.Count > 0) { writer.WriteStartArrayElement("relatedItem"); foreach (var item in value.RelatedItem) { writer.WriteStartArrayMember("relatedItem"); ProblemSerializer.SerializeProblemRelatedItemComponent(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element notes if (value.Notes != null) { writer.WriteStartElement("notes"); FhirStringSerializer.SerializeFhirString(value.Notes, writer); writer.WriteEndElement(); } writer.WriteEndComplexContent(); writer.WriteEndRootObject(); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as ClinicalImpression; if (dest != null) { base.CopyTo(dest); if (Patient != null) { dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy(); } if (Assessor != null) { dest.Assessor = (Hl7.Fhir.Model.ResourceReference)Assessor.DeepCopy(); } if (StatusElement != null) { dest.StatusElement = (Code <Hl7.Fhir.Model.ClinicalImpression.ClinicalImpressionStatus>)StatusElement.DeepCopy(); } if (DateElement != null) { dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy(); } if (DescriptionElement != null) { dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy(); } if (Previous != null) { dest.Previous = (Hl7.Fhir.Model.ResourceReference)Previous.DeepCopy(); } if (Problem != null) { dest.Problem = new List <Hl7.Fhir.Model.ResourceReference>(Problem.DeepCopy()); } if (Trigger != null) { dest.Trigger = (Hl7.Fhir.Model.Element)Trigger.DeepCopy(); } if (Investigations != null) { dest.Investigations = new List <Hl7.Fhir.Model.ClinicalImpression.InvestigationsComponent>(Investigations.DeepCopy()); } if (ProtocolElement != null) { dest.ProtocolElement = (Hl7.Fhir.Model.FhirUri)ProtocolElement.DeepCopy(); } if (SummaryElement != null) { dest.SummaryElement = (Hl7.Fhir.Model.FhirString)SummaryElement.DeepCopy(); } if (Finding != null) { dest.Finding = new List <Hl7.Fhir.Model.ClinicalImpression.FindingComponent>(Finding.DeepCopy()); } if (Resolved != null) { dest.Resolved = new List <Hl7.Fhir.Model.CodeableConcept>(Resolved.DeepCopy()); } if (RuledOut != null) { dest.RuledOut = new List <Hl7.Fhir.Model.ClinicalImpression.RuledOutComponent>(RuledOut.DeepCopy()); } if (PrognosisElement != null) { dest.PrognosisElement = (Hl7.Fhir.Model.FhirString)PrognosisElement.DeepCopy(); } if (Plan != null) { dest.Plan = new List <Hl7.Fhir.Model.ResourceReference>(Plan.DeepCopy()); } if (Action != null) { dest.Action = new List <Hl7.Fhir.Model.ResourceReference>(Action.DeepCopy()); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }