medizininformatik-initiative / sq2cql

1 stars 1 forks source link

Update mapping_tree creation #151

Closed juliangruendner closed 1 week ago

juliangruendner commented 2 weeks ago

note that this issue is similar to flare - as the same tree structure is used for resolving code hierachies. https://github.com/medizininformatik-initiative/flare/issues/191

The current mapping tree is based on a tree structure where each tree contains all subtrees, in essence making it a mono hierarchical structure.

As we are now expanding to more terminologies future terminologies will also include mulit-hierarchical terminologies like SNOMED.

This is why we will change the tree structure to the following:

[
  {
    "entries": [
      {
        "key": "309143001",
        "parents": [
          "303247002",
          "439479000"
        ],
        "children": [
          "396526009",
          "396527000"
        ]
      },
      {
        "key": "396526009",
        "parents": [
          "309143001"
        ],
        "children": []
      },
      {
        "key": "396527000",
        "parents": [
          "309143001"
        ],
        "children": []
      }
    ],
    "context": {
      "system": "fdpg.mii.cds",
      "code": "Specimen",
      "display": "Bioprobe",
      "version": "1.0.0"
    },
    "system": "http://snomed.info/sct",
    "version": "http://snomed.info/sct/900000000000207008/version/20240101"
  }
]

Given this structure the way the tree is held in memory will have to be changed to a map like structure, where each entry can be directly accessed to build the expansion of any termcode (node).

for Example:

309143001 would expand to: 309143001, 396526009 and 396527000

note that each "tree map" is per context and system. The reason for this is to save space when transferring the information for the tree.

=> given multiple contexts and systems which flare has to support simultaniously it will have to create a map of tree maps,

where first the correct tree map is selected by context + system and version from the termcode and then the code of the termcode is used to expand it within the selected tree map