/// <summary>
        /// Parse XdsEntryAuthenticatorComponent
        /// </summary>
        public static XdsEntry.XdsEntryAuthenticatorComponent ParseXdsEntryAuthenticatorComponent(IFhirReader reader, ErrorList errors, XdsEntry.XdsEntryAuthenticatorComponent existingInstance = null)
        {
            XdsEntry.XdsEntryAuthenticatorComponent result = existingInstance != null ? existingInstance : new XdsEntry.XdsEntryAuthenticatorComponent();
            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 id
                    else if (ParserUtils.IsAtFhirElement(reader, "id"))
                    {
                        result.Id = IdentifierParser.ParseIdentifier(reader, errors);
                    }

                    // Parse element name
                    else if (ParserUtils.IsAtFhirElement(reader, "name"))
                    {
                        result.Name = HumanNameParser.ParseHumanName(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);
        }
Пример #2
0
        /// <summary>
        /// Parse Patient
        /// </summary>
        public static Hl7.Fhir.Model.Patient ParsePatient(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Patient existingInstance = null)
        {
            Hl7.Fhir.Model.Patient result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Patient();
            string currentElementName     = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "name"))
                    {
                        result.Name.Add(HumanNameParser.ParseHumanName(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    while (ParserUtils.IsAtArrayElement(reader, "address"))
                    {
                        result.Address.Add(AddressParser.ParseAddress(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

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

                    while (ParserUtils.IsAtArrayElement(reader, "photo"))
                    {
                        result.Photo.Add(AttachmentParser.ParseAttachment(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

                // Parse element animal
                else if (atName == "animal")
                {
                    result.Animal = PatientParser.ParseAnimalComponent(reader, errors);
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse MedicationDispenseDispenseComponent
        /// </summary>
        public static Hl7.Fhir.Model.MedicationDispense.MedicationDispenseDispenseComponent ParseMedicationDispenseDispenseComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationDispense.MedicationDispenseDispenseComponent existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationDispense.MedicationDispenseDispenseComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationDispense.MedicationDispenseDispenseComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "dosage"))
                    {
                        result.Dosage.Add(MedicationDispenseParser.ParseMedicationDispenseDispenseDosageComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
Пример #4
0
        /// <summary>
        /// Parse RelatedPerson
        /// </summary>
        public static Hl7.Fhir.Model.RelatedPerson ParseRelatedPerson(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.RelatedPerson existingInstance = null)
        {
            Hl7.Fhir.Model.RelatedPerson result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.RelatedPerson();
            string currentElementName           = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

                    reader.LeaveArray();
                }

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

                // Parse element address
                else if (atName == "address")
                {
                    result.Address = AddressParser.ParseAddress(reader, errors);
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "photo"))
                    {
                        result.Photo.Add(AttachmentParser.ParseAttachment(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse DiagnosticReport
        /// </summary>
        public static Hl7.Fhir.Model.DiagnosticReport ParseDiagnosticReport(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DiagnosticReport existingInstance = null)
        {
            Hl7.Fhir.Model.DiagnosticReport result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DiagnosticReport();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "representation"))
                    {
                        result.Representation.Add(AttachmentParser.ParseAttachment(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

            reader.LeaveElement();
            return(result);
        }
        /// <summary>
        /// Parse Practitioner
        /// </summary>
        public static Hl7.Fhir.Model.Practitioner ParsePractitioner(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Practitioner existingInstance = null)
        {
            Hl7.Fhir.Model.Practitioner result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Practitioner();
            string currentElementName          = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

                // Parse element address
                else if (atName == "address")
                {
                    result.Address = AddressParser.ParseAddress(reader, errors);
                }

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

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

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

                    while (ParserUtils.IsAtArrayElement(reader, "photo"))
                    {
                        result.Photo.Add(AttachmentParser.ParseAttachment(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
        /// <summary>
        /// Parse Prescription
        /// </summary>
        public static Prescription ParsePrescription(IFhirReader reader, ErrorList errors, Prescription existingInstance = null)
        {
            Prescription result = existingInstance != null ? existingInstance : new Prescription();

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

                        reader.LeaveArray();
                    }

                    // Parse element status
                    else if (ParserUtils.IsAtFhirElement(reader, "status"))
                    {
                        result.Status = CodeParser.ParseCode <Prescription.PrescriptionStatus>(reader, errors);
                    }

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

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

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

                    // Parse element dispense
                    else if (ParserUtils.IsAtFhirElement(reader, "dispense"))
                    {
                        result.Dispense = PrescriptionParser.ParsePrescriptionDispenseComponent(reader, errors);
                    }

                    // Parse element medicine
                    else if (ParserUtils.IsAtFhirElement(reader, "medicine"))
                    {
                        result.Medicine = PrescriptionParser.ParsePrescriptionMedicineComponent(reader, errors);
                    }

                    // Parse element administrationRequest
                    else if (ParserUtils.IsAtFhirElement(reader, "administrationRequest"))
                    {
                        result.AdministrationRequest = PrescriptionParser.ParsePrescriptionAdministrationRequestComponent(reader, errors);
                    }

                    // Parse element reason
                    else if (ParserUtils.IsAtFhirElement(reader, "reason"))
                    {
                        result.Reason = 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();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
Пример #10
0
        /// <summary>
        /// Parse Document
        /// </summary>
        public static Hl7.Fhir.Model.Document ParseDocument(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Document existingInstance = null)
        {
            Hl7.Fhir.Model.Document result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Document();
            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 versionIdentifier
                else if (atName == "versionIdentifier")
                {
                    result.VersionIdentifier = IdentifierParser.ParseIdentifier(reader, errors);
                }

                // Parse element created
                else if (atName == "created")
                {
                    result.CreatedElement = InstantParser.ParseInstant(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 title
                else if (atName == "title")
                {
                    result.TitleElement = FhirStringParser.ParseFhirString(reader, errors);
                }

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

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

                // Parse element subject
                else if (atName == "subject")
                {
                    result.Subject = ResourceReferenceParser.ParseResourceReference(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 attester
                else if (atName == "attester")
                {
                    result.Attester = new List <Hl7.Fhir.Model.Document.DocumentAttesterComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "attester"))
                    {
                        result.Attester.Add(DocumentParser.ParseDocumentAttesterComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

                // Parse element event
                else if (atName == "event")
                {
                    result.Event = DocumentParser.ParseDocumentEventComponent(reader, errors);
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

                // Parse element section
                else if (atName == "section")
                {
                    result.Section = new List <Hl7.Fhir.Model.Document.SectionComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "section"))
                    {
                        result.Section.Add(DocumentParser.ParseSectionComponent(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);
        }
Пример #11
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);
        }
        /// <summary>
        /// Parse Questionnaire
        /// </summary>
        public static Hl7.Fhir.Model.Questionnaire ParseQuestionnaire(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Questionnaire existingInstance = null)
        {
            Hl7.Fhir.Model.Questionnaire result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Questionnaire();
            string currentElementName           = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

                // Parse element question
                else if (atName == "question")
                {
                    result.Question = new List <Hl7.Fhir.Model.Questionnaire.QuestionComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "question"))
                    {
                        result.Question.Add(QuestionnaireParser.ParseQuestionComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "group"))
                    {
                        result.Group.Add(QuestionnaireParser.ParseGroupComponent(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 AllergyIntolerance
        /// </summary>
        public static Hl7.Fhir.Model.AllergyIntolerance ParseAllergyIntolerance(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.AllergyIntolerance existingInstance = null)
        {
            Hl7.Fhir.Model.AllergyIntolerance result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.AllergyIntolerance();
            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 criticality
                else if (atName == "criticality")
                {
                    result.Criticality_Element = CodeParser.ParseCode <Hl7.Fhir.Model.AllergyIntolerance.Criticality>(reader, errors);
                }

                // Parse element sensitivityType
                else if (atName == "sensitivityType")
                {
                    result.SensitivityType_Element = CodeParser.ParseCode <Hl7.Fhir.Model.AllergyIntolerance.SensitivityType>(reader, errors);
                }

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "sensitivityTest"))
                    {
                        result.SensitivityTest.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);
        }
Пример #14
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);
        }
        /// <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);
        }
Пример #16
0
        /// <summary>
        /// Parse VisitHospitalizationComponent
        /// </summary>
        public static Hl7.Fhir.Model.Visit.VisitHospitalizationComponent ParseVisitHospitalizationComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Visit.VisitHospitalizationComponent existingInstance = null)
        {
            Hl7.Fhir.Model.Visit.VisitHospitalizationComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Visit.VisitHospitalizationComponent();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

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

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

                    // Parse element accomodation
                    else if (atName == "accomodation")
                    {
                        result.Accomodation = new List <Hl7.Fhir.Model.Visit.VisitHospitalizationAccomodationComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "accomodation"))
                        {
                            result.Accomodation.Add(VisitParser.ParseVisitHospitalizationAccomodationComponent(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

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

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

                        reader.LeaveArray();
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

                reader.LeaveElement();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
Пример #17
0
        /// <summary>
        /// Parse Visit
        /// </summary>
        public static Hl7.Fhir.Model.Visit ParseVisit(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Visit existingInstance = null)
        {
            Hl7.Fhir.Model.Visit result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Visit();
            try
            {
                string currentElementName = reader.CurrentElementName;
                reader.EnterElement();

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

                        reader.LeaveArray();
                    }

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

                    // Parse element class
                    else if (atName == "class")
                    {
                        result.Class = CodeParser.ParseCode <Hl7.Fhir.Model.Visit.EncounterClass>(reader, errors);
                    }

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

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

                    // Parse element participant
                    else if (atName == "participant")
                    {
                        result.Participant = new List <Hl7.Fhir.Model.Visit.VisitParticipantComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "participant"))
                        {
                            result.Participant.Add(VisitParser.ParseVisitParticipantComponent(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

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

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

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

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

                    // Parse element hospitalization
                    else if (atName == "hospitalization")
                    {
                        result.Hospitalization = VisitParser.ParseVisitHospitalizationComponent(reader, errors);
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "name"))
                        {
                            result.Name.Add(HumanNameParser.ParseHumanName(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

                        while (ParserUtils.IsAtArrayElement(reader, "address"))
                        {
                            result.Address.Add(AddressParser.ParseAddress(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                        while (ParserUtils.IsAtArrayElement(reader, "photo"))
                        {
                            result.Photo.Add(AttachmentParser.ParseAttachment(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                    // Parse element language
                    else if (atName == "language")
                    {
                        result.Language = new List <Hl7.Fhir.Model.Demographics.DemographicsLanguageComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "language"))
                        {
                            result.Language.Add(DemographicsParser.ParseDemographicsLanguageComponent(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);
        }
Пример #20
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);
        }
Пример #21
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 DocumentInformation
        /// </summary>
        public static DocumentInformation ParseDocumentInformation(IFhirReader reader, ErrorList errors, DocumentInformation existingInstance = null)
        {
            DocumentInformation result = existingInstance != null ? existingInstance : new DocumentInformation();

            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 id
                    else if (ParserUtils.IsAtFhirElement(reader, "id"))
                    {
                        result.Id = IdentifierParser.ParseIdentifier(reader, errors);
                    }

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

                    // Parse element created
                    else if (ParserUtils.IsAtFhirElement(reader, "created"))
                    {
                        result.Created = InstantParser.ParseInstant(reader, errors);
                    }

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

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

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

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

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

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

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

                        reader.LeaveArray();
                    }

                    // Parse element attester
                    else if (ParserUtils.IsAtFhirElement(reader, "attester"))
                    {
                        result.Attester = new List <DocumentInformation.DocumentInformationAttesterComponent>();
                        reader.EnterArray();

                        while (ParserUtils.IsAtArrayElement(reader, "attester"))
                        {
                            result.Attester.Add(DocumentInformationParser.ParseDocumentInformationAttesterComponent(reader, errors));
                        }

                        reader.LeaveArray();
                    }

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

                    // Parse element event
                    else if (ParserUtils.IsAtFhirElement(reader, "event"))
                    {
                        result.Event = DocumentInformationParser.ParseDocumentInformationEventComponent(reader, errors);
                    }

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

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

                    // Parse element practiceSetting
                    else if (ParserUtils.IsAtFhirElement(reader, "practiceSetting"))
                    {
                        result.PracticeSetting = 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();
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message, reader);
            }
            return(result);
        }
        /// <summary>
        /// Parse DiagnosticReportRequestDetailComponent
        /// </summary>
        public static Hl7.Fhir.Model.DiagnosticReport.DiagnosticReportRequestDetailComponent ParseDiagnosticReportRequestDetailComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.DiagnosticReport.DiagnosticReportRequestDetailComponent existingInstance = null)
        {
            Hl7.Fhir.Model.DiagnosticReport.DiagnosticReportRequestDetailComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.DiagnosticReport.DiagnosticReportRequestDetailComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

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

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

                // Parse element reliability
                else if (atName == "reliability")
                {
                    result.ReliabilityElement = CodeParser.ParseCode <Hl7.Fhir.Model.Observation.ObservationReliability>(reader, errors);
                }

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

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

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

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

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

                // Parse element referenceRange
                else if (atName == "referenceRange")
                {
                    result.ReferenceRange = new List <Hl7.Fhir.Model.Observation.ObservationReferenceRangeComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "referenceRange"))
                    {
                        result.ReferenceRange.Add(ObservationParser.ParseObservationReferenceRangeComponent(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element component
                else if (atName == "component")
                {
                    result.Component = new List <Hl7.Fhir.Model.Observation.ObservationComponentComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "component"))
                    {
                        result.Component.Add(ObservationParser.ParseObservationComponentComponent(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 Organization
        /// </summary>
        public static Hl7.Fhir.Model.Organization ParseOrganization(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Organization existingInstance = null)
        {
            Hl7.Fhir.Model.Organization result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Organization();
            string currentElementName          = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

                    while (ParserUtils.IsAtArrayElement(reader, "address"))
                    {
                        result.Address.Add(AddressParser.ParseAddress(reader, errors));
                    }

                    reader.LeaveArray();
                }

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

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

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

                    reader.LeaveArray();
                }

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

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

            reader.LeaveElement();
            return(result);
        }
Пример #26
0
        /// <summary>
        /// Parse XdsFolder
        /// </summary>
        public static XdsFolder ParseXdsFolder(IFhirReader reader, ErrorList errors, XdsFolder existingInstance = null)
        {
            XdsFolder result = existingInstance != null ? existingInstance : new XdsFolder();

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

                    // Parse element comments
                    else if (ParserUtils.IsAtFhirElement(reader, "comments"))
                    {
                        result.Comments = 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);
        }
Пример #27
0
        /// <summary>
        /// Parse Device
        /// </summary>
        public static Hl7.Fhir.Model.Device ParseDevice(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.Device existingInstance = null)
        {
            Hl7.Fhir.Model.Device result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.Device();
            string currentElementName    = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

            reader.LeaveElement();
            return(result);
        }
Пример #28
0
        /// <summary>
        /// Parse XdsEntry
        /// </summary>
        public static XdsEntry ParseXdsEntry(IFhirReader reader, ErrorList errors, XdsEntry existingInstance = null)
        {
            XdsEntry result = existingInstance != null ? existingInstance : new XdsEntry();

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

                    // Parse element repositoryId
                    else if (ParserUtils.IsAtFhirElement(reader, "repositoryId"))
                    {
                        result.RepositoryId = FhirUriParser.ParseFhirUri(reader, errors);
                    }

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

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

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

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

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

                    // Parse element documentId
                    else if (ParserUtils.IsAtFhirElement(reader, "documentId"))
                    {
                        result.DocumentId = FhirUriParser.ParseFhirUri(reader, errors);
                    }

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

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

                    // Parse element created
                    else if (ParserUtils.IsAtFhirElement(reader, "created"))
                    {
                        result.Created = InstantParser.ParseInstant(reader, errors);
                    }

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

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

                        reader.LeaveArray();
                    }

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

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

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

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

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

                        reader.LeaveArray();
                    }

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

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

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

                    // Parse element author
                    else if (ParserUtils.IsAtFhirElement(reader, "author"))
                    {
                        result.Author = new List <XdsEntry.XdsEntryAuthorComponent>();
                        reader.EnterArray();

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

                        reader.LeaveArray();
                    }

                    // Parse element authenticator
                    else if (ParserUtils.IsAtFhirElement(reader, "authenticator"))
                    {
                        result.Authenticator = XdsEntryParser.ParseXdsEntryAuthenticatorComponent(reader, errors);
                    }

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

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

                    // Parse element homeCommunity
                    else if (ParserUtils.IsAtFhirElement(reader, "homeCommunity"))
                    {
                        result.HomeCommunity = FhirUriParser.ParseFhirUri(reader, errors);
                    }

                    // Parse element service
                    else if (ParserUtils.IsAtFhirElement(reader, "service"))
                    {
                        result.Service = XdsEntryParser.ParseXdsEntryServiceComponent(reader, errors);
                    }

                    // Parse element comments
                    else if (ParserUtils.IsAtFhirElement(reader, "comments"))
                    {
                        result.Comments = 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);
        }
        /// <summary>
        /// Parse MedicationDispense
        /// </summary>
        public static Hl7.Fhir.Model.MedicationDispense ParseMedicationDispense(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.MedicationDispense existingInstance = null)
        {
            Hl7.Fhir.Model.MedicationDispense result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.MedicationDispense();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

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

                    reader.LeaveArray();
                }

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

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

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

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

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

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

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

                    reader.LeaveArray();
                }

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

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

                    reader.LeaveArray();
                }

                // Parse element substitution
                else if (atName == "substitution")
                {
                    result.Substitution = MedicationDispenseParser.ParseMedicationDispenseSubstitutionComponent(reader, errors);
                }

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

            reader.LeaveElement();
            return(result);
        }
Пример #30
0
        /// <summary>
        /// Parse SecurityEventObjectComponent
        /// </summary>
        public static Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent ParseSecurityEventObjectComponent(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent existingInstance = null)
        {
            Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectComponent();
            string currentElementName = reader.CurrentElementName;

            reader.EnterElement();

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

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

                    reader.LeaveArray();
                }

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

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

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

                // Parse element type
                else if (atName == "type")
                {
                    result.TypeElement = CodeParser.ParseCode <Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectType>(reader, errors);
                }

                // Parse element role
                else if (atName == "role")
                {
                    result.RoleElement = CodeParser.ParseCode <Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectRole>(reader, errors);
                }

                // Parse element lifecycle
                else if (atName == "lifecycle")
                {
                    result.LifecycleElement = CodeParser.ParseCode <Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectLifecycle>(reader, errors);
                }

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

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

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

                // Parse element detail
                else if (atName == "detail")
                {
                    result.Detail = new List <Hl7.Fhir.Model.SecurityEvent.SecurityEventObjectDetailComponent>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "detail"))
                    {
                        result.Detail.Add(SecurityEventParser.ParseSecurityEventObjectDetailComponent(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);
        }