# FLAT format for leaf that can be both DV\_CODED\_TEXT and DV\_TEXT

**URL:** https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317
**Category:** Platform
**Tags:** ehrbase
**Created:** [11 February 2025 11:48 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317 "2025-02-11T11:48:19Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![surfer](https://discourse.openehr.org/user_avatar/discourse.openehr.org/surfer/32/2326_2.png) [@surfer](https://discourse.openehr.org/u/surfer)
#### Post date: [11 February 2025 11:48 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/1 "2025-02-11T11:48:19Z")

</div>

Hello,  
I have a template that includes the laboratory\_test\_results archetype ( [https://ckm.openehr.org/ckm/archetypes/1013.1.2191](https://ckm.openehr.org/ckm/archetypes/1013.1.2191) ). Inside laboratory\_test\_results there is a leaf called overall\_test\_status that I left open to both DV\_CODED\_TEXT and DV\_TEXT. When I create a flat composition I can instantiate a DV\_CODED\_TEXT for overall\_test\_status but it fails for DV\_TEXT complaining about the missing code and terminology essentially. How can I instantiate a DV\_TEXT in this case?

---

<div class="post-metadata">

### Author: ![ian.mcnicoll](https://discourse.openehr.org/user_avatar/discourse.openehr.org/ian.mcnicoll/32/4430_2.png) [@ian.mcnicoll](https://discourse.openehr.org/u/ian.mcnicoll)
#### Post date: [11 February 2025 11:55 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/2 "2025-02-11T11:55:01Z")

</div>

Can you show the composition snippet that is failing? Also which CDR?

---

<div class="post-metadata">

### Author: ![surfer](https://discourse.openehr.org/user_avatar/discourse.openehr.org/surfer/32/2326_2.png) [@surfer](https://discourse.openehr.org/u/surfer)
#### Post date: [11 February 2025 12:00 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/3 "2025-02-11T12:00:22Z")

</div>

yeah sorry I tagged EHRBase but forgot to write it

“interhealth\_cancer\_registry/laboratory\_tests/laboratory\_test\_result/any\_event:0/overall\_test\_status:0|value”: “text value”,

the error:  
/content[openEHR-EHR-SECTION.adhoc.v1, 3]/items[openEHR-EHR-OBSERVATION.laboratory\_test\_result.v1, 1]/data[at0001]/events[at0002, 1]/data[at0003]/items[at0073, 2]/value/defining\_code/code\_string: Attribute code\_string of class CODE\_PHRASE does not match existence 1…1

---

<div class="post-metadata">

### Author: ![ian.mcnicoll](https://discourse.openehr.org/user_avatar/discourse.openehr.org/ian.mcnicoll/32/4430_2.png) [@ian.mcnicoll](https://discourse.openehr.org/u/ian.mcnicoll)
#### Post date: [11 February 2025 12:09 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/4 "2025-02-11T12:09:24Z")

</div>

I think this does work on Better, at least they told me it would when I asked!!

“interhealth\_cancer\_registry/laboratory\_tests/laboratory\_test\_result/any\_event:0/overall\_test\_status:0”: “text value”,

I’d submit a CR to Ehrbase - it is annoying to have to switch

---

<div class="post-metadata">

### Author: ![surfer](https://discourse.openehr.org/user_avatar/discourse.openehr.org/surfer/32/2326_2.png) [@surfer](https://discourse.openehr.org/u/surfer)
#### Post date: [11 February 2025 12:19 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/5 "2025-02-11T12:19:32Z")

</div>

in EHRBase the result is an unprocessable entity error and the following message:  
/content[openEHR-EHR-SECTION.adhoc.v1, 3]/items[openEHR-EHR-OBSERVATION.laboratory\_test\_result.v1, 1]/data[at0001]/events[at0002, 1]/data[at0003]/items[at0073, 2]/value/defining\_code/code\_string: Attribute code\_string of class CODE\_PHRASE does not match existence 1…1  
/content[openEHR-EHR-SECTION.adhoc.v1, 3]/items[openEHR-EHR-OBSERVATION.laboratory\_test\_result.v1, 1]/data[at0001]/events[at0002, 1]/data[at0003]/items[at0073, 2]/value/value: Attribute value of class DV\_CODED\_TEXT does not match existence 1…1  
I guess it means that it is expecting the coded text

---

<div class="post-metadata">

### Author: ![ian.mcnicoll](https://discourse.openehr.org/user_avatar/discourse.openehr.org/ian.mcnicoll/32/4430_2.png) [@ian.mcnicoll](https://discourse.openehr.org/u/ian.mcnicoll)
#### Post date: [11 February 2025 12:31 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/6 "2025-02-11T12:31:59Z")

</div>

I would say that is probably an error but to work around, I would constrain out the Coded\_TEXT. TEXT can always be sub-classed to CIODED\_TEXT, so it should be able to handle both TEXT and CODED\_TEXT.

---

<div class="post-metadata">

### Author: ![stefanspiska](https://discourse.openehr.org/user_avatar/discourse.openehr.org/stefanspiska/32/819_2.png) [@stefanspiska](https://discourse.openehr.org/u/stefanspiska)
#### Post date: [11 February 2025 12:33 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/7 "2025-02-11T12:33:27Z")

</div>

If you look at the corresponding webtemplate you get

```auto
        }, {
          "id" : "overall_test_status",
          "name" : "Overall test status",
          "localizedName" : "Overall test status",
          "rmType" : "DV_CODED_TEXT",
          "nodeId" : "at0073",
          "min" : 0,
          "max" : -1,
          "localizedNames" : {
            "en" : "Overall test status"
          },
          "localizedDescriptions" : {
            "en" : "The status of the laboratory test result as a whole."
          },
          "annotations" : {
            "comment" : "The values have been specifically chosen to match those in the HL7 FHIR Diagnostic report, historically derived from HL7v2 practice. Other local codes/terms can be used via the Text 'choice'.\r\n\r\nThis element is multiple occurrence to cater for the use cases where statuses for different aspects of the result have been split into several elements."
          },
          "aqlPath" : "/content[openEHR-EHR-OBSERVATION.laboratory_test_result.v1]/data[at0001]/events[at0002]/data[at0003]/items[at0073]/value",
          "inputs" : [ {
            "suffix" : "code",
            "type" : "CODED_TEXT",
            "list" : [ {
              "value" : "at0107",
              "label" : "Registered",
              "localizedLabels" : {
                "en" : "Registered"
              },
              "localizedDescriptions" : {
                "en" : "The existence of the test is registered in the Laboratory Information System, but there is nothing yet available."
              }
            }, {
              "value" : "at0037",
              "label" : "Partial",
              "localizedLabels" : {
                "en" : "Partial"
              },
              "localizedDescriptions" : {
                "en" : "This is a partial (e.g. initial, interim or preliminary) Test Result: data in the Test Result may be incomplete or unverified."
              }
            }, {
              "value" : "at0120",
              "label" : "Preliminary",
              "localizedLabels" : {
                "en" : "Preliminary"
              },
              "localizedDescriptions" : {
                "en" : "Verified early results are available, but not all results are final. This is a sub-category of 'Partial'."
              }
            }, {
              "value" : "at0038",
              "label" : "Final",
              "localizedLabels" : {
                "en" : "Final"
              },
              "localizedDescriptions" : {
                "en" : "The Test result is complete and verified by an authorised person."
              }
            }, {
              "value" : "at0040",
              "label" : "Amended",
              "localizedLabels" : {
                "en" : "Amended"
              },
              "localizedDescriptions" : {
                "en" : "The result has been modified subsequent to being Final, and is complete and verified by the responsible pathologist, and result data has been changed."
              }
            }, {
              "value" : "at0115",
              "label" : "Corrected",
              "localizedLabels" : {
                "en" : "Corrected"
              },
              "localizedDescriptions" : {
                "en" : "The result has been modified subsequent to being Final, and is complete and verified by the responsible pathologist. This is a sub-category of 'Amended'."
              }
            }, {
              "value" : "at0119",
              "label" : "Appended",
              "localizedLabels" : {
                "en" : "Appended"
              },
              "localizedDescriptions" : {
                "en" : "Subsequent to being final, the report has been modified by adding new content. The existing content is unchanged. This is a sub-category of 'Amended'."
              }
            }, {
              "value" : "at0074",
              "label" : "Cancelled",
              "localizedLabels" : {
                "en" : "Cancelled"
              },
              "localizedDescriptions" : {
                "en" : "The result is unavailable because the test was not started or not completed (also sometimes called 'aborted')."
              }
            }, {
              "value" : "at0116",
              "label" : "Entered in error",
              "localizedLabels" : {
                "en" : "Entered in error"
              },
              "localizedDescriptions" : {
                "en" : "The Test Result has been withdrawn following previous Final release."
              }
            } ],
            "listOpen" : true
          }, {
            "suffix" : "other",
            "type" : "TEXT"
          } ]
        }

```

thus to set just a text value you have to use `other`

---

<div class="post-metadata">

### Author: ![surfer](https://discourse.openehr.org/user_avatar/discourse.openehr.org/surfer/32/2326_2.png) [@surfer](https://discourse.openehr.org/u/surfer)
#### Post date: [11 February 2025 12:42 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/8 "2025-02-11T12:42:39Z")

</div>

unfortunately I don’t have the same structure you showed.  
[https://gist.github.com/sasurfer/087b716fcb970b4b3de67134f0b7e5af](https://gist.github.com/sasurfer/087b716fcb970b4b3de67134f0b7e5af)  
The webtemplate is created by EHRBase, the template created in the Archetype Designer.

---

<div class="post-metadata">

### Author: ![stefanspiska](https://discourse.openehr.org/user_avatar/discourse.openehr.org/stefanspiska/32/819_2.png) [@stefanspiska](https://discourse.openehr.org/u/stefanspiska)
#### Post date: [11 February 2025 12:45 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/9 "2025-02-11T12:45:14Z")

</div>

@surfer see [Web Template is incorrect · Issue #1469 · ehrbase/ehrbase · GitHub](https://github.com/ehrbase/ehrbase/issues/1469)

---

<div class="post-metadata">

### Author: ![stefanspiska](https://discourse.openehr.org/user_avatar/discourse.openehr.org/stefanspiska/32/819_2.png) [@stefanspiska](https://discourse.openehr.org/u/stefanspiska)
#### Post date: [11 February 2025 12:48 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/10 "2025-02-11T12:48:41Z")

</div>

@surfer you can also get the webtemplate from the archetype designer. and the flat format works even if the endpoint gives back a wrong webtemplate.

---

<div class="post-metadata">

### Author: ![surfer](https://discourse.openehr.org/user_avatar/discourse.openehr.org/surfer/32/2326_2.png) [@surfer](https://discourse.openehr.org/u/surfer)
#### Post date: [11 February 2025 12:49 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/11 "2025-02-11T12:49:53Z")

</div>

ok I’ll try it. thanks @stefanspiska

---

<div class="post-metadata">

### Author: ![surfer](https://discourse.openehr.org/user_avatar/discourse.openehr.org/surfer/32/2326_2.png) [@surfer](https://discourse.openehr.org/u/surfer)
#### Post date: [12 February 2025 15:14 UTC](https://discourse.openehr.org/t/flat-format-for-leaf-that-can-be-both-dv-coded-text-and-dv-text/6317/12 "2025-02-12T15:14:53Z")

</div>

tried. As predicted it works.
