FLAT format for leaf that can be both DV_CODED_TEXT and DV_TEXT

Hello,
I have a template that includes the laboratory_test_results archetype ( 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?

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

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

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

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

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.

If you look at the corresponding webtemplate you get

        }, {
          "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

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

@surfer see Web Template is incorrect · Issue #1469 · ehrbase/ehrbase · GitHub

@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.

ok I’ll try it. thanks @stefanspiska

tried. As predicted it works.