Skip to content

Commit

Permalink
Separated and improved parsing galenic forms
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed May 12, 2015
1 parent 20f747e commit eaabe2d
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 27 deletions.
46 changes: 41 additions & 5 deletions lib/oddb2xml/compositions_syntax.rb
Expand Up @@ -435,6 +435,10 @@ def tag(opts={})
space.repeat(3)
}

root :expression_comp
end

class GalenicFormParser < CompositionParser

rule(:prepation_separator) { str(', ') | str("\n") }

Expand Down Expand Up @@ -480,22 +484,54 @@ def tag(opts={})
comma >> space >>
any.repeat(1).as(:galenic_form)
}
rule(:simple_name) { (match(["a-zA-Z0-9,%"]) | str('-') | umlaut).repeat(1) }
rule(:simple_name) { ((match(["a-zA-Z0-9,%"]) | str('-') | umlaut).repeat(1)) >>
(lparen >> (rparen.absent? >> any.repeat(1)) >> rparen).maybe
}
rule(:name_gal_form) { # e.g. Dicloabak 0,1% Augentropfen or 35 Clear-Flex 3,86 % Peritonealdialyselösung
(simple_name >> space).repeat(1).as(:prepation_name) >>
space? >>
(dose_with_pro >> space?).maybe >>
gal_form >> space?
(digits.absent? >> gal_form) >> space?
}

rule(:name_without_comma_gal_form) { # Sulfure de Rhénium (186Re)-RE-186-MM-1 Cis bio International
((str(', ')| str(',') >> match(['A-Z'])).absent? >> any).repeat(1).as(:prepation_name) >>
comma >> space? >>
gal_form >> space?
}

# Phytopharma foie et bile capsules/Leber-Galle Kapseln
rule(:leber_gallen_kapseln) { ((str('/Leber-Galle Kapseln').absent? >> any).repeat(1)).as(:prepation_name) >>
str('/') >> any.repeat(1).as(:galenic_form) >>
space?
}
# Plak-out Spray 0,1 %
rule(:plak_out_spray) { str('Plak-out Spray 0,1 %').as(:prepation_name) >>
space? >> str('dummy').maybe.as(:galenic_form) >> space?
}
rule(:galenic) {
plak_out_spray |
leber_gallen_kapseln |
standard_galenic |
name_comma_gal_form |
name_then_dose >> space? |
name_without_comma_gal_form |
name_gal_form |
only_name >> space? |
space?
}

root :expression_comp
end

# for debugging purposes only
rule(:galenicD) {
plak_out_spray.as(:plak_out_spray) |
leber_gallen_kapseln.as(:leber_gallen_kapseln) |
standard_galenic.as(:standard_galenic) |
name_comma_gal_form.as(:name_comma_gal_form) |
name_then_dose.as(:name_then_dose) >> space? |
name_without_comma_gal_form.as(:name_without_comma_gal_form) |
name_gal_form.as(:name_gal_form) |
only_name.as(:only_name) >> space? |
space?
}
root :galenic
end
115 changes: 93 additions & 22 deletions spec/galenic_spec.rb
Expand Up @@ -6,43 +6,114 @@
require 'parslet/convenience'
require 'csv'

RunAllParsingExamples = false # RunAllParsingExamples /travis|localhost/i.match(hostname) != nil # takes about one minute to run
RunAllParsingExamples = true # RunAllParsingExamples /travis|localhost/i.match(hostname) != nil # takes about one minute to run

