{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Quickstart" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We download some test data for the 32 tables from the address below and populate the Concept registry." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "hide-output" ] }, "outputs": [], "source": [ "!wget -nc https://physionet.org/static/published-projects/mimic-iv-demo-omop/mimic-iv-demo-data-in-the-omop-common-data-model-0.9.zip\n", "!unzip -n mimic-iv-demo-data-in-the-omop-common-data-model-0.9.zip" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a test instance:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "!lamin init --storage ./test-omop --name test-omop --schema omop" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import `omop`:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import lamindb as ln\n", "import omop as op\n", "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Load the data into a Pandas DataFrame:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "hide-output" ] }, "outputs": [], "source": [ "df = pd.read_csv(\"./mimic-iv-demo-data-in-the-omop-common-data-model-0.9/1_omop_data_csv/2b_concept.csv\")\n", "df.columns = df.columns.str.lower()\n", "df.rename(columns={\"concept_class_id\": \"concept_class\"}, inplace=True)\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Populate the Concept registry:" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "hide-output" ] }, "outputs": [], "source": [ "concepts = [op.Concept(**row.to_dict()) for _, row in df.iterrows()]\n", "for concept in concepts:\n", " concept.save()\n", "op.Concept.df()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Perform validation of new data." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "op.Concept.validate([\"Stroke Volume Variation\", \"this concept does not exist\"], field=op.Concept.concept_name)" ] } ], "metadata": { "kernelspec": { "display_name": "lamindb", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }