Skip to content

Commit

Permalink
🍱 Add test data (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf authored May 8, 2024
1 parent 019f976 commit 40c1432
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 75 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
docs/mimic-iv-demo-data-in-the-omop-common-data-model-0.9
docs/mimic-iv-demo-data-in-the-omop-common-data-model-0.9.zip
docs/test-omop/

# macOS
.DS_Store
.AppleDouble
Expand Down
File renamed without changes.
59 changes: 0 additions & 59 deletions docs/guide/quickstart.ipynb

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:maxdepth: 1
:hidden:
guide/index
guide
reference
changelog
```
102 changes: 102 additions & 0 deletions docs/quickstart.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Quickstart"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"hide-output"
]
},
"outputs": [],
"source": [
"!wget 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 mimic-iv-demo-data-in-the-omop-common-data-model-0.9.zip"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"!lamin init --storage ./test-omop --schema omop"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import lamindb as ln\n",
"import omop as oo\n",
"import pandas as pd"
]
},
{
"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": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"concepts = [oo.Concept(**row.to_dict()) for _, row in df.iterrows()]\n",
"for concept in concepts:\n",
" concept.save()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"oo.Concept.df()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "py310",
"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.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
2 changes: 0 additions & 2 deletions omop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
CohortDefinition
Concept
ConceptAncestor
ConceptClass
ConceptRelationship
ConceptSynonym
ConditionEra
Expand Down Expand Up @@ -74,7 +73,6 @@ def __getattr__(name):
CohortDefinition,
Concept,
ConceptAncestor,
ConceptClass,
ConceptRelationship,
ConceptSynonym,
ConditionEra,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Generated by Django 5.0.4 on 2024-05-08 10:00

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("omop", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="concept",
name="concept_class",
field=models.CharField(max_length=255),
),
migrations.RemoveField(
model_name="concept",
name="domain",
),
migrations.RemoveField(
model_name="concept",
name="vocabulary",
),
migrations.AddField(
model_name="concept",
name="domain_id",
field=models.CharField(default="0", max_length=255),
preserve_default=False,
),
migrations.AddField(
model_name="concept",
name="vocabulary_id",
field=models.CharField(default="0", max_length=255),
preserve_default=False,
),
migrations.DeleteModel(
name="ConceptClass",
),
]
26 changes: 13 additions & 13 deletions omop/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ class Concept(Registry):

concept_id = models.IntegerField(primary_key=True)
concept_name = models.CharField(max_length=255)
domain = models.ForeignKey("Domain", models.DO_NOTHING)
vocabulary = models.ForeignKey("Vocabulary", models.DO_NOTHING)
concept_class = models.ForeignKey("ConceptClass", models.DO_NOTHING)
domain_id = models.CharField(max_length=255)
vocabulary_id = models.CharField(max_length=255)
concept_class = models.CharField(max_length=255)
standard_concept = models.CharField(max_length=1, blank=True, null=True)
concept_code = models.CharField(max_length=50)
valid_start_date = models.DateField()
Expand Down Expand Up @@ -136,19 +136,19 @@ class Meta:
db_table = "concept_ancestor"


class ConceptClass(Registry):
"""The CONCEPT_CLASS table is a reference table, which includes a list of the classifications used to differentiate Concepts within a given Vocabulary.
# class ConceptClass(Registry):
# """The CONCEPT_CLASS table is a reference table, which includes a list of the classifications used to differentiate Concepts within a given Vocabulary.

This reference table is populated with a single record for each Concept Class.
"""
# This reference table is populated with a single record for each Concept Class.
# """

concept_class_id = models.CharField(primary_key=True, max_length=20)
concept_class_name = models.CharField(max_length=255)
concept_class_concept = models.ForeignKey(Concept, models.DO_NOTHING)
# concept_class_id = models.CharField(primary_key=True, max_length=20)
# concept_class_name = models.CharField(max_length=255)
# concept_class_concept = models.ForeignKey(Concept, models.DO_NOTHING) # introduce a loop

class Meta:
managed = True
db_table = "concept_class"
# class Meta:
# managed = True
# db_table = "concept_class"


class ConceptRelationship(Registry):
Expand Down

0 comments on commit 40c1432

Please sign in to comment.