oddb2tdat 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ === 1.0.0 / 05.01.2011
2
+
3
+ * oddb2tdat Version 1.0.0 released
@@ -0,0 +1,6 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/oddb2tdat
6
+ lib/oddb2tdat.rb
@@ -0,0 +1,50 @@
1
+ = oddb2tdat
2
+
3
+ * http://scm.ywesee.com/?p=oddb2tdat/.git;a=summary
4
+
5
+ == DESCRIPTION:
6
+
7
+ * oddb2tdat converts oddb.csv to oddb.dat
8
+ * http://dev.ywesee.com/wiki.php/ODDB/Oddb2tdat
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * oddb2tdat just converts files. It does not manage any codes.
13
+
14
+ == REQUIREMENTS:
15
+
16
+ * ruby 1.8 or later
17
+
18
+ == INSTALL LINUX:
19
+
20
+ The easiest way to install is via RubyGems. On the command line enter:
21
+
22
+ * sudo gem install oddb2tdat
23
+
24
+ == INSTALL WINDOWS:
25
+
26
+ For Windows users, use this oneclick installer to install Ruby.
27
+
28
+ * http://rubyforge.org/frs/download.php/71066/rubyinstaller-1.8.6-p398.exe
29
+
30
+ then
31
+
32
+ * be sure to check the two checkboxes (.rb and PATH for Ruby on Windows)
33
+ * gem install oddb2tdat
34
+ * chdir to where your config file and XLS files are
35
+
36
+ == USAGE:
37
+
38
+
39
+ == LICENSE:
40
+
41
+ * GPLv2, see LICENSE file
42
+
43
+ == Author:
44
+
45
+ * Masaomi Hatakeyama <mhatakeyama@ywesee.com>
46
+
47
+ == Author README
48
+
49
+ * Masaomi Hatakeyama <mhatakeyama@ywesee.com>
50
+ * Zeno R.R. Davatz <zdavatz@ywesee.com>
@@ -0,0 +1,41 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ # Hoe.plugin :compiler
7
+ # Hoe.plugin :compiler
8
+ # Hoe.plugin :compiler
9
+ # Hoe.plugin :cucumberfeatures
10
+ # Hoe.plugin :gem_prelude_sucks
11
+ # Hoe.plugin :gem_prelude_sucks
12
+ # Hoe.plugin :gem_prelude_sucks
13
+ # Hoe.plugin :git
14
+ # Hoe.plugin :git
15
+ # Hoe.plugin :inline
16
+ # Hoe.plugin :inline
17
+ # Hoe.plugin :inline
18
+ # Hoe.plugin :inline
19
+ # Hoe.plugin :manifest
20
+ # Hoe.plugin :newgem
21
+ # Hoe.plugin :racc
22
+ # Hoe.plugin :racc
23
+ # Hoe.plugin :racc
24
+ # Hoe.plugin :rubyforge
25
+ # Hoe.plugin :rubyforge
26
+ # Hoe.plugin :rubyforge
27
+ # Hoe.plugin :rubyforge
28
+ # Hoe.plugin :website
29
+ # Hoe.plugin :yard
30
+
31
+ Hoe.spec 'oddb2tdat' do
32
+ # HEY! If you fill these out in ~/.hoe_template/Rakefile.erb then
33
+ # you'll never have to touch them again!
34
+ # (delete this comment too, of course)
35
+
36
+ developer('Masaomi Hatakeyama, Zeno R.R. Davatz', 'mhatakeyama@ywesee.com, zdavatz@ywesee.com')
37
+
38
+ # self.rubyforge_name = 'oddb2tdatx' # if different than 'oddb2tdat'
39
+ end
40
+
41
+ # vim: syntax=ruby
@@ -0,0 +1,22 @@
1
+ #! /usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'oddb2tdat'
5
+
6
+ def usage
7
+ puts <<-EOS
8
+ #$0 ver.#{Oddb2tdat::VERSION}
9
+ Usage: #$0 <input file (oddb.csv)> <output file (oddb.dat)>
10
+
11
+ EOS
12
+ end
13
+
14
+ if ARGV.length < 2 or !File.exist?(ARGV[0])
15
+ usage
16
+ exit
17
+ end
18
+
19
+ app = Oddb2tdat.new(*ARGV)
20
+ app.run
21
+
22
+
@@ -0,0 +1,89 @@
1
+ # /usr/bin/env ruby
2
+ # encoding: utf-8
3
+ # Oddb2tdat -- 05.01.2012 -- mhatakeyama@ywesee.com
4
+
5
+ =begin
6
+ 01 RECA Recordart 001 – 002 2 alpha: 11
7
+ 02 CMUT Mutationscode 003 – 003 1 num: 3 ausser Handel (AE) sonst 1
8
+ 03 PHAR Pharmacode 004 – 010 7 num: Pharmacode (G)
9
+ 04 ABEZ Artikelbezeichnung 011 – 060 50 alpha: Präparate (H)
10
+ 05 PRMO Arztpreis (=Galexis-Basis-Preis) 061 – 066 6 num: NIL
11
+ 06 PRPU Publikumspreis (inkl. MWSt) 067 – 072 6 num: PP (N)
12
+ 07 CKZL Kassenzulässigkeit 073 – 073 1 num: (Q)
13
+ 08 CLAG Lagerart 074 – 074 1 num: NIL
14
+ 09 CBGG Betäubung - Gift 075 – 075 1 num: (AI)
15
+ 10 CIKS Swissmedic-Listencode 076 – 076 1 alpha: (P)
16
+ 11 ITHE Index-Therapeutikus 077 – 083 7 num: (AH)
17
+ 12 CEAN EAN-Code 084 – 096: (E)
18
+ =end
19
+
20
+ class Oddb2tdat
21
+ VERSION = '1.0.0'
22
+ COL = {
23
+ :CMUT => 30, # AE
24
+ :PHAR => 6, # G
25
+ :ABEZ => 7, # H
26
+ :PRPU => 13, # N
27
+ :CKZL => 16, # Q
28
+ :CBGG => 34, # AI
29
+ :CIKS => 15, # P
30
+ :ITHE => 33, # AH
31
+ :CEAN => 4, # E
32
+
33
+ }
34
+ LEN = {
35
+ :RECA => 2,
36
+ :CMUT => 1,
37
+ :PHAR => 7,
38
+ :ABEZ => 50,
39
+ :PRMO => 6,
40
+ :PRPU => 6,
41
+ :CKZL => 1,
42
+ :CLAG => 1,
43
+ :CBGG => 1,
44
+ :CIKS => 1,
45
+ :ITHE => 7,
46
+ :CEAN => 13,
47
+ }
48
+
49
+ def initialize(input, output)
50
+ @input = input
51
+ @output = output
52
+ end
53
+ def run
54
+ parse
55
+ output
56
+ end
57
+ def parse
58
+ @rows = []
59
+ File.open(@input, 'r:iso-8859-1:utf-8') do |input|
60
+ while line=input.gets
61
+ row = ''
62
+ cols = line.split(/;/)
63
+ if cmut = cols[COL[:CMUT]] and cmut =~ /Ja/ or cmut =~ /Nein/
64
+ row << "%#{LEN[:RECA]}s" % '11'
65
+ row << "%#{LEN[:CMUT]}s" % (cmut =~ /Ja/ ? '3':'1')
66
+ row << "%0#{LEN[:PHAR]}d" % cols[COL[:PHAR]].to_i
67
+ row << "%-#{LEN[:ABEZ]}s" % cols[COL[:ABEZ]].to_s[0,LEN[:ABEZ]]
68
+ row << "%0#{LEN[:PRMO]}d" % 0
69
+ row << "%#{LEN[:PRPU]}s" % cols[COL[:PRPU]].to_s[0,LEN[:PRPU]]
70
+ row << "%#{LEN[:CKZL]}s" % (cols[COL[:CKZL]] =~ /Ja/ ? 1:0)
71
+ row << "%#{LEN[:CLAG]}s" % 0
72
+ row << "%#{LEN[:CBGG]}s" % (cols[COL[:CBGG]] =~ /Ja/ ? 1:0)
73
+ row << "%#{LEN[:CIKS]}s" % cols[COL[:CIKS]]
74
+ row << "%0#{LEN[:ITHE]}d" % cols[COL[:ITHE]].gsub('.','').to_i
75
+ row << "%#{LEN[:CEAN]}s" % cols[COL[:CEAN]]
76
+ @rows << row
77
+ end
78
+ end
79
+ end
80
+ end
81
+ def output
82
+ open(@output, "w") do |out|
83
+ @rows.each do |line|
84
+ out.print line, "\n"
85
+ end
86
+ end
87
+ end
88
+
89
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oddb2tdat
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Masaomi Hatakeyama, Zeno R.R. Davatz
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-05 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: hoe
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 41
30
+ segments:
31
+ - 2
32
+ - 9
33
+ - 1
34
+ version: 2.9.1
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: |-
38
+ * oddb2tdat converts oddb.csv to oddb.dat
39
+ * http://dev.ywesee.com/wiki.php/ODDB/Oddb2tdat
40
+ email:
41
+ - mhatakeyama@ywesee.com, zdavatz@ywesee.com
42
+ executables:
43
+ - oddb2tdat
44
+ extensions: []
45
+
46
+ extra_rdoc_files:
47
+ - History.txt
48
+ - Manifest.txt
49
+ - README.txt
50
+ files:
51
+ - History.txt
52
+ - Manifest.txt
53
+ - README.txt
54
+ - Rakefile
55
+ - bin/oddb2tdat
56
+ - lib/oddb2tdat.rb
57
+ has_rdoc: true
58
+ homepage: http://scm.ywesee.com/?p=oddb2tdat/.git;a=summary
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options:
63
+ - --main
64
+ - README.txt
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ hash: 3
82
+ segments:
83
+ - 0
84
+ version: "0"
85
+ requirements: []
86
+
87
+ rubyforge_project: oddb2tdat
88
+ rubygems_version: 1.4.2
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: "* oddb2tdat converts oddb.csv to oddb.dat * http://dev.ywesee.com/wiki.php/ODDB/Oddb2tdat"
92
+ test_files: []
93
+