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

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Exemplo n.º 2
0
        internal static Element ParseElement(IFhirReader reader, ErrorList errors)
        {
            try
            {
                reader.MoveToContent();

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