galenic_tests = {

'1001 Blattgrün Dragées' => { :prepation_name=>'1001 Blattgrün ', :galenic_form=> 'Dragées' },
'Amoxicillin Streuli, Granulat zur Herstellung einer Suspension' => { :prepation_name=>'Amoxicillin Streuli', :galenic_form=> 'Granulat zur Herstellung einer Suspension', },
'3TC 150 mg, Filmtabletten' => { :prepation_name=>'3TC 150 mg', :galenic_form=>'Filmtabletten' },
'Acetocaustin, Lösung' => { :prepation_name=>'Acetocaustin', :galenic_form=>'Lösung' },
'Alustal 3-Bäume, Injektionssuspension' => {:prepation_name=>'Alustal 3-Bäume', :galenic_form=> 'Injektionssuspension' },
'Alustal Bäume, Injektionssuspension' => {:prepation_name=>'Alustal Bäume', :galenic_form=> 'Injektionssuspension' },
'Amoxicillin Streuli, Granulat zur Herstellung einer Suspension' => { :prepation_name=>'Amoxicillin Streuli', :galenic_form=> 'Granulat zur Herstellung einer Suspension', },
'Arkocaps Passiflore/Passionsblume, 300 mg, capsules'=> { :prepation_name=>'Arkocaps Passiflore/Passionsblume', :galenic_form=>'capsules' },
'Atenativ, Antithrombin III 500 I.E., Injektionspräparat' => { :prepation_name=>'Atenativ', :galenic_form=>'Injektionspräparat' },
'Atorvastatin Helvepharm, 10 mg Filmtabletten' => {:prepation_name=>'Atorvastatin Helvepharm', :galenic_form=> 'Filmtabletten' },
'Atorvastax-Drossapharm 20 mg' => {:prepation_name=> 'Atorvastax-Drossapharm 20 mg', :galenic_form=> nil},
'Co-Losartan Spirig HC 50/12,5 mg' => { :prepation_name=>'Co-Losartan Spirig HC 50/12,5 mg', :galenic_form=> nil, },
'Dicloabak 0,1% Augentropfen' => { :prepation_name=>'Dicloabak 0,1% ', :galenic_form=>'Augentropfen' },
'Kaliumchlorid 14,9 % B. Braun, Zusatzampullen'=> { :prepation_name=>'Kaliumchlorid 14,9 % B. Braun', :galenic_form=>'Zusatzampullen' },
'Methrexx 7.5 mg / 0.75 ml,Injektionslösung in Fertigspritzen'=> { :prepation_name=>'Methrexx 7.5 mg / 0.75 ml', :galenic_form=> 'Injektionslösung in Fertigspritzen' },
'Nitroderm TTS 10' => { :prepation_name=>'Nitroderm TTS 10', :galenic_form=> nil },
'Ondansetron Labatec, 8mg/4ml, concentré pour perfusion' => {:prepation_name=>'Ondansetron Labatec', :galenic_form=> 'concentré pour perfusion' },
'Paronex 20, Filmtabletten'=> { :prepation_name=>'Paronex 20', :galenic_form=>'Filmtabletten' },
'Physioneal 35 Clear-Flex 3,86 % Peritonealdialyselösung' => { :prepation_name=>'Physioneal 35 Clear-Flex 3,86 % ', :galenic_form=>'Peritonealdialyselösung' },
'Phytopharma foie et bile capsules/Leber-Galle Kapseln' => { :prepation_name=>'Phytopharma foie et bile capsules', :galenic_form=> 'Leber-Galle Kapseln' },
'Plak-out Spray 0,1 %' => { :prepation_name=>'Plak-out Spray 0,1 %', :galenic_form=> nil },
'Sandostatin 0,2 mg/mL, Injektionslösung' => { :prepation_name=>'Sandostatin 0,2 mg/mL', :galenic_form=>'Injektionslösung' },
'Sulfure de Rhénium (186Re)-RE-186-MM-1 Cis bio International, Suspension' => { :prepation_name=>'Sulfure de Rhénium (186Re)-RE-186-MM-1 Cis bio International', :galenic_form=> 'Suspension' },
'Tramal 100, Injektionslösung (i.m., i.v.)' => { :prepation_name=>'Tramal 100', :galenic_form=>'Injektionslösung (i.m., i.v.)' },
'Uman Albumin Kedrion 20%' => { :prepation_name=>'Uman Albumin Kedrion 20%', :galenic_form=> nil },

}

