HSCP-T-012 · open test
Notification register: purpose and frequency given, every non-disableable notification justified
What the test checks
The evidence is the notification register, one JSON object per notification and per recipient (JSON Lines), following the recipe's data model:
| Field | Required | Meaning |
|---|---|---|
notification |
yes | notification name |
destinataire |
yes | professionnel (professional), etablissement (facility), patient or aidant (caregiver) |
canal |
yes | application, courriel (email), sms or interface (in-app message) |
finalite |
yes | soin (care), securite (security), obligation (legal duty), service, information or promotion |
frequence_max |
yes | {"nombre": N, "par": "jour"}, period jour (day), semaine (week), mois (month) or evenement (event); nombre: null for no cap |
active_par_defaut |
yes | default setting |
desactivable |
yes | the user can turn it off |
justification |
non-disableable | rule or risk that requires it |
revue_le |
yes | date of the last review |
The test accepts the register if each notification carries these fields, if every non-disableable notification has a care, security or legal-duty purpose and a written justification, if every information or promotion notification is off by default and can be turned off, if no promotion targets a patient or a caregiver, if an uncapped frequency is kept for care and security, and if the review is more recent than the review period.
It reports, without refusing, each uncapped frequency.
Running the test
python3 verifier.py registre.jsonl --date 2026-12-02 --revue-mois 12
--date sets the check date (today by default), --revue-mois the review period (12 by default), --json returns the answer in JSON. Exit code: 0 evidence accepted, 1 evidence refused, 2 incorrect call. Python 3.10 or later, no dependencies.
Examples
exemples/valide/: an appointment reminder that can be turned off, a critical result alert and an unusual sign-in alert that cannot, both justified, and an information notification off by default. Accepted, with the alert's uncapped frequency reported.exemples/refuse/: a forced engagement nudge, a promotion sent to a caregiver, a legal-duty notification without justification, an uncapped service notification with an old review, a channel and a period outside the lists. Refused.
What the test does not say
- It does not say that the register lists every notification actually sent: the review compares it with real sends.
- It does not say that the rule or risk invoked exists.
- It does not look at screens: infinite scroll, manipulative patterns and advertising are left to the review.
Code
Download the test (zip archive: program, examples, README, licence) (11 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-012 : registre des notifications, finalité et fréquence données, notification non désactivable justifiée.
python3 verifier.py <registre.jsonl> [--date AAAA-MM-JJ] [--revue-mois N] [--json]
Lit le registre, un objet JSON par notification et par destinataire (JSON Lines) : notification, destinataire, canal,
finalite, frequence_max {nombre, par}, active_par_defaut, desactivable, justification, revue_le.
Refus : ligne illisible ; champ obligatoire absent ; destinataire, canal, finalité ou période hors liste ; couple
notification et destinataire en double ; fréquence illisible ; notification non désactivable hors soin, sécurité ou
obligation, ou sans justification ; information ou promotion active par défaut ou non désactivable ; promotion adressée
à un patient ou à un aidant ; revue plus ancienne que --revue-mois mois (12 par défaut).
Note seulement : fréquence sans borne (`"nombre": null`), admise pour le soin et la sécurité seulement.
Il ne dit pas que le registre est complet, ni que les obligations invoquées existent.
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-012"
DESTINATAIRES = {"professionnel", "etablissement", "patient", "aidant"}
CANAUX = {"application", "courriel", "sms", "interface"}
FINALITES = {"soin", "securite", "obligation", "service", "information", "promotion"}
IMPOSEES = {"soin", "securite", "obligation"}
PERIODES = {"jour", "semaine", "mois", "evenement"}
OBLIGATOIRES = ("notification", "destinataire", "canal", "finalite", "frequence_max", "active_par_defaut",
"desactivable", "revue_le")
def jour(v):
try:
return dt.date.fromisoformat(str(v))
except ValueError:
return None
def verifier(chemin, aujourdhui, revue):
refus, notes, vus, n = [], [], set(), 0
limite = aujourdhui - dt.timedelta(days=round(revue * 30.44))
for num, ligne in enumerate(open(chemin, encoding="utf-8"), 1):
if not ligne.strip():
continue
try:
x = json.loads(ligne)
assert isinstance(x, dict)
except (ValueError, AssertionError):
refus.append(f"ligne {num} : objet JSON illisible")
continue
n += 1
nom = f"{x.get('notification') or 'ligne ' + str(num)} ({x.get('destinataire')})"
manque = [c for c in OBLIGATOIRES if x.get(c) in (None, "")]
if manque:
refus.append(f"{nom} : champ(s) absent(s) : {', '.join(manque)}")
continue
if nom in vus:
refus.append(f"{nom} : notification en double")
vus.add(nom)
for champ, liste in (("destinataire", DESTINATAIRES), ("canal", CANAUX), ("finalite", FINALITES)):
if x[champ] not in liste:
refus.append(f"{nom} : {champ} hors liste")
f = x["frequence_max"]
if not isinstance(f, dict) or f.get("par") not in PERIODES or not (
f.get("nombre") is None or (isinstance(f.get("nombre"), int) and f["nombre"] > 0)):
refus.append(f"{nom} : fréquence maximale illisible (nombre et période)")
elif f.get("nombre") is None:
if x["finalite"] in ("soin", "securite"):
notes.append(f"{nom} : fréquence sans borne")
else:
refus.append(f"{nom} : fréquence sans borne hors soin ou sécurité")
if x["desactivable"] is not True:
if x["finalite"] not in IMPOSEES:
refus.append(f"{nom} : non désactivable sans finalité de soin, de sécurité ou d'obligation")
elif not x.get("justification"):
refus.append(f"{nom} : non désactivable sans justification écrite")
if x["finalite"] in ("information", "promotion") and (x["active_par_defaut"] is not False or x["desactivable"] is not True):
refus.append(f"{nom} : {x['finalite']} active par défaut ou non désactivable")
if x["finalite"] == "promotion" and x["destinataire"] in ("patient", "aidant"):
refus.append(f"{nom} : promotion adressée à un patient ou à un aidant")
r = jour(x["revue_le"])
if r is None or r < limite:
refus.append(f"{nom} : revue illisible ou plus ancienne que {revue} 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("--date", default=dt.date.today().isoformat())
p.add_argument("--revue-mois", type=int, default=12)
p.add_argument("--json", action="store_true")
try:
a = p.parse_args(argv)
aujourdhui = dt.date.fromisoformat(a.date)
except (SystemExit, ValueError):
return 2
try:
refus, notes, n = verifier(a.registre, aujourdhui, a.revue_mois)
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, "notifications": 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} notification(s))")
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:]))