Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenbspence committed Jun 20, 2024
1 parent d5eba55 commit 91b4823
Show file tree
Hide file tree
Showing 25 changed files with 492 additions and 14 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.10' # Ensure this matches your project's requirements

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install duckdb # Install the duckdb package
pip install duckdb==1.0.0
- name: Run MotherDuck Test
env:
MOTHERDUCK_TOKEN: ${{ secrets.MOTHERDUCK_TOKEN }}
run: python ./tests/motherduck_test.py
run: python ./hestia/tests/motherduck_test.py
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
notebooks/
data/*

.ruff_cache
.old
.vscode


# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Changelog

## [0.2.0](https://github.com/OHDSI/Hestia/compare/v0.1.0...v0.2.0) (2024-03-05)


### Features

* added dev container ([3ddcc41](https://github.com/OHDSI/Hestia/commit/3ddcc4104b618c622a9f8e13f0b98d4810bb89f0))
* added dev container ([3934c53](https://github.com/OHDSI/Hestia/commit/3934c5373e806430402851f067537a45f535590c))


### Bug Fixes

* release-please set to push for main ([5682581](https://github.com/OHDSI/Hestia/commit/568258197dd56a08b451f267a46e83a100e7657e))


### Documentation

* added CONTRIBUTING.md ([54d393c](https://github.com/OHDSI/Hestia/commit/54d393c5131504d95391de3b0e2087d61b10a06a))
* organization ([9efe22f](https://github.com/OHDSI/Hestia/commit/9efe22f9c83e70e5b1caed9e20c58dc810296d81))
* typo ([e32f838](https://github.com/OHDSI/Hestia/commit/e32f83821de303ad17f96b1aba0bce7d6ba4d1c6))
* update readme ([fc8f48a](https://github.com/OHDSI/Hestia/commit/fc8f48a17319725e2bcd06067b30b459f48c6297))
* updated contrib ([2f2ead3](https://github.com/OHDSI/Hestia/commit/2f2ead3f73cd487022b13e1337f8c92770a0353f))
* updated readme ([aaae4da](https://github.com/OHDSI/Hestia/commit/aaae4dae9e26113186b08920032dce200994201c))
* updated README ([2919cec](https://github.com/OHDSI/Hestia/commit/2919cec4cafdc67b572405900620fd50f449b2bf))
* updated security.md ([6272ebc](https://github.com/OHDSI/Hestia/commit/6272ebcb57ce65d7b600e8d8253f35430e3a3dd0))
* updates ([b6c6be3](https://github.com/OHDSI/Hestia/commit/b6c6be3502c44e79892eb3872b97ed1b055cad2d))

## 0.1.0 (2024-02-16)


### Features

* added setup.cfg ([7aff036](https://github.com/OHDSI/Hestia/commit/7aff036b5b1e437220c725532d063eccddb97a8c))


### Documentation

* added code owner ([887b7df](https://github.com/OHDSI/Hestia/commit/887b7dfa3e494c21e84d548df19e1ddc5e09eaf0))
* added templates and file structure ([3d33b3d](https://github.com/OHDSI/Hestia/commit/3d33b3d399144224116690ef1ddc215f229f3413))
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ Hestia is an implementation of the OpenAPI standard to the OMOP CDM and OHDSI to
## Design


## Technology

| Name | Licence |
|------|---------|
| [FastAPI](https://fastapi.tiangolo.com/) | MIT |
| [Ibis](https://ibis-project.org/) | Apache License 2.0 |
| [Pydantic](https://docs.pydantic.dev/latest/) | MIT |
| [Duckdb](https://github.com/duckdb/duckdb) | MIT |
| [Pytest](https://github.com/pytest-dev/pytest) | MIT |
| [Ruff](https://github.com/astral-sh/ruff) | MIT |
| [Docker Engine](https://docs.docker.com/engine/) | Apache License 2.0 |
| [FastUI](https://github.com/pydantic/FastUI) | MIT|



## Installation

```bash
Expand Down Expand Up @@ -49,7 +64,11 @@ Pre-alpha

- Please read our [CONTRIBUTING.md](.github/CONTRIBUTING.md) document.

- We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) to assist with change log automation, please use this style as much as possible.

## References

- [zhanymkanov/fastapi-best-practices](https://github.com/zhanymkanov/fastapi-best-practices?tab=readme-ov-file#project-structure)
- [tiangolo/full-stack-fastapi-template](https://github.com/tiangolo/full-stack-fastapi-template)

## License
Hestia is licensed under [Apache License 2.0](./LICENSE)
8 changes: 8 additions & 0 deletions hestia/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Python
__pycache__
app.egg-info
*.pyc
.mypy_cache
.coverage
htmlcov
.venv
8 changes: 8 additions & 0 deletions hestia/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
__pycache__
app.egg-info
*.pyc
.mypy_cache
.coverage
htmlcov
.cache
.venv
Empty file added hestia/__init__.py
Empty file.
Empty file added hestia/app/__init__.py
Empty file.
Empty file added hestia/app/api/__init__.py
Empty file.
15 changes: 15 additions & 0 deletions hestia/app/api/endpoints/endpoint_concept.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# app/api/endpoints/endpoint_concept.py

from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy.orm import Session
from app.crud import crud_concept
from app.db.session import get_db # Assuming you have a function to get the DB session

router = APIRouter()

@router.get("/concept/{concept_id}")
def read_concept(concept_id: int, db: Session = Depends(get_db)):
db_concept = crud_concept.get_concept(db, concept_id=concept_id)
if db_concept is None:
raise HTTPException(status_code=404, detail="Concept not found")
return db_concept
Empty file added hestia/app/core/__init__.py
Empty file.
Empty file added hestia/app/db/__init__.py
Empty file.
161 changes: 161 additions & 0 deletions hestia/app/db/queries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@

### CARE SITE ###



### CONDITION ###

### CONDITION ERA ###

### CONDITION OCCURRENCE COMBINATIONS ###




### DRUG ###

### DRUG COST ###

### DRUG ERA ###

### DRUG EXPOSURE ###

### OBSERVATION PERIOD ###

### OBSERVATION ###

### PAYER PLAN ###

### PROCEDURE ###

### PERSON ###




### GENERAL ###



# G01: Find concept by concept ID
def find_concept_by_concept_id(concept_id, connection):
"""
This is the most generic look-up for obtaining concept details associated with a concept identifier. The query is intended as a tool for quick reference for the name, class, level and source vocabulary details associated with a concept identifier.
Parameters:
concept_id (int): The ID of the concept to retrieve.
connection: An ibis backend connection object to the OMOP CDM database using the ibis framework.
Returns:
DataFrame: The result of the query is an Ibis DataFrame.
"""

query = (
connection.table('concept').sql(f"""
SELECT
c.concept_id,
c.concept_name,
c.concept_code,
c.concept_class_id,
c.standard_concept,
c.vocabulary_id
FROM concept AS c
WHERE concept_id = {concept_id}
;
""")
)

return query


# G02: Find a concept by code from a source vocabulary
def find_concept_by_code_form_a_source_vocabulary(concept_id, vocabulary_id, connection):
"""
This query obtains the concept details associated with a concept code, such as name, class, level and source vocabulary.
Only concepts from the Standard Vocabularies can be searched using this query. If you want to translate codes from other Source Vocabularies to Standard Vocabularies use G06 query.
Parameters:
concept_id (int): The ID of the concept to retrieve.
vocabulary_id (str): The source vocabulary ID of the concept to retrieve.
connection: An ibis backend connection object to the OMOP CDM database using the ibis framework.
Returns:
DataFrame: The result of the query is an Ibis DataFrame.
"""

query = (
connection.table('concept').sql(f"""
SELECT
c.concept_id,
c.concept_name,
c.concept_code,
c.concept_class_id,
c.vocabulary_id
FROM concept AS c
WHERE
c.concept_code = {concept_id} AND
c.vocabulary_id = {vocabulary_id} AND
c.invalid_reason IS NULL
;
""")
)

return query


# G04: Find synonyms for a given concept
def find_synonyms_for_a_given_concept():


# G05: Translate a code from a source to a standard vocabulary.
def translate_a_code_from_a_source_to_a_standard_vocabulary():


# G06: Find concepts and their descendants that are covered by a given source code
def find_concepts_and_their_descendants_that_are_covered_by_a_given_source_code():


# G07: Find concepts that have a relationship with a given concept
def find_concepts_that_have_a_relationship_with_a_given_concept():


# G08: Find ancestors for a given concept
def find_ancestors_for_a_given_concept():


# G09: Find descendants for a given concept
def find_descendants_for_a_given_concept():


# G10: Find parents for a given concept
def find_parents_for_a_given_concept():


# G11: Find children for a given concept
def find_children_for_a_given_concept():


# G12: List current vocabulary release number
def list_current_vocabulary_release_number():


# G13: List available vocabularies
def list_available_vocabularies():


# G14: Statistics about relationships between concepts
def statistics_about_relationships_between_concepts():


# G15: Statistic about Concepts, Vocabularies, Classes and Levels
def statistic_about_concepts_vocabularies_classes_and_levels():


# G16: Statistics about Condition Mapping of Source Vocabularies
def statistics_about_condition_mapping_of_source_vocabularies():


# G17: Statistics about Drugs Mapping of Source Vocabularies
def statistics_about_drugs_mapping_of_source_vocabularies():

Empty file added hestia/app/main.py
Empty file.
Empty file added hestia/app/schemas/__init__.py
Empty file.
Empty file added hestia/app/tests/__init__.py
Empty file.
Empty file added hestia/main.py
Empty file.
Empty file added hestia/models/__init__.py
Empty file.
Loading

0 comments on commit 91b4823

Please sign in to comment.