Gnumed.importers.gmDrugsFromCSV

Package Gnumed :: Package importers :: Module gmDrugsFromCSV |
[frames] | no frames]

# Module gmDrugsFromCSV

source code

Functions
create_sql(filename) | source code

Variables
| field_names = `['substance', 'product', 'form', 'company', 'str`...``
| non_empty_fields = `['substance', 'product', 'form', 'company',`...``
| numeric_fields = `['strength_1', 'strength_2', 'strength_3']`
| SQL_start = `"""-- --------------------------------------------`...``
| SQL_stage_drug = `"""INSERT INTO staging.india_drugs (brand_nam`...``
| SQL_end = `"""-- ----------------------------------------------`...``

Imports: sys, io, gmLog2, gmTools

Variables Details

  ### field_names Value:
      ['substance', 'product', 'form', 'company', 'strength_1', 'strength_2'
      , 'strength_3', 'always_empty', 'unit']

  ### non_empty_fields Value:
      ['substance', 'product', 'form', 'company', 'strength_1', 'unit']

  ### SQL_start Value:
      """-- ---------------------------------------------------------
      -- data pack install script example
      --
      -- add a description here: Mono-substance drugs as available in India
      -- license: GPL v2 or later, manually transferred 3rd party data
      -- provided by Vaibhav Banait
      --
      -- http://wiki.gnumed.de/bin/view/Gnumed/GmManualReferenceData
      ...

  ### SQL_stage_drug Value:
      """INSERT INTO staging.india_drugs (brand_name, substance, form, stren
      gth, unit) SELECT
      	'%(brand_name)s',
      	'%(substance)s',
      	'%(form)s',
      	gm.nullify_empty_string('%(strength)s')::numeric,
      	'%(unit)s'
      WHERE NOT EXISTS (
      ...

  ### SQL_end Value:
      """-- ---------------------------------------------------------
      -- transfer data to real tables

      -- substances
      INSERT INTO ref.consumable_substance (description, amount, unit) SELEC
      T
      	DISTINCT ON (s_id.substance, s_id.strength, s_id.unit)
      	s_id.substance, s_id.strength, s_id.unit
      ...