CBHPMTable
A simple gem to wrap the CBHPM excel files from Associação Brasileira de Medicina.
CBHPM:
- Classificação Brasileira Hierarquizada de Procedimentos Médicos (pt)
- Brazilian Hierarchical Classification of Medical Procedures (en)
Installation
Add this line to your application's Gemfile:
gem 'cbhpm_table'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cbhpm_table
Usage
cbhpm_table = CBHPMTable.new "CBHPM 2012.xlsx"
cbhpm_table.headers
#=> { "code"=>"ID do Procedimento", "name"=>"Descrição do Procedimento", "cir_size"=>nil, "uco"=>"Custo Operac.", "aux_qty"=>"Nº de Aux.", "an_size"=>"Porte Anestés."}
cbhpm_table.row(2)
#=> {"code"=>"10101012", "name"=>"Em consultório (no horário normal ou preestabelecido)", "cir_size"=>"2B", "uco"=>nil, "aux_qty"=>nil, "an_size"=>nil})}
cbhpm_table.rows
#=> # Returns an Array of Rows (as individual Hashes)
cbhpm_table.each_row do |row|
# do whatever with the row
endSupported editions: 3a, 4a, 5a, 2010, 2012, 2014, 2016, 2018, 2020, 2022 and 2026
(.xls, .xlsx and .xlsm). The edition is detected by the file basename.
Row values are normalized for every edition:
-
codeandnamecome as Strings. -
cir_sizecomes upcased (the 2020+ spreadsheets have a9c). -
ucocomes as a Float. -
aux_qtyandan_sizecome as Integers. - Blank cells come as
nil.
From the 2022 edition on, an_size already takes the "Novo Porte Anest" column
into account. Rows without code and rows with duplicated codes are discarded.
Contributing
- Fork it ( https://github.com/[my-github-username]/cbhpm_table/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Thanks to:
- Brandon Hilkert (@brandonhilkert) - for his "Build a Ruby Gem Email Course"