fhirconnect 0.2.3

The FHIRconnect mapping language for Rust: the mapping file model and its validation, context resolution into an immutable program, and the bidirectional interpreter between openEHR compositions and FHIR resources
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
// SPDX-FileCopyrightText: Cadasto B.V.
// SPDX-License-Identifier: BUSL-1.1

//! `DV_TEXT` against FHIR `string`, `Coding` and `CodeableConcept`.
//!
//! The cell is
//! `docs/specs/fhirconnect/modules/ROOT/pages/types-of-mappings/data-type/DV_TEXT.adoc`.
//! The `string` table pairs `value` with `value`; the `Coding` and
//! `CodeableConcept` tables put the codings in `mappings`, "in openEHR each
//! `DV_TEXT` can be annotated with codings using mappings", and pair the
//! rubric with `display` and with `text`.

use fhir_types::r4::codeable_concept::CodeableConcept;
use fhir_types::r4::coding::Coding;
use fhir_types::r4::primitives;
use openehr_base::containers::NonEmptyVec;
use openehr_rm::v1_2::data_types::text::dv_text::DvTextData;

use crate::engine::lens::Fallback;
use crate::engine::lens::Lens;
use crate::engine::lens::LensError;
use crate::engine::lens::code_phrase::text_of;
use crate::engine::lens::term_mapping::EQUIVALENT;
use crate::engine::lens::term_mapping::Withheld;
use crate::engine::lens::term_mapping::coding_of;
use crate::engine::lens::term_mapping::equivalents;
use crate::engine::lens::term_mapping::mappings_of;
use crate::engine::lens::term_mapping::uncarried;
use crate::engine::lens::term_mapping::withheld;
use crate::model::ast::keyword::Direction;

/// The name the `string` cell carries in a diagnostic.
pub const STRING_CELL: &str = "DV_TEXT against string";

/// The name the `Coding` cell carries in a diagnostic.
pub const CODING_CELL: &str = "DV_TEXT against Coding";

/// The name the `CodeableConcept` cell carries in a diagnostic.
pub const CODEABLE_CONCEPT_CELL: &str = "DV_TEXT against CodeableConcept";

/// `DV_TEXT` against the three FHIR elements its page names.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct TextLens;

impl Lens<DvTextData, primitives::String> for TextLens {
    fn cell(&self) -> &'static str {
        STRING_CELL
    }

    fn get(&self, source: &DvTextData) -> Result<primitives::String, LensError> {
        Ok(primitives::String::from(source.value.clone()))
    }

    fn put(
        &self,
        view: &primitives::String,
        existing: Option<&DvTextData>,
    ) -> Result<DvTextData, LensError> {
        let value = text_of(Some(&view.value)).ok_or(LensError::Missing {
            cell: STRING_CELL,
            attribute: "DV_TEXT.value",
            direction: Direction::FhirToOpenehr,
        })?;
        Ok(DvTextData {
            value: String::from(value),
            ..carried(existing)
        })
    }

    fn fallbacks(&self, _view: &primitives::String) -> Vec<Fallback> {
        Vec::new()
    }

    // NOTE: DV_TEXT.adoc §String gives `mappings` no FHIRpath row, so a string
    // carries none of them and each is a declared loss.
    fn withheld(&self, source: &DvTextData) -> Vec<Withheld> {
        uncarried(source.mappings.iter().flatten())
    }
}

impl Lens<DvTextData, CodeableConcept> for TextLens {
    fn cell(&self) -> &'static str {
        CODEABLE_CONCEPT_CELL
    }

    fn get(&self, source: &DvTextData) -> Result<CodeableConcept, LensError> {
        let mut codings = Vec::new();
        for mapping in equivalents(source.mappings.iter().flatten()) {
            codings.push(coding_of(mapping, CODEABLE_CONCEPT_CELL)?);
        }
        Ok(CodeableConcept {
            coding: codings,
            text: Some(primitives::String::from(source.value.clone())),
            ..CodeableConcept::default()
        })
    }

    fn put(
        &self,
        view: &CodeableConcept,
        existing: Option<&DvTextData>,
    ) -> Result<DvTextData, LensError> {
        let value = rubric_of(view).ok_or(LensError::Missing {
            cell: CODEABLE_CONCEPT_CELL,
            attribute: "DV_TEXT.value",
            direction: Direction::FhirToOpenehr,
        })?;
        let held = existing.and_then(|text| text.mappings.as_deref());
        let mappings = mappings_of(&view.coding, held)?;
        Ok(DvTextData {
            value: String::from(value),
            mappings: NonEmptyVec::new(mappings).ok(),
            ..carried(existing)
        })
    }

    fn fallbacks(&self, view: &CodeableConcept) -> Vec<Fallback> {
        if text_of(view.text.as_ref().map(|text| &text.value)).is_some() {
            return Vec::new();
        }
        vec![Fallback::new(CODEABLE_CONCEPT_CELL, "DV_TEXT.value")]
    }

    fn withheld(&self, source: &DvTextData) -> Vec<Withheld> {
        withheld(source.mappings.iter().flatten())
    }
}

