view · edit · sidebar · attach · print · history

20110609-replace-load_ikskey-bsvxmlplugin-swissinex-ch_oddb

<< | Index | >>


  1. Check dependency SL-Update(XML)
  2. Update Testcases suspend
  3. Replace load_key with swissindex in BsvXmlPlugin

Goal/Estimate/Evaluation
  • update load_ikskey BsvXmlPlugin / 70% / 100%
Milestones
Summary
Commits
Next

Check dependency SL-Update(XML)

Check

  1. src/util/updater.rb#update_swissmedic_followers
  2. src/plugin/medwin.rb#MedwinCompanyPlugin class
  3. src/plugin/medwin.rb#update
  4. src/plugin/medwin.rb#update_company
  5. src/plugin/medwin.rb#update_company_data

Note

 As far as I read the code,

  update_medwin_companies

 method is called in update_swissmedic_followers method of src/util/updater.rb.
 The update_medwin_companies method does as follows:
 1. search the company by company name or company ean-code
 2. (if the data is found) the company address, phone, fax, etc. are updated

Update Testcases

  1. src/plugin/swissindex.rb (coverage: 100%)
  2. src/state/bsv_xml.rb (7 Errors)
  3. src/state/substances/substance.rb (coverage: 81.82%)
  4. src/state/admin/companyuser.rb (coverage: 63.27%)
  5. src/view/user/plugin.rb (coverage: 38.38%)
  6. src/view/admin/orphaned_fachinfo_assign.rb (coverage: 81.44%)

Replace load_key with swissindex in BsvXmlPlugin

Test

masa@masa ~/ywesee/oddb.org $ bin/admin
ch.oddb> registration('31706').package('114').ikskey
-> 31706114
ch.oddb> registration('31706').package('114').iksnr
-> 31706
ch.oddb> registration('31706').package('114').ikscd
-> 114
ch.oddb> registration('31706').package('114').barcode
-> 7680317061142

Note

  • ikskey = iksnr (registration number, 5 digits) + ikscd (package number, 3 digits)
  • barcode(ean-code, 13 digits) = 7680(4 digits) + ikskey(8 digits) + checksum(1 digits)

Experiment

  • ext/swissindex/src/swissindex_pharma.rb#search_item_by_pharmacode
  #def search_item(eancode, lang = 'DE', search_type = :get_by_gtin)
  def search_item(code, search_type = :get_by_gtin, lang = 'DE')
    client = Savon::Client.new do | wsdl, http |
      wsdl.document = "https://index.ws.e-mediat.net/Swissindex/Pharma/ws_Pharma_V101.asmx?WSDL"
    end
    try_time = 3
    begin
      #response = client.request :get_by_gtin do
      response = client.request search_type do
      soap.xml = if search_type == :get_by_gting
      '<?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
          <GTIN xmlns="http://swissindex.e-mediat.net/SwissindexPharma_out_V101">' + code + '</GTIN>
          <lang xmlns="http://swissindex.e-mediat.net/SwissindexPharma_out_V101">' + lang    + '</lang>
        </soap:Body>
      </soap:Envelope>'
                 elsif search_type == :get_by_pharmacode
      '<?xml version="1.0" encoding="utf-8"?>
      <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Body>
          <pharmacode xmlns="http://swissindex.e-mediat.net/SwissindexPharma_out_V101">' + code + '</pharmacode>
          <lang xmlns="http://swissindex.e-mediat.net/SwissindexPharma_out_V101">' + lang    + '</lang>
        </soap:Body>
      </soap:Envelope>'
                 end
      end
      if pharma = response.to_hash[:pharma]
        return pharma[:item]
      else
        return nil
      end
...
  • src/plugin/swissindex.rb#SwissindexPharmaPlugin#load_ikskey
    def load_ikskey(pharmacode)
        SWISSINDEX_PHARMA_SERVER.session(ODDB::Swissindex::SwissindexPharma) do |swissindex|
          if item = swissindex.search_item(pharmacode, :get_by_pharmacode)
            if ean = item[:gtin]
              ikskey = ean.to_s[4,8]
            end
          end
        end
    end

Result

masa@masa ~/ywesee/oddb.org $ bin/admin
ch.oddb> ODDB::SwissindexPharmaPlugin.new(self).load_ikskey('4020608')
-> 59169007

Experiment (src/plugin/swissindex.rb#load_ikskey)

    def load_ikskey(pharmacode)
      ikskey = nil
nonpharma = false
      SWISSINDEX_PHARMA_SERVER.session(ODDB::Swissindex::SwissindexPharma) do |swissindex|
        if item = swissindex.search_item(pharmacode, :get_by_pharmacode)
          if ean = item[:gtin]
            ikskey = ean.to_s[4,8]
          end
        end
      end
      unless ikskey
        SWISSINDEX_NONPHARMA_SERVER.session(ODDB::Swissindex::SwissindexNonpharma) do |swissindex|
          if item = swissindex.search_item(pharmacode, :get_by_pharmacode)
            if ean = item[:gtin]
              ikskey = ean.to_s[4,8]
            end
          end
        end
      end
open("/home/masa/work/log.dat", "a"){|f|
  f.print "pharmacode = ", pharmacode, ", ikskey = ", ikskey
  f.print " (nonpharma)" if nonpharma
  f.print "\n"
}

      return ikskey
    end

Result

masa@masa ~/ywesee/oddb.org $ bin/admin
ch.oddb> ODDB::SwissindexPlugin.new(self).load_ikskey('4020608')
-> 59169007
ch.oddb> ODDB::SwissindexPlugin.new(self).load_ikskey('1111111')
-> 

Experiment (src/plugin/bsv_xml.rb#load_ikskey)

      def load_ikskey pcode
        return if pcode.to_s.empty?
        ODDB::SwissindexPlugin.new(@app).load_ikskey(pcode)
      end

Run

masa@masa ~/ywesee/oddb.org $ bin/admin
ch.oddb> Updater.new(self).update_bsv

Result

Created SL-Entries                                            2
Updated SL-Entries                                         8332
Deleted SL-Entries                                            0
Created Limitation-Texts                                      0
Updated Limitation-Texts                                   1309
Deleted Limitation-Texts                                      0

Duplicate Registrations in SL 09.06.2011                      0
Package-Data was completed from SL                            2
SMeX/SL-Differences (Registrations) 09.06.2011                0
SMeX/SL-Differences (Packages) 09.06.2011                     6
Critical Pharmacodes BAG-XML 09.06.2011                       9
Missing Swissmedic-Codes in SL 09.06.2011                     7
Missing Pharmacodes in SL 09.06.2011                        198
Missing Swissmedic-Codes in SL (out of trade) 09.06.2011     28
Unknown Packages in SL 09.06.2011                           173
Unknown Registrations in SL 09.06.2011                        2
Unknown Packages in SL (out of trade) 09.06.2011             53
Packungen in der ODDB Total: 23782
Packungen ohne Pharmacode: 10695
- ausser Handel: 10683
- inaktive Registration: 1
- noch nicht auf MedWin: 11

Note

Commit

view · edit · sidebar · attach · print · history
Page last modified on June 09, 2011, at 04:28 PM