galenic_tests = {
'Nitroderm TTS 10' => { :prepation_name=>'Nitroderm TTS 10', :galenic_form=> nil },
'Methrexx 7.5 mg / 0.75 ml,Injektionslösung in Fertigspritzen'=> { :prepation_name=>'Methrexx', :galenic_form=> 'Injektionslösung in Fertigspritzen' },
'Phytopharma foie et bile capsules/Leber-Galle Kapseln' => { :prepation_name=>'Phytopharma', :galenic_form=> 'Kapseln' },
'Sulfure de Rhénium (186Re)-RE-186-MM-1 Cis bio International, Suspension' => { :prepation_name=>'Sulfure de Rhénium (186Re)-RE-186-MM-1 Cis bio International', :galenic_form=> 'Suspension' },
'Amoxicillin Sandoz 100mg/4ml,Granulat zur Herst.einer Suspension' => { :prepation_name=>'Amoxicillin Sandoz', :galenic_form=> 'Granulat zur Herst.einer Suspension' },

# 'Tramal 100, Injektionslösung (i.m., i.v.)' => { :prepation_name=>'Tramal 100', :galenic_form=>'Injektionslösung (i.m., i.v.)' },

# Fix ,Zusatzampullen
# "Kaliumchlorid 14,9 % B. Braun,Zusatzampullen"=> { :prepation_name=>"Kaliumchlorid 14,9 % B. Braun", :galenic_form=>"Zusatzampullen" },
}
todo = %(
Testlösung zur Allergiediagnose Teomed Kaninchen (Fell) Lösung
Testlösung zur Allergiediagnose Teomed Hund (Haare) Lösung
Pandemrix (Pandemic Influenza Vaccine H1N1)
Phytopharma dragées pour la détente et le sommeil / Entspannungs- und Schlafdragées
Phytopharma dragées pour le coeur / Herz Dragées
Best Friend Katzenhalsband / Katzenhalsband Reflex ad us.vet.
Amlodipin Helvepharm 10 Tabletten
Salbu Orion Easyhaler 100 ug Inhalationspulver
TISSEEL 10 ml 2 Fertigspritzen
TISSEEL 2 ml 2 Fertigspritzen
TISSEEL 4 ml 2 Fertigspritzen
Norprolac Starter-pack 25 ug + 50 ug, Tabletten
Phostal 5-Gräser 4-Getreidemischung 10IR, Injektionssuspension
Alustal 5-Gräser 4-Getreidemischung Kombipackung, Injektionssuspension
Staloral Beifuss 5-Gräser 100IR, Injektionssuspension
Phostal Beifuss 5-Gräser 10IR, Injektionssuspension
Alustal Beifuss 5-Gräser 10IR, Injektionssuspension
Seebri Breezhaler 50 Mikrogramm, Pulver zur Inhalation, Hartkapseln
Nplate 500 mcg Pulver und Lösungsmittel zur Herstellung einer Injektionslösung
Bayvantage ad us.vet. 80 für Katzen, Lösung
Ondansetron-Teva 8mg, Filmtabletten
Soluprick SQ 3-Bäumemischung (Alnus glutinosa Betula verrucosa, Corylus avellana), Lösung
BicaVera 2,3% Glucose Calcium, Peritonealdialyselösung
Telfastin Allergo 120 comprimés pelliculés 120 mg
Multaq comprimés pelliculés de 400 mg de dronédarone
KCL 7,45% Sintetica concentrato per soluzione per infusione (fiala di 20 ml)
Alk7 Frühblühermischung Depotsuspension zur s.c. Injektion "1 Flasche B"
Alk7 Gräsermischung und Roggen Depotsuspension zur s.c. Injektion "1 Flasche B"
Relenza 5 mg Disk (Pulverinhalation)
Ventolin Dosier-Aerosol (FCKW-frei)
Axotide 0,125 mg Dosier-Aerosol (FCKW-frei)
Axotide 0,250 mg Dosier-Aerosol (FCKW-frei)
Axotide 0,050 mg Dosier-Aerosol (FCKW-frei)
Serevent Dosier-Aerosol FCKW-frei
Bronchialpastillen Dr. Welti
Conoxia Druckgasflasche 300 bar
Staloral Pollen 3-Bäume Esche 100IR, Lösung zur sublingualen Anwendung
Staloral Pollen Birke Esche 100IR, Lösung zur sublingualen Anwendung
Phostal Birke Esche 10IR, Injektionssuspension
Alustal Birke Esche 10IR, Injektionssuspension
Alustal 3-Bäume Esche Kombipackung , Injektionssuspension
Phostal 3-Bäume Esche Kombipackung, Injektionssuspension
Fisherman's Friend Eucalyptus-Menthol, sans sucre, avec sorbitol, nouvelle formule, pastilles
Victoza 6 mg/ml Fertigpen (Triple-Dose)
Fluimucil Erkältungshusten Fertigsirup mit Himbeergeschmack
Rebif Neue Formulierung 22 Fertigspritzen, Injektionslösung
Rebif Neue Formulierung 44 Fertigspritzen, Injektionslösung
Rebif Neue Formulierung 8.8 Fertigspritzen, Injektionslösung
Bonherba rocks Kräuterzucker, Kräuterbonbon 2,7 g
Ricola Kräuter, Kräuterbonbons ohne Zucker, 2,5 g
Testlösung zur Allergiediagnose Teomed Ei ganz, Lösung
Helena's Fenchelfruchttee ganze Droge
Intron A 10 Mio. I.E./1 mL gebrauchsfertige, HSA-freie Injektionslösung
Picato Gel 500 mcg/g
Duodopa Gel zur intestinalen Anwendung
Weleda Arnica-Gel Gel, anthroposophisches Arzneimittel
Burgerstein Vitamin E-Kapseln 400 I.E.
Solmucol 10 % local i.v., i.m., soluzione iniettabile
Synacthen (i.m. i.v.), Injektionslösung
Nutriflex Lipid plus ohne Elektrolyte Infusionsemulsion 1250ml
Nutriflex Omega plus Infusionsemulsion 1875 ml
SmofKabiven Infusionsemulsion 1970 ml
SmofKabiven EF Infusionsemulsion 1970 ml
Nutriflex Omega special Infusionsemulsion 2500 ml
Nutriflex Lipid special ohne Elektrolyte Infusionsemulsion 2500ml
Nutriflex Lipid peri Infusionsemulsion, 1250ml
Nutriflex Lipid plus Infusionsemulsion, 1250ml
Nutriflex Lipid special Infusionsemulsion, 1250ml
Dexdor Infusionskonzentrat 1000ug/10ml
Peditrace Infusionskonzentrat, Zusatzampulle
M Classic Eucalyptus Gummipastillen zuckerfrei
M Classic Halsbonbons zuckerfrei
Salbisan Halspastillen zuckerfrei
Madopar LIQ 125 Tabletten zur Herstellung einer Suspension zum Einnehmen
Anginazol forte tablettes à sucer
Tisane provençale No 1 tisane laxative, plantes coupées
)

