Skip to main content

ehds_logging/balp/
inserted.rs

1// SPDX-FileCopyrightText: Cadasto B.V.
2// SPDX-License-Identifier: BUSL-1.1
3
4//! The mark of a write whose information the data subject, or their
5//! representative, inserted.
6//!
7//! Regulation (EU) 2025/327 Art 5 asks that information a natural person or
8//! their representative of Art 4(2) inserts in the person's EHR "be clearly
9//! distinguishable as having been inserted by the natural person or by his
10//! or her representative". The written data carries that mark; the record
11//! of the write says so in one entity of its own, `ehds-subject-inserted`
12//! for the person and `ehds-representative-inserted` for a representative,
13//! whose `description` states the mark in words and whose one `detail`
14//! entry, named as the entity, is set to `true`, so a reader of the record
15//! need not read the written data to know it.
16
17use ihe_atna::balp::{Described, Detail, Entity, OTHER};
18
19use crate::record::Insertion;
20
21/// The name of the entity that marks a write the data subject inserted,
22/// and of its one `detail` entry, whose value is `true`.
23pub const ENTITY: &str = "ehds-subject-inserted";
24
25/// The `description` of the entity that marks a write the data subject
26/// inserted.
27pub const DESCRIPTION: &str = "Inserted by the data subject: the information \
28     this access wrote was inserted by the natural person under a grant of \
29     their own, and the written data marks it as inserted by them \
30     (Regulation (EU) 2025/327 Art 5).";
31
32/// The name of the entity that marks a write a representative of the data
33/// subject inserted, and of its one `detail` entry, whose value is `true`.
34pub const REPRESENTATIVE_ENTITY: &str = "ehds-representative-inserted";
35
36/// The `description` of the entity that marks a write a representative of
37/// the data subject inserted.
38pub const REPRESENTATIVE_DESCRIPTION: &str = "Inserted by a representative \
39     of the data subject: the information this access wrote was inserted, \
40     under the natural person's grant, by a natural person who acts for them \
41     as a proxy or a legal representative, and the written data names that \
42     representative as its provider, never the natural person (Regulation \
43     (EU) 2025/327 Art 4(2), Art 5).";
44
45/// The entity that marks a write `inserted` says who inserted.
46pub(super) fn entity(inserted: Insertion) -> Entity {
47    let (name, description) = match inserted {
48        Insertion::Subject => (ENTITY, DESCRIPTION),
49        Insertion::Representative => (REPRESENTATIVE_ENTITY, REPRESENTATIVE_DESCRIPTION),
50    };
51    Entity::Described(Described {
52        what: None,
53        kind: OTHER,
54        role: None,
55        name: Some(name.to_owned()),
56        description: Some(description.to_owned()),
57        details: vec![Detail::new(name, "true")],
58        security_labels: Vec::new(),
59    })
60}