view · edit · sidebar · attach · print · history

20111101-debug-slupdate-replace-hospital-link-format-oddb_org

<< | Index | >>


  1. Debug SL-Update (XML) oddb.org
  2. Replace Hospital link with ean-code
  3. Replace updated log link
  4. Replace Admin Company Link

Goal/Estimate/Evaluation
  • Replace Hospital link with Eancode / 100% / 90%
Commit

Debug SL-Update (XML) oddb.org

Refer to http://dev.ywesee.com/wiki.php/Choddb/Bagxml

Replace Hospital link with ean-code

Link

Update

  • src/state/global.rb
      def hospital
        if ean = @session.user_input(:ean) and model = @session.app.hospital(ean)
           State::Hospitals::Hospital.new(@session, model)
        end
      end
  • src/state/admin/root.rb
  def hospital
    if ean = @session.user_input(:ean) and model = @session.app.hospital(ean)
      State::Hospitals::RootHospital.new(@session, model)
    end
  end
  • src/util/validator.rb
    EVENTS = [
      :hospital,

VCard link

Update

  • src/state/global.rb
      def vcard
        doctor = if ean_or_oid = @session.user_input(:doctor)
                   @session.search_doctor(ean_or_oid) or @session.search_doctors(ean_or_oid).first
                 elsif pointer = @session.user_input(:pointer)
                   pointer.resolve(@session)
                 end
        hospital = if ean = @session.user_input(:hospital)
                     @session.app.hospital(ean)
                   elsif pointer = @session.user_input(:pointer)
                     pointer.resolve(@session)
                   end
        if doctor
          State::Doctors::VCard.new(@session, doctor)
        elsif hospital
          State::Hospitals::VCard.new(@session, hospital)
        end
      end
  • src/util/validator.rb
    STRINGS = [
      :hospital,
  • src/view/hospitals/hospital.rb
  • src/view/hospitals/hospitallist.rb
  def vcard(model)
    link = View::PointerLink.new(:vcard, model, @session, self)
    link.href = @lookandfeel._event_url(:vcard, {:hospital => model.ean13})
    link
  end

Commit

Korrigieren link

Update

  • src/util/session.rb
    def search_hospital(ean)
      @persistent_user_input[:ean] ||= ean
      @app.hospital(ean)
    end
  • src/state/global.rb
      def suggest_address
 ...
        else
          doctor = if oid_or_ean = @session.user_input(:doctor)
                     @session.search_doctor(oid_or_ean) || @session.search_doctors(oid_or_ean).first
                   end
          hospital = if ean = @session.user_input(:hospital)
                       @session.search_hospital(ean)
                     end
          if (doctor and addr = doctor.address(@session.user_input(:address))) 
or (hospital and addr = hospital.address(@session.user_input(:address))) SuggestAddress.new(@session, addr) end end end
  • src/view/address.rb
    def correct(model)
    button = HtmlGrid::Button.new(:correct,
      model, @session, self)
    args = if ean = @session.user_input(:ean) and hospital = @session.search_hospital(ean) \
             and address = hospital.addresses.index(model)
      [
        :hospital, ean,
        :address, address,
        :zone, @session.zone,
      ]
    elsif ean = @session.user_input(:ean) and doctors = @session.search_doctors(ean) and doctor = doctors.first       and address = doctor.addresses.index(model)
      [
        :doctor, ean,
        :address, address,
        :zone, @session.zone,
      ]

Note

  • It is no problem to use 'ean' key in a link to get an eancode for both doctor and hospital because an eancode is never duplicated both in doctor and hospital

Email link (State::AddressSuggest)

Update

  • src/state/admin/address_suggestion.rb
 def init
    if(addr = @model.address_instance or addr = @model.address_pointer.resolve(@session))
      @active_address = AddressWrapper.new(addr)
      @parent = if ean_or_oid = @session.persistent_user_input(:ean) || @session.persistent_user_input(:oid) \\
                  and parent = @session.search_doctor(ean_or_oid) || @session.search_doctors(ean_or_oid).first
                    parent
                elsif ean = @session.persistent_user_input(:ean) and  parent = @session.search_hospital(ean_or_oid)
                  parent
                else pointer = @model.address_pointer
                  pointer.parent.resolve(@session)
                end
      select_zone(@parent)
      @active_address.email_suggestion = @parent.email
    end
    super
 end
  • src/state/global.rb
      def address_suggestion
        if (ean_or_oid = @session.user_input(:doctor) and (doctor = @session.search_doctor(ean_or_oid) || @session.search_doctors(ean_or_oid).first)) \\
          or (ean = @session.user_input(:hospital) and hospital = @session.search_hospital(ean))
          if oid = @session.user_input(:oid) and model = @session.app.address_suggestion(oid)
            State::Admin::TransparentLogin.new(@session, model)
          end
        end
      end
  • src/state/admin/root.rb
 def address_suggestion
    if (ean_or_oid = @session.user_input(:doctor) and (doctor = @session.search_doctor(ean_or_oid) || @session.search_doctors(ean_or_oid).first)) \\
      or (ean = @session.user_input(:hospital) and hospital = @session.search_hospital(ean))
      if oid = @session.user_input(:oid) and model = @session.app.address_suggestion(oid)
        State::Admin::AddressSuggestion.new(@session, model)
      end
    end
 end
  • src/state/suggest_address.rb
      def save_suggestion

        @parent = if ean_or_oid = @session.persistent_user_input(:oid) and parent = (@session.search_doctor(ean_or_oid) || @session.search_doctors(ean_or_oid).first)
                   parent
                 elsif ean = @session.persistent_user_input(:ean) and parent = @session.search_hospital(ean)
                   parent
                 else
                   @model.parent(@session)
                 end

      def send_notification(suggestion)
        url = if @parent.is_a?(ODDB::Doctor)
                @session.lookandfeel._event_url(:address_suggestion, [:doctor, (@parent.ean13 || @parent.oid), :oid, suggestion.oid])
              elsif @parent.is_a?(ODDB::Hospital)
                @session.lookandfeel._event_url(:address_suggestion, [:hospital, @parent.ean13, :oid, suggestion.oid])
              else
                @session.lookandfeel._event_url(:resolve, {:pointer => suggestion.pointer})
              end

Commit

Replace updated log link

View

  • The updated log view is shown when 'löschen' button is clicked in the view of the korrigieren link

Question

Problem

  • View::Admin::Addresses view is shown based on AddressSuggestion instance
  • Pointer#parent method is use to get Doctor or Hospital instance

Solution

  • To save new type link information in AddressSuggestion instance

Update

  • src/model/address.rb
    class AddressSuggestion < Address2
    attr_accessor :url, :parent
  • src/state/suggest_address.rb
      def save_suggestion
 ...
         input.store(:parent, @parent)
         unless error?
 ...
          input.store(:url, @url)
          @session.app.update(pointer, input, unique_email)
        end
  • src/view/admin/addresses.rb
 def parent_class(model)
    obj = model.parent || begin
      ptr = model.address_pointer
      ptr.parent.resolve(@session)
    end
    @lookandfeel.lookup(obj.class)
 end
 def time(model)
    if(time = model.time)
      link = PointerLink.new(:time, model, @session,self)
      fmt = @lookandfeel.lookup(:time_format_long)
      link.value = time.strftime(fmt)
      link.href = model.url if model.url
      link
    end
 end
 def name(model)
    link = View::PointerLink.new(:name, model, @session, self)
    link.href = model.url if model.url
    link
 end

Replace Admin Company Link

Link

Check

ch.oddb> companies.values.map{|c| c.ean13}.length
-> 740
ch.oddb> companies.values.map{|c| c.ean13}.compact.length
-> 456
ch.oddb> companies.values.map{|c| c.ean13}.compact.uniq.length
-> 384
ch.oddb> open('/home/masa/work/company_ean.dat', 'w'){|out| out.print companies.values.map{|c| c.ean13}.compact.join("\n")

Note

view · edit · sidebar · attach · print · history
Page last modified on November 01, 2011, at 04:59 PM