Skip to content

Health Software Common Practices

HSCP-T-020 · open test

Register of AI system deployments approved by the organisation's governance

Serves HSCP-G-130, HSCP-G-029 · Recipe: HSCP-R-033

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 the deployment register, one JSON object per record (JSON Lines): etablissement, fonction, version, gouvernance (comite or referent), impact_evalue_le, raci_signee_le, validation_le, usagers_associes, active, activation_le.

The test accepts the register if each active record carries an impact assessment and a responsibility matrix dated no later than the approval day, an approval by the organisation's governance, an activation that does not precede it, and involved patient representatives.

It reports, without rejecting, a function prepared but not yet approved, as long as it is not active.

Running the test

python3 verifier.py deploiements.jsonl

--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/: two deployments approved then activated, one by a committee, the other by a lead; a new function awaiting approval, not active. Accepted, with a note.
  • exemples/refuse/: function activated before its approval, governance outside the list without a signed matrix, impact assessment after the approval, patient representatives not involved. Rejected.

What the test does not say

  • It does not say that the impact assessment is serious or that the approval was given with full knowledge.
  • It does not say that the product really prevents activation before approval: the test run of each version shows that.
  • It says nothing about the vendor's committee, whose minutes are reviewed separately.

Code

Download the test (zip archive: program, examples, README, licence) (9 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-020 : registre des déploiements d'un système d'IA, validés par la gouvernance de chaque établissement.

    python3 verifier.py <deploiements.jsonl> [--json]

Lit le registre, un objet JSON par fiche (JSON Lines) : etablissement, fonction, version, gouvernance (comite ou
referent), validation_le, raci_signee_le, impact_evalue_le, usagers_associes, active, activation_le.
Refus : ligne illisible ; champ d'identité absent ; gouvernance hors liste ; fiche active sans évaluation d'impact,
sans matrice signée ou sans validation ; évaluation d'impact ou matrice postérieure à la validation ; activation
absente ou antérieure à la validation ; fiche active sans usagers associés ; date illisible.
Note seulement : fonction préparée mais pas encore validée (non active).
Il ne dit pas que l'évaluation d'impact est sérieuse ni que la validation a été prise en connaissance de cause.

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-020"


def jour(v):
    try:
        return dt.date.fromisoformat(str(v))
    except ValueError:
        return None


def verifier(chemin):
    refus, notes, n = [], [], 0
    for num, ligne in enumerate(open(chemin, encoding="utf-8"), 1):
        if not ligne.strip():
            continue
        try:
            e = json.loads(ligne)
            assert isinstance(e, dict)
        except (ValueError, AssertionError):
            refus.append(f"ligne {num} : objet JSON illisible")
            continue
        n += 1
        nom = f"{e.get('etablissement') or 'ligne ' + str(num)}, {e.get('fonction') or '?'}"
        if not e.get("etablissement") or not e.get("fonction") or not e.get("version"):
            refus.append(f"{nom} : établissement, fonction ou version absent")
            continue
        if e.get("gouvernance") not in ("comite", "referent"):
            refus.append(f"{nom} : gouvernance absente ou hors liste")
        if e.get("active") is not True:
            if not e.get("validation_le"):
                notes.append(f"{nom} : fonction non validée, non active")
            continue
        dates = {k: jour(e.get(k)) for k in ("impact_evalue_le", "raci_signee_le", "validation_le", "activation_le")}
        manque = [k for k, v in dates.items() if v is None]
        if manque:
            refus.append(f"{nom} : active sans date lisible : {', '.join(manque)}")
            continue
        for k in ("impact_evalue_le", "raci_signee_le"):
            if dates[k] > dates["validation_le"]:
                refus.append(f"{nom} : {k} postérieure à la validation")
        if dates["activation_le"] < dates["validation_le"]:
            refus.append(f"{nom} : activée avant sa validation par la gouvernance")
        if e.get("usagers_associes") is not True:
            refus.append(f"{nom} : active sans représentants des usagers associés")
    if n == 0:
        refus.append("registre vide")
    return refus, notes, n


def main(argv):
    p = argparse.ArgumentParser(prog="verifier.py", description=__doc__.splitlines()[0])
    p.add_argument("registre")
    p.add_argument("--json", action="store_true")
    try:
        a = p.parse_args(argv)
    except SystemExit:
        return 2
    try:
        refus, notes, n = verifier(a.registre)
    except OSError as e:
        print(f"{ID} : pièce illisible : {e}", file=sys.stderr)
        return 2
    if a.json:
        print(json.dumps({"test": ID, "accepte": not refus, "fiches": n, "refus": refus, "notes": notes},
                         ensure_ascii=False, indent=2))
    else:
        print(f"{ID} : {'pièce acceptée' if not refus else 'pièce refusée'} ({n} fiche(s))")
        for x in refus:
            print("  refus :", x)
        for x in notes:
            print("  note :", x)
    return 0 if not refus else 1


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

Files of the test