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

                while (reader.HasMoreElements())
                {
                    // Parse element extension
                    if (ParserUtils.IsAtFhirElement(reader, "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 (ParserUtils.IsAtFhirElement(reader, "_id"))
                    {
                        result.LocalId = Id.Parse(reader.ReadPrimitiveContents("id"));
                    }

                    // Parse element alternative
                    else if (ParserUtils.IsAtFhirElement(reader, "alternative"))
                    {
                        result.Alternative = new List <Hl7.Fhir.Model.IdRef>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "alternative"))
                        {
                            result.Alternative.Add(IdRefParser.ParseIdRef(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element component
                    else if (ParserUtils.IsAtFhirElement(reader, "component"))
                    {
                        result.Component = new List <Hl7.Fhir.Model.Protocol.ProtocolStepActivityComponentComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "component"))
                        {
                            result.Component.Add(ProtocolParser.ParseProtocolStepActivityComponentComponent(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element following
                    else if (ParserUtils.IsAtFhirElement(reader, "following"))
                    {
                        result.Following = new List <Hl7.Fhir.Model.IdRef>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "following"))
                        {
                            result.Following.Add(IdRefParser.ParseIdRef(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element wait
                    else if (ParserUtils.IsAtFhirElement(reader, "wait"))
                    {
                        result.Wait = DurationParser.ParseDuration(reader, errors);
                    }

                    // Parse element detail
                    else if (ParserUtils.IsAtFhirElement(reader, "detail"))
                    {
                        result.Detail = ActivityDefinitionParser.ParseActivityDefinition(reader, errors);
                    }

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

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
        /// <summary>
        /// Parse ProtocolStepComponent
        /// </summary>
        public static Hl7.Fhir.Model.Protocol.ProtocolStepComponent ParseProtocolStepComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Protocol.ProtocolStepComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Protocol.ProtocolStepComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Protocol.ProtocolStepComponent();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

                while (reader.HasMoreElements())
                {
                    // Parse element extension
                    if (ParserUtils.IsAtFhirElement(reader, "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 (ParserUtils.IsAtFhirElement(reader, "_id"))
                    {
                        result.LocalId = Id.Parse(reader.ReadPrimitiveContents("id"));
                    }

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

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

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

                    // Parse element precondition
                    else if (ParserUtils.IsAtFhirElement(reader, "precondition"))
                    {
                        result.Precondition = ProtocolParser.ParseProtocolStepPreconditionComponent(reader, errors);
                    }

                    // Parse element exit
                    else if (ParserUtils.IsAtFhirElement(reader, "exit"))
                    {
                        result.Exit = ProtocolParser.ParseProtocolStepPreconditionComponent(reader, errors);
                    }

                    // Parse element firstActivity
                    else if (ParserUtils.IsAtFhirElement(reader, "firstActivity"))
                    {
                        result.FirstActivity = IdRefParser.ParseIdRef(reader, errors);
                    }

                    // Parse element activity
                    else if (ParserUtils.IsAtFhirElement(reader, "activity"))
                    {
                        result.Activity = new List <Hl7.Fhir.Model.Protocol.ProtocolStepActivityComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "activity"))
                        {
                            result.Activity.Add(ProtocolParser.ParseProtocolStepActivityComponent(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element next
                    else if (ParserUtils.IsAtFhirElement(reader, "next"))
                    {
                        result.Next = new List <Hl7.Fhir.Model.Protocol.ProtocolStepNextComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "next"))
                        {
                            result.Next.Add(ProtocolParser.ParseProtocolStepNextComponent(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. 3
0
        /// <summary>
        /// Parse Visit
        /// </summary>
        public static Hl7.Fhir.Model.Visit ParseVisit(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Visit existingInstance = null)
        {
            Hl7.Fhir.Model.Visit result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Visit();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

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

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

                        reader.LeaveArray();
                    }

                    // Parse element language
                    else if (atName == "language")
                    {
                        result.Language = 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.LocalId = 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.Status = CodeParser.ParseCode <Hl7.Fhir.Model.Visit.EncounterState>(reader, errors);
                    }

                    // Parse element class
                    else if (atName == "class")
                    {
                        result.Class = CodeParser.ParseCode <Hl7.Fhir.Model.Visit.EncounterClass>(reader, errors);
                    }

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

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

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

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

                        reader.LeaveArray();
                    }

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

                    // Parse element length
                    else if (atName == "length")
                    {
                        result.Length = DurationParser.ParseDuration(reader, errors);
                    }

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

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

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

                    // Parse element hospitalization
                    else if (atName == "hospitalization")
                    {
                        result.Hospitalization = VisitParser.ParseVisitHospitalizationComponent(reader, errors);
                    }

                    // Parse element location
                    else if (atName == "location")
                    {
                        result.Location = new List <Hl7.Fhir.Model.Visit.VisitLocationComponent>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

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

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

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// Parse Study
        /// </summary>
        public static Hl7.Fhir.Model.Study ParseStudy(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Study existingInstance = null)
        {
            Hl7.Fhir.Model.Study result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Study();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

                while (reader.HasMoreElements())
                {
                    // Parse element extension
                    if (ParserUtils.IsAtFhirElement(reader, "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 (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 <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 (ParserUtils.IsAtFhirElement(reader, "_id"))
                    {
                        result.LocalId = Id.Parse(reader.ReadPrimitiveContents("id"));
                    }

                    // Parse element identifier
                    else if (ParserUtils.IsAtFhirElement(reader, "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 sponsor
                    else if (ParserUtils.IsAtFhirElement(reader, "sponsor"))
                    {
                        result.Sponsor = FhirStringParser.ParseFhirString(reader, errors);
                    }

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

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

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

                    // Parse element condition
                    else if (ParserUtils.IsAtFhirElement(reader, "condition"))
                    {
                        result.Condition = new List <Hl7.Fhir.Model.CodeableConcept>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element treatment
                    else if (ParserUtils.IsAtFhirElement(reader, "treatment"))
                    {
                        result.Treatment = new List <Hl7.Fhir.Model.Study.StudyTreatmentComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "treatment"))
                        {
                            result.Treatment.Add(StudyParser.ParseStudyTreatmentComponent(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element controlType
                    else if (ParserUtils.IsAtFhirElement(reader, "controlType"))
                    {
                        result.ControlType = new List <Hl7.Fhir.Model.CodeableConcept>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element objective
                    else if (ParserUtils.IsAtFhirElement(reader, "objective"))
                    {
                        result.Objective = new List <Hl7.Fhir.Model.FhirString>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element outcomeMeasure
                    else if (ParserUtils.IsAtFhirElement(reader, "outcomeMeasure"))
                    {
                        result.OutcomeMeasure = new List <Hl7.Fhir.Model.FhirString>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element eligibility
                    else if (ParserUtils.IsAtFhirElement(reader, "eligibility"))
                    {
                        result.Eligibility = new List <Hl7.Fhir.Model.ResourceReference>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

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

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

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

                    // Parse element intervention
                    else if (ParserUtils.IsAtFhirElement(reader, "intervention"))
                    {
                        result.Intervention = StudyParser.ParseStudyInterventionComponent(reader, errors);
                    }

                    // Parse element protocol
                    else if (ParserUtils.IsAtFhirElement(reader, "protocol"))
                    {
                        result.Protocol = new List <Hl7.Fhir.Model.ResourceReference>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

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

                    // Parse element data
                    else if (ParserUtils.IsAtFhirElement(reader, "data"))
                    {
                        result.Data = new List <Hl7.Fhir.Model.ResourceReference>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

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

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
        /// <summary>
        /// Parse Picture
        /// </summary>
        public static Hl7.Fhir.Model.Picture ParsePicture(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Picture existingInstance = null)
        {
            Hl7.Fhir.Model.Picture result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Picture();
            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 dateTime
                else if (atName == "dateTime")
                {
                    result.DateTimeElement = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                }

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

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

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

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

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

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

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

                // Parse element modality
                else if (atName == "modality")
                {
                    result.ModalityElement = CodeParser.ParseCode <Hl7.Fhir.Model.Picture.PictureType>(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 bits
                else if (atName == "bits")
                {
                    result.BitsElement = IntegerParser.ParseInteger(reader, errors);
                }

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

                // Parse element frameDelay
                else if (atName == "frameDelay")
                {
                    result.FrameDelay = DurationParser.ParseDuration(reader, errors);
                }

                // Parse element view
                else if (atName == "view")
                {
                    result.View = CodeableConceptParser.ParseCodeableConcept(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 MedicationPrescriptionDispenseComponent
        /// </summary>
        public static Hl7.Fhir.Model.MedicationPrescription.MedicationPrescriptionDispenseComponent ParseMedicationPrescriptionDispenseComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationPrescription.MedicationPrescriptionDispenseComponent existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationPrescription.MedicationPrescriptionDispenseComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationPrescription.MedicationPrescriptionDispenseComponent();
            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 medication
                else if (atName == "medication")
                {
                    result.Medication = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

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

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

                // Parse element expectedSupplyDuration
                else if (atName == "expectedSupplyDuration")
                {
                    result.ExpectedSupplyDuration = DurationParser.ParseDuration(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
        internal static Element ParseElement(IFhirReader reader, ErrorList errors)
        {
            try
            {
                reader.MoveToContent();

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