コード例 #1
0
ファイル: test_bunsen_r4.py プロジェクト: datnoor/bunsen
def test_with_disjoint_maps_from_directory(spark_session):

  spark_session.sql("CREATE DATABASE IF NOT EXISTS disjoint_maps_db")

  create_concept_maps(spark_session) \
    .with_maps_from_directory("tests/resources/conceptmaps") \
    .write_to_database("disjoint_maps_db")

  reloaded = get_concept_maps(spark_session, "disjoint_maps_db") \
    .with_disjoint_maps_from_directory("tests/resources/conceptmaps", "disjoint_maps_db")

  assert reloaded.get_mappings("urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1") \
           .count() == 5
コード例 #2
0
ファイル: test_bunsen_r4.py プロジェクト: datnoor/bunsen
def test_with_maps_from_directory(spark_session):

  concept_maps = create_concept_maps(spark_session) \
    .with_maps_from_directory("tests/resources/conceptmaps")

  assert concept_maps.get_mappings("urn:cerner:poprec:fhir:conceptmap:demographics:gender", "0.0.1") \
           .count() == 5
コード例 #3
0
ファイル: test_bunsen_r4.py プロジェクト: datnoor/bunsen
def test_write_maps(spark_session):

  concept_maps = create_concept_maps(spark_session)

  snomed_to_loinc = [('http://snomed.info/sct', '75367002', 'http://loinc.org', '55417-0', 'equivalent'), # Blood pressure
                     ('http://snomed.info/sct', '271649006', 'http://loinc.org', '8480-6', 'equivalent'), # Systolic BP
                     ('http://snomed.info/sct', '271650006', 'http://loinc.org', '8462-4', 'equivalent')] # Diastolic BP

  appended = concept_maps.with_new_map(url='urn:cerner:test:snomed-to-loinc',
                                       version='0.1',
                                       source='urn:cerner:test:valueset',
                                       target='http://hl7.org/fhir/ValueSet/observation-code',
                                       mappings=snomed_to_loinc)

  spark_session.sql('create database if not exists ontologies')
  spark_session.sql('drop table if exists ontologies.mappings')
  spark_session.sql('drop table if exists ontologies.ancestors')
  spark_session.sql('drop table if exists ontologies.conceptmaps')

  appended.write_to_database('ontologies')

  # Check that the maps were written by reloading and inspecting them.
  reloaded = get_concept_maps(spark_session)

  assert reloaded.get_maps().count() == 1
  assert reloaded.get_mappings().where(col('conceptmapuri') == 'urn:cerner:test:snomed-to-loinc').count() == 3
コード例 #4
0
ファイル: test_bunsen_r4.py プロジェクト: rbrush/bunsen
def test_add_mappings(spark_session):

    concept_maps = create_concept_maps(spark_session)

    original = [('http://snomed.info/sct', '75367002', 'http://loinc.org',
                 '55417-0', 'equivalent')]

    added = [
        ('http://snomed.info/sct', '271649006', 'http://loinc.org', '8480-6',
         'equivalent'),  # Systolic BP
        ('http://snomed.info/sct', '271650006', 'http://loinc.org', '8462-4',
         'equivalent')
    ]  # Diastolic BP

    appended = concept_maps.with_new_map(url='urn:cerner:test:snomed-to-loinc',
                                        version='0.1',
                                        source='urn:cerner:test:valueset',
                                        target='http://hl7.org/fhir/ValueSet/observation-code',
                                        mappings=original) \
                           .add_mappings(url='urn:cerner:test:snomed-to-loinc',
                                        version='0.1',
                                        new_version='0.2',
                                        mappings=added)

    assert appended.get_maps().count() == 2
    assert appended.get_mappings() \
        .where(col('conceptmapuri') == 'urn:cerner:test:snomed-to-loinc') \
        .where(col('conceptmapversion') == '0.1') \
        .count() == 1
    assert appended.get_mappings() \
        .where(col('conceptmapuri') == 'urn:cerner:test:snomed-to-loinc') \
        .where(col('conceptmapversion') == '0.2') \
        .count() == 3
コード例 #5
0
ファイル: test_bunsen_r4.py プロジェクト: rbrush/bunsen
def test_latest_concept_map_version(spark_session):

    concept_maps = create_concept_maps(spark_session)

    added = concept_maps.with_new_map(url='urn:cerner:test:snomed-to-loinc',
                                      version='0.1',
                                      source='urn:cerner:test:valueset',
                                      target='http://hl7.org/fhir/ValueSet/observation-code',
                                      mappings=[]) \
                        .with_new_map(url='urn:cerner:test:snomed-to-loinc',
                                      version='0.2',
                                      source='urn:cerner:test:valueset',
                                      target='http://hl7.org/fhir/ValueSet/observation-code',
                                      mappings=[])

    assert added.latest_version('urn:cerner:test:snomed-to-loinc') == '0.2'
コード例 #6
0
ファイル: test_bunsen_r4.py プロジェクト: datnoor/bunsen
def test_get_map_as_xml(spark_session):

  concept_maps = create_concept_maps(spark_session)

  snomed_to_loinc = [('http://snomed.info/sct', '75367002', 'http://loinc.org', '55417-0', 'equivalent'), # Blood pressure
                     ('http://snomed.info/sct', '271649006', 'http://loinc.org', '8480-6', 'equivalent'), # Systolic BP
                     ('http://snomed.info/sct', '271650006', 'http://loinc.org', '8462-4', 'equivalent')] # Diastolic BP

  appended = concept_maps.with_new_map(url='urn:cerner:test:snomed-to-loinc',
                                       version='0.1',
                                       source='urn:cerner:test:valueset',
                                       target='http://hl7.org/fhir/ValueSet/observation-code',
                                       mappings=snomed_to_loinc)

  xml_str = appended.get_map_as_xml('urn:cerner:test:snomed-to-loinc', '0.1')

  root = ET.fromstring(xml_str)
  assert root.tag == '{http://hl7.org/fhir}ConceptMap'