コード例 #1
0
        /// <summary>
        /// Parse OrderWhenComponent
        /// </summary>
        public static Hl7.Fhir.Model.Order.OrderWhenComponent ParseOrderWhenComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Order.OrderWhenComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Order.OrderWhenComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Order.OrderWhenComponent();
            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 schedule
                else if (atName == "schedule")
                {
                    result.Schedule = ScheduleParser.ParseSchedule(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 PrescriptionAdministrationRequestDosageInstructionComponent
        /// </summary>
        public static Prescription.PrescriptionAdministrationRequestDosageInstructionComponent ParsePrescriptionAdministrationRequestDosageInstructionComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionAdministrationRequestDosageInstructionComponent existingInstance = null)
        {
            Prescription.PrescriptionAdministrationRequestDosageInstructionComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionAdministrationRequestDosageInstructionComponent();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

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

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

                        reader.LeaveArray();
                    }

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

                    // Parse element precondition
                    else if (ParserUtils.IsAtFhirElement(reader, "precondition"))
                    {
                        result.Precondition = new List <CodeableConcept>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element prn
                    else if (ParserUtils.IsAtFhirElement(reader, "prn"))
                    {
                        result.Prn = FhirBooleanParser.ParseFhirBoolean(reader, errors);
                    }

                    // Parse element additionalInstruction
                    else if (ParserUtils.IsAtFhirElement(reader, "additionalInstruction"))
                    {
                        result.AdditionalInstruction = new List <CodeableConcept>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

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

                    // Parse element dose
                    else if (ParserUtils.IsAtFhirElement(reader, "dose", true))
                    {
                        result.Dose = FhirParser.ParseElement(reader, errors);
                    }

                    // Parse element rate
                    else if (ParserUtils.IsAtFhirElement(reader, "rate"))
                    {
                        result.Rate = QuantityParser.ParseQuantity(reader, errors);
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "schedule"))
                        {
                            result.Schedule.Add(ScheduleParser.ParseSchedule(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);
        }
コード例 #3
0
        /// <summary>
        /// Parse MedicationAdministrationDosageComponent
        /// </summary>
        public static Hl7.Fhir.Model.MedicationAdministration.MedicationAdministrationDosageComponent ParseMedicationAdministrationDosageComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationAdministration.MedicationAdministrationDosageComponent existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationAdministration.MedicationAdministrationDosageComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationAdministration.MedicationAdministrationDosageComponent();
            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 timing
                else if (atName == "timing")
                {
                    result.Timing = ScheduleParser.ParseSchedule(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 method
                else if (atName == "method")
                {
                    result.Method = CodeableConceptParser.ParseCodeableConcept(reader, errors);
                }

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

                // Parse element rate
                else if (atName == "rate")
                {
                    result.Rate = RatioParser.ParseRatio(reader, errors);
                }

                // Parse element maxDosePerPeriod
                else if (atName == "maxDosePerPeriod")
                {
                    result.MaxDosePerPeriod = 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);
        }
コード例 #4
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);
            }
        }