HSCP-T-016 · open test
Training programme of an AI system and register of authorisations
What the test checks
The artefact is a JSON file following the recipe's data model: the system (nom, version, version_significative, haut_risque), the training programme (version, themes, evaluation.seuil) and the named register (personne, profil, module, version, date, score, habilitee).
The test accepts the artefact if the programme covers the latest significant version or a later one, includes the ten expected themes (fonctionnement, destination, performances, biais, responsabilite, validation_humaine, information_patient, signalement, mode_degrade, cas_pratiques) and sets a pass mark; if each authorisation covers a version equal to or later than the latest significant version, with a score at least equal to the pass mark; and if a high-risk system has at least one authorised person.
It reports, without rejecting, a person trained but not authorised.
Running the test
python3 verifier.py formation.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/: programme for version 3.2 with all ten themes, pass mark of 0.8, two people authorised on significant version 3.0, a third trained but not authorised. Accepted, with a note.exemples/refuse/: programme still at version 2.4 and incomplete, zero pass mark, an authorisation on a version older than the significant version, a line without a score. Rejected.
What the test does not say
- It does not say that the training is good or that people have understood: the review of the materials with a panel of users judges that.
- It does not say that everyone who uses the system is in the register.
- It does not say whom the organisation should authorise: that is its decision.
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-016 : programme de formation d'un système d'IA et registre des formations et des habilitations.
python3 verifier.py <formation.json> [--json]
Lit un objet JSON : systeme (nom, version, version_significative, haut_risque), programme (version, themes,
evaluation.seuil), registre (personne, profil, module, version, date, score, habilitee).
Refus : fichier illisible ; champ obligatoire absent ; programme antérieur à la dernière version significative ;
thème attendu absent ; seuil hors de ]0, 1] ; habilitation sur une version antérieure à la dernière version
significative ; habilitation avec un score sous le seuil ; système à haut risque sans personne habilitée.
Note seulement : personne formée sans habilitation (évaluation à refaire ou habilitation non décidée).
Il ne dit pas que la formation est bonne ni que les personnes ont compris.
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-016"
THEMES = ("fonctionnement", "destination", "performances", "biais", "responsabilite", "validation_humaine",
"information_patient", "signalement", "mode_degrade", "cas_pratiques")
REGISTRE = ("personne", "profil", "module", "version", "date", "score", "habilitee")
def version(v):
try:
return tuple(int(x) for x in str(v).split("."))
except ValueError:
return None
def nombre(v):
return isinstance(v, (int, float)) and not isinstance(v, bool)
def verifier(d):
refus, notes = [], []
s, p, r = d.get("systeme") or {}, d.get("programme") or {}, d.get("registre")
manque = [k for k in ("nom", "version", "version_significative", "haut_risque") if s.get(k) in (None, "")]
if manque or not isinstance(r, list) or not p:
return [f"systeme, programme ou registre incomplet ({', '.join(manque) or 'programme ou registre'})"], notes, 0
vs = version(s["version_significative"])
if vs is None or version(s["version"]) is None:
return ["numéro de version illisible"], notes, len(r)
vp = version(p.get("version"))
if vp is None or vp < vs:
refus.append("programme antérieur à la dernière version significative")
absents = [t for t in THEMES if t not in (p.get("themes") or [])]
if absents:
refus.append(f"thème(s) absent(s) du programme : {', '.join(absents)}")
seuil = (p.get("evaluation") or {}).get("seuil")
if not nombre(seuil) or not 0 < seuil <= 1:
refus.append("seuil de l'évaluation des acquis absent ou hors de ]0, 1]")
seuil = None
habilitees = 0
for i, e in enumerate(r, 1):
nom = f"registre, {e.get('personne') or 'ligne ' + str(i)}"
manque = [k for k in REGISTRE if e.get(k) in (None, "")]
if manque:
refus.append(f"{nom} : champ(s) absent(s) : {', '.join(manque)}")
continue
try:
dt.date.fromisoformat(str(e["date"]))
except ValueError:
refus.append(f"{nom} : date illisible")
if not nombre(e["score"]):
refus.append(f"{nom} : score non chiffré")
continue
if e["habilitee"] is True:
ve = version(e["version"])
if ve is None or ve < vs:
refus.append(f"{nom} : habilitation sur une version antérieure à la dernière version significative")
elif seuil is not None and e["score"] < seuil:
refus.append(f"{nom} : habilitée avec un score sous le seuil")
else:
habilitees += 1
else:
notes.append(f"{nom} : formée sans habilitation")
if s["haut_risque"] is True and not habilitees:
refus.append("système à haut risque sans personne habilitée")
return refus, notes, len(r)
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, notes, n = verifier(d)
if a.json:
print(json.dumps({"test": ID, "accepte": not refus, "entrees": 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} entrée(s) au registre)")
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:]))