Пример #1
0
        /// <summary>
        /// Parse ImmunizationReactionComponent
        /// </summary>
        public static Hl7.Fhir.Model.Immunization.ImmunizationReactionComponent ParseImmunizationReactionComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Immunization.ImmunizationReactionComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Immunization.ImmunizationReactionComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Immunization.ImmunizationReactionComponent();
            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 date
                else if (atName == "date")
                {
                    result.DateElement = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                }

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

                // Parse element reported
                else if (atName == "reported")
                {
                    result.ReportedElement = 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);
        }
Пример #2
0
        /// <summary>
        /// Parse VisitHospitalizationAccomodationComponent
        /// </summary>
        public static Hl7.Fhir.Model.Visit.VisitHospitalizationAccomodationComponent ParseVisitHospitalizationAccomodationComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Visit.VisitHospitalizationAccomodationComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Visit.VisitHospitalizationAccomodationComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Visit.VisitHospitalizationAccomodationComponent();
            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 _id
                    else if (atName == "_id")
                    {
                        result.LocalId = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                    }

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

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

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

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// Parse MessageDestinationComponent
        /// </summary>
        public static Hl7.Fhir.Model.Message.MessageDestinationComponent ParseMessageDestinationComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Message.MessageDestinationComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Message.MessageDestinationComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Message.MessageDestinationComponent();
            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 name
                else if (atName == "name")
                {
                    result.NameElement = FhirStringParser.ParseFhirString(reader, errors);
                }

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

                // Parse element endpoint
                else if (atName == "endpoint")
                {
                    result.EndpointElement = 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);
        }
        /// <summary>
        /// Parse PractitionerQualificationComponent
        /// </summary>
        public static Hl7.Fhir.Model.Practitioner.PractitionerQualificationComponent ParsePractitionerQualificationComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Practitioner.PractitionerQualificationComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Practitioner.PractitionerQualificationComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Practitioner.PractitionerQualificationComponent();
            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 period
                else if (atName == "period")
                {
                    result.Period = PeriodParser.ParsePeriod(reader, errors);
                }

                // Parse element issuer
                else if (atName == "issuer")
                {
                    result.Issuer = 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);
        }
        /// <summary>
        /// Parse ConformanceDocumentComponent
        /// </summary>
        public static Hl7.Fhir.Model.Conformance.ConformanceDocumentComponent ParseConformanceDocumentComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Conformance.ConformanceDocumentComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Conformance.ConformanceDocumentComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Conformance.ConformanceDocumentComponent();
            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 mode
                else if (atName == "mode")
                {
                    result.ModeElement = CodeParser.ParseCode <Hl7.Fhir.Model.Conformance.DocumentMode>(reader, errors);
                }

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

                // Parse element profile
                else if (atName == "profile")
                {
                    result.Profile = 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);
        }
