/// <summary>
        /// Parse PrescriptionMedicineInactiveIngredientComponent
        /// </summary>
        public static Prescription.PrescriptionMedicineInactiveIngredientComponent ParsePrescriptionMedicineInactiveIngredientComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionMedicineInactiveIngredientComponent existingInstance = null)
        {
            Prescription.PrescriptionMedicineInactiveIngredientComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionMedicineInactiveIngredientComponent();
            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 identification
                    else if (ParserUtils.IsAtFhirElement(reader, "identification"))
                    {
                        result.Identification = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                    }

                    // Parse element quantity
                    else if (ParserUtils.IsAtFhirElement(reader, "quantity", true))
                    {
                        result.Quantity = FhirParser.ParseElement(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 XdsEntryAuthenticatorComponent
        /// </summary>
        public static XdsEntry.XdsEntryAuthenticatorComponent ParseXdsEntryAuthenticatorComponent(IFhirReader reader, ErrorList errors, XdsEntry.XdsEntryAuthenticatorComponent existingInstance = null)
        {
            XdsEntry.XdsEntryAuthenticatorComponent result = existingInstance != null ? existingInstance : new XdsEntry.XdsEntryAuthenticatorComponent();
            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 name
                    else if (ParserUtils.IsAtFhirElement(reader, "name"))
                    {
                        result.Name = HumanNameParser.ParseHumanName(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);
        }
Пример #3
0
        /// <summary>
        /// Parse XdsEntryServiceComponent
        /// </summary>
        public static XdsEntry.XdsEntryServiceComponent ParseXdsEntryServiceComponent(IFhirReader reader, ErrorList errors, XdsEntry.XdsEntryServiceComponent existingInstance = null )
        {
            XdsEntry.XdsEntryServiceComponent result = existingInstance != null ? existingInstance : new XdsEntry.XdsEntryServiceComponent();
            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 start
                    else if( ParserUtils.IsAtFhirElement(reader, "start") )
                        result.Start = FhirDateTimeParser.ParseFhirDateTime(reader, errors);

                    // Parse element stop
                    else if( ParserUtils.IsAtFhirElement(reader, "stop") )
                        result.Stop = FhirDateTimeParser.ParseFhirDateTime(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;
        }
Пример #4
0
        /// <summary>
        /// Parse XdsEntry2
        /// </summary>
        public static XdsEntry2 ParseXdsEntry2(IFhirReader reader, ErrorList errors, XdsEntry2 existingInstance = null)
        {
            XdsEntry2 result = existingInstance != null ? existingInstance : new XdsEntry2();

            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 id
                    else if (ParserUtils.IsAtFhirElement(reader, "id"))
                    {
                        result.Id = IdentifierParser.ParseIdentifier(reader, errors);
                    }

                    // Parse element information
                    else if (ParserUtils.IsAtFhirElement(reader, "information"))
                    {
                        result.Information = DocumentInformationParser.ParseDocumentInformation(reader, errors);
                    }

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

                    // Parse element availability
                    else if (ParserUtils.IsAtFhirElement(reader, "availability"))
                    {
                        result.Availability = CodeParser.ParseCode(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 subject
                    else if (ParserUtils.IsAtFhirElement(reader, "subject"))
                    {
                        result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors);
                    }

                    // Parse element content
                    else if (ParserUtils.IsAtFhirElement(reader, "content"))
                    {
                        result.Content = AttachmentParser.ParseAttachment(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 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);
        }
Пример #6
0
        /// <summary>
        /// Parse Product
        /// </summary>
        public static Product ParseProduct(IFhirReader reader, ErrorList errors, Product existingInstance = null)
        {
            Product result = existingInstance != null ? existingInstance : new Product();

            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());
                    }

                    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 DocumentInformationEventComponent
        /// </summary>
        public static DocumentInformation.DocumentInformationEventComponent ParseDocumentInformationEventComponent(IFhirReader reader, ErrorList errors, DocumentInformation.DocumentInformationEventComponent existingInstance = null)
        {
            DocumentInformation.DocumentInformationEventComponent result = existingInstance != null ? existingInstance : new DocumentInformation.DocumentInformationEventComponent();
            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 code
                    else if (ParserUtils.IsAtFhirElement(reader, "code"))
                    {
                        result.Code = new List <CodeableConcept>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

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

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

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

                        reader.LeaveArray();
                    }

                    else
                    {
                        errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                        reader.SkipSubElementsFor(currentElementName);
                        result = null;
                    }
                }

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
        /// <summary>
        /// Parse PrescriptionAdministrationRequestDosageInstructionComponent
        /// </summary>
        public static Prescription.PrescriptionAdministrationRequestDosageInstructionComponent ParsePrescriptionAdministrationRequestDosageInstructionComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionAdministrationRequestDosageInstructionComponent existingInstance = null)
        {
            Prescription.PrescriptionAdministrationRequestDosageInstructionComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionAdministrationRequestDosageInstructionComponent();
            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 precondition
                    else if (ParserUtils.IsAtFhirElement(reader, "precondition"))
                    {
                        result.Precondition = new List <CodeableConcept>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element prn
                    else if (ParserUtils.IsAtFhirElement(reader, "prn"))
                    {
                        result.Prn = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                    }

                    // Parse element additionalInstruction
                    else if (ParserUtils.IsAtFhirElement(reader, "additionalInstruction"))
                    {
                        result.AdditionalInstruction = new List <CodeableConcept>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

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

                    // Parse element dose
                    else if (ParserUtils.IsAtFhirElement(reader, "dose", true))
                    {
                        result.Dose = FhirParser.ParseElement(reader, errors);
                    }

                    // Parse element rate
                    else if (ParserUtils.IsAtFhirElement(reader, "rate"))
                    {
                        result.Rate = QuantityParser.ParseQuantity(reader, errors);
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "schedule"))
                        {
                            result.Schedule.Add(ScheduleParser.ParseSchedule(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    else
                    {
                        errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                        reader.SkipSubElementsFor(currentElementName);
                        result = null;
                    }
                }

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
        /// <summary>
        /// Parse PrescriptionAdministrationRequestComponent
        /// </summary>
        public static Prescription.PrescriptionAdministrationRequestComponent ParsePrescriptionAdministrationRequestComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionAdministrationRequestComponent existingInstance = null )
        {
            Prescription.PrescriptionAdministrationRequestComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionAdministrationRequestComponent();
            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 description
                    else if( ParserUtils.IsAtFhirElement(reader, "description") )
                        result.Description = FhirStringParser.ParseFhirString(reader, errors);

                    // Parse element totalPeriodicDose
                    else if( ParserUtils.IsAtFhirElement(reader, "totalPeriodicDose") )
                        result.TotalPeriodicDose = RatioParser.ParseRatio(reader, errors);

                    // Parse element start
                    else if( ParserUtils.IsAtFhirElement(reader, "start") )
                        result.Start = FhirDateTimeParser.ParseFhirDateTime(reader, errors);

                    // Parse element end
                    else if( ParserUtils.IsAtFhirElement(reader, "end") )
                        result.End = FhirDateTimeParser.ParseFhirDateTime(reader, errors);

                    // Parse element duration
                    else if( ParserUtils.IsAtFhirElement(reader, "duration") )
                        result.Duration = QuantityParser.ParseQuantity(reader, errors);

                    // Parse element numberOfAdministrations
                    else if( ParserUtils.IsAtFhirElement(reader, "numberOfAdministrations") )
                        result.NumberOfAdministrations = IntegerParser.ParseInteger(reader, errors);

                    // Parse element dosageInstruction
                    else if( ParserUtils.IsAtFhirElement(reader, "dosageInstruction") )
                    {
                        result.DosageInstruction = new List<Prescription.PrescriptionAdministrationRequestDosageInstructionComponent>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "dosageInstruction") )
                            result.DosageInstruction.Add(PrescriptionParser.ParsePrescriptionAdministrationRequestDosageInstructionComponent(reader, errors));

                        reader.LeaveArray();
                    }

                    else
                    {
                        errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                        reader.SkipSubElementsFor(currentElementName);
                        result = null;
                    }
                }

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return result;
        }
Пример #10
0
        /// <summary>
        /// Parse XdsEntry2
        /// </summary>
        public static XdsEntry2 ParseXdsEntry2(IFhirReader reader, ErrorList errors, XdsEntry2 existingInstance = null )
        {
            XdsEntry2 result = existingInstance != null ? existingInstance : new XdsEntry2();
            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 id
                    else if( ParserUtils.IsAtFhirElement(reader, "id") )
                        result.Id = IdentifierParser.ParseIdentifier(reader, errors);

                    // Parse element information
                    else if( ParserUtils.IsAtFhirElement(reader, "information") )
                        result.Information = DocumentInformationParser.ParseDocumentInformation(reader, errors);

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

                    // Parse element availability
                    else if( ParserUtils.IsAtFhirElement(reader, "availability") )
                        result.Availability = CodeParser.ParseCode(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 subject
                    else if( ParserUtils.IsAtFhirElement(reader, "subject") )
                        result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors);

                    // Parse element content
                    else if( ParserUtils.IsAtFhirElement(reader, "content") )
                        result.Content = AttachmentParser.ParseAttachment(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 IssueReportIssueComponent
        /// </summary>
        public static IssueReport.IssueReportIssueComponent ParseIssueReportIssueComponent(IFhirReader reader, ErrorList errors, IssueReport.IssueReportIssueComponent existingInstance = null)
        {
            IssueReport.IssueReportIssueComponent result = existingInstance != null ? existingInstance : new IssueReport.IssueReportIssueComponent();
            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 severity
                    else if (ParserUtils.IsAtFhirElement(reader, "severity"))
                    {
                        result.Severity = CodeParser.ParseCode <IssueReport.IssueSeverity>(reader, errors);
                    }

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

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

                    // Parse element location
                    else if (ParserUtils.IsAtFhirElement(reader, "location"))
                    {
                        result.Location = new List <FhirString>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "location"))
                        {
                            result.Location.Add(FhirStringParser.ParseFhirString(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    else
                    {
                        errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                        reader.SkipSubElementsFor(currentElementName);
                        result = null;
                    }
                }

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
Пример #12
0
        /// <summary>
        /// Parse Provider
        /// </summary>
        public static Provider ParseProvider(IFhirReader reader, ErrorList errors, Provider existingInstance = null )
        {
            Provider result = existingInstance != null ? existingInstance : new Provider();
            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 identifier
                    else if( ParserUtils.IsAtFhirElement(reader, "identifier") )
                    {
                        result.Identifier = new List<Identifier>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "identifier") )
                            result.Identifier.Add(IdentifierParser.ParseIdentifier(reader, errors));

                        reader.LeaveArray();
                    }

                    // Parse element details
                    else if( ParserUtils.IsAtFhirElement(reader, "details") )
                        result.Details = DemographicsParser.ParseDemographics(reader, errors);

                    // Parse element organization
                    else if( ParserUtils.IsAtFhirElement(reader, "organization") )
                        result.Organization = ResourceReferenceParser.ParseResourceReference(reader, errors);

                    // Parse element role
                    else if( ParserUtils.IsAtFhirElement(reader, "role") )
                    {
                        result.Role = new List<CodeableConcept>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "role") )
                            result.Role.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors));

                        reader.LeaveArray();
                    }

                    // Parse element specialty
                    else if( ParserUtils.IsAtFhirElement(reader, "specialty") )
                    {
                        result.Specialty = new List<CodeableConcept>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "specialty") )
                            result.Specialty.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors));

                        reader.LeaveArray();
                    }

                    // Parse element period
                    else if( ParserUtils.IsAtFhirElement(reader, "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();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return result;
        }
        /// <summary>
        /// Parse IssueReportIssueComponent
        /// </summary>
        public static IssueReport.IssueReportIssueComponent ParseIssueReportIssueComponent(IFhirReader reader, ErrorList errors, IssueReport.IssueReportIssueComponent existingInstance = null )
        {
            IssueReport.IssueReportIssueComponent result = existingInstance != null ? existingInstance : new IssueReport.IssueReportIssueComponent();
            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 severity
                    else if( ParserUtils.IsAtFhirElement(reader, "severity") )
                        result.Severity = CodeParser.ParseCode<IssueReport.IssueSeverity>(reader, errors);

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

                    // Parse element details
                    else if( ParserUtils.IsAtFhirElement(reader, "details") )
                        result.Details = FhirStringParser.ParseFhirString(reader, errors);

                    // Parse element location
                    else if( ParserUtils.IsAtFhirElement(reader, "location") )
                    {
                        result.Location = new List<FhirString>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "location") )
                            result.Location.Add(FhirStringParser.ParseFhirString(reader, errors));

                        reader.LeaveArray();
                    }

                    else
                    {
                        errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                        reader.SkipSubElementsFor(currentElementName);
                        result = null;
                    }
                }

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return result;
        }
