app/controllers/application_controller.rb
def fetch_plans (id = nil)
    @plans = []
    parameters = {}
    @networks_by_plan = {}

    #parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' 
    parameters[:_count] = 100
    if (id.present?)
      parameters[:_id] = id
    end

    insurance_plans = @client.search(FHIR::InsurancePlan,
                                      search: { parameters: parameters })
    if good_response(insurance_plans.response[:code]) 
      insurance_plans.resource.entry.map do |entry|
        if entry.resource.id.present? && entry.resource.name.present?
          @plans << {
            value: entry.resource.id,
            name: entry.resource.name
          }
          @networks_by_plan[entry.resource.id] = entry.resource.network
        end
      end

      @plans.sort_by! { |hsh| hsh[:name] }
    else
      redirect_to root_path, 
          flash: { error: "Could not retrieve insurance plans from the server (fetch_plans, " + 
                        insurance_plans.response[:code].to_s + ")" }
    end
  end
# Fetch all plans, and remember their resources, names, and networks
Fetch all plans, and remember their resources, names, and networks
Fetch all plans and remember their resources names and networks
def fetch_plans (id = nil)
    @plans = []
    parameters = {}
    @networks_by_plan = {}
    parameters[:_count] = 100
    if (id.present?)
      parameters[:_id] = id
    end
    insurance_plans = @client.search(FHIR::InsurancePlan,
                                      search: { parameters: parameters })
    if good_response(insurance_plans.response[:code]) 
      insurance_plans.resource.entry.map do |entry|
        if entry.resource.id.present? && entry.resource.name.present?
          @plans << {
            value: entry.resource.id,
            name: entry.resource.name
          }
          @networks_by_plan[entry.resource.id] = entry.resource.network
        end
      end
      @plans.sort_by! { |hsh| hsh[:name] }
    else
      redirect_to root_path, 
          flash: { error: "Could not retrieve insurance plans from the server (fetch_plans, " + 
                        insurance_plans.response[:code].to_s + ")" }
    end
  end
def fetch_plans ( id = nil ) @plans = [ ] parameters = { } @networks_by_plan = { } parameters [ :_count ] = 100 if ( id . present? ) parameters [ :_id ] = id end insurance_plans = @client . search ( FHIR :: InsurancePlan , search : { parameters : parameters } ) if good_response ( insurance_plans . response [ :code ] ) insurance_plans . resource . entry . map do | entry | if entry . resource . id . present? && entry . resource . name . present? @plans << { value : entry . resource . id , name : entry . resource . name } @networks_by_plan [ entry . resource . id ] = entry . resource . network end end @plans . sort_by! { | hsh | hsh [ :name ] } else redirect_to root_path , flash : { error : "Could not retrieve insurance plans from the server (fetch_plans, " + insurance_plans . response [ :code ] . to_s + ")" } end end
Fetch all plans, and remember their resources, names, and networks
Fetch all plans and remember their resources names and networks
#parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' 
id