Skip to main content

GenPatientProfile

Librairie Python pour la génération de séjours médicaux fictifs et de scénarios textuels à partir de plusieurs stratégies spécifiques aux centres.

Python CC BY-NC-SA 4.0

Table des matières


Vue d'ensemble

L'idée est de pouvoir crée des scénarios hospitaliers fictifs à partir de séjours choisi selon la stratégie mis en place par le centre développeur de la pipeline. Ces séjours fictifs peuvent ensuite être utilisés en entrée d'un LLM pour en générer des CRH par exemple.


Installation

uv pip install GenPatientProfile

Ou depuis les sources :

git clone https://github.com/24p11/GenPatientProfile.git
cd GenPatientProfile
pip install -e .

Prérequis

  • Python 3.12+
  • polars
  • pyyaml
  • tqdm

Utilisation

En tant que librairie

La distribution s'installe sous le nom GenPatientProfile. Le module Python s'importe sous le nom genpatientprofile.

Pour le pipeline Brest :

from genpatientprofile import generate

df = generate(
    pipeline_name="pmsi_sampling",
    n_sejours=500,
    n_ccam=1,
    n_das=5,
    ghm5_pattern=None,
)

Pour le pipeline AP-HP :

from genpatientprofile import generate

df = generate(
    pipeline_name="profile_generation",
    n_sejours=500,
)

Le pipeline AP-HP utilise par défaut le jeu de prompts default en une étape. Le jeu old conserve les prompts historiques et prend également en charge la génération en deux étapes :

df = generate(
    pipeline_name="profile_generation",
    n_sejours=500,
    prompt_set="old",
    prompt_workflow="two_stage",
)

Un jeu de prompts externe peut être fourni sans modifier le paquet :

df = generate(
    pipeline_name="profile_generation",
    n_sejours=500,
    prompt_dir="/chemin/vers/mes_prompts",
    prompt_workflow="one_stage",
)

Le dossier doit contenir un manifest.yaml et un sous-dossier par étape déclarée :

mes_prompts/
├── manifest.yaml
├── prefix.txt
└── one_stage/
    ├── medical_inpatient.txt
    └── ...

Exemple de manifeste :

name: mes_prompts
version: "1.0"
workflows:
  one_stage: true
  two_stage: false

Le nom, la version, la source et l'empreinte du jeu sont ajoutés au DataFrame. Lorsqu'un dossier externe est utilisé, une copie est conservée sous prompts_snapshot/ dans le répertoire de sortie.

En ligne de commande

python main.py pmsi_sampling --n-sejours 100
python main.py profile_generation --n-sejours 100
python main.py profile_generation --n-sejours 100 \
  --prompt-set old --prompt-workflow two_stage
python main.py profile_generation --n-sejours 100 --prompt-dir ./mes_prompts

Les anciens noms brest et aphp restent temporairement acceptés comme alias dépréciés.


Pipelines disponibles

Nom Site Description
pmsi_sampling CHU de Brest Choix des codes CIM10 par pondération selon les extractions SNDS
profile_generation AP-HP Génération de scénarios cliniques à partir de profils PMSI AP-HP, avec règles ATIH, templates spécifiques, prompts système et préfixes LLM.

Architecture

genpatientprofile/
├── __init__.py        # API publique
├── core.py            # Fonction principale generate()
├── registry.py        # Registre des pipelines (PIPELINES) ainsi que du chemin vers le fichier de config (CONFIG_DIR)
├── config.py          # Chargement de la configuration
├── base.py            # Définition de la pipeline de base BasePipeline
├── ficitve.py         # Fonction général qui permet la génération des séjours fictifs
├── scenario.py        # Fonction général qui permet la génération des scenarios fictifs
├── config/  
│ └── servers.yaml 
└── sites/ 
    ├── brest/ 
    │ ├── __init__.py 
    │ ├── constants.py 
    │ ├── fictive.py 
    │ ├── pipeline.py 
    │ ├── sampler.py 
    │ └── scenario.py 
    └── aphp/ 
        ├── __init__.py 
        ├── constants.py 
        ├── fictive.py 
        ├── loader.py 
        ├── managment.py 
        ├── pipeline.py 
        ├── prompt.py 
        ├── sampler.py 
        └── scenario.py 


Contribuer

Ajouter un nouveau pipeline

  1. Créer un dossier genpatientprofile/sites/<nom_site>/
  2. Implémenter MedPipelineBase dans pipeline.py
  3. Enregistrer le pipeline dans registry.py
# registry.py
from genpatientprofile.sites.nouveau_site.pipeline import NouveauSitePipeline

PIPELINES = {
    "pmsi_sampling": BrestPipeline,
    "profile_generation": APHPPipeline,
    "nouveau_site": NouveauSitePipeline,  # ← ajouter ici
}

Contributeurs

Nom Rôle
Arthur LAMARD Data Engineer CHU Brest
Dr. Basile FUCHS Médecin DIM CHU Brest
Claire Dechaux Data Scientist INRIA
Dr. Remi Flicoteaux Médecin DIM APHP

Licence

Ce projet est sous licence Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.

Vous êtes libre de :

  • Partager — copier et redistribuer le projet
  • Adapter — remixer et transformer le projet Sous les conditions suivantes :
  • Attribution — Vous devez citer le projet original
  • Non Commercial — Usage commercial interdit sans accord explicite
  • Partage dans les mêmes conditions — Toute modification doit être publiée sous la même licence

Metadata

Release files for GenPatientProfile 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GenPatientProfile 0.1.0
File Size Uploaded Provenance Actions
genpatientprofile-0.1.0.tar.gz 95.9 kB With provenance Details for genpatientprofile-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for GenPatientProfile 0.1.0
File Interpreter ABI Platform Actions
genpatientprofile-0.1.0-py3-none-any.whl Python 3 none any Details for genpatientprofile-0.1.0-py3-none-any.whl

Total release size: 469.1 kB

Release files / genpatientprofile-0.1.0.tar.gz

Download URL genpatientprofile-0.1.0.tar.gz
Size 95.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3d14bb86a57099ae5ef379714ba9a7d468bcc38e2007c85a867fcf7531d4f918
BLAKE2b-256 checksum
How to use checksums
7eedec9c1d2962d93f562179ab229d216a0d9c48af5da96db6cefdbf81775bba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / genpatientprofile-0.1.0-py3-none-any.whl

Download URL genpatientprofile-0.1.0-py3-none-any.whl
Size 373.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
353490cacf7813e09504363665a1d8af1f41c64cc4ac2926109026f065b19c96
BLAKE2b-256 checksum
How to use checksums
164833ede5e1fd97fec74b3f6f85ea4d2eb7439ce3b35aac8a574bece2de524c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for GenPatientProfile 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for genpatientprofile-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page