示例#1
0
        /// <summary>
        /// Parse DiagnosticOrder
        /// </summary>
        public static Hl7.Fhir.Model.DiagnosticOrder ParseDiagnosticOrder(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DiagnosticOrder existingInstance = null)
        {
            Hl7.Fhir.Model.DiagnosticOrder result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DiagnosticOrder();
            string currentElementName             = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

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

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }