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

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

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

                        reader.LeaveArray();
                    }

                    // Parse element _id
                    else if (ParserUtils.IsAtFhirElement(reader, "_id"))
                    {
                        result.LocalId = Id.Parse(reader.ReadPrimitiveContents("id"));
                    }

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

                    // Parse element activity
                    else if (ParserUtils.IsAtFhirElement(reader, "activity"))
                    {
                        result.Activity = IdRefParser.ParseIdRef(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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parse Group
        /// </summary>
        public static Hl7.Fhir.Model.Group ParseGroup(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Group existingInstance = null)
        {
            Hl7.Fhir.Model.Group result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Group();
            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 type
                else if (atName == "type")
                {
                    result.TypeElement = CodeParser.ParseCode <Hl7.Fhir.Model.Group.GroupType>(reader, errors);
                }

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

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

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

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

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

                    while (ParserUtils.IsAtArrayElement(reader, "characteristic"))
                    {
                        result.Characteristic.Add(GroupParser.ParseGroupCharacteristicComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "member"))
                    {
                        result.Member.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 PrescriptionAdministrationRequestComponent
        /// </summary>
        public static Prescription.PrescriptionAdministrationRequestComponent ParsePrescriptionAdministrationRequestComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionAdministrationRequestComponent existingInstance = null)
        {
            Prescription.PrescriptionAdministrationRequestComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionAdministrationRequestComponent();
            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 description
                    else if (ParserUtils.IsAtFhirElement(reader, "description"))
                    {
                        result.Description = FhirStringParser.ParseFhirString(reader, errors);
                    }

                    // Parse element totalPeriodicDose
                    else if (ParserUtils.IsAtFhirElement(reader, "totalPeriodicDose"))
                    {
                        result.TotalPeriodicDose = RatioParser.ParseRatio(reader, errors);
                    }

                    // Parse element start
                    else if (ParserUtils.IsAtFhirElement(reader, "start"))
                    {
                        result.Start = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                    }

                    // Parse element end
                    else if (ParserUtils.IsAtFhirElement(reader, "end"))
                    {
                        result.End = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                    }

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

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

                    // Parse element dosageInstruction
                    else if (ParserUtils.IsAtFhirElement(reader, "dosageInstruction"))
                    {
                        result.DosageInstruction = new List <Prescription.PrescriptionAdministrationRequestDosageInstructionComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "dosageInstruction"))
                        {
                            result.DosageInstruction.Add(PrescriptionParser.ParsePrescriptionAdministrationRequestDosageInstructionComponent(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);
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Parse Array
        /// </summary>
        public static Hl7.Fhir.Model.Array ParseArray(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Array existingInstance = null)
        {
            Hl7.Fhir.Model.Array result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Array();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

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

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

                        reader.LeaveArray();
                    }

                    // Parse element _id
                    else if (ParserUtils.IsAtFhirElement(reader, "_id"))
                    {
                        result.LocalId = Id.Parse(reader.ReadPrimitiveContents("id"));
                    }

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

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

                    // Parse element factor
                    else if (ParserUtils.IsAtFhirElement(reader, "factor"))
                    {
                        result.Factor = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                    }

                    // Parse element lowerLimit
                    else if (ParserUtils.IsAtFhirElement(reader, "lowerLimit"))
                    {
                        result.LowerLimit = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                    }

                    // Parse element upperLimit
                    else if (ParserUtils.IsAtFhirElement(reader, "upperLimit"))
                    {
                        result.UpperLimit = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                    }

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

                    // Parse element data
                    else if (ParserUtils.IsAtFhirElement(reader, "data"))
                    {
                        result.Data = 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();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Parse Picture
        /// </summary>
        public static Hl7.Fhir.Model.Picture ParsePicture(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Picture existingInstance = null)
        {
            Hl7.Fhir.Model.Picture result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Picture();
            string currentElementName     = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

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

                // Parse element modality
                else if (atName == "modality")
                {
                    result.ModalityElement = CodeParser.ParseCode <Hl7.Fhir.Model.Picture.PictureType>(reader, errors);
                }

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

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

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

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

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

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

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

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

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

            reader.LeaveElement();
            return(result);
        }
Exemplo n.º 8
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);
        }
        /// <summary>
        /// Parse ImmunizationProfileRecommendationComponent
        /// </summary>
        public static Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationComponent ParseImmunizationProfileRecommendationComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationComponent existingInstance = null)
        {
            Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationComponent();
            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 recommendationDate
                else if (atName == "recommendationDate")
                {
                    result.RecommendationDateElement = FhirDateTimeParser.ParseFhirDateTime(reader, errors);
                }

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

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

                // Parse element forecastStatus
                else if (atName == "forecastStatus")
                {
                    result.ForecastStatusElement = CodeParser.ParseCode <Hl7.Fhir.Model.ImmunizationProfile.ImmunizationForecastStatus>(reader, errors);
                }

                // Parse element dateCriterion
                else if (atName == "dateCriterion")
                {
                    result.DateCriterion = new List <Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationDateCriterionComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "dateCriterion"))
                    {
                        result.DateCriterion.Add(ImmunizationProfileParser.ParseImmunizationProfileRecommendationDateCriterionComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element protocol
                else if (atName == "protocol")
                {
                    result.Protocol = ImmunizationProfileParser.ParseImmunizationProfileRecommendationProtocolComponent(reader, errors);
                }

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

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

                    reader.LeaveArray();
                }

                // Parse element supportingAdverseEventReport
                else if (atName == "supportingAdverseEventReport")
                {
                    result.SupportingAdverseEventReport = new List <Hl7.Fhir.Model.ImmunizationProfile.ImmunizationProfileRecommendationSupportingAdverseEventReportComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "supportingAdverseEventReport"))
                    {
                        result.SupportingAdverseEventReport.Add(ImmunizationProfileParser.ParseImmunizationProfileRecommendationSupportingAdverseEventReportComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "supportingPatientObservation"))
                    {
                        result.SupportingPatientObservation.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 DocumentReference
        /// </summary>
        public static Hl7.Fhir.Model.DocumentReference ParseDocumentReference(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DocumentReference existingInstance = null)
        {
            Hl7.Fhir.Model.DocumentReference result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DocumentReference();
            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 masterIdentifier
                else if (atName == "masterIdentifier")
                {
                    result.MasterIdentifier = 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 subject
                else if (atName == "subject")
                {
                    result.Subject = ResourceReferenceParser.ParseResourceReference(reader, errors);
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                // Parse element service
                else if (atName == "service")
                {
                    result.Service = DocumentReferenceParser.ParseDocumentReferenceServiceComponent(reader, errors);
                }

                // Parse element context
                else if (atName == "context")
                {
                    result.Context = DocumentReferenceParser.ParseDocumentReferenceContextComponent(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);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Parse Attachment
        /// </summary>
        public static Hl7.Fhir.Model.Attachment ParseAttachment(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Attachment existingInstance = null)
        {
            Hl7.Fhir.Model.Attachment result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Attachment();
            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 contentType
                else if (atName == "contentType")
                {
                    result.ContentTypeElement = CodeParser.ParseCode(reader, errors);
                }

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

                // Parse element data
                else if (atName == "data")
                {
                    result.DataElement = Base64BinaryParser.ParseBase64Binary(reader, errors);
                }

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

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

                // Parse element hash
                else if (atName == "hash")
                {
                    result.HashElement = Base64BinaryParser.ParseBase64Binary(reader, errors);
                }

                // Parse element title
                else if (atName == "title")
                {
                    result.TitleElement = 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 MedicationPrescriptionDispenseComponent
        /// </summary>
        public static Hl7.Fhir.Model.MedicationPrescription.MedicationPrescriptionDispenseComponent ParseMedicationPrescriptionDispenseComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationPrescription.MedicationPrescriptionDispenseComponent existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationPrescription.MedicationPrescriptionDispenseComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationPrescription.MedicationPrescriptionDispenseComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

            reader.LeaveElement();
            return(result);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Parse ScheduleRepeatComponent
        /// </summary>
        public static Hl7.Fhir.Model.Schedule.ScheduleRepeatComponent ParseScheduleRepeatComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Schedule.ScheduleRepeatComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Schedule.ScheduleRepeatComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Schedule.ScheduleRepeatComponent();
            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 frequency
                else if (atName == "frequency")
                {
                    result.FrequencyElement = IntegerParser.ParseInteger(reader, errors);
                }

                // Parse element when
                else if (atName == "when")
                {
                    result.WhenElement = CodeParser.ParseCode <Hl7.Fhir.Model.Schedule.EventTiming>(reader, errors);
                }

                // Parse element duration
                else if (atName == "duration")
                {
                    result.DurationElement = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                }

                // Parse element units
                else if (atName == "units")
                {
                    result.UnitsElement = CodeParser.ParseCode <Hl7.Fhir.Model.Schedule.UnitsOfTime>(reader, errors);
                }

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

                // Parse element end
                else if (atName == "end")
                {
                    result.EndElement = FhirDateTimeParser.ParseFhirDateTime(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);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Parse ImagingStudySeriesComponent
        /// </summary>
        public static Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesComponent ParseImagingStudySeriesComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesComponent existingInstance = null)
        {
            Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.ImagingStudy.ImagingStudySeriesComponent();
            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 modality
                else if (atName == "modality")
                {
                    result.ModalityElement = CodeParser.ParseCode <Hl7.Fhir.Model.ImagingStudy.Modality>(reader, errors);
                }

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

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

                // Parse element numberOfInstances
                else if (atName == "numberOfInstances")
                {
                    result.NumberOfInstancesElement = IntegerParser.ParseInteger(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 bodySite
                else if (atName == "bodySite")
                {
                    result.BodySite = CodingParser.ParseCoding(reader, errors);
                }

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

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

                    while (ParserUtils.IsAtArrayElement(reader, "instance"))
                    {
                        result.Instance.Add(ImagingStudyParser.ParseImagingStudySeriesInstanceComponent(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.º 15
0
        /// <summary>
        /// Parse ElementDefinitionComponent
        /// </summary>
        public static Hl7.Fhir.Model.Profile.ElementDefinitionComponent ParseElementDefinitionComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Profile.ElementDefinitionComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Profile.ElementDefinitionComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Profile.ElementDefinitionComponent();
            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 short
                else if (atName == "short")
                {
                    result.ShortElement = FhirStringParser.ParseFhirString(reader, errors);
                }

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

                // Parse element type
                else if (atName == "type")
                {
                    result.Type = new List <Hl7.Fhir.Model.Profile.TypeRefComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "type"))
                    {
                        result.Type.Add(ProfileParser.ParseTypeRefComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

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

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

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

                    while (ParserUtils.IsAtArrayElement(reader, "condition"))
                    {
                        result.ConditionElement.Add(IdParser.ParseId(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element constraint
                else if (atName == "constraint")
                {
                    result.Constraint = new List <Hl7.Fhir.Model.Profile.ElementDefinitionConstraintComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "constraint"))
                    {
                        result.Constraint.Add(ProfileParser.ParseElementDefinitionConstraintComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

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

                // Parse element mapping
                else if (atName == "mapping")
                {
                    result.Mapping = new List <Hl7.Fhir.Model.Profile.ElementDefinitionMappingComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "mapping"))
                    {
                        result.Mapping.Add(ProfileParser.ParseElementDefinitionMappingComponent(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.º 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);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Parse SampledData
        /// </summary>
        public static Hl7.Fhir.Model.SampledData ParseSampledData(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.SampledData existingInstance = null)
        {
            Hl7.Fhir.Model.SampledData result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.SampledData();
            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 origin
                else if (atName == "origin")
                {
                    result.Origin = QuantityParser.ParseQuantity(reader, errors);
                }

                // Parse element period
                else if (atName == "period")
                {
                    result.PeriodElement = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                }

                // Parse element factor
                else if (atName == "factor")
                {
                    result.FactorElement = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                }

                // Parse element lowerLimit
                else if (atName == "lowerLimit")
                {
                    result.LowerLimitElement = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                }

                // Parse element upperLimit
                else if (atName == "upperLimit")
                {
                    result.UpperLimitElement = FhirDecimalParser.ParseFhirDecimal(reader, errors);
                }

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

                // Parse element data
                else if (atName == "data")
                {
                    result.DataElement = 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 ConformanceMessagingComponent
        /// </summary>
        public static Hl7.Fhir.Model.Conformance.ConformanceMessagingComponent ParseConformanceMessagingComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Conformance.ConformanceMessagingComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Conformance.ConformanceMessagingComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Conformance.ConformanceMessagingComponent();
            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 endpoint
                else if (atName == "endpoint")
                {
                    result.EndpointElement = FhirUriParser.ParseFhirUri(reader, errors);
                }

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

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

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

                    while (ParserUtils.IsAtArrayElement(reader, "event"))
                    {
                        result.Event.Add(ConformanceParser.ParseConformanceMessagingEventComponent(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.º 19
0
        /// <summary>
        /// Parse Study
        /// </summary>
        public static Hl7.Fhir.Model.Study ParseStudy(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Study existingInstance = null)
        {
            Hl7.Fhir.Model.Study result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Study();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

                        reader.LeaveArray();
                    }

                    // Parse element _id
                    else if (ParserUtils.IsAtFhirElement(reader, "_id"))
                    {
                        result.LocalId = Id.Parse(reader.ReadPrimitiveContents("id"));
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

                        reader.LeaveArray();
                    }

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

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
Exemplo n.º 20
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);
        }
        /// <summary>
        /// Parse PrescriptionDispenseComponent
        /// </summary>
        public static Prescription.PrescriptionDispenseComponent ParsePrescriptionDispenseComponent(IFhirReader reader, ErrorList errors, Prescription.PrescriptionDispenseComponent existingInstance = null)
        {
            Prescription.PrescriptionDispenseComponent result = existingInstance != null ? existingInstance : new Prescription.PrescriptionDispenseComponent();
            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 repeats
                    else if (ParserUtils.IsAtFhirElement(reader, "repeats"))
                    {
                        result.Repeats = IntegerParser.ParseInteger(reader, errors);
                    }

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

                    // Parse element dispenser
                    else if (ParserUtils.IsAtFhirElement(reader, "dispenser"))
                    {
                        result.Dispenser = 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);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Parse Test
        /// </summary>
        public static Hl7.Fhir.Model.Test ParseTest(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Test existingInstance = null)
        {
            Hl7.Fhir.Model.Test result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Test();
            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 stringErr
                    else if (ParserUtils.IsAtFhirElement(reader, "stringErr"))
                    {
                        result.StringErr = new List <Hl7.Fhir.Model.FhirString>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

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

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

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "booleanErr"))
                        {
                            result.BooleanErr.Add(FhirBooleanParser.ParseFhirBoolean(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "booleanCorr"))
                        {
                            result.BooleanCorr.Add(FhirBooleanParser.ParseFhirBoolean(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "integerErr"))
                        {
                            result.IntegerErr.Add(IntegerParser.ParseInteger(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "integerCorr"))
                        {
                            result.IntegerCorr.Add(IntegerParser.ParseInteger(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "decimalErr"))
                        {
                            result.DecimalErr.Add(FhirDecimalParser.ParseFhirDecimal(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "decimalCorr"))
                        {
                            result.DecimalCorr.Add(FhirDecimalParser.ParseFhirDecimal(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "b64Err"))
                        {
                            result.B64Err.Add(Base64BinaryParser.ParseBase64Binary(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "b64Corr"))
                        {
                            result.B64Corr.Add(Base64BinaryParser.ParseBase64Binary(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "instantErr"))
                        {
                            result.InstantErr.Add(InstantParser.ParseInstant(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "instantCorr"))
                        {
                            result.InstantCorr.Add(InstantParser.ParseInstant(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "uriErr"))
                        {
                            result.UriErr.Add(FhirUriParser.ParseFhirUri(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "uriCorr"))
                        {
                            result.UriCorr.Add(FhirUriParser.ParseFhirUri(reader, errors));
                        }

                        reader.LeaveArray();
                    }

                    // Parse element idrefSingle
                    else if (ParserUtils.IsAtFhirElement(reader, "idrefSingle"))
                    {
                        result.IdrefSingle = IdRefParser.ParseIdRef(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);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Parse QueryResponseComponent
        /// </summary>
        public static Hl7.Fhir.Model.Query.QueryResponseComponent ParseQueryResponseComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Query.QueryResponseComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Query.QueryResponseComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Query.QueryResponseComponent();
            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.IdentifierElement = FhirUriParser.ParseFhirUri(reader, errors);
                }

                // Parse element outcome
                else if (atName == "outcome")
                {
                    result.OutcomeElement = CodeParser.ParseCode <Hl7.Fhir.Model.Query.QueryOutcome>(reader, errors);
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "reference"))
                    {
                        result.Reference.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);
        }