Metadata-Version: 2.1
Name: femr
Version: 0.2.2
Summary: Framework for Electronic Medical Records. A python package for building models using EHR data.
Requires-Python: >3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.22
Requires-Dist: scipy>=1.6
Requires-Dist: scikit-learn>=0.24
Requires-Dist: tqdm>=4.60.0
Requires-Dist: zstandard>=0.18
Requires-Dist: icecream==2.1.3
Requires-Dist: nptyping==2.4.1
Requires-Dist: msgpack>=1.0.5
Requires-Dist: meds==0.1.3
Requires-Dist: torch>=2.1.2
Requires-Dist: transformers>=4.25
Requires-Dist: datasets>=2.15
Requires-Dist: polars>=0.20
Requires-Dist: dill>=0.3.7
Provides-Extra: build
Requires-Dist: pytest>=5.2; extra == "build"
Requires-Dist: flake8-future-import>=0.4.6; extra == "build"
Requires-Dist: black>=19.10b0; extra == "build"
Requires-Dist: isort>=5.3.2; extra == "build"
Requires-Dist: mypy>=0.782; extra == "build"
Requires-Dist: flake8>=3.8.3; extra == "build"
Requires-Dist: sphinx>=3.2.1; extra == "build"
Requires-Dist: sphinx-rtd-theme>=0.5.0; extra == "build"
Requires-Dist: sphinx-autoapi>=1.5.1; extra == "build"
Requires-Dist: torchtyping==0.1.4; extra == "build"

# FEMR
### Framework for Electronic Medical Records

**FEMR** is a Python package for manipulating longitudinal EHR data for machine learning, with a focus on supporting the creation of foundation models and verifying their [presumed benefits](https://hai.stanford.edu/news/how-foundation-models-can-advance-ai-healthcare) in healthcare. Such a framework is needed given the [current state of large language models in healthcare](https://hai.stanford.edu/news/shaky-foundations-foundation-models-healthcare) and the need for better evaluation frameworks.

The currently supported foundation models are [CLMBR](https://arxiv.org/pdf/2001.05295.pdf) and [MOTOR](https://arxiv.org/abs/2301.03150).

**FEMR** works with data that has been converted to the [MEDS](https://github.com/Medical-Event-Data-Standard/) schema, a simple schema that supports a wide variety of EHR / claims datasets. Please see the MEDS documentation, and in particular its [provided ETLs](https://github.com/Medical-Event-Data-Standard/meds_etl) for help converting your data to MEDS.

**FEMR** helps users:
1. [Use ontologies to better understand / featurize medical codes](http://github.com/som-shahlab/femr/blob/main/tutorials/1_Ontology.ipynb)
2. [Algorithmically label patient records based on structured data](https://github.com/som-shahlab/femr/blob/main/tutorials/2_Labeling.ipynb)
3. [Generate tabular features from patient timelines for use with traditional gradient boosted tree models](https://github.com/som-shahlab/femr/blob/main/tutorials/3_Count%20Featurization%20And%20Modeling.ipynb)
4. [Train](https://github.com/som-shahlab/femr/blob/main/tutorials/4_Train%20CLMBR.ipynb) and [finetune](https://github.com/som-shahlab/femr/blob/main/tutorials/5_CLMBR%20Featurization%20And%20Modeling.ipynb) CLMBR-derived models for binary classification and prediction tasks.
5. [Train](https://github.com/som-shahlab/femr/blob/main/tutorials/6_Train%20MOTOR.ipynb) and [finetune](https://github.com/som-shahlab/femr/blob/main/tutorials/7_MOTOR%20Featurization%20And%20Modeling.ipynb) MOTOR-derived models for binary classification and prediction tasks.

We recommend users start with our [tutorial folder](https://github.com/som-shahlab/femr/tree/main/tutorials)

# Installation

FEMR can be installed with the simple command ```pip install femr```.

If you are using deep learning, you need to also install xformers ```pip install xformers```.

# Getting Started

The first step of using **FEMR** is to convert your patient data into [MEDS](https://github.com/Medical-Event-Data-Standard), the standard input format expected by **FEMR** codebase.

The best way to do this is with the [ETLs provided by MEDS](https://github.com/Medical-Event-Data-Standard/meds_etl).

# Development

The following guides are for developers who want to contribute to **FEMR**.

## Precommit checks

Before committing, please run the following commands to ensure that your code is formatted correctly and passes all tests.

### Installation
```bash
conda install pre-commit pytest -y
pre-commit install
```

### Running

#### Test Functions

```bash
pytest tests
```

### Formatting Checks

```bash
pre-commit run --all-files
```
