public static void SerializeVisitHospitalizationComponent(Hl7.Fhir.Model.Visit.VisitHospitalizationComponent value, IFhirWriter writer) { writer.WriteStartComplexContent(); // Serialize element _id if (value.LocalId != null) { writer.WritePrimitiveContents("_id", value.LocalId, XmlSerializationHint.Attribute); } // 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 preAdmissionIdentifier if (value.PreAdmissionIdentifier != null) { writer.WriteStartElement("preAdmissionIdentifier"); IdentifierSerializer.SerializeIdentifier(value.PreAdmissionIdentifier, writer); writer.WriteEndElement(); } // Serialize element preAdmissionTest if (value.PreAdmissionTest != null) { writer.WriteStartElement("preAdmissionTest"); CodeableConceptSerializer.SerializeCodeableConcept(value.PreAdmissionTest, writer); writer.WriteEndElement(); } // Serialize element origin if (value.Origin != null) { writer.WriteStartElement("origin"); ResourceReferenceSerializer.SerializeResourceReference(value.Origin, writer); writer.WriteEndElement(); } // Serialize element admitSource if (value.AdmitSource != null) { writer.WriteStartElement("admitSource"); CodeableConceptSerializer.SerializeCodeableConcept(value.AdmitSource, writer); writer.WriteEndElement(); } // Serialize element period if (value.Period != null) { writer.WriteStartElement("period"); PeriodSerializer.SerializePeriod(value.Period, writer); writer.WriteEndElement(); } // Serialize element accomodation if (value.Accomodation != null && value.Accomodation.Count > 0) { writer.WriteStartArrayElement("accomodation"); foreach (var item in value.Accomodation) { writer.WriteStartArrayMember("accomodation"); VisitSerializer.SerializeVisitHospitalizationAccomodationComponent(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element diet if (value.Diet != null) { writer.WriteStartElement("diet"); CodeableConceptSerializer.SerializeCodeableConcept(value.Diet, writer); writer.WriteEndElement(); } // Serialize element specialCourtesy if (value.SpecialCourtesy != null && value.SpecialCourtesy.Count > 0) { writer.WriteStartArrayElement("specialCourtesy"); foreach (var item in value.SpecialCourtesy) { writer.WriteStartArrayMember("specialCourtesy"); CodeableConceptSerializer.SerializeCodeableConcept(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element specialArrangement if (value.SpecialArrangement != null && value.SpecialArrangement.Count > 0) { writer.WriteStartArrayElement("specialArrangement"); foreach (var item in value.SpecialArrangement) { writer.WriteStartArrayMember("specialArrangement"); CodeableConceptSerializer.SerializeCodeableConcept(item, writer); writer.WriteEndArrayMember(); } writer.WriteEndArrayElement(); } // Serialize element destination if (value.Destination != null) { writer.WriteStartElement("destination"); ResourceReferenceSerializer.SerializeResourceReference(value.Destination, writer); writer.WriteEndElement(); } // Serialize element dischargeDisposition if (value.DischargeDisposition != null) { writer.WriteStartElement("dischargeDisposition"); CodeableConceptSerializer.SerializeCodeableConcept(value.DischargeDisposition, writer); writer.WriteEndElement(); } // Serialize element reAdmission if (value.ReAdmission != null) { writer.WriteStartElement("reAdmission"); FhirBooleanSerializer.SerializeFhirBoolean(value.ReAdmission, writer); writer.WriteEndElement(); } writer.WriteEndComplexContent(); }
/// <summary> /// Parse VisitHospitalizationComponent /// </summary> public static Hl7.Fhir.Model.Visit.VisitHospitalizationComponent ParseVisitHospitalizationComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Visit.VisitHospitalizationComponent existingInstance = null) { Hl7.Fhir.Model.Visit.VisitHospitalizationComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Visit.VisitHospitalizationComponent(); try { string currentElementName = reader.CurrentElementName; reader.EnterElement(); while (reader.HasMoreElements()) { var atName = reader.CurrentElementName; // Parse element extension if (atName == "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 _id else if (atName == "_id") { result.LocalId = Id.Parse(reader.ReadPrimitiveContents(typeof(Id))); } // Parse element preAdmissionIdentifier else if (atName == "preAdmissionIdentifier") { result.PreAdmissionIdentifier = IdentifierParser.ParseIdentifier(reader, errors); } // Parse element preAdmissionTest else if (atName == "preAdmissionTest") { result.PreAdmissionTest = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element origin else if (atName == "origin") { result.Origin = ResourceReferenceParser.ParseResourceReference(reader, errors); } // Parse element admitSource else if (atName == "admitSource") { result.AdmitSource = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element period else if (atName == "period") { result.Period = PeriodParser.ParsePeriod(reader, errors); } // Parse element accomodation else if (atName == "accomodation") { result.Accomodation = new List <Hl7.Fhir.Model.Visit.VisitHospitalizationAccomodationComponent>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "accomodation")) { result.Accomodation.Add(VisitParser.ParseVisitHospitalizationAccomodationComponent(reader, errors)); } reader.LeaveArray(); } // Parse element diet else if (atName == "diet") { result.Diet = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element specialCourtesy else if (atName == "specialCourtesy") { result.SpecialCourtesy = new List <Hl7.Fhir.Model.CodeableConcept>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "specialCourtesy")) { result.SpecialCourtesy.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors)); } reader.LeaveArray(); } // Parse element specialArrangement else if (atName == "specialArrangement") { result.SpecialArrangement = new List <Hl7.Fhir.Model.CodeableConcept>(); reader.EnterArray(); while (ParserUtils.IsAtArrayElement(reader, "specialArrangement")) { result.SpecialArrangement.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors)); } reader.LeaveArray(); } // Parse element destination else if (atName == "destination") { result.Destination = ResourceReferenceParser.ParseResourceReference(reader, errors); } // Parse element dischargeDisposition else if (atName == "dischargeDisposition") { result.DischargeDisposition = CodeableConceptParser.ParseCodeableConcept(reader, errors); } // Parse element reAdmission else if (atName == "reAdmission") { result.ReAdmission = FhirBooleanParser.ParseFhirBoolean(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); }