view · edit · sidebar · attach · print · history

20110930-setup-new-bbmb-rename-order-filename-bbmb-update-fi-google-twitter-button-migel

<< | Index | >>


  1. Check setting process of 'bezugsgruppe'
  2. Update new FI
  3. Put google button in the search result view migel
  4. Remove page number if the result is in only one page migel
  5. Add Twitter button migel
  6. Rename normal order file name bbmb.ch

Goal/Estimate/Evaluation
  • Set up new bbmb / 100% / 100%
  • Update migel / 100% / 100%
Milestones
  1. 'Lieferant' (company name) is not shown in the search result view (bbmb.ch) already resolved (I have done nothing though...)
  2. Check setting process 'bezugsgruppe' to 'Apo' (create new bin/admin command to change 'bezugsgruppe' to 'Apo' (bbmb.ch))
  3. Update 'FI' information (get a new atc.yaml file from ch.oddb.org and put it manually, refer to http://dev.ywesee.com/wiki.php/Masa/20110728-setup-fi-ddd-bbmbCh)
  4. Google search migel
  5. Remove page migel
  6. Twitter migel
  7. Rename order file name bbmb.ch
  8. Testcases, migel, oddb.org, bbmb.ch
Commit

Check setting process of 'bezugsgruppe'

Check all 'Apo' users (locally)

ch.bbmb.globopharm> open('/home/masa/work/apo_users.dat','w'){|f| users.values.each{|u| f.print u.value('customer_ean13'), "\t", u.value('group_short'), "\n" if u.value('group_short')=='Apo'}}
-> Array
ch.bbmb.globopharm> open('/home/masa/work/nonapo_users.dat','w'){|f| users.values.each{|u| f.print u.value('customer_ean13'), "\t", u.value('address1'), "\n" if u.value('address1')=='Konditionskunde'}}
-> Array

ch.bbmb.globopharm> users.values.select{|u| u.value('group_short')=='Apo'}.length
-> 1802
ch.bbmb.globopharm> users.values.select{|u| u.value('address1')=='Konditionskunde'}.length
-> 0

Server

ch.bbmb.globopharm> users.values.select{|u| u.value('group_short')=='Apo'}.length
-> 2077
ch.bbmb.globopharm> users.values.select{|u| u.value('address1')=='Konditionskunde'}.length
-> 0

Summary

  • No problem
  • All customers in 'Customers.csv' belong to 'Apo', the other customers' group does not change
  • To update customers and stocks, Customers.csv and Items.csv must be located on the 'OUT' directory of the server

Update new FI

Problem

  • Fachinformation on the server is old (2002)

Note

  • New fachinfo.yaml is not downloaded from ch.oddb.org server
  • I have to put it on manually

Check code

  • src/plugin/yaml.rb
        def update_fachinfos
      #http = Net::HTTP.new(self::class::HTTP_SERVER)
      docs = nil
      http = nil
      path = self::class::FACHINFO_PATH
p path
      name = File.basename(path)
p name
      local = File.expand_path(name, self::class::DATA_DIR)
p local
p is_newer?(http, path, local)
p download(http, path, local)
      if(is_newer?(http, path, local) && download(http, path, local))
        self::class::YAML_COLLECTOR.fachinfos(local) { |collector|
          docs = collect_dump('fi_dump', :fachinfo_documents, collector) 
          '' # return empty string across drb-boundary
        }
      end
      docs
    end

Set up cron job

Get atc.yaml and fachinfo.yaml from ch.oddb.org

  • /usr/local/sbin/bbmb-fi-ddd-atc
  • /etc/crontab
0 21 27 * * root /usr/local/sbin/bbmb-fi-ddd-atc

Note

  • bbmb.ch compares 2 yaml files between in bbmb.ch/data/yaml and in /var/data directories
  • If they are different, bbmb.ch updates them
  • Refer to src/plugin/yaml.rb

Commit

Put google button in the search result view migel

Update

  • src/view/migel/items.rb
    class SearchedList < HtmlGrid::List
    include View::AdditionalInformation
def init
    @components = {
      [7,0]    =>  :google_search,
    }
    @css_map = {
      [7,0]   => 'list',
    }
  • lib/migel/model/product.rb
      def localized_name(language)
        self.name.send(language)
      end

Result

Note

  • Google button use Migel::Model::Product#localized_name method (Refer to src/view/additional_information.rb#google_search)

Commit

Remove page number if the result is in only one page migel

Update

  • src/state/global.rb
      def migel_search
        @session.set_cookie_input(:resultview, '')
        sortvalue = @session.user_input(:sortvalue) || @session.user_input(:reverse)
        reverse  = @session.user_input(:reverse)
        if migel_code = @session.user_input(:migel_code) and result = @session.app.search_migel_items_by_migel_code(migel_code, sortvalue, reverse)
          product = StubProduct.new(result)
          @session.set_cookie_input(:resultview, 'pages') if items = product.items and items.length > ODDB::State::Migel::Items::ITEM_LIMIT
          ODDB::State::Migel::Items.new(@session, ODDB::Migel::Items.new(product))
  • src/state/migel/items.rb
    def pages(model, session=@session)
    if @session.cookie_set_or_get(:resultview) == "pages"
      ...
      View::Pager.new(pages, @session, self, event, args)
    end
    end

Run

  • bin/currencyd
  • bin/oddbd
  • bin/migeld

Access

Result

  • one page result
  • many pages result

Note

  • Cookie information is used for the on/off condition to show the page navigator
  • Be careful to use cookie because this is a kind of global variable
  • The same cookie data is used for the other process
    • Check the search result of
grep -r "cookie_set_or_get(:resultview" src
grep -r "set_cookie_input(:resultview" src

Commit

Add Twitter button migel

Experiment

  • src/view/migel/items.rb
    class SearchedList < HtmlGrid::List include View::AdditionalInformation def init
    @components = {
      [8,0]    =>  :twitter_share,
    }
    @css_map = {
      [8,0]   => 'list',
  • lib/migel/model/product.rb
      def name_base
        self.name.de
      end
      def commercial_forms
        []
      end
      def indication
        nil
      end

Note

  • These are all called from from ch.oddb.org (src/view/addtional_information.rb#twitter_share method)

Access

Result

  • The twitter button is shown but it does not work

Experiment

  • src/view/additional_information.rb
      def twitter_share(model, session=@session)
        link = HtmlGrid::Link.new(:twitter_share_short, model, @session, self)
        link.value = HtmlGrid::Image.new(:icon_twitter, model, @session, self)
        base = ''
        url  = ''
        if model.is_a?(DRb::DRbObject)
          # in the case of migel items
          base = model.localized_name(session.language)
          url  = @lookandfeel._event_url(:migel_search, {:migel_pharmacode => model.pharmacode})
        else
          base = model.name_base
          url = @lookandfeel._event_url(:show, {:pointer => model.pointer})
        end
  • src/view/migel/items.rb
    class Items < View::PrivateTemplate
    JAVASCRIPTS = ['bit.ly']

Result

Note

  • To activate 'twitter_share' button (to pop up twitter window), we need 'bit.ly' java script

Commit

Rename normal order file name bbmb.ch

Updates

  • src/custom/behavior.rb
    def transmission_filename(user, order, flavor=BBMB::DEFAULT_FLAVOR)
      case flavor
      when 'astrazeneca'
        "AZ#{user.value(:customer_ean13) || user.value(:customer_id)}_#{order.uid}.dat1"
      else
        @order_id = "%015d" % rand(10**15).to_s
        #"KD#{user.value(:customer_ean13) || user.value(:customer_id)}_#{order.uid}.dat"
        "CO_#{@order_id}_#{Time.now.strftime("mH%M")}.dat"
      end
    end

    def transmission_header(user, order)
      header2 = [
        "250:ADE",
        #"251:#{order.uid}",
        "251:#{@order_id}",
        "300:4",
        "301:#{order.commit_time.strftime('m%d')}",
      ]

Run

  • bin/bbmbd

Login by Hospital User

Order

  1. search some drug (For example, astra)
  2. select and put in a number
  3. click 'Zu bestellung Hinzufügen'
  4. select 'Nichts Auswählen'
  5. click 'Bestellung Auslösen'

Then

  • the order file will be sent to the ftp server (IN/CustomerOrder)

Result

  • File name: CO_266227125866183_201109301631.dat
  • 010: CO_266227125866183_201109301631.dat
  • 251:266227125866183

Commit

view · edit · sidebar · attach · print · history
Page last modified on September 30, 2011, at 04:48 PM