Пример #6
0
        /// <summary>
        /// Parse MedicationProductIngredientComponent
        /// </summary>
        public static Hl7.Fhir.Model.Medication.MedicationProductIngredientComponent ParseMedicationProductIngredientComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Medication.MedicationProductIngredientComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Medication.MedicationProductIngredientComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Medication.MedicationProductIngredientComponent();
            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 item
                else if (atName == "item")
                {
                    result.Item = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

                // Parse element amount
                else if (atName == "amount")
                {
                    result.Amount = RatioParser.ParseRatio(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 ResultGroupComponent
        /// </summary>
        public static Hl7.Fhir.Model.DiagnosticReport.ResultGroupComponent ParseResultGroupComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DiagnosticReport.ResultGroupComponent existingInstance = null)
        {
            Hl7.Fhir.Model.DiagnosticReport.ResultGroupComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DiagnosticReport.ResultGroupComponent();
            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 name
                else if (atName == "name")
                {
                    result.Name = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

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

                // Parse element group
                else if (atName == "group")
                {
                    result.Group = new List <Hl7.Fhir.Model.DiagnosticReport.ResultGroupComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "group"))
                    {
                        result.Group.Add(DiagnosticReportParser.ParseResultGroupComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "result"))
                    {
                        result.Result.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 Practitioner
        /// </summary>
        public static Hl7.Fhir.Model.Practitioner ParsePractitioner(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Practitioner existingInstance = null)
        {
            Hl7.Fhir.Model.Practitioner result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Practitioner();
            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 = HumanNameParser.ParseHumanName(reader, errors);
                }

                // 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 address
                else if (atName == "address")
                {
                    result.Address = AddressParser.ParseAddress(reader, errors);
                }

                // 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 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 organization
                else if (atName == "organization")
                {
                    result.Organization = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

                // Parse element qualification
                else if (atName == "qualification")
                {
                    result.Qualification = new List <Hl7.Fhir.Model.Practitioner.PractitionerQualificationComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "qualification"))
                    {
                        result.Qualification.Add(PractitionerParser.ParsePractitionerQualificationComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

                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 DiagnosticReportRequestDetailComponent
        /// </summary>
        public static Hl7.Fhir.Model.DiagnosticReport.DiagnosticReportRequestDetailComponent ParseDiagnosticReportRequestDetailComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DiagnosticReport.DiagnosticReportRequestDetailComponent existingInstance = null)
        {
            Hl7.Fhir.Model.DiagnosticReport.DiagnosticReportRequestDetailComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DiagnosticReport.DiagnosticReportRequestDetailComponent();
            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 encounter
                else if (atName == "encounter")
                {
                    result.Encounter = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

                // Parse element clinicalInfo
                else if (atName == "clinicalInfo")
                {
                    result.ClinicalInfoElement = 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);
        }
Пример #10
0
        /// <summary>
        /// Parse Coverage
        /// </summary>
        public static Hl7.Fhir.Model.Coverage ParseCoverage(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Coverage existingInstance = null)
        {
            Hl7.Fhir.Model.Coverage result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Coverage();
            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 issuer
                else if (atName == "issuer")
                {
                    result.Issuer = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

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

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

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

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

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

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

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

                // Parse element subscriber
                else if (atName == "subscriber")
                {
                    result.Subscriber = CoverageParser.ParseCoverageSubscriberComponent(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);
        }
Пример #11
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);
        }
Пример #12
0
        /// <summary>
        /// Parse RelatedPerson
        /// </summary>
        public static Hl7.Fhir.Model.RelatedPerson ParseRelatedPerson(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.RelatedPerson existingInstance = null)
        {
            Hl7.Fhir.Model.RelatedPerson result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.RelatedPerson();
            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 patient
                else if (atName == "patient")
                {
                    result.Patient = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

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

                // 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 address
                else if (atName == "address")
                {
                    result.Address = AddressParser.ParseAddress(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();
                }

                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);
        }
Пример #13
0
        /// <summary>
        /// Parse XdsEntry2
        /// </summary>
        public static XdsEntry2 ParseXdsEntry2(IFhirReader reader, ErrorList errors, XdsEntry2 existingInstance = null)
        {
            XdsEntry2 result = existingInstance != null ? existingInstance : new XdsEntry2();

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

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

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

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

                        reader.LeaveArray();
                    }

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

                    // Parse element content
                    else if (ParserUtils.IsAtFhirElement(reader, "content"))
                    {
                        result.Content = AttachmentParser.ParseAttachment(reader, errors);
                    }

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

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
        /// <summary>
        /// Parse MedicationDispenseSubstitutionComponent
        /// </summary>
        public static Hl7.Fhir.Model.MedicationDispense.MedicationDispenseSubstitutionComponent ParseMedicationDispenseSubstitutionComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationDispense.MedicationDispenseSubstitutionComponent existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationDispense.MedicationDispenseSubstitutionComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationDispense.MedicationDispenseSubstitutionComponent();
            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 reason
                else if (atName == "reason")
                {
                    result.Reason = new List <Hl7.Fhir.Model.CodeableConcept>();
                    reader.EnterArray();

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

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "responsibleParty"))
                    {
                        result.ResponsibleParty.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 MedicationDispense
        /// </summary>
        public static Hl7.Fhir.Model.MedicationDispense ParseMedicationDispense(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationDispense existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationDispense result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationDispense();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

                // Parse element substitution
                else if (atName == "substitution")
                {
                    result.Substitution = MedicationDispenseParser.ParseMedicationDispenseSubstitutionComponent(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);
        }
Пример #16
0
        /// <summary>
        /// Parse ImagingStudySeriesInstanceComponent
        /// </summary>
        public static Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesInstanceComponent ParseImagingStudySeriesInstanceComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesInstanceComponent existingInstance = null)
        {
            Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesInstanceComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesInstanceComponent();
            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 number
                else if (atName == "number")
                {
                    result.NumberElement = IntegerParser.ParseInteger(reader, errors);
                }

                // Parse element uid
                else if (atName == "uid")
                {
                    result.UidElement = OidParser.ParseOid(reader, errors);
                }

                // Parse element sopclass
                else if (atName == "sopclass")
                {
                    result.SopclassElement = OidParser.ParseOid(reader, errors);
                }

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

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

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

                // Parse element attachment
                else if (atName == "attachment")
                {
                    result.Attachment = 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);
        }
Пример #17
0
        /// <summary>
        /// Parse ImagingStudy
        /// </summary>
        public static Hl7.Fhir.Model.ImagingStudy ParseImagingStudy(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.ImagingStudy existingInstance = null)
        {
            Hl7.Fhir.Model.ImagingStudy result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.ImagingStudy();
            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 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 uid
                else if (atName == "uid")
                {
                    result.UidElement = OidParser.ParseOid(reader, errors);
                }

                // Parse element accessionNo
                else if (atName == "accessionNo")
                {
                    result.AccessionNo = 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 modality
                else if (atName == "modality")
                {
                    result.Modality_Element = new List <Code <Hl7.Fhir.Model.ImagingStudy.ImagingModality> >();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "modality"))
                    {
                        result.Modality_Element.Add(CodeParser.ParseCode <Hl7.Fhir.Model.ImagingStudy.ImagingModality>(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

                // Parse element availability
                else if (atName == "availability")
                {
                    result.AvailabilityElement = CodeParser.ParseCode <Hl7.Fhir.Model.ImagingStudy.InstanceAvailability>(reader, errors);
                }

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

                // Parse element series
                else if (atName == "series")
                {
                    result.Series = new List <Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "series"))
                    {
                        result.Series.Add(ImagingStudyParser.ParseImagingStudySeriesComponent(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);
        }
Пример #18
0
        /// <summary>
        /// Parse Message
        /// </summary>
        public static Hl7.Fhir.Model.Message ParseMessage(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Message existingInstance = null)
        {
            Hl7.Fhir.Model.Message result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Message();
            string currentElementName     = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Пример #19
0
        /// <summary>
        /// Parse Immunization
        /// </summary>
        public static Hl7.Fhir.Model.Immunization ParseImmunization(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Immunization existingInstance = null)
        {
            Hl7.Fhir.Model.Immunization result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Immunization();
            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 vaccineType
                else if (atName == "vaccineType")
                {
                    result.VaccineType = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

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

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

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

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

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

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

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

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

                // Parse element expirationDate
                else if (atName == "expirationDate")
                {
                    result.ExpirationDateElement = DateParser.ParseDate(reader, errors);
                }

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

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

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

                // Parse element explanation
                else if (atName == "explanation")
                {
                    result.Explanation = ImmunizationParser.ParseImmunizationExplanationComponent(reader, errors);
                }

                // Parse element reaction
                else if (atName == "reaction")
                {
                    result.Reaction = new List <Hl7.Fhir.Model.Immunization.ImmunizationReactionComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "reaction"))
                    {
                        result.Reaction.Add(ImmunizationParser.ParseImmunizationReactionComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element vaccinationProtocol
                else if (atName == "vaccinationProtocol")
                {
                    result.VaccinationProtocol = ImmunizationParser.ParseImmunizationVaccinationProtocolComponent(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 Condition
        /// </summary>
        public static Hl7.Fhir.Model.Condition ParseCondition(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Condition existingInstance = null)
        {
            Hl7.Fhir.Model.Condition result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Condition();
            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 encounter
                else if (atName == "encounter")
                {
                    result.Encounter = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

                // Parse element dateAsserted
                else if (atName == "dateAsserted")
                {
                    result.DateAssertedElement = DateParser.ParseDate(reader, errors);
                }

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

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

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

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

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

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

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

                // Parse element stage
                else if (atName == "stage")
                {
                    result.Stage = ConditionParser.ParseConditionStageComponent(reader, errors);
                }

                // Parse element evidence
                else if (atName == "evidence")
                {
                    result.Evidence = new List <Hl7.Fhir.Model.Condition.ConditionEvidenceComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "evidence"))
                    {
                        result.Evidence.Add(ConditionParser.ParseConditionEvidenceComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

                // Parse element relatedItem
                else if (atName == "relatedItem")
                {
                    result.RelatedItem = new List <Hl7.Fhir.Model.Condition.ConditionRelatedItemComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "relatedItem"))
                    {
                        result.RelatedItem.Add(ConditionParser.ParseConditionRelatedItemComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse DiagnosticReport
        /// </summary>
        public static Hl7.Fhir.Model.DiagnosticReport ParseDiagnosticReport(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DiagnosticReport existingInstance = null)
        {
            Hl7.Fhir.Model.DiagnosticReport result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DiagnosticReport();
            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 status
                else if (atName == "status")
                {
                    result.StatusElement = CodeParser.ParseCode <Hl7.Fhir.Model.ObservationStatus>(reader, errors);
                }

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

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

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

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

                // Parse element requestDetail
                else if (atName == "requestDetail")
                {
                    result.RequestDetail = new List <Hl7.Fhir.Model.DiagnosticReport.DiagnosticReportRequestDetailComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "requestDetail"))
                    {
                        result.RequestDetail.Add(DiagnosticReportParser.ParseDiagnosticReportRequestDetailComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

                // Parse element results
                else if (atName == "results")
                {
                    result.Results = DiagnosticReportParser.ParseResultGroupComponent(reader, errors);
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "representation"))
                    {
                        result.Representation.Add(AttachmentParser.ParseAttachment(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);
        }
Пример #22
0
        /// <summary>
        /// Parse ImmunizationVaccinationProtocolComponent
        /// </summary>
        public static Hl7.Fhir.Model.Immunization.ImmunizationVaccinationProtocolComponent ParseImmunizationVaccinationProtocolComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Immunization.ImmunizationVaccinationProtocolComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Immunization.ImmunizationVaccinationProtocolComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Immunization.ImmunizationVaccinationProtocolComponent();
            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 doseSequence
                else if (atName == "doseSequence")
                {
                    result.DoseSequenceElement = IntegerParser.ParseInteger(reader, errors);
                }

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

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

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

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

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

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

                // Parse element doseStatusReason
                else if (atName == "doseStatusReason")
                {
                    result.DoseStatusReason = 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 Organization
        /// </summary>
        public static Hl7.Fhir.Model.Organization ParseOrganization(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Organization existingInstance = null)
        {
            Hl7.Fhir.Model.Organization result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Organization();
            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.NameElement = FhirStringParser.ParseFhirString(reader, errors);
                }

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

                // 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 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 partOf
                else if (atName == "partOf")
                {
                    result.PartOf = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "contact"))
                    {
                        result.Contact.Add(OrganizationParser.ParseOrganizationContactComponent(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);
        }
        /// <summary>
        /// Parse DeviceLog
        /// </summary>
        public static Hl7.Fhir.Model.DeviceLog ParseDeviceLog(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DeviceLog existingInstance = null)
        {
            Hl7.Fhir.Model.DeviceLog result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DeviceLog();
            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 instant
                else if (atName == "instant")
                {
                    result.InstantElement = InstantParser.ParseInstant(reader, errors);
                }

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

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

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

                    while (ParserUtils.IsAtArrayElement(reader, "item"))
                    {
                        result.Item.Add(DeviceLogParser.ParseDeviceLogItemComponent(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);
        }
Пример #25
0
        /// <summary>
        /// Parse Device
        /// </summary>
        public static Hl7.Fhir.Model.Device ParseDevice(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Device existingInstance = null)
        {
            Hl7.Fhir.Model.Device result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Device();
            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.Type = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

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

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

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

                // Parse element expiry
                else if (atName == "expiry")
                {
                    result.ExpiryElement = DateParser.ParseDate(reader, errors);
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

                // Parse element url
                else if (atName == "url")
                {
                    result.UrlElement = 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);
        }
        /// <summary>
        /// Parse FamilyHistory
        /// </summary>
        public static Hl7.Fhir.Model.FamilyHistory ParseFamilyHistory(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.FamilyHistory existingInstance = null)
        {
            Hl7.Fhir.Model.FamilyHistory result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.FamilyHistory();
            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 note
                else if (atName == "note")
                {
                    result.NoteElement = FhirStringParser.ParseFhirString(reader, errors);
                }

                // Parse element relation
                else if (atName == "relation")
                {
                    result.Relation = new List <Hl7.Fhir.Model.FamilyHistory.FamilyHistoryRelationComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "relation"))
                    {
                        result.Relation.Add(FamilyHistoryParser.ParseFamilyHistoryRelationComponent(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 MedicationDispenseDispenseComponent
        /// </summary>
        public static Hl7.Fhir.Model.MedicationDispense.MedicationDispenseDispenseComponent ParseMedicationDispenseDispenseComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationDispense.MedicationDispenseDispenseComponent existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationDispense.MedicationDispenseDispenseComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationDispense.MedicationDispenseDispenseComponent();
            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 <Hl7.Fhir.Model.MedicationDispense.MedicationDispenseStatus>(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 medication
                else if (atName == "medication")
                {
                    result.Medication = 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();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "dosage"))
                    {
                        result.Dosage.Add(MedicationDispenseParser.ParseMedicationDispenseDispenseDosageComponent(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 ConformanceRestResourceComponent
        /// </summary>
        public static Hl7.Fhir.Model.Conformance.ConformanceRestResourceComponent ParseConformanceRestResourceComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Conformance.ConformanceRestResourceComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Conformance.ConformanceRestResourceComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Conformance.ConformanceRestResourceComponent();
            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(reader, errors);
                }

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

                // Parse element operation
                else if (atName == "operation")
                {
                    result.Operation = new List <Hl7.Fhir.Model.Conformance.ConformanceRestResourceOperationComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "operation"))
                    {
                        result.Operation.Add(ConformanceParser.ParseConformanceRestResourceOperationComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

                // Parse element searchParam
                else if (atName == "searchParam")
                {
                    result.SearchParam = new List <Hl7.Fhir.Model.Conformance.ConformanceRestResourceSearchParamComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "searchParam"))
                    {
                        result.SearchParam.Add(ConformanceParser.ParseConformanceRestResourceSearchParamComponent(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 Identifier
        /// </summary>
        public static Hl7.Fhir.Model.Identifier ParseIdentifier(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Identifier existingInstance = null)
        {
            Hl7.Fhir.Model.Identifier result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Identifier();
            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.Identifier.IdentifierUse>(reader, errors);
                }

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

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

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

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

                // Parse element assigner
                else if (atName == "assigner")
                {
                    result.Assigner = 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);
        }
Пример #30
0
        /// <summary>
        /// Parse Protocol
        /// </summary>
        public static Hl7.Fhir.Model.Protocol ParseProtocol(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Protocol existingInstance = null)
        {
            Hl7.Fhir.Model.Protocol result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Protocol();
            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 title
                    else if (ParserUtils.IsAtFhirElement(reader, "title"))
                    {
                        result.Title = FhirStringParser.ParseFhirString(reader, errors);
                    }

                    // Parse element type
                    else if (ParserUtils.IsAtFhirElement(reader, "type"))
                    {
                        result.Type = CodeParser.ParseCode <Hl7.Fhir.Model.Protocol.ProtocolType>(reader, errors);
                    }

                    // Parse element status
                    else if (ParserUtils.IsAtFhirElement(reader, "status"))
                    {
                        result.Status = CodeParser.ParseCode <Hl7.Fhir.Model.Protocol.ProtocolStatus>(reader, errors);
                    }

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

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

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

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

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

                        while (ParserUtils.IsAtArrayElement(reader, "step"))
                        {
                            result.Step.Add(ProtocolParser.ParseProtocolStepComponent(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);
        }