Skip to content

Health Software Common Practices

HSCP-T-017 · open test

Supporting file for the obligations of the deployer of a high-risk AI system

Serves HSCP-G-176, HSCP-G-087 · Recipe: HSCP-R-030

Code under the licence Apache 2.0 · Python 3.10 or later, standard library only, no network access

What the test checks

The artefact is a JSON file following the recipe's data model: the system (nom, version in service) and one section per obligation (obligation, piece, motif, version, date, fourni_par, conservation_mois for logs).

The test accepts the file if all eleven obligations are present, once each (notice, controle_humain, donnees_entree, surveillance, journaux, information_travailleurs, information_personnes, aipd, aidf, enregistrement, explication); if each document carries its date, the version covered and who supplied it; if no document covers a version older than the one in service; if the instructions for use come from the vendor; if logs are kept for at least six months; and if each sans-objet carries its reason.

Running the test

python3 verifier.py dossier.json

--json gives the answer in JSON. Exit code: 0 artefact accepted, 1 artefact rejected, 2 incorrect call. Python 3.10 or later, no dependencies.

Examples

  • exemples/valide/: eleven sections for version 3.2, two obligations not applicable with their reason, logs kept for twelve months. Accepted.
  • exemples/refuse/: instructions still at version 2.4 and copied by the organisation, a document without a date, logs kept for three months, a not-applicable entry without a reason, an unknown section, seven obligations missing. Rejected.

What the test does not say

  • It does not say that the documents are correct or complete.
  • It does not say that a sans-objet is justified: the organisation's status and the use decide.
  • It does not say that the system is used according to its instructions.

Code

Download the test (zip archive: program, examples, README, licence) (10 KB) · verifier.py

The code and its messages are not translated (French).

#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
# Copyright 2026 les contributeurs des Gestes communs du logiciel de santé
"""HSCP-T-017 : dossier d'appui aux obligations du déployeur d'un système d'IA à haut risque.

    python3 verifier.py <dossier.json> [--json]

Lit un objet JSON : systeme (nom, version) et rubriques (obligation, piece, motif, version, date, fourni_par,
conservation_mois pour les journaux).
Refus : fichier illisible ; obligation attendue absente ou en double ; obligation hors liste ; pièce sans date, sans
version ou sans fournisseur ; pièce qui couvre une version antérieure à la version en service ; « sans-objet » sans
motif ; notice qui ne vient pas de l'éditeur ; conservation des journaux inférieure à six mois.
Il ne dit pas que les pièces sont justes ni qu'un « sans-objet » est fondé.

Codes de retour : 0 pièce acceptée, 1 pièce refusée, 2 appel incorrect.
Bibliothèque standard seulement, aucun accès réseau.
"""
import argparse
import datetime as dt
import json
import sys

ID = "HSCP-T-017"
OBLIGATIONS = ("notice", "controle_humain", "donnees_entree", "surveillance", "journaux", "information_travailleurs",
               "information_personnes", "aipd", "aidf", "enregistrement", "explication")
FOURNISSEURS = {"editeur", "etablissement"}


def version(v):
    try:
        return tuple(int(x) for x in str(v).split("."))
    except ValueError:
        return None


def verifier(d):
    refus = []
    s, rub = d.get("systeme") or {}, d.get("rubriques")
    vs = version(s.get("version"))
    if not s.get("nom") or vs is None or not isinstance(rub, list):
        return ["systeme (nom, version) ou rubriques absents ou illisibles"], 0
    vues = {}
    for i, r in enumerate(rub, 1):
        o = r.get("obligation")
        nom = f"rubrique {o or i}"
        if o not in OBLIGATIONS:
            refus.append(f"{nom} : obligation hors liste")
            continue
        if o in vues:
            refus.append(f"{nom} : en double")
        vues[o] = r
        if r.get("piece") == "sans-objet":
            if not r.get("motif"):
                refus.append(f"{nom} : sans objet sans motif")
            continue
        if not r.get("piece"):
            refus.append(f"{nom} : pièce absente")
            continue
        try:
            dt.date.fromisoformat(str(r.get("date")))
        except ValueError:
            refus.append(f"{nom} : date absente ou illisible")
        vr = version(r.get("version"))
        if vr is None:
            refus.append(f"{nom} : version couverte absente")
        elif vr < vs:
            refus.append(f"{nom} : couvre la version {r['version']}, antérieure à la version en service {s['version']}")
        if r.get("fourni_par") not in FOURNISSEURS:
            refus.append(f"{nom} : fournisseur de la pièce absent ou hors liste")
        if o == "notice" and r.get("fourni_par") != "editeur":
            refus.append(f"{nom} : la notice doit venir de l'éditeur")
        if o == "journaux":
            m = r.get("conservation_mois")
            if not isinstance(m, (int, float)) or isinstance(m, bool) or m < 6:
                refus.append(f"{nom} : conservation des journaux absente ou inférieure à six mois")
    absentes = [o for o in OBLIGATIONS if o not in vues]
    if absentes:
        refus.append(f"obligation(s) absente(s) : {', '.join(absentes)}")
    return refus, len(rub)


def main(argv):
    p = argparse.ArgumentParser(prog="verifier.py", description=__doc__.splitlines()[0])
    p.add_argument("fichier")
    p.add_argument("--json", action="store_true")
    try:
        a = p.parse_args(argv)
    except SystemExit:
        return 2
    try:
        d = json.load(open(a.fichier, encoding="utf-8"))
        assert isinstance(d, dict)
    except (OSError, ValueError, AssertionError) as e:
        print(f"{ID} : pièce illisible : {e}", file=sys.stderr)
        return 2
    refus, n = verifier(d)
    if a.json:
        print(json.dumps({"test": ID, "accepte": not refus, "rubriques": n, "refus": refus}, ensure_ascii=False, indent=2))
    else:
        print(f"{ID} : {'pièce acceptée' if not refus else 'pièce refusée'} ({n} rubrique(s))")
        for x in refus:
            print("  refus :", x)
    return 0 if not refus else 1


if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))

Files of the test