/// Returns the rubric a `CodeableConcept` gives `DV_TEXT.value`.
///
/// `text` when the concept carries one, else the first coding's `display`,
/// else its `code`. The last two are one-way rows, recorded by
/// [`Lens::fallbacks`].
fn rubric_of(view: &CodeableConcept) -> Option<&str> {
    // NOTE: DV_TEXT.adoc §CodeableConcept gives `value` (1..1) no fallback;
    // FerroBRIDGE reads that silence by DV_CODED_TEXT.adoc §CodeableConcept,
    // which inherits from DV_TEXT and falls back to `coding.display`, `coding.code`.
    let first = view.coding.first();
    text_of(view.text.as_ref().map(|text| &text.value))
        .or_else(|| {
            text_of(
                first
                    .and_then(|coding| coding.display.as_ref())
                    .map(|display| &display.value),
            )
        })
        .or_else(|| {
            text_of(
                first
                    .and_then(|coding| coding.code.as_ref())
                    .map(|code| &code.value),
            )
        })
}

impl Lens<DvTextData, Coding> for TextLens {
    fn cell(&self) -> &'static str {
        CODING_CELL
    }

    fn get(&self, source: &DvTextData) -> Result<Coding, LensError> {
        let mut codings = equivalents(source.mappings.iter().flatten());
        let first = codings.next();
        if codings.next().is_some() {
            return Err(LensError::Shape {
                cell: CODING_CELL,
                attribute: "DV_TEXT.mappings",
                found: String::from("more than one `=` term mapping"),
                reason: "one Coding carries one code, so the extra mappings have nowhere to go",
                direction: Direction::OpenehrToFhir,
            });
        }
        let mut coding = match first {
            Some(mapping) => coding_of(mapping, CODING_CELL)?,
            None => Coding::default(),
        };
        coding.display = Some(primitives::String::from(source.value.clone()));
        Ok(coding)
    }

    fn put(&self, view: &Coding, existing: Option<&DvTextData>) -> Result<DvTextData, LensError> {
        let value = text_of(view.display.as_ref().map(|display| &display.value)).ok_or(
            LensError::Missing {
                cell: CODING_CELL,
                attribute: "DV_TEXT.value",
                direction: Direction::FhirToOpenehr,
            },
        )?;
        let held = existing.and_then(|text| text.mappings.as_deref());
        let preferred = equivalents(held.unwrap_or_default())
            .next()
            .and_then(|mapping| mapping.target.preferred_term.clone());
        let coded = text_of(view.system.as_ref().map(|uri| &uri.value)).is_some()
            || text_of(view.code.as_ref().map(|code| &code.value)).is_some();
        let mut mappings = mappings_of(coded.then_some(view), held)?;
        // NOTE: DV_TEXT.adoc §Coding pairs `display` with `value`, so the
        // display is the rubric here and the target's preferred term,
        // which FHIR has nowhere to put, comes from the held mapping.
        if let Some(written) = mappings
            .iter_mut()
            .find(|mapping| mapping.r#match == EQUIVALENT)
        {
            written.target.preferred_term = preferred;
        }
        Ok(DvTextData {
            value: String::from(value),
            mappings: NonEmptyVec::new(mappings).ok(),
            ..carried(existing)
        })
    }

    fn fallbacks(&self, _view: &Coding) -> Vec<Fallback> {
        Vec::new()
    }

    fn withheld(&self, source: &DvTextData) -> Vec<Withheld> {
        withheld(source.mappings.iter().flatten())
    }
}

/// Returns the attributes the three tables mark as having no FHIR counterpart.
///
/// `hyperlink`, `formatting`, `language` and `encoding` are `-` in every row,
/// so they are taken from the value the target already holds.
fn carried(existing: Option<&DvTextData>) -> DvTextData {
    DvTextData {
        value: String::new(),
        hyperlink: existing.and_then(|held| held.hyperlink.clone()),
        formatting: existing.and_then(|held| held.formatting.clone()),
        mappings: None,
        language: existing.and_then(|held| held.language.clone()),
        encoding: existing.and_then(|held| held.encoding.clone()),
    }
}

