HSCP-T-009 · open test
Interface register: standard named, interoperability framework followed, closed choices justified
What the test checks
The evidence is the interface register, one JSON object per flow (JSON Lines), following the recipe's data model:
| Field | Required | Meaning |
|---|---|---|
flux |
yes | flow identifier |
sens |
yes | entrant, sortant or les-deux |
donnee_sante |
yes | true if the flow carries health data |
standard |
yes | name and version of the standard followed |
ouvert |
yes | true if the standard is open and published |
cadre_volet |
for a health flow, unless justified | part of the health interoperability framework followed, and its version |
revue |
for a health flow | date of the last review against changes to the framework |
justification |
for a closed standard or a health flow outside the framework | motif, date, sortie |
The test accepts the register if each flow names its standard, if every closed standard and every health flow outside the framework carries a written, dated justification with a planned exit, and if the review of each health flow is more recent than the interval passed to the test (--revue-mois).
It reports, without refusing, a justification dated more than two years ago.
Running the test
python3 verifier.py registre.jsonl --revue-mois 12
--date sets the day of the check, --json returns the answer as JSON. Exit code: 0 evidence accepted, 1 evidence refused, 2 incorrect call. Python 3.10 or later, no dependency.
Examples
exemples/valide/: a report in the framework's format, reviewed; a device flow using the manufacturer's protocol, justified with its exit; an export without health data. Accepted.exemples/refuse/: a product-specific format justified without a date or an exit; a health flow outside the framework, without justification, with a direction outside the list and reviewed three years ago; a flow without a standard. Refused.
What the test does not say
- It does not say that the part of the framework given is the one that covers the flow, nor that the implementation conforms to it: the framework's tests and, for some connections, an approval demonstrate that.
- It does not say that the list of flows is complete.
- It does not say that a standard declared open actually is.
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-009 : registre des interfaces, standard nommé, cadre d'interopérabilité suivi, choix fermés justifiés.
python3 verifier.py <registre.jsonl> --revue-mois N [--date AAAA-MM-JJ] [--json]
Lit le registre, un objet JSON par flux (JSON Lines) : flux, sens, donnee_sante, standard, ouvert, cadre_volet,
revue, justification {motif, date, sortie}.
Refus : ligne illisible ; champ obligatoire absent ; sens hors liste ; flux en double ; standard fermé sans
justification complète ; flux de santé sans volet du cadre et sans justification complète ; flux de santé dont la
revue est absente, illisible ou plus ancienne que --revue-mois ; justification non datée ou sans sortie.
Note seulement : justification dont la date a plus de deux ans.
Il ne dit pas que le volet indiqué est le bon, ni que l'implémentation y est conforme.
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-009"
SENS = {"entrant", "sortant", "les-deux"}
OBLIGATOIRES = ("flux", "sens", "standard", "ouvert", "donnee_sante")
def jour(v):
s = str(v or "")
try:
return dt.date.fromisoformat(s if len(s) > 7 else s + "-01")
except ValueError:
return None
def justifiee(nom, j, quoi, refus, notes, aujourdhui):
if not isinstance(j, dict) or not j.get("motif"):
refus.append(f"{nom} : {quoi} sans justification écrite")
return
d = jour(j.get("date"))
if d is None:
refus.append(f"{nom} : justification non datée")
elif (aujourdhui - d).days > 730:
notes.append(f"{nom} : justification datée de plus de deux ans, à revoir")
if not j.get("sortie"):
refus.append(f"{nom} : justification sans sortie prévue")
def verifier(chemin, revue_mois, aujourdhui):
refus, notes, vus, n = [], [], set(), 0
for num, ligne in enumerate(open(chemin, encoding="utf-8"), 1):
if not ligne.strip():
continue
try:
f = json.loads(ligne)
assert isinstance(f, dict)
except (ValueError, AssertionError):
refus.append(f"ligne {num} : objet JSON illisible")
continue
n += 1
nom = str(f.get("flux") or f"ligne {num}")
manque = [c for c in OBLIGATOIRES if f.get(c) in (None, "")]
if manque:
refus.append(f"{nom} : champ(s) absent(s) : {', '.join(manque)}")
if nom in vus:
refus.append(f"{nom} : flux en double")
vus.add(nom)
if f.get("sens") and f["sens"] not in SENS:
refus.append(f"{nom} : sens hors liste (entrant, sortant, les-deux)")
j = f.get("justification")
if f.get("ouvert") is False:
justifiee(nom, j, "standard fermé", refus, notes, aujourdhui)
if f.get("donnee_sante") is True:
if not f.get("cadre_volet") and f.get("ouvert") is not False: # un standard fermé est déjà justifié plus haut
justifiee(nom, j, "flux de santé hors du cadre d'interopérabilité", refus, notes, aujourdhui)
r = jour(f.get("revue"))
if r is None:
refus.append(f"{nom} : flux de santé sans date de revue face au cadre")
elif (aujourdhui - r).days > revue_mois * 31:
refus.append(f"{nom} : revue du flux plus ancienne que {revue_mois} mois")
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("--revue-mois", type=int, required=True)
p.add_argument("--date")
p.add_argument("--json", action="store_true")
try:
a = p.parse_args(argv)
except SystemExit:
return 2
aujourdhui = jour(a.date) if a.date else dt.date.today()
if aujourdhui is None or a.revue_mois < 1:
print(f"{ID} : appel incorrect (--date AAAA-MM-JJ, --revue-mois positif)", file=sys.stderr)
return 2
try:
refus, notes, n = verifier(a.registre, a.revue_mois, aujourdhui)
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, "flux": 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} flux)")
for r in refus:
print(" refus :", r)
for x in notes:
print(" note :", x)
return 0 if not refus else 1
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))