The good, the bad and the "Wat?" of current simplified FLAT/SimSDT openEHR exchange format

@ian.mcnicoll’s post cited above saved the day again today when some colleagues and I in an implementation tried to understand the “simplifications” done in the “simplified” format. There is a lot of non obvious black magic happening under the hood in the simplified format implementations that make it difficult to understand for somebody looking at the “normal” openEHR UML-diagrams. Now, thanks to heroic work of @sebastian.iancu and inventors from Better and implementers from Vitasytems and others there is finally an explanation of the black magic published at Simplified Formats for openEHR Data

Somebody just following an example-document for a specific simplifed format will likely have an easier time than somebody looking at the UML unaware of the black magic, so below is an example regarding the Swedish use of both 2x nested Organisation archetypes (in an ITEM_STRUCTURE under EVENT_CONTEXT.other_context) and the RM-built-in EVENT_CONTEXT.healthcare_facility to represent care units (“vårdenhet”) and healthcare provider organisations (“vårdgivare”) at different levels as described in https://openehr.atlassian.net/wiki/spaces/SWE/pages/1893105737/PDL+i+openEHR.

In the Swedish case we do not want to use external_ref inherited to PARTY_IDENTIFIER but rather use identifiers inside the PARTY_IDENTIFIER object itself:

When to use underscores and plural-“s” on the key identifier in this mix is far from obvious for beginners…

Excerpt in simplified FLAT format:

        "granskning/context/_health_care_facility|name": "S Bäckencancer MBA QA",
        "granskning/context/_health_care_facility/_identifier:0": "SE2321000016-C4DV",
        "granskning/context/_health_care_facility/_identifier:0|type": "urn:oid:1.2.752.29.4.19",
        "granskning/context/vårdenhet/namn": "OO Cancer TC QA",
        "granskning/context/vårdenhet/identifierare:0": "SE2321000016-ADNF",
        "granskning/context/vårdenhet/identifierare:0|type": "urn:oid:1.2.752.29.4.19",
        "granskning/context/vårdenhet/roll:0|code": "43741000",
        "granskning/context/vårdenhet/roll:0|value": "vårdenhet",
        "granskning/context/vårdenhet/roll:0|terminology": "http://snomed.info/sct/900000000000207008",
        "granskning/context/vårdenhet/vårdgivare/namn": "PDL-vårdgivare SLL IdP QA",
        "granskning/context/vårdenhet/vårdgivare/identifierare:0": "SE2321000016-I1MN",
        "granskning/context/vårdenhet/vårdgivare/identifierare:0|type": "urn:oid:1.2.752.29.4.19",
        "granskning/context/vårdenhet/vårdgivare/organisationsnummer:0": "2321000016",
        "granskning/context/vårdenhet/vårdgivare/organisationsnummer:0|type": "urn:oid:2.5.4.97",
        "granskning/context/vårdenhet/vårdgivare/roll:0|code": "143591000052106",
        "granskning/context/vårdenhet/vårdgivare/roll:0|value": "vårdgivare",
        "granskning/context/vårdenhet/vårdgivare/roll:0|terminology": "http://snomed.info/sct/45991000052106"

Excerpt in simplified STRUCTURED format:

                 {
                    "_health_care_facility": [
                        {
                            "|name": "S Bäckencancer MBA QA",
                            "_identifier": [
                                {
                                    "|id": "SE2321000016-C4DV",
                                    "|type": "urn:oid:1.2.752.29.4.19"
                                }
                            ]
                        }
                    ],
                    "vårdenhet": [
                        {
                            "namn": [
                                "OO Cancer TC QA"
                            ],
                            "identifierare": [
                                {
                                    "|id": "SE2321000016-ADNF",
                                    "|type": "urn:oid:1.2.752.29.4.19"
                                }
                            ],
                            "roll": [
                                {
                                    "|code": "43741000",
                                    "|value": "vårdenhet",
                                    "|terminology": "http://snomed.info/sct/900000000000207008"
                                }
                            ],
                            "vårdgivare": [
                                {
                                    "namn": [
                                        "PDL-vårdgivare SLL IdP QA"
                                    ],
                                    "identifierare": [
                                        {
                                            "|id": "SE2321000016-I1MN",
                                            "|type": "urn:oid:1.2.752.29.4.19"
                                        }
                                    ],
                                    "organisationsnummer": [
                                        {
                                            "|id": "2321000016",
                                            "|type": "urn:oid:2.5.4.97"
                                        }
                                    ],
                                    "roll": [
                                        {
                                            "|code": "143591000052106",
                                            "|value": "vårdgivare",
                                            "|terminology": "http://snomed.info/sct/45991000052106"
                                        }
                                    ]
                                }
                            ]
                        }
                    ],