Exemplo n.º 1
0
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
Exemplo n.º 2
0
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