#[cfg(test)]
mod tests {
    use super::CODEABLE_CONCEPT_CELL;
    use super::CODING_CELL;
    use super::TextLens;
    use crate::engine::lens::Fallback;
    use crate::engine::lens::Lens;
    use crate::engine::lens::LensError;
    use crate::engine::lens::code_phrase::tests::code_phrase;
    use crate::engine::lens::code_phrase::tests::coding;
    use fhir_types::r4::codeable_concept::CodeableConcept;
    use fhir_types::r4::coding::Coding;
    use fhir_types::r4::primitives;
    use fhir_types::r4::primitives::Code;
    use fhir_types::r4::primitives::Uri;
    use openehr_base::containers::NonEmptyVec;
    use openehr_base::v1_3::base_types::identification::terminology_id::TerminologyId;
    use openehr_rm::v1_2::data_types::text::code_phrase::CodePhrase;
    use openehr_rm::v1_2::data_types::text::dv_text::DvTextData;
    use openehr_rm::v1_2::data_types::text::term_mapping::TermMapping;
    use proptest::collection::vec;
    use proptest::prop_compose;
    use proptest::proptest;

    prop_compose! {
        /// A `DV_TEXT` carrying `count` codings in its mappings.
        fn text_with(count: core::ops::Range<usize>)(
            value in "[A-Za-z ]{1,12}",
            targets in vec(code_phrase(), count),
        ) -> DvTextData {
            DvTextData {
                value,
                hyperlink: None,
                formatting: None,
                mappings: NonEmptyVec::new(
                    targets
                        .into_iter()
                        .map(|target| TermMapping { r#match: '=', purpose: None, target })
                        .collect::<Vec<TermMapping>>(),
                )
                .ok(),
                language: None,
                encoding: None,
            }
        }
    }

    prop_compose! {
        /// A `CodeableConcept` carrying a text and any number of codings.
        fn codeable_concept()(
            codings in vec(coding(), 0..3),
            text in "[A-Za-z ]{1,12}",
        ) -> CodeableConcept {
            CodeableConcept {
                coding: codings,
                text: Some(primitives::String::from(text)),
                ..CodeableConcept::default()
            }
        }
    }

    proptest! {
        #[test]
        fn string_get_put(source in text_with(0..1)) {
            let view: primitives::String = TextLens.get(&source).expect("the value travels");
            let back = TextLens.put(&view, Some(&source)).expect("the string carries a value");
            assert_eq!(back, source, "GetPut failed for {source:?}");
        }

        #[test]
        fn string_put_get(text in "[A-Za-z ]{1,12}") {
            let view = primitives::String::from(text);
            let source: DvTextData = TextLens.put(&view, None).expect("the string carries a value");
            let back: primitives::String = TextLens.get(&source).expect("the value travels");
            assert_eq!(back, view, "PutGet failed for {view:?}");
        }

        #[test]
        fn codeable_concept_get_put(source in text_with(0..3)) {
            let view: CodeableConcept = TextLens.get(&source).expect("the generated subset is carried");
            let back = TextLens.put(&view, Some(&source)).expect("the view carries a text");
            assert_eq!(back, source, "GetPut failed for {source:?}");
        }

        #[test]
        fn codeable_concept_put_get(view in codeable_concept()) {
            let source: DvTextData = TextLens.put(&view, None).expect("the generated subset is carried");
            let back: CodeableConcept = TextLens.get(&source).expect("the value is complete");
            assert_eq!(back, view, "PutGet failed for {view:?}");
        }

        #[test]
        fn a_concept_without_text_comes_back_with_text_added(
            codings in vec(coding(), 1..3),
        ) {
            let view = CodeableConcept { coding: codings, ..CodeableConcept::default() };
            let source: DvTextData = TextLens.put(&view, None).expect("the first coding names the value");
            let back: CodeableConcept = TextLens.get(&source).expect("the value is complete");
            assert_eq!(back.coding, view.coding, "the codings come back unchanged");
            assert_eq!(
                back.text.map(|text| text.value),
                Some(Some(source.value.clone())),
                "the rubric comes back as an added text"
            );
            assert_eq!(
                TextLens.fallbacks(&view),
                vec![Fallback::new(CODEABLE_CONCEPT_CELL, "DV_TEXT.value")],
                "the one-way row is recorded"
            );
        }

        #[test]
        fn coding_get_put(source in text_with(1..2)) {
            let view: Coding = TextLens.get(&source).expect("one mapping is one coding");
            let back = TextLens.put(&view, Some(&source)).expect("the coding carries a display");
            assert_eq!(back, source, "GetPut failed for {source:?}");
        }

        #[test]
        fn coding_put_get(source in text_with(1..2)) {
            let view: Coding = TextLens.get(&source).expect("one mapping is one coding");
            let back: DvTextData = TextLens.put(&view, None).expect("the coding carries a display");
            let again: Coding = TextLens.get(&back).expect("one mapping is one coding");
            assert_eq!(again, view, "PutGet failed for {view:?}");
        }
    }

    #[test]
    fn a_text_with_two_mappings_has_no_single_coding() {
        let source = DvTextData {
            value: String::from("Fever"),
            hyperlink: None,
            formatting: None,
            mappings: NonEmptyVec::new(vec![
                TermMapping {
                    r#match: '=',
                    purpose: None,
                    target: CodePhrase {
                        terminology_id: TerminologyId::new("http://loinc.org", ""),
                        code_string: String::from("LP74849-8"),
                        preferred_term: None,
                    },
                },
                TermMapping {
                    r#match: '=',
                    purpose: None,
                    target: CodePhrase {
                        terminology_id: TerminologyId::new("http://snomed.info/sct", ""),
                        code_string: String::from("386661006"),
                        preferred_term: None,
                    },
                },
            ])
            .ok(),
            language: None,
            encoding: None,
        };
        let error = <TextLens as Lens<DvTextData, Coding>>::get(&TextLens, &source)
            .expect_err("two mappings do not fit one coding");
        assert!(
            error.to_string().contains(CODING_CELL),
            "the refusal names the cell: {error}"
        );
    }

    #[test]
    fn a_display_only_coding_leaves_the_mappings_empty() {
        let view = Coding {
            display: Some(primitives::String::from("Fever")),
            ..Coding::default()
        };
        let source: DvTextData = TextLens
            .put(&view, None)
            .expect("the coding carries a display");
        assert_eq!(source.value, "Fever", "the display fills the value");
        assert!(
            source.mappings.is_none(),
            "a coding with no code annotates nothing"
        );
    }

    /// A `TERM_MAPPING` with `relation` to `code` of `system`.
    fn term(relation: char, system: &str, code: &str) -> TermMapping {
        TermMapping {
            r#match: relation,
            purpose: None,
            target: CodePhrase {
                terminology_id: TerminologyId::new(system, ""),
                code_string: String::from(code),
                preferred_term: None,
            },
        }
    }

    /// A `DV_TEXT` annotated with `mappings`.
    fn annotated(mappings: Vec<TermMapping>) -> DvTextData {
        DvTextData {
            value: String::from("Fever"),
            hyperlink: None,
            formatting: None,
            mappings: NonEmptyVec::new(mappings).ok(),
            language: None,
            encoding: None,
        }
    }

    /// Returns the codes a list of codings carries.
    fn codes(codings: &[Coding]) -> Vec<Option<&str>> {
        codings
            .iter()
            .map(|coding| coding.code.as_ref().and_then(|code| code.value.as_deref()))
            .collect()
    }

    // TERM_MAPPING.adoc: `match` is "hard coded to `=`, other operators not mappable
    // to FHIR", so the mapping writes no coding and the rest of the value converts.
    #[test]
    fn a_concept_leaves_out_a_term_mapping_fhir_cannot_carry() {
        for relation in ['>', '<', '?'] {
            let source = annotated(vec![
                term(relation, "http://snomed.info/sct", "386661006"),
                term('=', "http://loinc.org", "LP74849-8"),
            ]);
            let view: CodeableConcept = TextLens.get(&source).expect("the mapping is withheld");
            assert_eq!(
                codes(&view.coding),
                [Some("LP74849-8")],
                "only the `=` mapping travels past `{relation}`"
            );
            let taken = Lens::<DvTextData, CodeableConcept>::withheld(&TextLens, &source);
            let rows: Vec<(char, &str, &str)> = taken
                .iter()
                .map(|term| (term.match_code(), term.terminology(), term.code()))
                .collect();
            assert_eq!(rows, [(relation, "http://snomed.info/sct", "386661006")]);
            let back = TextLens
                .put(&view, Some(&source))
                .expect("the view carries a text");
            assert_eq!(back, source, "GetPut holds past `{relation}`");
        }
    }

    #[test]
    fn a_coding_leaves_out_a_term_mapping_fhir_cannot_carry() {
        for relation in ['>', '<', '?'] {
            let source = annotated(vec![
                term('=', "http://loinc.org", "LP74849-8"),
                term(relation, "http://snomed.info/sct", "386661006"),
            ]);
            let view: Coding = TextLens
                .get(&source)
                .expect("one `=` mapping is one coding");
            assert_eq!(
                codes(core::slice::from_ref(&view)),
                [Some("LP74849-8")],
                "the `=` mapping is the coding past `{relation}`"
            );
            assert_eq!(
                Lens::<DvTextData, Coding>::withheld(&TextLens, &source).len(),
                1,
                "the `{relation}` mapping is withheld"
            );
            let back = TextLens
                .put(&view, Some(&source))
                .expect("the coding carries a display");
            assert_eq!(back, source, "GetPut holds past `{relation}`");
        }
    }

    #[test]
    fn a_coding_of_only_a_withheld_mapping_carries_the_rubric() {
        let source = annotated(vec![term('<', "http://snomed.info/sct", "386661006")]);
        let view: Coding = TextLens.get(&source).expect("the mapping is withheld");
        assert_eq!(view.code, None, "no code travels");
        assert_eq!(
            view.display
                .as_ref()
                .and_then(|display| display.value.as_deref()),
            Some("Fever"),
            "the rubric is the display"
        );
        let back = TextLens
            .put(&view, Some(&source))
            .expect("the coding carries a display");
        assert_eq!(back, source, "the held mapping returns");
    }

    #[test]
    fn equivalent_term_mappings_are_withheld_from_nothing() {
        let source = annotated(vec![
            term('=', "http://snomed.info/sct", "386661006"),
            term('=', "http://loinc.org", "LP74849-8"),
        ]);
        let view: CodeableConcept = TextLens.get(&source).expect("both mappings travel");
        assert_eq!(codes(&view.coding), [Some("386661006"), Some("LP74849-8")]);
        assert_eq!(
            Lens::<DvTextData, CodeableConcept>::withheld(&TextLens, &source),
            Vec::<crate::engine::lens::term_mapping::Withheld>::new()
        );
    }
    /// A `CodeableConcept` with no `text` whose first coding carries `display`
    /// and `code` as given, followed by a second, fully described coding.
    fn untexted(display: Option<&str>, code: Option<&str>) -> CodeableConcept {
        CodeableConcept {
            coding: vec![
                Coding {
                    system: Some(Uri::from("http://snomed.info/sct")),
                    code: code.map(Code::from),
                    display: display.map(primitives::String::from),
                    ..Coding::default()
                },
                Coding {
                    system: Some(Uri::from("http://snomed.info/sct")),
                    code: Some(Code::from("386661006")),
                    display: Some(primitives::String::from("Second")),
                    ..Coding::default()
                },
            ],
            ..CodeableConcept::default()
        }
    }

    #[test]
    fn the_text_wins_over_the_first_display() {
        let view = CodeableConcept {
            text: Some(primitives::String::from("Fever")),
            ..untexted(Some("Pyrexia"), Some("386661006"))
        };
        let source: DvTextData = TextLens.put(&view, None).expect("the text names the value");
        assert_eq!(source.value, "Fever", "the text fills the value");
        assert!(
            <TextLens as Lens<DvTextData, CodeableConcept>>::fallbacks(&TextLens, &view).is_empty(),
            "a text takes no fallback"
        );
    }

    #[test]
    fn a_missing_text_falls_back_to_the_first_display() {
        let view = untexted(Some("Pyrexia"), Some("386661006"));
        let source: DvTextData = TextLens
            .put(&view, None)
            .expect("the display names the value");
        assert_eq!(source.value, "Pyrexia", "the first display fills the value");
    }

    #[test]
    fn a_missing_display_falls_back_to_the_first_code() {
        let view = untexted(None, Some("39065001"));
        let source: DvTextData = TextLens.put(&view, None).expect("the code names the value");
        assert_eq!(source.value, "39065001", "the first code fills the value");
        assert_eq!(
            TextLens.fallbacks(&view),
            vec![Fallback::new(CODEABLE_CONCEPT_CELL, "DV_TEXT.value")],
            "the one-way row is recorded"
        );
    }

    #[test]
    fn a_concept_with_nothing_to_name_the_value_is_refused() {
        let view = untexted(None, None);
        let error = <TextLens as Lens<DvTextData, CodeableConcept>>::put(&TextLens, &view, None)
            .expect_err("no text, display or code on the first coding");
        assert!(
            matches!(
                error,
                LensError::Missing {
                    cell: CODEABLE_CONCEPT_CELL,
                    attribute: "DV_TEXT.value",
                    ..
                }
            ),
            "the refusal names the cell and the attribute: {error}"
        );
    }
}