|
| 1 | +# Adjusting for the progressive digitization of health records: working examples on a multi-hospital clinical data warehouse |
| 2 | + |
| 3 | + |
| 4 | +<div align="center"> |
| 5 | + <img src="logo.svg" alt="EDS-TeVa"> |
| 6 | + |
| 7 | +<p align="center"> |
| 8 | +<a href="https://github.com/psf/black" target="_blank"> |
| 9 | + <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Black"> |
| 10 | +</a> |
| 11 | +<a href="https://python-poetry.org/" target="_blank"> |
| 12 | + <img src="https://img.shields.io/badge/reproducibility-poetry-blue" alt="Poetry"> |
| 13 | +</a> |
| 14 | +<a href="https://www.python.org/" target="_blank"> |
| 15 | + <img src="https://img.shields.io/badge/python-%3E%3D%203.7.1%20%7C%20%3C%203.8-brightgreen" alt="Supported Python versions"> |
| 16 | +</a> |
| 17 | +<a href="https://spark.apache.org/docs/2.4.8/" target="_blank"> |
| 18 | + <img src="https://img.shields.io/badge/spark-2.4-brightgreen" alt="Supported Java version"> |
| 19 | +</a> |
| 20 | +</p> |
| 21 | +</div> |
| 22 | + |
| 23 | +## Study |
| 24 | + |
| 25 | +This repositoy contains the computer code that has been executed to generate the results of the article: |
| 26 | +``` |
| 27 | +@unpublished{edsteva, |
| 28 | +author = {Adam Remaki and Benoît Playe and Paul Bernard and Simon Vittoz and Matthieu Doutreligne and Gilles Chatellier and Etienne Audureau and Emmanuelle Kempf and Raphaël Porcher and Romain Bey}, |
| 29 | +title = {Adjusting for the progressive digitization of health records: working examples on a multi-hospital clinical data warehouse}, |
| 30 | +note = {Manuscript submitted for publication}, |
| 31 | +year = {2023} |
| 32 | +} |
| 33 | +``` |
| 34 | +The code has been executed on the OMOP database of the clinical data warehouse of the <a href="https://eds.aphp.fr/" target="_blank">Greater Paris University Hospitals</a> |
| 35 | + |
| 36 | +- IRB number: CSE210033 |
| 37 | +- This study stands on the shoulders of the library [EDS-TeVa](https://github.com/aphp/edsteva) (an open-source library providing a set of tools that aims at modeling the adoption over time and across space of the Electronic Health Records). |
| 38 | +## Version 1.0.0 |
| 39 | + |
| 40 | +- Submission of the article for review. |
| 41 | +## Setup |
| 42 | + |
| 43 | +- In order to process large-scale data, the study uses [Spark 2.4](https://spark.apache.org/docs/2.4.8/index.html) (an open-source engine for large-scale data processing) which requires to: |
| 44 | + |
| 45 | + - Install a version of Python $\geq 3.7.1$ and $< 3.8$. |
| 46 | + - Install Java 8 (you can install [OpenJDK 8](https://openjdk.org/projects/jdk8/), an open-source reference implementation of Java 8) |
| 47 | + |
| 48 | +- Clone the repository: |
| 49 | + |
| 50 | +```shell |
| 51 | +git clone https://gitlab.eds.aphp.fr/equipedatascience/cse_210033.git |
| 52 | +``` |
| 53 | + |
| 54 | +- Create a virtual environment with the suitable Python version (**>= 3.7.1 and < 3.8**): |
| 55 | + |
| 56 | +```shell |
| 57 | +cd cse_210033 |
| 58 | +python -m venv .venv |
| 59 | +source .venv/bin/activate |
| 60 | +``` |
| 61 | + |
| 62 | +- Install [Poetry](https://python-poetry.org/) (a tool for dependency management and packaging in Python) with the following command line: |
| 63 | + - Linux, macOS, Windows (WSL): |
| 64 | + |
| 65 | + ```shell |
| 66 | + curl -sSL https://install.python-poetry.org | python3 - |
| 67 | + ``` |
| 68 | + |
| 69 | + - Windows (Powershell): |
| 70 | + |
| 71 | + ```shell |
| 72 | + (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py - |
| 73 | + ``` |
| 74 | + |
| 75 | + For more details, check the [installation guide](https://python-poetry.org/docs/#installation) |
| 76 | + |
| 77 | +- Install dependencies: |
| 78 | + |
| 79 | +```shell |
| 80 | +pip install pypandoc==1.7.5 |
| 81 | +pip install pyspark==2.4.8 |
| 82 | +poetry install |
| 83 | +pip uninstall pypandoc |
| 84 | +``` |
| 85 | +## How to run the code on AP-HP's data platform |
| 86 | +### 1. Install EDS-Toolbox: |
| 87 | + |
| 88 | +EDS-Toolbox is python library that provides an efficient way of submitting PySpark scripts on AP-HP's data platform. As it is AP-HP specific, it is not available on PyPI: |
| 89 | +
|
| 90 | +```shell |
| 91 | +pip install git+ssh://[email protected]:2224/datasciencetools/[email protected] |
| 92 | +``` |
| 93 | +### 2. Pre-processing: Compute, save models and data: |
| 94 | +
|
| 95 | +:warning: Depending on your resources, this step can take some times. |
| 96 | +
|
| 97 | +```shell |
| 98 | +cd scripts |
| 99 | +eds-toolbox spark submit --config ../conf/config.cfg --log-path ../logs/ehr_modeling ehr_modeling.py |
| 100 | +eds-toolbox spark submit --config ../conf/config.cfg --log-path ../logs/cohort_selection cohort_selection.py |
| 101 | +``` |
| 102 | +
|
| 103 | +### 3. Post-processing: Main statistical analysis |
| 104 | +
|
| 105 | +```shell |
| 106 | +pip install pyarrow==12.0.1 |
| 107 | +python statistical_analysis.py --config-name config.cfg |
| 108 | +``` |
| 109 | +
|
| 110 | +### 4. Generate figures |
| 111 | +
|
| 112 | +- **Option 1**: Generate all figures in a raw from the terminal: |
| 113 | +
|
| 114 | + ```shell |
| 115 | + python generate_figures.py --config-name config.cfg |
| 116 | + ``` |
| 117 | +
|
| 118 | +- **Option 2**: Generate figure one at a time from a notebook: |
| 119 | +
|
| 120 | + - Create a Spark-enabled kernel with your environnement: |
| 121 | +
|
| 122 | + ```shell |
| 123 | + eds-toolbox kernel --spark --hdfs |
| 124 | + ``` |
| 125 | +
|
| 126 | + - Convert markdown into jupyter notebook: |
| 127 | +
|
| 128 | + ```shell |
| 129 | + cd notebooks |
| 130 | + jupytext --set-formats md,ipynb 'generate_figures.md' |
| 131 | + ``` |
| 132 | +
|
| 133 | + - Open *generate_figures.ipynb* and start the kernel you've just created. |
| 134 | + - Run the cells to obtain every figure. |
| 135 | + |
| 136 | +### 5. Generate HTML report |
| 137 | + |
| 138 | +- Create a Spark-enabled kernel with your environnement (if you have not previously): |
| 139 | + |
| 140 | +```shell |
| 141 | +eds-toolbox kernel --spark --hdfs |
| 142 | +``` |
| 143 | + |
| 144 | +- Convert markdown into jupyter notebook: |
| 145 | + |
| 146 | +```shell |
| 147 | +cd notebooks |
| 148 | +jupytext --set-formats md,ipynb 'report.md' |
| 149 | +``` |
| 150 | + |
| 151 | +- Open *report.ipynb*, start the kernel you've created and run the cells. |
| 152 | +
|
| 153 | +- Convert notebook to HTML: |
| 154 | +```shell |
| 155 | +eds-toolbox report report.ipynb --output report.html |
| 156 | +``` |
| 157 | +
|
| 158 | +#### Note |
| 159 | +If you would like to run the scripts on a different database from the AP-HP database, you will have to adapt the python scripts with the configuration of the desired database. |
| 160 | +## Project structure |
| 161 | +
|
| 162 | +- `conf`: Configuration files. |
| 163 | +- `data`: Saved processed data and models. |
| 164 | +- `figures`: Saved results. |
| 165 | +- `notebooks`: Notebooks that generate figures. |
| 166 | +- `cse_210033`: Source code. |
| 167 | +- `scripts`: Typer applications to process data and generate figures. |
| 168 | +
|
| 169 | +## Acknowledgement |
| 170 | +
|
| 171 | +We would like to thank [Assistance Publique – Hôpitaux de Paris](https://www.aphp.fr/) and [AP-HP Foundation](https://fondationrechercheaphp.fr/) for funding this project. |
0 commit comments