Skip to content
/ oddb2xml Public
forked from zdavatz/oddb2xml

oddb2xml, create xml files using refdata, swissmedic and bag xml files

License

Notifications You must be signed in to change notification settings

pcai/oddb2xml

Repository files navigation

oddb2xml

Build Status

  • oddb2xml -a nonpharma -o fi

creates the following xml files:

  • oddb_substance.xml
  • oddb_limitation.xml
  • oddb_interaction.xml
  • oddb_code.xml
  • oddb_product.xml
  • oddb_article.xml
  • oddb_fi.xml
  • oddb_fi_product.xml

and

  • oddb2xml -f dat
  • oddb2xml -f dat -a nonpharma

creates .dat files according to (IGM-11). IGM-11 describes the structure of the zurrose_transfer.dat.

  • oddb.dat
  • oddb_with_migel.dat

the files are using swissINDEX, BAG-XML and Swissmedic as sources.

The following additional data is in the files:

usage

see --help.

/usr/local/bin/oddb2xml ver.1.8.4
Usage:
  oddb2xml [option]
    produced files are found under data
    -a T, --append=T     Additional target. T, only 'nonpharma' is available.
    -c F, --compress=F   Compress format F. {tar.gz|zip}
    -e    --extended     pharma, non-pharma plus prices and non-pharma from zurrose. Products without EAN-Code will also be listed.
    -f F, --format=F     File format F, default is xml. {xml|dat}
                         If F is given, -o option is ignored.
    -i I, --include=I    Include target option for 'dat' format. only 'ean14' is available.
                         'xml' format includes always ean14 records.
    -o O, --option=O     Optional output. O, only 'fi' is available.
    -p P, --price=P      Price source (transfer.dat). P, only 'zurrose' is available.
    -t S, --tag-suffix=S XML tag suffix S. Default is none. [A-z0-9]
                         If S is given, it is also used as prefix of filename.
    -x N, --context=N    context N {product|address}. product is default.
                         
                         For debugging purposes
    --skip-download      skips downloading files it the file is already under data/downloads.
                         Downloaded files are saved under data/downloads
    -h,   --help         Show this help message.

Option examples

$ oddb2xml -t md                        # => md_article.xml, md_product.xml, md_substance.xml
$ oddb2xml -a nonpharma -t md -c tar.gz # => md_xml_dd.mm.yyyy_hh.mm.tar.gz
$ oddb2xml -f dat                       # => oddb.dat
$ oddb2xml -f dat -a nonpharma          # => oddb_with_migel.dat
$ oddb2xml -e                           # => oddb_article.xml

output.

$ oddb2xml
DE
        Pharma products: 14801
FR
        Pharma products: 14801

Supported ruby version

We run tests on travis-ci.org for the Ruby versions mentioned in the .travis.yml file. These are

  • 1.9.3
  • 2.0.0
  • 2.1
  • ruby-head

If you are running an older Ruby-Version (eg. 1.8 or 1.9.1), please upgrade before reporting a bug. See also http://bugs.ruby-lang.org/projects/ruby/wiki/ReleaseEngineering

XSD files

The file oddb2xml.xsd was manually created by merging the output of the xmlbeans tools inst2xsd and trang

Running rake spec will validated the XML-files generated during the tests using the Nokogiri validator.

Manually you can also validate (assuming that you have installed the xmlbeans tools) all generated XML-files using

  • xsdvalidate oddb2xml.xsd *.xml

XML files

xml files generated are:

  • oddb_substance.xml
  • oddb_limitation.xml
  • oddb_interaction.xml
  • oddb_code.xml
  • oddb_product.xml
  • oddb_article.xml
  • oddb_fi.xml
  • oddb_fi_product.xml

article.xml

oddb2xml creates article.xml as oddb_article.xml by default.

<?xml version="1.0" encoding="utf-8"?>
<ARTICLE xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://wiki.oddb.org/wiki.php?pagename=Swissmedic.Datendeklaration" CREATION_DATETIME="2012-11-21T13:09:23.6787110+0900" PROD_DATE="2012-11-21T13:09:23.6787110+0900" VALID_DATE="2012-11-21T13:09:23.6787110+0900">
  <ART DT="">
    <PHAR>31532</PHAR>
    <PRDNO>4123</PRDNO>
    <SMCAT>D</SMCAT>
    <SMNO>29152039</SMNO>
    <SALECD>A</SALECD>
    <QTY>10 Stk</QTY>
    <DSCRD>BEN-U-RON Supp 250 mg Kind</DSCRD>
    <DSCRF>BEN-U-RON supp 250 mg enf</DSCRF>
    <SORTD>BEN-U-RON SUPP 250 MG KIND</SORTD>
    <SORTF>BEN-U-RON SUPP 250 MG ENF</SORTF>
    <SYN1D>Ben-u-ron</SYN1D>
    <SYN1F>Ben-u-ron</SYN1F>
    <SLOPLUS>2</SLOPLUS>
    <ARTCOMP/>
    <ARTBAR>
      <CDTYP>E13</CDTYP>
      <BC>7680291520390</BC>
      <BCSTAT>A</BCSTAT>
    </ARTBAR>
    <ARTPRI>
      <VDAT>01.11.2012</VDAT>
      <PTYP>PEXF</PTYP>
      <PRICE>1.780086</PRICE>
    </ARTPRI>
    <ARTPRI>
      <VDAT>01.11.2012</VDAT>
      <PTYP>PPUB</PTYP>
      <PRICE>3.3</PRICE>
    </ARTPRI>
  </ART>
  ...
  <RESULT>
    <OK_ERROR>OK</OK_ERROR>
    <NBR_RECORD>14801</NBR_RECORD>
    <ERROR_CODE/>
    <MESSAGE/>
  </RESULT>
