Exemple #1
0
        public static void SerializeContact(Hl7.Fhir.Model.Contact value, IFhirWriter writer, bool summary)
        {
            writer.WriteStartComplexContent();

            // Serialize element _id
            if (value.LocalIdElement != null)
            {
                writer.WritePrimitiveContents("_id", value.LocalIdElement, XmlSerializationHint.Attribute);
            }

            // Serialize element extension
            if (value.Extension != null && !summary && value.Extension.Count > 0)
            {
                writer.WriteStartArrayElement("extension");
                foreach (var item in value.Extension)
                {
                    writer.WriteStartArrayMember("extension");
                    ExtensionSerializer.SerializeExtension(item, writer, summary);
                    writer.WriteEndArrayMember();
                }
                writer.WriteEndArrayElement();
            }

            // Serialize element system
            if (value.SystemElement != null)
            {
                writer.WriteStartElement("system");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.Contact.ContactSystem>(value.SystemElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element value
            if (value.ValueElement != null)
            {
                writer.WriteStartElement("value");
                FhirStringSerializer.SerializeFhirString(value.ValueElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element use
            if (value.UseElement != null)
            {
                writer.WriteStartElement("use");
                CodeSerializer.SerializeCode <Hl7.Fhir.Model.Contact.ContactUse>(value.UseElement, writer, summary);
                writer.WriteEndElement();
            }

            // Serialize element period
            if (value.Period != null)
            {
                writer.WriteStartElement("period");
                PeriodSerializer.SerializePeriod(value.Period, writer, summary);
                writer.WriteEndElement();
            }


            writer.WriteEndComplexContent();
        }
        /// <summary>
        /// Parse Contact
        /// </summary>
        public static Hl7.Fhir.Model.Contact ParseContact(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Contact existingInstance = null)
        {
            Hl7.Fhir.Model.Contact result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Contact();
            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.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element system
                else if (atName == "system")
                {
                    result.SystemElement = CodeParser.ParseCode <Hl7.Fhir.Model.Contact.ContactSystem>(reader, errors);
                }

                // Parse element value
                else if (atName == "value")
                {
                    result.ValueElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element use
                else if (atName == "use")
                {
                    result.UseElement = CodeParser.ParseCode <Hl7.Fhir.Model.Contact.ContactUse>(reader, errors);
                }

                // Parse element period
                else if (atName == "period")
                {
                    result.Period = PeriodParser.ParsePeriod(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();
            return(result);
        }
Exemple #3
0
 public void Collect(Definition definition, Contact contact)
 {
     Write(definition, Cast(contact.ValueElement));
 }
Exemple #4
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Organization;

            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 (ActiveElement != null)
            {
                dest.ActiveElement = (Hl7.Fhir.Model.FhirBoolean)ActiveElement.DeepCopy();
            }
            if (Type != null)
            {
                dest.Type = new List <Hl7.Fhir.Model.CodeableConcept>(Type.DeepCopy());
            }
            if (NameElement != null)
            {
                dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
            }
            if (AliasElement != null)
            {
                dest.AliasElement = new List <Hl7.Fhir.Model.FhirString>(AliasElement.DeepCopy());
            }
            if (Telecom != null)
            {
                dest.Telecom = new List <Hl7.Fhir.Model.ContactPoint>(Telecom.DeepCopy());
            }
            if (Address != null)
            {
                dest.Address = new List <Hl7.Fhir.Model.Address>(Address.DeepCopy());
            }
            if (PartOf != null)
            {
                dest.PartOf = (Hl7.Fhir.Model.ResourceReference)PartOf.DeepCopy();
            }
            if (Contact != null)
            {
                dest.Contact = new List <Hl7.Fhir.Model.Organization.ContactComponent>(Contact.DeepCopy());
            }
            if (Endpoint != null)
            {
                dest.Endpoint = new List <Hl7.Fhir.Model.ResourceReference>(Endpoint.DeepCopy());
            }
            return(dest);
        }
Exemple #5
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as SearchParameter;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (UrlElement != null)
            {
                dest.UrlElement = (Hl7.Fhir.Model.FhirUri)UrlElement.DeepCopy();
            }
            if (NameElement != null)
            {
                dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.ConformanceResourceStatus>)StatusElement.DeepCopy();
            }
            if (ExperimentalElement != null)
            {
                dest.ExperimentalElement = (Hl7.Fhir.Model.FhirBoolean)ExperimentalElement.DeepCopy();
            }
            if (PublisherElement != null)
            {
                dest.PublisherElement = (Hl7.Fhir.Model.FhirString)PublisherElement.DeepCopy();
            }
            if (Contact != null)
            {
                dest.Contact = new List <Hl7.Fhir.Model.SearchParameter.ContactComponent>(Contact.DeepCopy());
            }
            if (DateElement != null)
            {
                dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy();
            }
            if (RequirementsElement != null)
            {
                dest.RequirementsElement = (Hl7.Fhir.Model.FhirString)RequirementsElement.DeepCopy();
            }
            if (CodeElement != null)
            {
                dest.CodeElement = (Hl7.Fhir.Model.Code)CodeElement.DeepCopy();
            }
            if (BaseElement != null)
            {
                dest.BaseElement = (Code <Hl7.Fhir.Model.ResourceType>)BaseElement.DeepCopy();
            }
            if (TypeElement != null)
            {
                dest.TypeElement = (Code <Hl7.Fhir.Model.SearchParamType>)TypeElement.DeepCopy();
            }
            if (DescriptionElement != null)
            {
                dest.DescriptionElement = (Hl7.Fhir.Model.FhirString)DescriptionElement.DeepCopy();
            }
            if (XpathElement != null)
            {
                dest.XpathElement = (Hl7.Fhir.Model.FhirString)XpathElement.DeepCopy();
            }
            if (XpathUsageElement != null)
            {
                dest.XpathUsageElement = (Code <Hl7.Fhir.Model.SearchParameter.XPathUsageType>)XpathUsageElement.DeepCopy();
            }
            if (TargetElement != null)
            {
                dest.TargetElement = new List <Code <Hl7.Fhir.Model.ResourceType> >(TargetElement.DeepCopy());
            }
            return(dest);
        }
Exemple #6
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as CompartmentDefinition;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (UrlElement != null)
            {
                dest.UrlElement = (Hl7.Fhir.Model.FhirUri)UrlElement.DeepCopy();
            }
            if (NameElement != null)
            {
                dest.NameElement = (Hl7.Fhir.Model.FhirString)NameElement.DeepCopy();
            }
            if (TitleElement != null)
            {
                dest.TitleElement = (Hl7.Fhir.Model.FhirString)TitleElement.DeepCopy();
            }
            if (StatusElement != null)
            {
                dest.StatusElement = (Code <Hl7.Fhir.Model.PublicationStatus>)StatusElement.DeepCopy();
            }
            if (ExperimentalElement != null)
            {
                dest.ExperimentalElement = (Hl7.Fhir.Model.FhirBoolean)ExperimentalElement.DeepCopy();
            }
            if (DateElement != null)
            {
                dest.DateElement = (Hl7.Fhir.Model.FhirDateTime)DateElement.DeepCopy();
            }
            if (PublisherElement != null)
            {
                dest.PublisherElement = (Hl7.Fhir.Model.FhirString)PublisherElement.DeepCopy();
            }
            if (Contact != null)
            {
                dest.Contact = new List <Hl7.Fhir.Model.ContactDetail>(Contact.DeepCopy());
            }
            if (Description != null)
            {
                dest.Description = (Hl7.Fhir.Model.Markdown)Description.DeepCopy();
            }
            if (Purpose != null)
            {
                dest.Purpose = (Hl7.Fhir.Model.Markdown)Purpose.DeepCopy();
            }
            if (UseContext != null)
            {
                dest.UseContext = new List <Hl7.Fhir.Model.UsageContext>(UseContext.DeepCopy());
            }
            if (Jurisdiction != null)
            {
                dest.Jurisdiction = new List <Hl7.Fhir.Model.CodeableConcept>(Jurisdiction.DeepCopy());
            }
            if (CodeElement != null)
            {
                dest.CodeElement = (Code <Hl7.Fhir.Model.CompartmentType>)CodeElement.DeepCopy();
            }
            if (SearchElement != null)
            {
                dest.SearchElement = (Hl7.Fhir.Model.FhirBoolean)SearchElement.DeepCopy();
            }
            if (Resource != null)
            {
                dest.Resource = new List <Hl7.Fhir.Model.CompartmentDefinition.ResourceComponent>(Resource.DeepCopy());
            }
            return(dest);
        }
Exemple #7
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Device;

            if (dest != null)
            {
                base.CopyTo(dest);
                if (Identifier != null)
                {
                    dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
                }
                if (Type != null)
                {
                    dest.Type = (Hl7.Fhir.Model.CodeableConcept)Type.DeepCopy();
                }
                if (Note != null)
                {
                    dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
                }
                if (StatusElement != null)
                {
                    dest.StatusElement = (Code <Hl7.Fhir.Model.Device.DeviceStatus>)StatusElement.DeepCopy();
                }
                if (ManufacturerElement != null)
                {
                    dest.ManufacturerElement = (Hl7.Fhir.Model.FhirString)ManufacturerElement.DeepCopy();
                }
                if (ModelElement != null)
                {
                    dest.ModelElement = (Hl7.Fhir.Model.FhirString)ModelElement.DeepCopy();
                }
                if (VersionElement != null)
                {
                    dest.VersionElement = (Hl7.Fhir.Model.FhirString)VersionElement.DeepCopy();
                }
                if (ManufactureDateElement != null)
                {
                    dest.ManufactureDateElement = (Hl7.Fhir.Model.FhirDateTime)ManufactureDateElement.DeepCopy();
                }
                if (ExpiryElement != null)
                {
                    dest.ExpiryElement = (Hl7.Fhir.Model.FhirDateTime)ExpiryElement.DeepCopy();
                }
                if (UdiElement != null)
                {
                    dest.UdiElement = (Hl7.Fhir.Model.FhirString)UdiElement.DeepCopy();
                }
                if (LotNumberElement != null)
                {
                    dest.LotNumberElement = (Hl7.Fhir.Model.FhirString)LotNumberElement.DeepCopy();
                }
                if (Owner != null)
                {
                    dest.Owner = (Hl7.Fhir.Model.ResourceReference)Owner.DeepCopy();
                }
                if (Location != null)
                {
                    dest.Location = (Hl7.Fhir.Model.ResourceReference)Location.DeepCopy();
                }
                if (Patient != null)
                {
                    dest.Patient = (Hl7.Fhir.Model.ResourceReference)Patient.DeepCopy();
                }
                if (Contact != null)
                {
                    dest.Contact = new List <Hl7.Fhir.Model.ContactPoint>(Contact.DeepCopy());
                }
                if (UrlElement != null)
                {
                    dest.UrlElement = (Hl7.Fhir.Model.FhirUri)UrlElement.DeepCopy();
                }
                return(dest);
            }
            else
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }
        }