/// <summary>
        /// Parse MedicationPrescription
        /// </summary>
        public static Hl7.Fhir.Model.MedicationPrescription ParseMedicationPrescription(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationPrescription existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationPrescription result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationPrescription();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

                // Parse element dosageInstruction
                else if (atName == "dosageInstruction")
                {
                    result.DosageInstruction = new List <Hl7.Fhir.Model.MedicationPrescription.MedicationPrescriptionDosageInstructionComponent>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element dispense
                else if (atName == "dispense")
                {
                    result.Dispense = MedicationPrescriptionParser.ParseMedicationPrescriptionDispenseComponent(reader, errors);
                }

                // Parse element substitution
                else if (atName == "substitution")
                {
                    result.Substitution = MedicationPrescriptionParser.ParseMedicationPrescriptionSubstitutionComponent(reader, errors);
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Parse OrderResponse
        /// </summary>
        public static Hl7.Fhir.Model.OrderResponse ParseOrderResponse(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.OrderResponse existingInstance = null)
        {
            Hl7.Fhir.Model.OrderResponse result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.OrderResponse();
            string currentElementName           = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

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

                // Parse element cost
                else if (atName == "cost")
                {
                    result.Cost = MoneyParser.ParseMoney(reader, errors);
                }

                // Parse element code
                else if (atName == "code")
                {
                    result.CodeElement = CodeParser.ParseCode <Hl7.Fhir.Model.OrderResponse.OrderOutcomeCode>(reader, errors);
                }

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

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

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

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse 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);
        }
Esempio n. 4
0
        /// <summary>
        /// Parse SecurityEventObjectComponent
        /// </summary>
        public static Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent ParseSecurityEventObjectComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent existingInstance = null)
        {
            Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

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

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

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

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

                // Parse element query
                else if (atName == "query")
                {
                    result.QueryElement = Base64BinaryParser.ParseBase64Binary(reader, errors);
                }

                // Parse element detail
                else if (atName == "detail")
                {
                    result.Detail = new List <Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectDetailComponent>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// Parse SecurityEvent
        /// </summary>
        public static Hl7.Fhir.Model.SecurityEvent ParseSecurityEvent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.SecurityEvent existingInstance = null)
        {
            Hl7.Fhir.Model.SecurityEvent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.SecurityEvent();
            string currentElementName           = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

                // Parse element participant
                else if (atName == "participant")
                {
                    result.Participant = new List <Hl7.Fhir.Model.SecurityEvent.SecurityEventParticipantComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "participant"))
                    {
                        result.Participant.Add(SecurityEventParser.ParseSecurityEventParticipantComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

                // Parse element object
                else if (atName == "object")
                {
                    result.Object = new List <Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "object"))
                    {
                        result.Object.Add(SecurityEventParser.ParseSecurityEventObjectComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse Provenance
        /// </summary>
        public static Hl7.Fhir.Model.Provenance ParseProvenance(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Provenance existingInstance = null)
        {
            Hl7.Fhir.Model.Provenance result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Provenance();
            string currentElementName        = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// Parse DeviceCapabilities
        /// </summary>
        public static Hl7.Fhir.Model.DeviceCapabilities ParseDeviceCapabilities(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DeviceCapabilities existingInstance = null)
        {
            Hl7.Fhir.Model.DeviceCapabilities result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DeviceCapabilities();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

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

                // Parse element virtualDevice
                else if (atName == "virtualDevice")
                {
                    result.VirtualDevice = new List <Hl7.Fhir.Model.DeviceCapabilities.DeviceCapabilitiesVirtualDeviceComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "virtualDevice"))
                    {
                        result.VirtualDevice.Add(DeviceCapabilitiesParser.ParseDeviceCapabilitiesVirtualDeviceComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 8
0
        /// <summary>
        /// Parse DeviceObservation
        /// </summary>
        public static Hl7.Fhir.Model.DeviceObservation ParseDeviceObservation(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DeviceObservation existingInstance = null)
        {
            Hl7.Fhir.Model.DeviceObservation result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DeviceObservation();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 9
0
        /// <summary>
        /// Parse SupplyDispenseComponent
        /// </summary>
        public static Hl7.Fhir.Model.Supply.SupplyDispenseComponent ParseSupplyDispenseComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Supply.SupplyDispenseComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Supply.SupplyDispenseComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Supply.SupplyDispenseComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

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

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 10
0
        /// <summary>
        /// Parse AdverseReactionExposureComponent
        /// </summary>
        public static Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent ParseAdverseReactionExposureComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent existingInstance = null)
        {
            Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

                // Parse element exposureType
                else if (atName == "exposureType")
                {
                    result.ExposureTypeElement = CodeParser.ParseCode <Hl7.Fhir.Model.AdverseReaction.ExposureType>(reader, errors);
                }

                // Parse element causalityExpectation
                else if (atName == "causalityExpectation")
                {
                    result.CausalityExpectationElement = CodeParser.ParseCode <Hl7.Fhir.Model.AdverseReaction.CausalityExpectation>(reader, errors);
                }

                // Parse element substance
                else if (atName == "substance")
                {
                    result.Substance = 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();
            return(result);
        }
Esempio n. 11
0
        /// <summary>
        /// Parse AdverseReaction
        /// </summary>
        public static Hl7.Fhir.Model.AdverseReaction ParseAdverseReaction(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.AdverseReaction existingInstance = null)
        {
            Hl7.Fhir.Model.AdverseReaction result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.AdverseReaction();
            string currentElementName             = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

                // Parse element didNotOccurFlag
                else if (atName == "didNotOccurFlag")
                {
                    result.DidNotOccurFlagElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

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

                // Parse element symptom
                else if (atName == "symptom")
                {
                    result.Symptom = new List <Hl7.Fhir.Model.AdverseReaction.AdverseReactionSymptomComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "symptom"))
                    {
                        result.Symptom.Add(AdverseReactionParser.ParseAdverseReactionSymptomComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element exposure
                else if (atName == "exposure")
                {
                    result.Exposure = new List <Hl7.Fhir.Model.AdverseReaction.AdverseReactionExposureComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "exposure"))
                    {
                        result.Exposure.Add(AdverseReactionParser.ParseAdverseReactionExposureComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 12
0
        /// <summary>
        /// Parse Attachment
        /// </summary>
        public static Hl7.Fhir.Model.Attachment ParseAttachment(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Attachment existingInstance = null)
        {
            Hl7.Fhir.Model.Attachment result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Attachment();
            string currentElementName        = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

                // Parse element data
                else if (atName == "data")
                {
                    result.DataElement = Base64BinaryParser.ParseBase64Binary(reader, errors);
                }

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

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

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

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

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 13
0
        /// <summary>
        /// Parse Choice
        /// </summary>
        public static Hl7.Fhir.Model.Choice ParseChoice(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Choice existingInstance = null)
        {
            Hl7.Fhir.Model.Choice result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Choice();
            string currentElementName    = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

                // Parse element option
                else if (atName == "option")
                {
                    result.Option = new List <Hl7.Fhir.Model.Choice.ChoiceOptionComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "option"))
                    {
                        result.Option.Add(ChoiceParser.ParseChoiceOptionComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element isOrdered
                else if (atName == "isOrdered")
                {
                    result.IsOrderedElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 14
0
        /// <summary>
        /// Parse List
        /// </summary>
        public static Hl7.Fhir.Model.List ParseList(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.List existingInstance = null)
        {
            Hl7.Fhir.Model.List result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.List();
            string currentElementName  = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

                // Parse element ordered
                else if (atName == "ordered")
                {
                    result.OrderedElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

                // Parse element mode
                else if (atName == "mode")
                {
                    result.ModeElement = CodeParser.ParseCode <Hl7.Fhir.Model.List.ListMode>(reader, errors);
                }

                // Parse element entry
                else if (atName == "entry")
                {
                    result.Entry = new List <Hl7.Fhir.Model.List.ListEntryComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "entry"))
                    {
                        result.Entry.Add(ListParser.ParseListEntryComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element emptyReason
                else if (atName == "emptyReason")
                {
                    result.EmptyReason = 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();
            return(result);
        }
        /// <summary>
        /// Parse MedicationAdministration
        /// </summary>
        public static Hl7.Fhir.Model.MedicationAdministration ParseMedicationAdministration(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationAdministration existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationAdministration result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationAdministration();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

                // Parse element wasNotGiven
                else if (atName == "wasNotGiven")
                {
                    result.WasNotGivenElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

                // Parse element dosage
                else if (atName == "dosage")
                {
                    result.Dosage = new List <Hl7.Fhir.Model.MedicationAdministration.MedicationAdministrationDosageComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "dosage"))
                    {
                        result.Dosage.Add(MedicationAdministrationParser.ParseMedicationAdministrationDosageComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 16
0
        /// <summary>
        /// Parse Supply
        /// </summary>
        public static Hl7.Fhir.Model.Supply ParseSupply(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Supply existingInstance = null)
        {
            Hl7.Fhir.Model.Supply result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Supply();
            string currentElementName    = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

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

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

                // Parse element dispense
                else if (atName == "dispense")
                {
                    result.Dispense = new List <Hl7.Fhir.Model.Supply.SupplyDispenseComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "dispense"))
                    {
                        result.Dispense.Add(SupplyParser.ParseSupplyDispenseComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse ProvenanceEntityComponent
        /// </summary>
        public static Hl7.Fhir.Model.Provenance.ProvenanceEntityComponent ParseProvenanceEntityComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Provenance.ProvenanceEntityComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Provenance.ProvenanceEntityComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Provenance.ProvenanceEntityComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element role
                else if (atName == "role")
                {
                    result.RoleElement = CodeParser.ParseCode <Hl7.Fhir.Model.Provenance.ProvenanceEntityRole>(reader, errors);
                }

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

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

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

                // Parse element agent
                else if (atName == "agent")
                {
                    result.Agent = ProvenanceParser.ParseProvenanceAgentComponent(reader, errors);
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 18
0
        /// <summary>
        /// Parse DiagnosticOrderItemComponent
        /// </summary>
        public static Hl7.Fhir.Model.DiagnosticOrder.DiagnosticOrderItemComponent ParseDiagnosticOrderItemComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DiagnosticOrder.DiagnosticOrderItemComponent existingInstance = null)
        {
            Hl7.Fhir.Model.DiagnosticOrder.DiagnosticOrderItemComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DiagnosticOrder.DiagnosticOrderItemComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

                // Parse element event
                else if (atName == "event")
                {
                    result.Event = new List <Hl7.Fhir.Model.DiagnosticOrder.DiagnosticOrderEventComponent>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 19
0
        /// <summary>
        /// Parse DeviceCapabilitiesVirtualDeviceChannelMetricInfoComponent
        /// </summary>
        public static Hl7.Fhir.Model.DeviceCapabilities.DeviceCapabilitiesVirtualDeviceChannelMetricInfoComponent ParseDeviceCapabilitiesVirtualDeviceChannelMetricInfoComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DeviceCapabilities.DeviceCapabilitiesVirtualDeviceChannelMetricInfoComponent existingInstance = null)
        {
            Hl7.Fhir.Model.DeviceCapabilities.DeviceCapabilitiesVirtualDeviceChannelMetricInfoComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DeviceCapabilities.DeviceCapabilitiesVirtualDeviceChannelMetricInfoComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element type
                else if (atName == "type")
                {
                    result.TypeElement = CodeParser.ParseCode <Hl7.Fhir.Model.DeviceCapabilities.DeviceDataType>(reader, errors);
                }

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

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

                // Parse element template
                else if (atName == "template")
                {
                    result.Template = SampledDataParser.ParseSampledData(reader, errors);
                }

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

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 20
0
        /// <summary>
        /// Parse DiagnosticOrder
        /// </summary>
        public static Hl7.Fhir.Model.DiagnosticOrder ParseDiagnosticOrder(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DiagnosticOrder existingInstance = null)
        {
            Hl7.Fhir.Model.DiagnosticOrder result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DiagnosticOrder();
            string currentElementName             = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

                // Parse element priority
                else if (atName == "priority")
                {
                    result.PriorityElement = CodeParser.ParseCode <Hl7.Fhir.Model.DiagnosticOrder.DiagnosticOrderPriority>(reader, errors);
                }

                // Parse element event
                else if (atName == "event")
                {
                    result.Event = new List <Hl7.Fhir.Model.DiagnosticOrder.DiagnosticOrderEventComponent>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element item
                else if (atName == "item")
                {
                    result.Item = new List <Hl7.Fhir.Model.DiagnosticOrder.DiagnosticOrderItemComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "item"))
                    {
                        result.Item.Add(DiagnosticOrderParser.ParseDiagnosticOrderItemComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 21
0
        /// <summary>
        /// Parse Order
        /// </summary>
        public static Hl7.Fhir.Model.Order ParseOrder(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Order existingInstance = null)
        {
            Hl7.Fhir.Model.Order result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Order();
            string currentElementName   = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

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

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

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

                // Parse element when
                else if (atName == "when")
                {
                    result.When = OrderParser.ParseOrderWhenComponent(reader, errors);
                }

                // Parse element detail
                else if (atName == "detail")
                {
                    result.Detail = new List <Hl7.Fhir.Model.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();
            return(result);
        }
        /// <summary>
        /// Parse Location
        /// </summary>
        public static Hl7.Fhir.Model.Location ParseLocation(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Location existingInstance = null)
        {
            Hl7.Fhir.Model.Location result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Location();
            string currentElementName      = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

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

                    reader.LeaveArray();
                }

                // Parse element telecom
                else if (atName == "telecom")
                {
                    result.Telecom = ContactParser.ParseContact(reader, errors);
                }

                // Parse element address
                else if (atName == "address")
                {
                    result.Address = AddressParser.ParseAddress(reader, errors);
                }

                // Parse element position
                else if (atName == "position")
                {
                    result.Position = LocationParser.ParseLocationPositionComponent(reader, errors);
                }

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

                // Parse element active
                else if (atName == "active")
                {
                    result.ActiveElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

                // Parse element partOf
                else if (atName == "partOf")
                {
                    result.PartOf = 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();
            return(result);
        }
Esempio n. 23
0
        /// <summary>
        /// Parse SecurityEventEventComponent
        /// </summary>
        public static Hl7.Fhir.Model.SecurityEvent.SecurityEventEventComponent ParseSecurityEventEventComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.SecurityEvent.SecurityEventEventComponent existingInstance = null)
        {
            Hl7.Fhir.Model.SecurityEvent.SecurityEventEventComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.SecurityEvent.SecurityEventEventComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 24
0
        /// <summary>
        /// Parse Media
        /// </summary>
        public static Hl7.Fhir.Model.Media ParseMedia(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Media existingInstance = null)
        {
            Hl7.Fhir.Model.Media result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Media();
            string currentElementName   = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element type
                else if (atName == "type")
                {
                    result.TypeElement = CodeParser.ParseCode <Hl7.Fhir.Model.Media.MediaType>(reader, errors);
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

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

                // Parse element content
                else if (atName == "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();
            return(result);
        }
        /// <summary>
        /// Parse Patient
        /// </summary>
        public static Hl7.Fhir.Model.Patient ParsePatient(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Patient existingInstance = null)
        {
            Hl7.Fhir.Model.Patient result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Patient();
            string currentElementName     = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

                    reader.LeaveArray();
                }

                // Parse element name
                else if (atName == "name")
                {
                    result.Name = new List <Hl7.Fhir.Model.HumanName>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "name"))
                    {
                        result.Name.Add(HumanNameParser.ParseHumanName(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element telecom
                else if (atName == "telecom")
                {
                    result.Telecom = new List <Hl7.Fhir.Model.Contact>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "telecom"))
                    {
                        result.Telecom.Add(ContactParser.ParseContact(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

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

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

                    while (ParserUtils.IsAtArrayElement(reader, "address"))
                    {
                        result.Address.Add(AddressParser.ParseAddress(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

                // Parse element photo
                else if (atName == "photo")
                {
                    result.Photo = new List <Hl7.Fhir.Model.Attachment>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "photo"))
                    {
                        result.Photo.Add(AttachmentParser.ParseAttachment(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element contact
                else if (atName == "contact")
                {
                    result.Contact = new List <Hl7.Fhir.Model.Patient.ContactComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "contact"))
                    {
                        result.Contact.Add(PatientParser.ParseContactComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element animal
                else if (atName == "animal")
                {
                    result.Animal = PatientParser.ParseAnimalComponent(reader, errors);
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

                // Parse element active
                else if (atName == "active")
                {
                    result.ActiveElement = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                }

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

            reader.LeaveElement();
            return(result);
        }
Esempio n. 26
0
        /// <summary>
        /// Parse HumanName
        /// </summary>
        public static Hl7.Fhir.Model.HumanName ParseHumanName(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.HumanName existingInstance = null)
        {
            Hl7.Fhir.Model.HumanName result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.HumanName();
            string currentElementName       = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

                // Parse element family
                else if (atName == "family")
                {
                    result.FamilyElement = new List <Hl7.Fhir.Model.FhirString>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element given
                else if (atName == "given")
                {
                    result.GivenElement = new List <Hl7.Fhir.Model.FhirString>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element prefix
                else if (atName == "prefix")
                {
                    result.PrefixElement = new List <Hl7.Fhir.Model.FhirString>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element suffix
                else if (atName == "suffix")
                {
                    result.SuffixElement = new List <Hl7.Fhir.Model.FhirString>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse DocumentReference
        /// </summary>
        public static Hl7.Fhir.Model.DocumentReference ParseDocumentReference(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DocumentReference existingInstance = null)
        {
            Hl7.Fhir.Model.DocumentReference result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DocumentReference();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

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

                // Parse element contained
                else if (atName == "contained")
                {
                    result.Contained = new List <Hl7.Fhir.Model.Resource>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                // Parse element context
                else if (atName == "context")
                {
                    result.Context = DocumentReferenceParser.ParseDocumentReferenceContextComponent(reader, errors);
                }

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse ImmunizationProfileRecommendationComponent
        /// </summary>
        public static Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationComponent ParseImmunizationProfileRecommendationComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationComponent existingInstance = null)
        {
            Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

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

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

                // Parse element forecastStatus
                else if (atName == "forecastStatus")
                {
                    result.ForecastStatusElement = CodeParser.ParseCode <Hl7.Fhir.Model.ImmunizationProfile.ImmunizationForecastStatus>(reader, errors);
                }

                // Parse element dateCriterion
                else if (atName == "dateCriterion")
                {
                    result.DateCriterion = new List <Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationDateCriterionComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "dateCriterion"))
                    {
                        result.DateCriterion.Add(ImmunizationProfileParser.ParseImmunizationProfileRecommendationDateCriterionComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element protocol
                else if (atName == "protocol")
                {
                    result.Protocol = ImmunizationProfileParser.ParseImmunizationProfileRecommendationProtocolComponent(reader, errors);
                }

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

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

                    reader.LeaveArray();
                }

                // Parse element supportingAdverseEventReport
                else if (atName == "supportingAdverseEventReport")
                {
                    result.SupportingAdverseEventReport = new List <Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationSupportingAdverseEventReportComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "supportingAdverseEventReport"))
                    {
                        result.SupportingAdverseEventReport.Add(ImmunizationProfileParser.ParseImmunizationProfileRecommendationSupportingAdverseEventReportComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse IssueReport
        /// </summary>
        public static IssueReport ParseIssueReport(IFhirReader reader, ErrorList errors, IssueReport existingInstance = null)
        {
            IssueReport result = existingInstance != null ? existingInstance : new IssueReport();

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

                        while (ParserUtils.IsAtArrayElement(reader, "issue"))
                        {
                            result.Issue.Add(IssueReportParser.ParseIssueReportIssueComponent(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 ScheduleRepeatComponent
        /// </summary>
        public static Hl7.Fhir.Model.Schedule.ScheduleRepeatComponent ParseScheduleRepeatComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Schedule.ScheduleRepeatComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Schedule.ScheduleRepeatComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Schedule.ScheduleRepeatComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

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

                // Parse element when
                else if (atName == "when")
                {
                    result.WhenElement = CodeParser.ParseCode <Hl7.Fhir.Model.Schedule.EventTiming>(reader, errors);
                }

                // Parse element duration
                else if (atName == "duration")
                {
                    result.DurationElement = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                }

                // Parse element units
                else if (atName == "units")
                {
                    result.UnitsElement = CodeParser.ParseCode <Hl7.Fhir.Model.Schedule.UnitsOfTime>(reader, errors);
                }

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

                // Parse element end
                else if (atName == "end")
                {
                    result.EndElement = 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();
            return(result);
        }