</ARTICLE>

product.xml

For example, if -t _swiss is given then oddb2xml creates product.xml as swiss_product.xml.

<?xml version="1.0" encoding="utf-8"?>
<PRODUCT_SWISS xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://wiki.oddb.org/wiki.php?pagename=Swissmedic.Datendeklaration" CREATION_DATETIME="2012-11-21T13:01:29.5903756+0900" PROD_DATE="2012-11-21T13:01:29.5903756+0900" VALID_DATE="2012-11-21T13:01:29.5903756+0900">
  <PRD_SWISS DT="">
    <GTIN_SWISS>7680353660163</GTIN_SWISS>
    <PRODNO_SWISS>353661</PRODNO_SWISS>
    <DSCRD_SWISS>Kendural Depottabl </DSCRD_SWISS>
    <DSCRF_SWISS>Kendural cpr dépôt </DSCRF_SWISS>
    <ATC_SWISS>B03AE10</ATC_SWISS>
    <IT_SWISS>06.07.1.</IT_SWISS>
    <CPT_SWISS>
      <CPTCMP_SWISS>
        <LINE_SWISS>0</LINE_SWISS>
        <SUBNO_SWISS>507</SUBNO_SWISS>
        <QTY_SWISS>105</QTY_SWISS>
        <QTYU_SWISS>mg</QTYU_SWISS>
      </CPTCMP_SWISS>
      <CPTCMP_SWISS>
        <LINE_SWISS>1</LINE_SWISS>
        <SUBNO_SWISS>23</SUBNO_SWISS>
        <QTY_SWISS>500</QTY_SWISS>
        <QTYU_SWISS>mg</QTYU_SWISS>
      </CPTCMP_SWISS>
    </CPT_SWISS>
    <PackGrSwissmedic_SWISS>30</PackGrSwissmedic_SWISS>
    <EinheitSwissmedic_SWISS>Tablette(n)</EinheitSwissmedic_SWISS>
    <SubstanceSwissmedic_SWISS>ferrum(II), acidum ascorbicum</SubstanceSwissmedic_SWISS>
  </PRD_SWISS>
  ...
  <RESULT_SWISS>
    <OK_ERROR_SWISS>OK</OK_ERROR_SWISS>
    <NBR_RECORD_SWISS>14336</NBR_RECORD_SWISS>
    <ERROR_CODE_SWISS/>
    <MESSAGE_SWISS/>
  </RESULT_SWISS>
</PRODUCT_SWISS>

substance.xml

product.xml has relation to substance as <SUBNO>.

<?xml version="1.0" encoding="utf-8"?>
<SUBSTANCE xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://wiki.oddb.org/wiki.php?pagename=Swissmedic.Datendeklaration" CREATION_DATETIME="2012-12-11T14:27:17.4444763+0900" PROD_DATE="2012-12-11T14:27:17.4444763+0900" VALID_DATE="2012-12-11T14:27:17.4444763+0900">
  <SB DT="">
    <SUBNO>1</SUBNO>
    <NAML>3-Methoxy-butylis acetas</NAML>
  </SB>
  <SB DT="">
    <SUBNO>2</SUBNO>
    <NAML>4-Methylbenzylidene camphor</NAML>
  </SB>
  ...
  <RESULT>
    <OK_ERROR>OK</OK_ERROR>
    <NBR_RECORD>1441</NBR_RECORD>
    <ERROR_CODE/>
    <MESSAGE/>
  </RESULT>
</SUBSTANCE>

SSLv3 cert for Windows Users

Some websites need SSLv3 connection. If you don't have these root CA files (x509), Please install these Certificates before running.
see cURL Website

You can confirm wit ruby -ropenssl -e 'p OpenSSL::X509::DEFAULT_CERT_FILE'.

Windows User: Making your SSL Certificate permanent via your PATH

  1. Download this cacert.pem (cURL) into your HOME directory.
  • or directly select cacert.pem from your oddb2xml-x.x.x gems directory.
  • tools/cacert.pem is bundled with the oddb2xml gem.
  1. Then Choose Menu "Control Panel" > "System" > "Advanced system settings"
  • This opens the "System Properties" Window.
  1. Click "Advanced" Tab.
  2. Click "Environment Variables" button.
  3. Add set variable entry "SSL_CERT_FILE=%HOMEPATH%\cacert.pem"
  • Variable name: SSL_CERT_FILE
  • Variable value: %HOMEPATH%\cacert.pem
  • with "New..." button into upper are "User variables for xxx"
  1. Do not remove this cacert.pem. All SSLv3 connections use this file.

win_fetch_cacerts.rb

You can also run

  • tools/win_fetch_cacerts.rb

for your currently open Terminal to download and set the Certificate.

Testing

  • Calling rake spec runs spec tests.
  • Calling rake test installs the gems and runs oddb2xml with the most commonly used combinations. All output is placed under under ausgabe/. These files should be manually compared to the ones generated by the last release to check for possible problems.

About

oddb2xml, create xml files using refdata, swissmedic and bag xml files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 73.4%
  • HTML 23.5%
  • Nix 3.1%