Module: FHIR::Hashable
- Included in:
- Account, Account::Coverage, Account::Guarantor, ActivityDefinition, ActivityDefinition::DynamicValue, ActivityDefinition::Participant, Address, AdverseEvent, AdverseEvent::SuspectEntity, AdverseEvent::SuspectEntity::Causality, Age, AllergyIntolerance, AllergyIntolerance::Reaction, Annotation, Appointment, Appointment::Participant, AppointmentResponse, Attachment, AuditEvent, AuditEvent::Agent, AuditEvent::Agent::Network, AuditEvent::Entity, AuditEvent::Entity::Detail, AuditEvent::Source, BackboneElement, Basic, Binary, BiologicallyDerivedProduct, BiologicallyDerivedProduct::Collection, BiologicallyDerivedProduct::Manipulation, BiologicallyDerivedProduct::Processing, BiologicallyDerivedProduct::Storage, BodyStructure, Boot::Template, Bundle, Bundle::Entry, Bundle::Entry::Request, Bundle::Entry::Response, Bundle::Entry::Search, Bundle::Link, CapabilityStatement, CapabilityStatement::Document, CapabilityStatement::Implementation, CapabilityStatement::Messaging, CapabilityStatement::Messaging::Endpoint, CapabilityStatement::Messaging::SupportedMessage, CapabilityStatement::Rest, CapabilityStatement::Rest::Interaction, CapabilityStatement::Rest::Resource, CapabilityStatement::Rest::Resource::Interaction, CapabilityStatement::Rest::Resource::Operation, CapabilityStatement::Rest::Resource::SearchParam, CapabilityStatement::Rest::Security, CapabilityStatement::Software, CarePlan, CarePlan::Activity, CarePlan::Activity::Detail, CareTeam, CareTeam::Participant, CatalogEntry, CatalogEntry::RelatedEntry, ChargeItem, ChargeItem::Performer, ChargeItemDefinition, ChargeItemDefinition::Applicability, ChargeItemDefinition::PropertyGroup, ChargeItemDefinition::PropertyGroup::PriceComponent, Claim, Claim::Accident, Claim::CareTeam, Claim::Diagnosis, Claim::Insurance, Claim::Item, Claim::Item::Detail, Claim::Item::Detail::SubDetail, Claim::Payee, Claim::Procedure, Claim::Related, Claim::SupportingInfo, ClaimResponse, ClaimResponse::AddItem, ClaimResponse::AddItem::Detail, ClaimResponse::AddItem::Detail::SubDetail, ClaimResponse::Error, ClaimResponse::Insurance, ClaimResponse::Item, ClaimResponse::Item::Adjudication, ClaimResponse::Item::Detail, ClaimResponse::Item::Detail::SubDetail, ClaimResponse::Payment, ClaimResponse::ProcessNote, ClaimResponse::Total, ClinicalImpression, ClinicalImpression::Finding, ClinicalImpression::Investigation, CodeSystem, CodeSystem::Concept, CodeSystem::Concept::Designation, CodeSystem::Concept::Property, CodeSystem::Filter, CodeSystem::Property, CodeableConcept, Coding, Communication, Communication::Payload, CommunicationRequest, CommunicationRequest::Payload, CompartmentDefinition, CompartmentDefinition::Resource, Composition, Composition::Attester, Composition::Event, Composition::RelatesTo, Composition::Section, ConceptMap, ConceptMap::Group, ConceptMap::Group::Element, ConceptMap::Group::Element::Target, ConceptMap::Group::Element::Target::DependsOn, ConceptMap::Group::Unmapped, Condition, Condition::Evidence, Condition::Stage, Consent, Consent::Policy, Consent::Provision, Consent::Provision::Actor, Consent::Provision::Data, Consent::Verification, ContactDetail, ContactPoint, Contract, Contract::ContentDefinition, Contract::Friendly, Contract::Legal, Contract::Rule, Contract::Signer, Contract::Term, Contract::Term::Action, Contract::Term::Action::Subject, Contract::Term::Asset, Contract::Term::Asset::Context, Contract::Term::Asset::ValuedItem, Contract::Term::Offer, Contract::Term::Offer::Answer, Contract::Term::Offer::Party, Contract::Term::SecurityLabel, Contributor, Count, Coverage, Coverage::Class, Coverage::CostToBeneficiary, Coverage::CostToBeneficiary::Exception, CoverageEligibilityRequest, CoverageEligibilityRequest::Insurance, CoverageEligibilityRequest::Item, CoverageEligibilityRequest::Item::Diagnosis, CoverageEligibilityRequest::SupportingInfo, CoverageEligibilityResponse, CoverageEligibilityResponse::Error, CoverageEligibilityResponse::Insurance, CoverageEligibilityResponse::Insurance::Item, CoverageEligibilityResponse::Insurance::Item::Benefit, DataRequirement, DataRequirement::CodeFilter, DataRequirement::DateFilter, DataRequirement::Sort, DetectedIssue, DetectedIssue::Evidence, DetectedIssue::Mitigation, Device, Device::DeviceName, Device::Property, Device::Specialization, Device::UdiCarrier, Device::Version, DeviceDefinition, DeviceDefinition::Capability, DeviceDefinition::DeviceName, DeviceDefinition::Material, DeviceDefinition::Property, DeviceDefinition::Specialization, DeviceDefinition::UdiDeviceIdentifier, DeviceMetric, DeviceMetric::Calibration, DeviceRequest, DeviceRequest::Parameter, DeviceUseStatement, DiagnosticReport, DiagnosticReport::Media, Distance, DocumentManifest, DocumentManifest::Related, DocumentReference, DocumentReference::Content, DocumentReference::Context, DocumentReference::RelatesTo, DomainResource, Dosage, Dosage::DoseAndRate, Duration, EffectEvidenceSynthesis, EffectEvidenceSynthesis::Certainty, EffectEvidenceSynthesis::Certainty::CertaintySubcomponent, EffectEvidenceSynthesis::EffectEstimate, EffectEvidenceSynthesis::EffectEstimate::PrecisionEstimate, EffectEvidenceSynthesis::ResultsByExposure, EffectEvidenceSynthesis::SampleSize, Element, ElementDefinition, ElementDefinition::Base, ElementDefinition::Binding, ElementDefinition::Constraint, ElementDefinition::Example, ElementDefinition::Mapping, ElementDefinition::Slicing, ElementDefinition::Slicing::Discriminator, ElementDefinition::Type, Encounter, Encounter::ClassHistory, Encounter::Diagnosis, Encounter::Hospitalization, Encounter::Location, Encounter::Participant, Encounter::StatusHistory, Endpoint, EnrollmentRequest, EnrollmentResponse, EpisodeOfCare, EpisodeOfCare::Diagnosis, EpisodeOfCare::StatusHistory, EventDefinition, Evidence, EvidenceVariable, EvidenceVariable::Characteristic, ExampleScenario, ExampleScenario::Actor, ExampleScenario::Instance, ExampleScenario::Instance::ContainedInstance, ExampleScenario::Instance::Version, ExampleScenario::Process, ExampleScenario::Process::Step, ExampleScenario::Process::Step::Alternative, ExampleScenario::Process::Step::Operation, ExplanationOfBenefit, ExplanationOfBenefit::Accident, ExplanationOfBenefit::AddItem, ExplanationOfBenefit::AddItem::Detail, ExplanationOfBenefit::AddItem::Detail::SubDetail, ExplanationOfBenefit::BenefitBalance, ExplanationOfBenefit::BenefitBalance::Financial, ExplanationOfBenefit::CareTeam, ExplanationOfBenefit::Diagnosis, ExplanationOfBenefit::Insurance, ExplanationOfBenefit::Item, ExplanationOfBenefit::Item::Adjudication, ExplanationOfBenefit::Item::Detail, ExplanationOfBenefit::Item::Detail::SubDetail, ExplanationOfBenefit::Payee, ExplanationOfBenefit::Payment, ExplanationOfBenefit::Procedure, ExplanationOfBenefit::ProcessNote, ExplanationOfBenefit::Related, ExplanationOfBenefit::SupportingInfo, ExplanationOfBenefit::Total, Expression, Extension, FamilyMemberHistory, FamilyMemberHistory::Condition, Field, Flag, Goal, Goal::Target, GraphDefinition, GraphDefinition::Link, GraphDefinition::Link::Target, GraphDefinition::Link::Target::Compartment, Group, Group::Characteristic, Group::Member, GuidanceResponse, HealthcareService, FHIR::HealthcareService::AvailableTime, FHIR::HealthcareService::Eligibility, FHIR::HealthcareService::NotAvailable, HumanName, Identifier, ImagingStudy, ImagingStudy::Series, ImagingStudy::Series::Instance, ImagingStudy::Series::Performer, Immunization, Immunization::Education, Immunization::Performer, Immunization::ProtocolApplied, Immunization::Reaction, ImmunizationEvaluation, ImmunizationRecommendation, ImmunizationRecommendation::Recommendation, ImmunizationRecommendation::Recommendation::DateCriterion, ImplementationGuide, ImplementationGuide::Definition, ImplementationGuide::Definition::Grouping, ImplementationGuide::Definition::Page, ImplementationGuide::Definition::Parameter, ImplementationGuide::Definition::Resource, ImplementationGuide::Definition::Template, ImplementationGuide::DependsOn, ImplementationGuide::Global, ImplementationGuide::Manifest, ImplementationGuide::Manifest::Page, ImplementationGuide::Manifest::Resource, InsurancePlan, InsurancePlan::Contact, InsurancePlan::Coverage, InsurancePlan::Coverage::Benefit, InsurancePlan::Coverage::Benefit::Limit, InsurancePlan::Plan, InsurancePlan::Plan::GeneralCost, InsurancePlan::Plan::SpecificCost, InsurancePlan::Plan::SpecificCost::Benefit, InsurancePlan::Plan::SpecificCost::Benefit::Cost, Invoice, Invoice::LineItem, Invoice::LineItem::PriceComponent, Invoice::Participant, Library, Linkage, Linkage::Item, List, List::Entry, Location, Location::HoursOfOperation, Location::Position, MarketingStatus, Measure, Measure::Group, Measure::Group::Population, Measure::Group::Stratifier, Measure::Group::Stratifier::Component, Measure::SupplementalData, MeasureReport, MeasureReport::Group, MeasureReport::Group::Population, MeasureReport::Group::Stratifier, MeasureReport::Group::Stratifier::Stratum, MeasureReport::Group::Stratifier::Stratum::Component, MeasureReport::Group::Stratifier::Stratum::Population, Media, Medication, Medication::Batch, Medication::Ingredient, MedicationAdministration, MedicationAdministration::Dosage, MedicationAdministration::Performer, MedicationDispense, MedicationDispense::Performer, MedicationDispense::Substitution, MedicationKnowledge, MedicationKnowledge::AdministrationGuidelines, MedicationKnowledge::AdministrationGuidelines::Dosage, MedicationKnowledge::AdministrationGuidelines::PatientCharacteristics, MedicationKnowledge::Cost, MedicationKnowledge::DrugCharacteristic, MedicationKnowledge::Ingredient, MedicationKnowledge::Kinetics, MedicationKnowledge::MedicineClassification, MedicationKnowledge::MonitoringProgram, MedicationKnowledge::Monograph, MedicationKnowledge::Packaging, MedicationKnowledge::Regulatory, MedicationKnowledge::Regulatory::MaxDispense, MedicationKnowledge::Regulatory::Schedule, MedicationKnowledge::Regulatory::Substitution, MedicationKnowledge::RelatedMedicationKnowledge, MedicationRequest, MedicationRequest::DispenseRequest, MedicationRequest::DispenseRequest::InitialFill, MedicationRequest::Substitution, MedicationStatement, MedicinalProduct, MedicinalProduct::ManufacturingBusinessOperation, MedicinalProduct::Name, MedicinalProduct::Name::CountryLanguage, MedicinalProduct::Name::NamePart, MedicinalProduct::SpecialDesignation, MedicinalProductAuthorization, MedicinalProductAuthorization::JurisdictionalAuthorization, MedicinalProductAuthorization::Procedure, MedicinalProductContraindication, MedicinalProductContraindication::OtherTherapy, MedicinalProductIndication, MedicinalProductIndication::OtherTherapy, MedicinalProductIngredient, MedicinalProductIngredient::SpecifiedSubstance, MedicinalProductIngredient::SpecifiedSubstance::Strength, MedicinalProductIngredient::SpecifiedSubstance::Strength::ReferenceStrength, MedicinalProductIngredient::Substance, MedicinalProductInteraction, MedicinalProductInteraction::Interactant, MedicinalProductManufactured, MedicinalProductPackaged, MedicinalProductPackaged::BatchIdentifier, MedicinalProductPackaged::PackageItem, MedicinalProductPharmaceutical, MedicinalProductPharmaceutical::Characteristics, MedicinalProductPharmaceutical::RouteOfAdministration, MedicinalProductPharmaceutical::RouteOfAdministration::TargetSpecies, MedicinalProductPharmaceutical::RouteOfAdministration::TargetSpecies::WithdrawalPeriod, MedicinalProductUndesirableEffect, MessageDefinition, MessageDefinition::AllowedResponse, MessageDefinition::Focus, MessageHeader, MessageHeader::Destination, MessageHeader::Response, MessageHeader::Source, Meta, MolecularSequence, MolecularSequence::Quality, MolecularSequence::Quality::Roc, MolecularSequence::ReferenceSeq, MolecularSequence::Repository, MolecularSequence::StructureVariant, MolecularSequence::StructureVariant::Inner, MolecularSequence::StructureVariant::Outer, MolecularSequence::Variant, Money, NamingSystem, NamingSystem::UniqueId, Narrative, NutritionOrder, NutritionOrder::EnteralFormula, NutritionOrder::EnteralFormula::Administration, NutritionOrder::OralDiet, NutritionOrder::OralDiet::Nutrient, NutritionOrder::OralDiet::Texture, NutritionOrder::Supplement, Observation, Observation::Component, Observation::ReferenceRange, ObservationDefinition, ObservationDefinition::QualifiedInterval, ObservationDefinition::QuantitativeDetails, OperationDefinition, OperationDefinition::Overload, OperationDefinition::Parameter, OperationDefinition::Parameter::Binding, OperationDefinition::Parameter::ReferencedFrom, OperationOutcome, OperationOutcome::Issue, Organization, Organization::Contact, OrganizationAffiliation, ParameterDefinition, Parameters, Parameters::Parameter, Patient, Patient::Communication, Patient::Contact, Patient::Link, PaymentNotice, PaymentReconciliation, PaymentReconciliation::Detail, PaymentReconciliation::ProcessNote, Period, Person, Person::Link, PlanDefinition, PlanDefinition::Action, PlanDefinition::Action::Condition, PlanDefinition::Action::DynamicValue, PlanDefinition::Action::Participant, PlanDefinition::Action::RelatedAction, PlanDefinition::Goal, PlanDefinition::Goal::Target, Population, Practitioner, Practitioner::Qualification, PractitionerRole, PractitionerRole::AvailableTime, PractitionerRole::NotAvailable, Procedure, Procedure::FocalDevice, Procedure::Performer, ProdCharacteristic, ProductShelfLife, Provenance, Provenance::Agent, Provenance::Entity, Quantity, Questionnaire, Questionnaire::Item, Questionnaire::Item::AnswerOption, Questionnaire::Item::EnableWhen, Questionnaire::Item::Initial, QuestionnaireResponse, QuestionnaireResponse::Item, QuestionnaireResponse::Item::Answer, Range, Ratio, Reference, RelatedArtifact, RelatedPerson, RelatedPerson::Communication, RequestGroup, RequestGroup::Action, RequestGroup::Action::Condition, RequestGroup::Action::RelatedAction, ResearchDefinition, ResearchElementDefinition, ResearchElementDefinition::Characteristic, ResearchStudy, ResearchStudy::Arm, ResearchStudy::Objective, ResearchSubject, Resource, RiskAssessment, RiskAssessment::Prediction, RiskEvidenceSynthesis, RiskEvidenceSynthesis::Certainty, RiskEvidenceSynthesis::Certainty::CertaintySubcomponent, RiskEvidenceSynthesis::RiskEstimate, RiskEvidenceSynthesis::RiskEstimate::PrecisionEstimate, RiskEvidenceSynthesis::SampleSize, SampledData, Schedule, SearchParameter, SearchParameter::Component, ServiceRequest, Signature, Slot, Specimen, Specimen::Collection, Specimen::Container, Specimen::Processing, SpecimenDefinition, SpecimenDefinition::TypeTested, SpecimenDefinition::TypeTested::Container, SpecimenDefinition::TypeTested::Container::Additive, SpecimenDefinition::TypeTested::Handling, StructureDefinition, StructureDefinition::Context, StructureDefinition::Differential, StructureDefinition::Mapping, StructureDefinition::Snapshot, StructureMap, StructureMap::Group, StructureMap::Group::Input, StructureMap::Group::Rule, StructureMap::Group::Rule::Dependent, StructureMap::Group::Rule::Source, StructureMap::Group::Rule::Target, StructureMap::Group::Rule::Target::Parameter, StructureMap::Structure, Subscription, Subscription::Channel, Substance, Substance::Ingredient, Substance::Instance, SubstanceAmount, SubstanceAmount::ReferenceRange, SubstanceNucleicAcid, SubstanceNucleicAcid::Subunit, SubstanceNucleicAcid::Subunit::Linkage, SubstanceNucleicAcid::Subunit::Sugar, SubstancePolymer, SubstancePolymer::MonomerSet, SubstancePolymer::MonomerSet::StartingMaterial, SubstancePolymer::Repeat, SubstancePolymer::Repeat::RepeatUnit, SubstancePolymer::Repeat::RepeatUnit::DegreeOfPolymerisation, SubstancePolymer::Repeat::RepeatUnit::StructuralRepresentation, SubstanceProtein, SubstanceProtein::Subunit, SubstanceReferenceInformation, SubstanceReferenceInformation::Classification, SubstanceReferenceInformation::Gene, SubstanceReferenceInformation::GeneElement, SubstanceReferenceInformation::Target, SubstanceSourceMaterial, SubstanceSourceMaterial::FractionDescription, SubstanceSourceMaterial::Organism, SubstanceSourceMaterial::Organism::Author, SubstanceSourceMaterial::Organism::Hybrid, SubstanceSourceMaterial::Organism::OrganismGeneral, SubstanceSourceMaterial::PartDescription, SubstanceSpecification, SubstanceSpecification::Code, SubstanceSpecification::Moiety, SubstanceSpecification::Name, SubstanceSpecification::Name::Official, SubstanceSpecification::Property, SubstanceSpecification::Relationship, SubstanceSpecification::Structure, SubstanceSpecification::Structure::Isotope, SubstanceSpecification::Structure::Isotope::MolecularWeight, SubstanceSpecification::Structure::Representation, SupplyDelivery, SupplyDelivery::SuppliedItem, SupplyRequest, SupplyRequest::Parameter, Task, Task::Input, Task::Output, Task::Restriction, TerminologyCapabilities, TerminologyCapabilities::Closure, TerminologyCapabilities::CodeSystem, TerminologyCapabilities::CodeSystem::Version, TerminologyCapabilities::CodeSystem::Version::Filter, TerminologyCapabilities::Expansion, TerminologyCapabilities::Expansion::Parameter, TerminologyCapabilities::Implementation, TerminologyCapabilities::Software, TerminologyCapabilities::Translation, TerminologyCapabilities::ValidateCode, TestReport, TestReport::Participant, TestReport::Setup, TestReport::Setup::Action, TestReport::Setup::Action::Assert, TestReport::Setup::Action::Operation, TestReport::Teardown, TestReport::Teardown::Action, TestReport::Test, TestReport::Test::Action, TestScript, TestScript::Destination, TestScript::Fixture, TestScript::Metadata, TestScript::Metadata::Capability, TestScript::Metadata::Link, TestScript::Origin, TestScript::Setup, TestScript::Setup::Action, TestScript::Setup::Action::Assert, TestScript::Setup::Action::Operation, TestScript::Setup::Action::Operation::RequestHeader, TestScript::Teardown, TestScript::Teardown::Action, TestScript::Test, TestScript::Test::Action, TestScript::Variable, Timing, Timing::Repeat, TriggerDefinition, UsageContext, ValueSet, ValueSet::Compose, ValueSet::Compose::Include, ValueSet::Compose::Include::Concept, ValueSet::Compose::Include::Concept::Designation, ValueSet::Compose::Include::Filter, ValueSet::Expansion, ValueSet::Expansion::Contains, ValueSet::Expansion::Parameter, VerificationResult, VerificationResult::Attestation, VerificationResult::PrimarySource, VerificationResult::Validator, VisionPrescription, VisionPrescription::LensSpecification, VisionPrescription::LensSpecification::Prism
- Defined in:
- lib/fhir_models/bootstrap/hashable.rb
Instance Method Summary collapse
Instance Method Details
#from_hash(hash) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fhir_models/bootstrap/hashable.rb', line 44 def from_hash(hash) # eliminate empty stuff hash = prune(hash) unless hash.empty? # clear the existing variables self.class::METADATA.each do |key, value| local_name = key local_name = value['local_name'] if value['local_name'] instance_variable_set("@#{local_name}", nil) end # set the variables to the hash values hash.each do |key, value| key = key.to_s = self.class::METADATA[key] next if .nil? local_name = key local_name = ['local_name'] if ['local_name'] begin instance_variable_set("@#{local_name}", value) rescue # TODO: this appears to be a dead code branch nil end # inflate the value if it isn't a primitive klass = FHIR::PRIMITIVES.key?(['type']) ? nil : FHIR.const_get(['type']) if !klass.nil? && !value.nil? # handle array of objects if value.is_a?(Array) value = value.map { |child| make_child(child, klass) } else # handle single object value = make_child(value, klass) # if there is only one of these, but cardinality allows more, we need to wrap it in an array. value = [value] if value && (['max'] > 1) end instance_variable_set("@#{local_name}", value) elsif !FHIR::PRIMITIVES.include?(['type']) && ['type'] != 'xhtml' FHIR.logger.error("Unhandled and unrecognized class/type: #{['type']}") elsif value.is_a?(Array) # array of primitives value = value.map { |child| convert_primitive(child, ) } instance_variable_set("@#{local_name}", value) else # single primitive value = convert_primitive(value, ) # if there is only one of these, but cardinality allows more, we need to wrap it in an array. value = [value] if value && (['max'] > 1) instance_variable_set("@#{local_name}", value) end # !klass && !nil? end # hash loop self end |
#to_hash ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fhir_models/bootstrap/hashable.rb', line 4 def to_hash hash = {} self.class::METADATA.each do |key, value| local_name = key local_name = value['local_name'] if value['local_name'] hash[key] = instance_variable_get("@#{local_name}") if hash[key].respond_to?(:to_hash) hash[key] = hash[key].to_hash elsif hash[key].is_a? Array hash[key] = Array.new(hash[key]) # copy the array hash[key].each_with_index do |item, index| hash[key][index] = item.to_hash if item.respond_to?(:to_hash) end end end hash = prune(hash) hash['resourceType'] = resourceType if respond_to?(:resourceType) hash end |