/// <summary>
        /// Parse XdsEntry
        /// </summary>
        public static XdsEntry ParseXdsEntry(IFhirReader reader, ErrorList errors, XdsEntry existingInstance = null)
        {
            XdsEntry result = existingInstance != null ? existingInstance : new XdsEntry();

            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

                while (reader.HasMoreElements())
                {
                    // Parse element extension
                    if (ParserUtils.IsAtFhirElement(reader, "extension"))
                    {
                        result.Extension = new List <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 <Resource>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "contained"))
                        {
                            result.Contained.Add(ParserUtils.ParseContainedResource(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element internalId
                    else if (reader.IsAtRefIdElement())
                    {
                        result.InternalId = Id.Parse(reader.ReadRefIdContents());
                    }

                    // Parse element url
                    else if (ParserUtils.IsAtFhirElement(reader, "url"))
                    {
                        result.Url = FhirUriParser.ParseFhirUri(reader, errors);
                    }

                    // Parse element repositoryId
                    else if (ParserUtils.IsAtFhirElement(reader, "repositoryId"))
                    {
                        result.RepositoryId = FhirUriParser.ParseFhirUri(reader, errors);
                    }

                    // Parse element mimeType
                    else if (ParserUtils.IsAtFhirElement(reader, "mimeType"))
                    {
                        result.MimeType = FhirStringParser.ParseFhirString(reader, errors);
                    }

                    // Parse element format
                    else if (ParserUtils.IsAtFhirElement(reader, "format"))
                    {
                        result.Format = CodingParser.ParseCoding(reader, errors);
                    }

                    // Parse element class
                    else if (ParserUtils.IsAtFhirElement(reader, "class"))
                    {
                        result.Class = CodingParser.ParseCoding(reader, errors);
                    }

                    // Parse element type
                    else if (ParserUtils.IsAtFhirElement(reader, "type"))
                    {
                        result.Type = CodingParser.ParseCoding(reader, errors);
                    }

                    // Parse element title
                    else if (ParserUtils.IsAtFhirElement(reader, "title"))
                    {
                        result.Title = FhirStringParser.ParseFhirString(reader, errors);
                    }

                    // Parse element documentId
                    else if (ParserUtils.IsAtFhirElement(reader, "documentId"))
                    {
                        result.DocumentId = FhirUriParser.ParseFhirUri(reader, errors);
                    }

                    // Parse element availability
                    else if (ParserUtils.IsAtFhirElement(reader, "availability"))
                    {
                        result.Availability = CodeParser.ParseCode <XdsEntry.XdsEntryAvailability>(reader, errors);
                    }

                    // Parse element confidentialityCode
                    else if (ParserUtils.IsAtFhirElement(reader, "confidentialityCode"))
                    {
                        result.ConfidentialityCode = CodingParser.ParseCoding(reader, errors);
                    }

                    // Parse element created
                    else if (ParserUtils.IsAtFhirElement(reader, "created"))
                    {
                        result.Created = InstantParser.ParseInstant(reader, errors);
                    }

                    // Parse element event
                    else if (ParserUtils.IsAtFhirElement(reader, "event"))
                    {
                        result.Event = new List <Coding>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "event"))
                        {
                            result.Event.Add(CodingParser.ParseCoding(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element hash
                    else if (ParserUtils.IsAtFhirElement(reader, "hash"))
                    {
                        result.Hash = FhirStringParser.ParseFhirString(reader, errors);
                    }

                    // Parse element size
                    else if (ParserUtils.IsAtFhirElement(reader, "size"))
                    {
                        result.Size = FhirStringParser.ParseFhirString(reader, errors);
                    }

                    // Parse element lang
                    else if (ParserUtils.IsAtFhirElement(reader, "lang"))
                    {
                        result.Lang = FhirStringParser.ParseFhirString(reader, errors);
                    }

                    // Parse element folder
                    else if (ParserUtils.IsAtFhirElement(reader, "folder"))
                    {
                        result.Folder = new List <ResourceReference>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "folder"))
                        {
                            result.Folder.Add(ResourceReferenceParser.ParseResourceReference(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element patientId
                    else if (ParserUtils.IsAtFhirElement(reader, "patientId"))
                    {
                        result.PatientId = IdentifierParser.ParseIdentifier(reader, errors);
                    }

                    // Parse element sourcePatientId
                    else if (ParserUtils.IsAtFhirElement(reader, "sourcePatientId"))
                    {
                        result.SourcePatientId = IdentifierParser.ParseIdentifier(reader, errors);
                    }

                    // Parse element patientInfo
                    else if (ParserUtils.IsAtFhirElement(reader, "patientInfo"))
                    {
                        result.PatientInfo = ResourceReferenceParser.ParseResourceReference(reader, errors);
                    }

                    // Parse element author
                    else if (ParserUtils.IsAtFhirElement(reader, "author"))
                    {
                        result.Author = new List <XdsEntry.XdsEntryAuthorComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "author"))
                        {
                            result.Author.Add(XdsEntryParser.ParseXdsEntryAuthorComponent(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element authenticator
                    else if (ParserUtils.IsAtFhirElement(reader, "authenticator"))
                    {
                        result.Authenticator = XdsEntryParser.ParseXdsEntryAuthenticatorComponent(reader, errors);
                    }

                    // Parse element facilityType
                    else if (ParserUtils.IsAtFhirElement(reader, "facilityType"))
                    {
                        result.FacilityType = CodingParser.ParseCoding(reader, errors);
                    }

                    // Parse element practiceSetting
                    else if (ParserUtils.IsAtFhirElement(reader, "practiceSetting"))
                    {
                        result.PracticeSetting = CodingParser.ParseCoding(reader, errors);
                    }

                    // Parse element homeCommunity
                    else if (ParserUtils.IsAtFhirElement(reader, "homeCommunity"))
                    {
                        result.HomeCommunity = FhirUriParser.ParseFhirUri(reader, errors);
                    }

                    // Parse element service
                    else if (ParserUtils.IsAtFhirElement(reader, "service"))
                    {
                        result.Service = XdsEntryParser.ParseXdsEntryServiceComponent(reader, errors);
                    }

                    // Parse element comments
                    else if (ParserUtils.IsAtFhirElement(reader, "comments"))
                    {
                        result.Comments = 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);
        }
        /// <summary>
        /// Parse Message
        /// </summary>
        public static Hl7.Fhir.Model.Message ParseMessage(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Message existingInstance = null)
        {
            Hl7.Fhir.Model.Message result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Message();
            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 language
                else if (atName == "language")
                {
                    result.LanguageElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element text
                else if (atName == "text")
                {
                    result.Text = NarrativeParser.ParseNarrative(reader, errors);
                }

                // Parse element contained
                else if (atName == "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 (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element identifier
                else if (atName == "identifier")
                {
                    result.IdentifierElement = IdParser.ParseId(reader, errors);
                }

                // Parse element timestamp
                else if (atName == "timestamp")
                {
                    result.TimestampElement = InstantParser.ParseInstant(reader, errors);
                }

                // Parse element event
                else if (atName == "event")
                {
                    result.EventElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element response
                else if (atName == "response")
                {
                    result.Response = MessageParser.ParseMessageResponseComponent(reader, errors);
                }

                // Parse element source
                else if (atName == "source")
                {
                    result.Source = MessageParser.ParseMessageSourceComponent(reader, errors);
                }

                // Parse element destination
                else if (atName == "destination")
                {
                    result.Destination = MessageParser.ParseMessageDestinationComponent(reader, errors);
                }

                // Parse element enterer
                else if (atName == "enterer")
                {
                    result.Enterer = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element author
                else if (atName == "author")
                {
                    result.Author = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element receiver
                else if (atName == "receiver")
                {
                    result.Receiver = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element responsible
                else if (atName == "responsible")
                {
                    result.Responsible = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element effective
                else if (atName == "effective")
                {
                    result.Effective = PeriodParser.ParsePeriod(reader, errors);
                }

                // Parse element reason
                else if (atName == "reason")
                {
                    result.Reason = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element data
                else if (atName == "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();
            return(result);
        }
        /// <summary>
        /// Parse DocumentInformation
        /// </summary>
        public static DocumentInformation ParseDocumentInformation(IFhirReader reader, ErrorList errors, DocumentInformation existingInstance = null)
        {
            DocumentInformation result = existingInstance != null ? existingInstance : new DocumentInformation();

            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

                while (reader.HasMoreElements())
                {
                    // Parse element extension
                    if (ParserUtils.IsAtFhirElement(reader, "extension"))
                    {
                        result.Extension = new List <Extension>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "extension"))
                        {
                            result.Extension.Add(ExtensionParser.ParseExtension(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element internalId
                    else if (reader.IsAtRefIdElement())
                    {
                        result.InternalId = Id.Parse(reader.ReadRefIdContents());
                    }

                    // Parse element id
                    else if (ParserUtils.IsAtFhirElement(reader, "id"))
                    {
                        result.Id = IdentifierParser.ParseIdentifier(reader, errors);
                    }

                    // Parse element versionId
                    else if (ParserUtils.IsAtFhirElement(reader, "versionId"))
                    {
                        result.VersionId = IdentifierParser.ParseIdentifier(reader, errors);
                    }

                    // Parse element created
                    else if (ParserUtils.IsAtFhirElement(reader, "created"))
                    {
                        result.Created = InstantParser.ParseInstant(reader, errors);
                    }

                    // Parse element class
                    else if (ParserUtils.IsAtFhirElement(reader, "class"))
                    {
                        result.Class = CodingParser.ParseCoding(reader, errors);
                    }

                    // Parse element type
                    else if (ParserUtils.IsAtFhirElement(reader, "type"))
                    {
                        result.Type = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                    }

                    // Parse element title
                    else if (ParserUtils.IsAtFhirElement(reader, "title"))
                    {
                        result.Title = FhirStringParser.ParseFhirString(reader, errors);
                    }

                    // Parse element confidentiality
                    else if (ParserUtils.IsAtFhirElement(reader, "confidentiality"))
                    {
                        result.Confidentiality = CodingParser.ParseCoding(reader, errors);
                    }

                    // Parse element subject
                    else if (ParserUtils.IsAtFhirElement(reader, "subject"))
                    {
                        result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors);
                    }

                    // Parse element author
                    else if (ParserUtils.IsAtFhirElement(reader, "author"))
                    {
                        result.Author = new List <ResourceReference>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "author"))
                        {
                            result.Author.Add(ResourceReferenceParser.ParseResourceReference(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element attester
                    else if (ParserUtils.IsAtFhirElement(reader, "attester"))
                    {
                        result.Attester = new List <DocumentInformation.DocumentInformationAttesterComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "attester"))
                        {
                            result.Attester.Add(DocumentInformationParser.ParseDocumentInformationAttesterComponent(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element custodian
                    else if (ParserUtils.IsAtFhirElement(reader, "custodian"))
                    {
                        result.Custodian = ResourceReferenceParser.ParseResourceReference(reader, errors);
                    }

                    // Parse element event
                    else if (ParserUtils.IsAtFhirElement(reader, "event"))
                    {
                        result.Event = DocumentInformationParser.ParseDocumentInformationEventComponent(reader, errors);
                    }

                    // Parse element encounter
                    else if (ParserUtils.IsAtFhirElement(reader, "encounter"))
                    {
                        result.Encounter = ResourceReferenceParser.ParseResourceReference(reader, errors);
                    }

                    // Parse element facilityType
                    else if (ParserUtils.IsAtFhirElement(reader, "facilityType"))
                    {
                        result.FacilityType = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                    }

                    // Parse element practiceSetting
                    else if (ParserUtils.IsAtFhirElement(reader, "practiceSetting"))
                    {
                        result.PracticeSetting = CodeableConceptParser.ParseCodeableConcept(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);
        }
Esempio n. 4
0
        /// <summary>
        /// Parse Observation
        /// </summary>
        public static Hl7.Fhir.Model.Observation ParseObservation(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Observation existingInstance = null)
        {
            Hl7.Fhir.Model.Observation result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Observation();
            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 language
                else if (atName == "language")
                {
                    result.LanguageElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element text
                else if (atName == "text")
                {
                    result.Text = NarrativeParser.ParseNarrative(reader, errors);
                }

                // Parse element contained
                else if (atName == "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 (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element name
                else if (atName == "name")
                {
                    result.Name = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element value
                else if (atName.StartsWith("value"))
                {
                    result.Value = FhirParser.ParseElement(reader, errors);
                }

                // Parse element interpretation
                else if (atName == "interpretation")
                {
                    result.Interpretation = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

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

                // Parse element applies
                else if (atName.StartsWith("applies"))
                {
                    result.Applies = FhirParser.ParseElement(reader, errors);
                }

                // Parse element issued
                else if (atName == "issued")
                {
                    result.IssuedElement = InstantParser.ParseInstant(reader, errors);
                }

                // Parse element status
                else if (atName == "status")
                {
                    result.StatusElement = CodeParser.ParseCode <Hl7.Fhir.Model.ObservationStatus>(reader, errors);
                }

                // Parse element reliability
                else if (atName == "reliability")
                {
                    result.ReliabilityElement = CodeParser.ParseCode <Hl7.Fhir.Model.Observation.ObservationReliability>(reader, errors);
                }

                // Parse element bodySite
                else if (atName == "bodySite")
                {
                    result.BodySite = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element method
                else if (atName == "method")
                {
                    result.Method = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element identifier
                else if (atName == "identifier")
                {
                    result.Identifier = IdentifierParser.ParseIdentifier(reader, errors);
                }

                // Parse element subject
                else if (atName == "subject")
                {
                    result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element performer
                else if (atName == "performer")
                {
                    result.Performer = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element referenceRange
                else if (atName == "referenceRange")
                {
                    result.ReferenceRange = new List <Hl7.Fhir.Model.Observation.ObservationReferenceRangeComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "referenceRange"))
                    {
                        result.ReferenceRange.Add(ObservationParser.ParseObservationReferenceRangeComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element component
                else if (atName == "component")
                {
                    result.Component = new List <Hl7.Fhir.Model.Observation.ObservationComponentComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "component"))
                    {
                        result.Component.Add(ObservationParser.ParseObservationComponentComponent(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();
            return(result);
        }
        /// <summary>
        /// Parse ValueSetExpansionComponent
        /// </summary>
        public static Hl7.Fhir.Model.ValueSet.ValueSetExpansionComponent ParseValueSetExpansionComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.ValueSet.ValueSetExpansionComponent existingInstance = null)
        {
            Hl7.Fhir.Model.ValueSet.ValueSetExpansionComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.ValueSet.ValueSetExpansionComponent();
            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 timestamp
                else if (atName == "timestamp")
                {
                    result.TimestampElement = InstantParser.ParseInstant(reader, errors);
                }

                // Parse element contains
                else if (atName == "contains")
                {
                    result.Contains = new List <Hl7.Fhir.Model.ValueSet.ValueSetExpansionContainsComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "contains"))
                    {
                        result.Contains.Add(ValueSetParser.ParseValueSetExpansionContainsComponent(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();
            return(result);
        }
        /// <summary>
        /// Parse Document
        /// </summary>
        public static Hl7.Fhir.Model.Document ParseDocument(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Document existingInstance = null)
        {
            Hl7.Fhir.Model.Document result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Document();
            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 language
                else if (atName == "language")
                {
                    result.LanguageElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element text
                else if (atName == "text")
                {
                    result.Text = NarrativeParser.ParseNarrative(reader, errors);
                }

                // Parse element contained
                else if (atName == "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 (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element identifier
                else if (atName == "identifier")
                {
                    result.Identifier = IdentifierParser.ParseIdentifier(reader, errors);
                }

                // Parse element versionIdentifier
                else if (atName == "versionIdentifier")
                {
                    result.VersionIdentifier = IdentifierParser.ParseIdentifier(reader, errors);
                }

                // Parse element created
                else if (atName == "created")
                {
                    result.CreatedElement = InstantParser.ParseInstant(reader, errors);
                }

                // Parse element type
                else if (atName == "type")
                {
                    result.Type = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element subtype
                else if (atName == "subtype")
                {
                    result.Subtype = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

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

                // Parse element status
                else if (atName == "status")
                {
                    result.StatusElement = CodeParser.ParseCode <Hl7.Fhir.Model.Document.DocumentStatus>(reader, errors);
                }

                // Parse element confidentiality
                else if (atName == "confidentiality")
                {
                    result.Confidentiality = CodingParser.ParseCoding(reader, errors);
                }

                // Parse element subject
                else if (atName == "subject")
                {
                    result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element author
                else if (atName == "author")
                {
                    result.Author = new List <Hl7.Fhir.Model.ResourceReference>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "author"))
                    {
                        result.Author.Add(ResourceReferenceParser.ParseResourceReference(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element attester
                else if (atName == "attester")
                {
                    result.Attester = new List <Hl7.Fhir.Model.Document.DocumentAttesterComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "attester"))
                    {
                        result.Attester.Add(DocumentParser.ParseDocumentAttesterComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element custodian
                else if (atName == "custodian")
                {
                    result.Custodian = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element event
                else if (atName == "event")
                {
                    result.Event = DocumentParser.ParseDocumentEventComponent(reader, errors);
                }

                // Parse element encounter
                else if (atName == "encounter")
                {
                    result.Encounter = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element replaces
                else if (atName == "replaces")
                {
                    result.ReplacesElement = IdParser.ParseId(reader, errors);
                }

                // Parse element provenance
                else if (atName == "provenance")
                {
                    result.Provenance = new List <Hl7.Fhir.Model.ResourceReference>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "provenance"))
                    {
                        result.Provenance.Add(ResourceReferenceParser.ParseResourceReference(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element stylesheet
                else if (atName == "stylesheet")
                {
                    result.Stylesheet = AttachmentParser.ParseAttachment(reader, errors);
                }

                // Parse element representation
                else if (atName == "representation")
                {
                    result.Representation = AttachmentParser.ParseAttachment(reader, errors);
                }

                // Parse element section
                else if (atName == "section")
                {
                    result.Section = new List <Hl7.Fhir.Model.Document.SectionComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "section"))
                    {
                        result.Section.Add(DocumentParser.ParseSectionComponent(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();
            return(result);
        }
        /// <summary>
        /// Parse DocumentReference
        /// </summary>
        public static Hl7.Fhir.Model.DocumentReference ParseDocumentReference(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DocumentReference existingInstance = null)
        {
            Hl7.Fhir.Model.DocumentReference result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DocumentReference();
            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 language
                else if (atName == "language")
                {
                    result.LanguageElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element text
                else if (atName == "text")
                {
                    result.Text = NarrativeParser.ParseNarrative(reader, errors);
                }

                // Parse element contained
                else if (atName == "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 (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element masterIdentifier
                else if (atName == "masterIdentifier")
                {
                    result.MasterIdentifier = IdentifierParser.ParseIdentifier(reader, errors);
                }

                // Parse element identifier
                else if (atName == "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 subject
                else if (atName == "subject")
                {
                    result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element type
                else if (atName == "type")
                {
                    result.Type = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element subtype
                else if (atName == "subtype")
                {
                    result.Subtype = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element author
                else if (atName == "author")
                {
                    result.Author = new List <Hl7.Fhir.Model.ResourceReference>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "author"))
                    {
                        result.Author.Add(ResourceReferenceParser.ParseResourceReference(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element custodian
                else if (atName == "custodian")
                {
                    result.Custodian = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element authenticator
                else if (atName == "authenticator")
                {
                    result.Authenticator = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element created
                else if (atName == "created")
                {
                    result.CreatedElement = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                }

                // Parse element indexed
                else if (atName == "indexed")
                {
                    result.IndexedElement = InstantParser.ParseInstant(reader, errors);
                }

                // Parse element status
                else if (atName == "status")
                {
                    result.StatusElement = CodeParser.ParseCode <Hl7.Fhir.Model.DocumentReference.DocumentReferenceStatus>(reader, errors);
                }

                // Parse element docStatus
                else if (atName == "docStatus")
                {
                    result.DocStatus = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element supercedes
                else if (atName == "supercedes")
                {
                    result.Supercedes = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

                // Parse element confidentiality
                else if (atName == "confidentiality")
                {
                    result.Confidentiality = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element primaryLanguage
                else if (atName == "primaryLanguage")
                {
                    result.PrimaryLanguageElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element mimeType
                else if (atName == "mimeType")
                {
                    result.MimeTypeElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element format
                else if (atName == "format")
                {
                    result.Format = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element size
                else if (atName == "size")
                {
                    result.SizeElement = IntegerParser.ParseInteger(reader, errors);
                }

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

                // Parse element location
                else if (atName == "location")
                {
                    result.LocationElement = FhirUriParser.ParseFhirUri(reader, errors);
                }

                // Parse element service
                else if (atName == "service")
                {
                    result.Service = DocumentReferenceParser.ParseDocumentReferenceServiceComponent(reader, errors);
                }

                // Parse element context
                else if (atName == "context")
                {
                    result.Context = DocumentReferenceParser.ParseDocumentReferenceContextComponent(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);
        }
Esempio n. 8
0
        /// <summary>
        /// Parse SecurityEventEventComponent
        /// </summary>
        public static Hl7.Fhir.Model.SecurityEvent.SecurityEventEventComponent ParseSecurityEventEventComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.SecurityEvent.SecurityEventEventComponent existingInstance = null)
        {
            Hl7.Fhir.Model.SecurityEvent.SecurityEventEventComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.SecurityEvent.SecurityEventEventComponent();
            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 type
                else if (atName == "type")
                {
                    result.Type = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element subtype
                else if (atName == "subtype")
                {
                    result.Subtype = new List <Hl7.Fhir.Model.CodeableConcept>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "subtype"))
                    {
                        result.Subtype.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element action
                else if (atName == "action")
                {
                    result.ActionElement = CodeParser.ParseCode <Hl7.Fhir.Model.SecurityEvent.SecurityEventAction>(reader, errors);
                }

                // Parse element dateTime
                else if (atName == "dateTime")
                {
                    result.DateTimeElement = InstantParser.ParseInstant(reader, errors);
                }

                // Parse element outcome
                else if (atName == "outcome")
                {
                    result.OutcomeElement = CodeParser.ParseCode <Hl7.Fhir.Model.SecurityEvent.SecurityEventOutcome>(reader, errors);
                }

                // Parse element outcomeDesc
                else if (atName == "outcomeDesc")
                {
                    result.OutcomeDescElement = 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();
            return(result);
        }
        /// <summary>
        /// Parse Provenance
        /// </summary>
        public static Hl7.Fhir.Model.Provenance ParseProvenance(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Provenance existingInstance = null)
        {
            Hl7.Fhir.Model.Provenance result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Provenance();
            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 language
                else if (atName == "language")
                {
                    result.LanguageElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element text
                else if (atName == "text")
                {
                    result.Text = NarrativeParser.ParseNarrative(reader, errors);
                }

                // Parse element contained
                else if (atName == "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 (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element target
                else if (atName == "target")
                {
                    result.Target = new List <Hl7.Fhir.Model.ResourceReference>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "target"))
                    {
                        result.Target.Add(ResourceReferenceParser.ParseResourceReference(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element period
                else if (atName == "period")
                {
                    result.Period = PeriodParser.ParsePeriod(reader, errors);
                }

                // Parse element recorded
                else if (atName == "recorded")
                {
                    result.RecordedElement = InstantParser.ParseInstant(reader, errors);
                }

                // Parse element reason
                else if (atName == "reason")
                {
                    result.Reason = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element location
                else if (atName == "location")
                {
                    result.Location = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element policy
                else if (atName == "policy")
                {
                    result.PolicyElement = new List <Hl7.Fhir.Model.FhirUri>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "policy"))
                    {
                        result.PolicyElement.Add(FhirUriParser.ParseFhirUri(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element agent
                else if (atName == "agent")
                {
                    result.Agent = new List <Hl7.Fhir.Model.Provenance.ProvenanceAgentComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "agent"))
                    {
                        result.Agent.Add(ProvenanceParser.ParseProvenanceAgentComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element entity
                else if (atName == "entity")
                {
                    result.Entity = new List <Hl7.Fhir.Model.Provenance.ProvenanceEntityComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "entity"))
                    {
                        result.Entity.Add(ProvenanceParser.ParseProvenanceEntityComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element signature
                else if (atName == "signature")
                {
                    result.SignatureElement = 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();
            return(result);
        }
Esempio n. 10
0
        /// <summary>
        /// Parse DeviceObservation
        /// </summary>
        public static Hl7.Fhir.Model.DeviceObservation ParseDeviceObservation(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DeviceObservation existingInstance = null)
        {
            Hl7.Fhir.Model.DeviceObservation result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DeviceObservation();
            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 language
                else if (atName == "language")
                {
                    result.LanguageElement = CodeParser.ParseCode(reader, errors);
                }

                // Parse element text
                else if (atName == "text")
                {
                    result.Text = NarrativeParser.ParseNarrative(reader, errors);
                }

                // Parse element contained
                else if (atName == "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 (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element code
                else if (atName == "code")
                {
                    result.Code = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

                // Parse element identifier
                else if (atName == "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 issued
                else if (atName == "issued")
                {
                    result.IssuedElement = InstantParser.ParseInstant(reader, errors);
                }

                // Parse element subject
                else if (atName == "subject")
                {
                    result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element device
                else if (atName == "device")
                {
                    result.Device = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element measurement
                else if (atName == "measurement")
                {
                    result.Measurement = new List <Hl7.Fhir.Model.ResourceReference>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "measurement"))
                    {
                        result.Measurement.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();
            return(result);
        }
Esempio n. 11
0
        internal static Element ParseElement(IFhirReader reader, ErrorList errors)
        {
            try
            {
                reader.MoveToContent();

                if (ParserUtils.IsAtFhirElementEndingWith(reader, "Age"))
                {
                    return(AgeParser.ParseAge(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Count"))
                {
                    return(CountParser.ParseCount(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Distance"))
                {
                    return(DistanceParser.ParseDistance(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Duration"))
                {
                    return(DurationParser.ParseDuration(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Money"))
                {
                    return(MoneyParser.ParseMoney(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Address"))
                {
                    return(AddressParser.ParseAddress(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Attachment"))
                {
                    return(AttachmentParser.ParseAttachment(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Choice"))
                {
                    return(ChoiceParser.ParseChoice(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "CodeableConcept"))
                {
                    return(CodeableConceptParser.ParseCodeableConcept(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Coding"))
                {
                    return(CodingParser.ParseCoding(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Contact"))
                {
                    return(ContactParser.ParseContact(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Extension"))
                {
                    return(ExtensionParser.ParseExtension(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "HumanName"))
                {
                    return(HumanNameParser.ParseHumanName(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Identifier"))
                {
                    return(IdentifierParser.ParseIdentifier(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Narrative"))
                {
                    return(NarrativeParser.ParseNarrative(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Period"))
                {
                    return(PeriodParser.ParsePeriod(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Quantity"))
                {
                    return(QuantityParser.ParseQuantity(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Range"))
                {
                    return(RangeParser.ParseRange(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Ratio"))
                {
                    return(RatioParser.ParseRatio(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Resource"))
                {
                    return(ResourceReferenceParser.ParseResourceReference(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "SampledData"))
                {
                    return(SampledDataParser.ParseSampledData(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Schedule"))
                {
                    return(ScheduleParser.ParseSchedule(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Base64Binary"))
                {
                    return(Base64BinaryParser.ParseBase64Binary(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Boolean"))
                {
                    return(FhirBooleanParser.ParseFhirBoolean(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Code"))
                {
                    return(CodeParser.ParseCode(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Date"))
                {
                    return(DateParser.ParseDate(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "DateTime"))
                {
                    return(FhirDateTimeParser.ParseFhirDateTime(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Decimal"))
                {
                    return(FhirDecimalParser.ParseFhirDecimal(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Id"))
                {
                    return(IdParser.ParseId(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Idref"))
                {
                    return(IdRefParser.ParseIdRef(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Instant"))
                {
                    return(InstantParser.ParseInstant(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Integer"))
                {
                    return(IntegerParser.ParseInteger(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Oid"))
                {
                    return(OidParser.ParseOid(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "String"))
                {
                    return(FhirStringParser.ParseFhirString(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Uri"))
                {
                    return(FhirUriParser.ParseFhirUri(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Uuid"))
                {
                    return(UuidParser.ParseUuid(reader, errors));
                }
                else if (ParserUtils.IsAtFhirElementEndingWith(reader, "Xhtml"))
                {
                    return(XHtmlParser.ParseXHtml(reader, errors));
                }
                else
                {
                    errors.Add(String.Format("Encountered unrecognized datatype '{0}'", reader.CurrentElementName), reader);
                    reader.SkipSubElementsFor(reader.CurrentElementName);
                    return(null);
                }
            }
            catch (Exception xe)
            {
                errors.Add(xe.Message, reader);
                return(null);
            }
        }