Пример #14
0
        /// <summary>
        /// Parse Provider
        /// </summary>
        public static Provider ParseProvider(IFhirReader reader, ErrorList errors, Provider existingInstance = null)
        {
            Provider result = existingInstance != null ? existingInstance : new Provider();

            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 identifier
                    else if (ParserUtils.IsAtFhirElement(reader, "identifier"))
                    {
                        result.Identifier = new List <Identifier>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "identifier"))
                        {
                            result.Identifier.Add(IdentifierParser.ParseIdentifier(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element details
                    else if (ParserUtils.IsAtFhirElement(reader, "details"))
                    {
                        result.Details = DemographicsParser.ParseDemographics(reader, errors);
                    }

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

                    // Parse element role
                    else if (ParserUtils.IsAtFhirElement(reader, "role"))
                    {
                        result.Role = new List <CodeableConcept>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element specialty
                    else if (ParserUtils.IsAtFhirElement(reader, "specialty"))
                    {
                        result.Specialty = new List <CodeableConcept>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element period
                    else if (ParserUtils.IsAtFhirElement(reader, "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();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
Пример #15
0
        /// <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 PrescriptionDispenseComponent
        /// </summary>
        public static Prescription.PrescriptionDispenseComponent ParsePrescriptionDispenseComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionDispenseComponent existingInstance = null)
        {
            Prescription.PrescriptionDispenseComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionDispenseComponent();
            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 repeats
                    else if (ParserUtils.IsAtFhirElement(reader, "repeats"))
                    {
                        result.Repeats = IntegerParser.ParseInteger(reader, errors);
                    }

                    // Parse element quantity
                    else if (ParserUtils.IsAtFhirElement(reader, "quantity"))
                    {
                        result.Quantity = QuantityParser.ParseQuantity(reader, errors);
                    }

                    // Parse element dispenser
                    else if (ParserUtils.IsAtFhirElement(reader, "dispenser"))
                    {
                        result.Dispenser = ResourceReferenceParser.ParseResourceReference(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 PrescriptionAdministrationRequestComponent
        /// </summary>
        public static Prescription.PrescriptionAdministrationRequestComponent ParsePrescriptionAdministrationRequestComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionAdministrationRequestComponent existingInstance = null)
        {
            Prescription.PrescriptionAdministrationRequestComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionAdministrationRequestComponent();
            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 description
                    else if (ParserUtils.IsAtFhirElement(reader, "description"))
                    {
                        result.Description = FhirStringParser.ParseFhirString(reader, errors);
                    }

                    // Parse element totalPeriodicDose
                    else if (ParserUtils.IsAtFhirElement(reader, "totalPeriodicDose"))
                    {
                        result.TotalPeriodicDose = RatioParser.ParseRatio(reader, errors);
                    }

                    // Parse element start
                    else if (ParserUtils.IsAtFhirElement(reader, "start"))
                    {
                        result.Start = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                    }

                    // Parse element end
                    else if (ParserUtils.IsAtFhirElement(reader, "end"))
                    {
                        result.End = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                    }

                    // Parse element duration
                    else if (ParserUtils.IsAtFhirElement(reader, "duration"))
                    {
                        result.Duration = QuantityParser.ParseQuantity(reader, errors);
                    }

                    // Parse element numberOfAdministrations
                    else if (ParserUtils.IsAtFhirElement(reader, "numberOfAdministrations"))
                    {
                        result.NumberOfAdministrations = IntegerParser.ParseInteger(reader, errors);
                    }

                    // Parse element dosageInstruction
                    else if (ParserUtils.IsAtFhirElement(reader, "dosageInstruction"))
                    {
                        result.DosageInstruction = new List <Prescription.PrescriptionAdministrationRequestDosageInstructionComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "dosageInstruction"))
                        {
                            result.DosageInstruction.Add(PrescriptionParser.ParsePrescriptionAdministrationRequestDosageInstructionComponent(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    else
                    {
                        errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                        reader.SkipSubElementsFor(currentElementName);
                        result = null;
                    }
                }

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
        /// <summary>
        /// Parse PrescriptionAdministrationRequestDosageInstructionComponent
        /// </summary>
        public static Prescription.PrescriptionAdministrationRequestDosageInstructionComponent ParsePrescriptionAdministrationRequestDosageInstructionComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionAdministrationRequestDosageInstructionComponent existingInstance = null )
        {
            Prescription.PrescriptionAdministrationRequestDosageInstructionComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionAdministrationRequestDosageInstructionComponent();
            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 precondition
                    else if( ParserUtils.IsAtFhirElement(reader, "precondition") )
                    {
                        result.Precondition = new List<CodeableConcept>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "precondition") )
                            result.Precondition.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors));

                        reader.LeaveArray();
                    }

                    // Parse element prn
                    else if( ParserUtils.IsAtFhirElement(reader, "prn") )
                        result.Prn = FhirBooleanParser.ParseFhirBoolean(reader, errors);

                    // Parse element additionalInstruction
                    else if( ParserUtils.IsAtFhirElement(reader, "additionalInstruction") )
                    {
                        result.AdditionalInstruction = new List<CodeableConcept>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "additionalInstruction") )
                            result.AdditionalInstruction.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors));

                        reader.LeaveArray();
                    }

                    // Parse element route
                    else if( ParserUtils.IsAtFhirElement(reader, "route") )
                        result.Route = CodeableConceptParser.ParseCodeableConcept(reader, errors);

                    // Parse element dose
                    else if( ParserUtils.IsAtFhirElement(reader, "dose", true) )
                        result.Dose = FhirParser.ParseElement(reader, errors);

                    // Parse element rate
                    else if( ParserUtils.IsAtFhirElement(reader, "rate") )
                        result.Rate = QuantityParser.ParseQuantity(reader, errors);

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

                        while( ParserUtils.IsAtArrayElement(reader, "schedule") )
                            result.Schedule.Add(ScheduleParser.ParseSchedule(reader, errors));

                        reader.LeaveArray();
                    }

                    else
                    {
                        errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                        reader.SkipSubElementsFor(currentElementName);
                        result = null;
                    }
                }

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return result;
        }
        /// <summary>
        /// Parse Prescription
        /// </summary>
        public static Prescription ParsePrescription(IFhirReader reader, ErrorList errors, Prescription existingInstance = null)
        {
            Prescription result = existingInstance != null ? existingInstance : new Prescription();

            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 identifier
                    else if (ParserUtils.IsAtFhirElement(reader, "identifier"))
                    {
                        result.Identifier = new List <Identifier>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "identifier"))
                        {
                            result.Identifier.Add(IdentifierParser.ParseIdentifier(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element status
                    else if (ParserUtils.IsAtFhirElement(reader, "status"))
                    {
                        result.Status = CodeParser.ParseCode <Prescription.PrescriptionStatus>(reader, errors);
                    }

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

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

                    // Parse element prescribed
                    else if (ParserUtils.IsAtFhirElement(reader, "prescribed"))
                    {
                        result.Prescribed = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                    }

                    // Parse element dispense
                    else if (ParserUtils.IsAtFhirElement(reader, "dispense"))
                    {
                        result.Dispense = PrescriptionParser.ParsePrescriptionDispenseComponent(reader, errors);
                    }

                    // Parse element medicine
                    else if (ParserUtils.IsAtFhirElement(reader, "medicine"))
                    {
                        result.Medicine = PrescriptionParser.ParsePrescriptionMedicineComponent(reader, errors);
                    }

                    // Parse element administrationRequest
                    else if (ParserUtils.IsAtFhirElement(reader, "administrationRequest"))
                    {
                        result.AdministrationRequest = PrescriptionParser.ParsePrescriptionAdministrationRequestComponent(reader, errors);
                    }

                    // Parse element reason
                    else if (ParserUtils.IsAtFhirElement(reader, "reason"))
                    {
                        result.Reason = 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);
        }
        /// <summary>
        /// Parse PrescriptionDispenseComponent
        /// </summary>
        public static Prescription.PrescriptionDispenseComponent ParsePrescriptionDispenseComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionDispenseComponent existingInstance = null )
        {
            Prescription.PrescriptionDispenseComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionDispenseComponent();
            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 repeats
                    else if( ParserUtils.IsAtFhirElement(reader, "repeats") )
                        result.Repeats = IntegerParser.ParseInteger(reader, errors);

                    // Parse element quantity
                    else if( ParserUtils.IsAtFhirElement(reader, "quantity") )
                        result.Quantity = QuantityParser.ParseQuantity(reader, errors);

                    // Parse element dispenser
                    else if( ParserUtils.IsAtFhirElement(reader, "dispenser") )
                        result.Dispenser = ResourceReferenceParser.ParseResourceReference(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 DocumentInformationAttesterComponent
        /// </summary>
        public static DocumentInformation.DocumentInformationAttesterComponent ParseDocumentInformationAttesterComponent(IFhirReader reader, ErrorList errors, DocumentInformation.DocumentInformationAttesterComponent existingInstance = null)
        {
            DocumentInformation.DocumentInformationAttesterComponent result = existingInstance != null ? existingInstance : new DocumentInformation.DocumentInformationAttesterComponent();
            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 mode
                    else if (ParserUtils.IsAtFhirElement(reader, "mode"))
                    {
                        result.Mode = CodeParser.ParseCode <DocumentInformation.DocumentAttestationMode>(reader, errors);
                    }

                    // Parse element time
                    else if (ParserUtils.IsAtFhirElement(reader, "time"))
                    {
                        result.Time = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                    }

                    // Parse element party
                    else if (ParserUtils.IsAtFhirElement(reader, "party"))
                    {
                        result.Party = ResourceReferenceParser.ParseResourceReference(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 Prescription
        /// </summary>
        public static Prescription ParsePrescription(IFhirReader reader, ErrorList errors, Prescription existingInstance = null )
        {
            Prescription result = existingInstance != null ? existingInstance : new Prescription();
            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 identifier
                    else if( ParserUtils.IsAtFhirElement(reader, "identifier") )
                    {
                        result.Identifier = new List<Identifier>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "identifier") )
                            result.Identifier.Add(IdentifierParser.ParseIdentifier(reader, errors));

                        reader.LeaveArray();
                    }

                    // Parse element status
                    else if( ParserUtils.IsAtFhirElement(reader, "status") )
                        result.Status = CodeParser.ParseCode<Prescription.PrescriptionStatus>(reader, errors);

                    // Parse element patient
                    else if( ParserUtils.IsAtFhirElement(reader, "patient") )
                        result.Patient = ResourceReferenceParser.ParseResourceReference(reader, errors);

                    // Parse element prescriber
                    else if( ParserUtils.IsAtFhirElement(reader, "prescriber") )
                        result.Prescriber = ResourceReferenceParser.ParseResourceReference(reader, errors);

                    // Parse element prescribed
                    else if( ParserUtils.IsAtFhirElement(reader, "prescribed") )
                        result.Prescribed = FhirDateTimeParser.ParseFhirDateTime(reader, errors);

                    // Parse element dispense
                    else if( ParserUtils.IsAtFhirElement(reader, "dispense") )
                        result.Dispense = PrescriptionParser.ParsePrescriptionDispenseComponent(reader, errors);

                    // Parse element medicine
                    else if( ParserUtils.IsAtFhirElement(reader, "medicine") )
                        result.Medicine = PrescriptionParser.ParsePrescriptionMedicineComponent(reader, errors);

                    // Parse element administrationRequest
                    else if( ParserUtils.IsAtFhirElement(reader, "administrationRequest") )
                        result.AdministrationRequest = PrescriptionParser.ParsePrescriptionAdministrationRequestComponent(reader, errors);

                    // Parse element reason
                    else if( ParserUtils.IsAtFhirElement(reader, "reason") )
                        result.Reason = 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;
        }
        /// <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);
        }
        /// <summary>
        /// Parse PrescriptionMedicineInactiveIngredientComponent
        /// </summary>
        public static Prescription.PrescriptionMedicineInactiveIngredientComponent ParsePrescriptionMedicineInactiveIngredientComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionMedicineInactiveIngredientComponent existingInstance = null )
        {
            Prescription.PrescriptionMedicineInactiveIngredientComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionMedicineInactiveIngredientComponent();
            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 identification
                    else if( ParserUtils.IsAtFhirElement(reader, "identification") )
                        result.Identification = CodeableConceptParser.ParseCodeableConcept(reader, errors);

                    // Parse element quantity
                    else if( ParserUtils.IsAtFhirElement(reader, "quantity", true) )
                        result.Quantity = FhirParser.ParseElement(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;
        }
Пример #25
0
        /// <summary>
        /// Parse XdsFolder
        /// </summary>
        public static XdsFolder ParseXdsFolder(IFhirReader reader, ErrorList errors, XdsFolder existingInstance = null)
        {
            XdsFolder result = existingInstance != null ? existingInstance : new XdsFolder();

            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 code
                    else if (ParserUtils.IsAtFhirElement(reader, "code"))
                    {
                        result.Code = new List <Coding>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

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

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

                    // Parse element homeCommunity
                    else if (ParserUtils.IsAtFhirElement(reader, "homeCommunity"))
                    {
                        result.HomeCommunity = FhirStringParser.ParseFhirString(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 DocumentInformationAttesterComponent
        /// </summary>
        public static DocumentInformation.DocumentInformationAttesterComponent ParseDocumentInformationAttesterComponent(IFhirReader reader, ErrorList errors, DocumentInformation.DocumentInformationAttesterComponent existingInstance = null )
        {
            DocumentInformation.DocumentInformationAttesterComponent result = existingInstance != null ? existingInstance : new DocumentInformation.DocumentInformationAttesterComponent();
            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 mode
                    else if( ParserUtils.IsAtFhirElement(reader, "mode") )
                        result.Mode = CodeParser.ParseCode<DocumentInformation.DocumentAttestationMode>(reader, errors);

                    // Parse element time
                    else if( ParserUtils.IsAtFhirElement(reader, "time") )
                        result.Time = FhirDateTimeParser.ParseFhirDateTime(reader, errors);

                    // Parse element party
                    else if( ParserUtils.IsAtFhirElement(reader, "party") )
                        result.Party = ResourceReferenceParser.ParseResourceReference(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 DocumentInformationEventComponent
        /// </summary>
        public static DocumentInformation.DocumentInformationEventComponent ParseDocumentInformationEventComponent(IFhirReader reader, ErrorList errors, DocumentInformation.DocumentInformationEventComponent existingInstance = null )
        {
            DocumentInformation.DocumentInformationEventComponent result = existingInstance != null ? existingInstance : new DocumentInformation.DocumentInformationEventComponent();
            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 code
                    else if( ParserUtils.IsAtFhirElement(reader, "code") )
                    {
                        result.Code = new List<CodeableConcept>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "code") )
                            result.Code.Add(CodeableConceptParser.ParseCodeableConcept(reader, errors));

                        reader.LeaveArray();
                    }

                    // Parse element period
                    else if( ParserUtils.IsAtFhirElement(reader, "period") )
                        result.Period = PeriodParser.ParsePeriod(reader, errors);

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

                        while( ParserUtils.IsAtArrayElement(reader, "detail") )
                            result.Detail.Add(ResourceReferenceParser.ParseResourceReference(reader, errors));

                        reader.LeaveArray();
                    }

                    else
                    {
                        errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                        reader.SkipSubElementsFor(currentElementName);
                        result = null;
                    }
                }

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return result;
        }
        /// <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;
        }
        /// <summary>
        /// Parse AnatomicalLocation
        /// </summary>
        public static AnatomicalLocation ParseAnatomicalLocation(IFhirReader reader, ErrorList errors, AnatomicalLocation existingInstance = null )
        {
            AnatomicalLocation result = existingInstance != null ? existingInstance : new AnatomicalLocation();
            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());

                    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;
        }
Пример #30
0
        /// <summary>
        /// Parse XdsEntryAuthorComponent
        /// </summary>
        public static XdsEntry.XdsEntryAuthorComponent ParseXdsEntryAuthorComponent(IFhirReader reader, ErrorList errors, XdsEntry.XdsEntryAuthorComponent existingInstance = null )
        {
            XdsEntry.XdsEntryAuthorComponent result = existingInstance != null ? existingInstance : new XdsEntry.XdsEntryAuthorComponent();
            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 name
                    else if( ParserUtils.IsAtFhirElement(reader, "name") )
                        result.Name = HumanNameParser.ParseHumanName(reader, errors);

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

                    // Parse element role
                    else if( ParserUtils.IsAtFhirElement(reader, "role") )
                    {
                        result.Role = new List<FhirString>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "role") )
                            result.Role.Add(FhirStringParser.ParseFhirString(reader, errors));

                        reader.LeaveArray();
                    }

                    // Parse element specialty
                    else if( ParserUtils.IsAtFhirElement(reader, "specialty") )
                    {
                        result.Specialty = new List<FhirString>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "specialty") )
                            result.Specialty.Add(FhirStringParser.ParseFhirString(reader, errors));

                        reader.LeaveArray();
                    }

                    // Parse element institution
                    else if( ParserUtils.IsAtFhirElement(reader, "institution") )
                    {
                        result.Institution = new List<XdsEntry.XdsEntryAuthorInstitutionComponent>();
                        reader.EnterArray();

                        while( ParserUtils.IsAtArrayElement(reader, "institution") )
                            result.Institution.Add(XdsEntryParser.ParseXdsEntryAuthorInstitutionComponent(reader, errors));

                        reader.LeaveArray();
                    }

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

                        while( ParserUtils.IsAtArrayElement(reader, "contact") )
                            result.Contact.Add(ContactParser.ParseContact(reader, errors));

                        reader.LeaveArray();
                    }

                    else
                    {
                        errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                        reader.SkipSubElementsFor(currentElementName);
                        result = null;
                    }
                }

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return result;
        }