def test_one_string(parser, string, expected)
res1 = parser.parse_with_debug(string)
Expand All @@ -57,8 +128,8 @@ def test_one_string(parser, string, expected)
expect(stringified).to eq expected.to_s if expected
end

if false then describe CompositionParser do
let(:parser) { CompositionParser.new }
if true then describe GalenicFormParser do
let(:parser) { GalenicFormParser.new }
context "identifier parsing" do
let(:galenic_parser) { parser.galenic }
let(:qty_unit_parser) { parser.qty_unit }
Expand All @@ -73,12 +144,12 @@ def test_one_string(parser, string, expected)
end
end end

if RunAllParsingExamples then describe CompositionParser do
if RunAllParsingExamples then describe GalenicFormParser do
context "should parse all lines in #{File.basename(AllColumn_C_Lines)}" do
let(:galenic_parser) { CompositionParser.new.galenic }
let(:galenic_parser) { GalenicFormParser.new.galenic }
ausgabe = {}
count = 0
galenic_parser = CompositionParser.new.galenic
galenic_parser = GalenicFormParser.new.galenic
IO.readlines(AllColumn_C_Lines).each {
|string|
count += 1
Expand All @@ -105,8 +176,8 @@ def test_one_string(parser, string, expected)
end
end end

describe CompositionParser do
let(:parser) { CompositionParser.new }
describe GalenicFormParser do
let(:parser) { GalenicFormParser.new }
context "gal_form parsing" do
let(:gal_form_parser) { parser.gal_form }

Expand Down

0 comments on commit eaabe2d

Please sign in to comment.