I am having Array of object like below
[
{
"HLT": "Infections NEC",
"LLT": "Adrenalitis",
"HLGT": "Infections - pathogen unspecified",
"PT": "Adrenalitis",
"SOC": "Infections and infestations"
},
{
"HLT": "Adrenal neoplasms",
"LLT": "Adrenal cyst",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal cyst",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal mass",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal mass",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenomegaly",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenomegaly",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal nodule",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal mass",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland therapeutic procedures",
"LLT": "Adrenalectomy",
"HLGT": "Endocrine gland therapeutic procedures",
"PT": "Adrenalectomy",
"SOC": "Surgical and medical procedures"
},
{
"HLT": "Adrenal cortical hypofunctions",
"LLT": "Adrenal crisis",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenocortical insufficiency acute",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal cortical hypofunctions",
"LLT": "Adrenal atrophy",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal atrophy",
"SOC": "Endocrine disorders"
},
{
"HLT": "Endocrine neoplasms malignant and unspecified NEC",
"LLT": "Adrenal neoplasm",
"HLGT": "Endocrine neoplasms malignant and unspecified",
"PT": "Adrenal neoplasm",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Adrenal disorders congenital",
"LLT": "Adrenal virilism",
"HLGT": "Endocrine disorders congenital",
"PT": "Adrenogenital syndrome",
"SOC": "Congenital, familial and genetic disorders"
},
{
"HLT": "Adrenal neoplasms benign",
"LLT": "Adrenal adenoma",
"HLGT": "Endocrine neoplasms benign",
"PT": "Adrenal adenoma",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal hematoma",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal haematoma",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal bleeding",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal haemorrhage",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal disorder",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal disorder",
"SOC": "Endocrine disorders"
},
{
"HLT": "Cerebral disorders congenital",
"LLT": "Adrenoleukodystrophy",
"HLGT": "Neurological disorders congenital",
"PT": "Adrenoleukodystrophy",
"SOC": "Congenital, familial and genetic disorders"
},
{
"HLT": "Abdominal and gastrointestinal injuries NEC",
"LLT": "Adrenal gland injury",
"HLGT": "Injuries NEC",
"PT": "Adrenal gland injury",
"SOC": "Injury, poisoning and procedural complications"
},
{
"HLT": "Metastases to specified sites",
"LLT": "Adrenal metastases",
"HLGT": "Metastases",
"PT": "Metastases to adrenals",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Adrenal neoplasms malignant",
"LLT": "Adrenal gland cancer",
"HLGT": "Endocrine neoplasms malignant and unspecified",
"PT": "Adrenal gland cancer",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Adrenal neoplasms benign",
"LLT": "Adrenal myelolipoma",
"HLGT": "Endocrine neoplasms benign",
"PT": "Benign neoplasm of adrenal gland",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Autonomic nervous system disorders",
"LLT": "Adrenolytic syndrome",
"HLGT": "Neuromuscular disorders",
"PT": "Adrenolytic syndrome",
"SOC": "Nervous system disorders"
},
{
"HLT": "Endocrine analyses and imaging NEC",
"LLT": "Adrenal scintigraphy",
"HLGT": "Endocrine investigations (incl sex hormones)",
"PT": "Scan adrenal gland",
"SOC": "Investigations"
},
{
"HLT": "Pituitary analyses anterior",
"LLT": "Adrenocorticotropin",
"HLGT": "Endocrine investigations (incl sex hormones)",
"PT": "Blood corticotrophin",
"SOC": "Investigations"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal thrombosis",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal thrombosis",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal cortical hypofunctions",
"LLT": "Adrenal hypofunction",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal insufficiency",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland therapeutic procedures",
"LLT": "Adrenalectomy NOS",
"HLGT": "Endocrine gland therapeutic procedures",
"PT": "Adrenalectomy",
"SOC": "Surgical and medical procedures"
},
{
"HLT": "Endocrine neoplasms malignant and unspecified NEC",
"LLT": "Adrenal neoplasm NOS",
"HLGT": "Endocrine neoplasms malignant and unspecified",
"PT": "Adrenal neoplasm",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Adrenal neoplasms malignant",
"LLT": "Adrenal carcinoma",
"HLGT": "Endocrine neoplasms malignant and unspecified",
"PT": "Adrenal gland cancer",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Autonomic nervous system disorders",
"LLT": "Adrenergic syndrome",
"HLGT": "Neuromuscular disorders",
"PT": "Adrenergic syndrome",
"SOC": "Nervous system disorders"
},
{
"HLT": "Adrenal gland histopathology procedures",
"LLT": "Adrenal gland biopsy",
"HLGT": "Endocrine investigations (incl sex hormones)",
"PT": "Biopsy adrenal gland",
"SOC": "Investigations"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal haematoma",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal haematoma",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal haemorrhage",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal haemorrhage",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal hemorrhage",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal haemorrhage",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal disorder NOS",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal disorder",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal cortical hypofunctions",
"LLT": "Adrenal suppression",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal suppression",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal disorders congenital",
"LLT": "Adrenogenital syndrome",
"HLGT": "Endocrine disorders congenital",
"PT": "Adrenogenital syndrome",
"SOC": "Congenital, familial and genetic disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal cortex necrosis",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal cortex necrosis",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal cortical hypofunctions",
"LLT": "Adrenal cortex atrophy",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal atrophy",
"SOC": "Endocrine disorders"
},
{
"HLT": "Hormonal therapeutic procedures NEC",
"LLT": "Adrenal blockade therapy",
"HLGT": "Endocrine gland therapeutic procedures",
"PT": "Adrenal blockade therapy",
"SOC": "Surgical and medical procedures"
},
{
"HLT": "Adrenal gland therapeutic procedures",
"LLT": "Adrenal gland operation",
"HLGT": "Endocrine gland therapeutic procedures",
"PT": "Adrenal gland operation",
"SOC": "Surgical and medical procedures"
},
{
"HLT": "Endocrine neoplasms malignant and unspecified NEC",
"LLT": "Adrenal incidentaloma",
"HLGT": "Endocrine neoplasms malignant and unspecified",
"PT": "Adrenal neoplasm",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Adrenal neoplasms malignant",
"LLT": "Adrenal adenocarcinoma",
"HLGT": "Endocrine neoplasms malignant and unspecified",
"PT": "Adrenal gland cancer",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Adrenal neoplasms malignant",
"LLT": "Adrenocortical carcinoma",
"HLGT": "Endocrine neoplasms malignant and unspecified",
"PT": "Adrenocortical carcinoma",
"SOC": "Neoplasms benign, malignant and unspecified (incl cysts and polyps)"
},
{
"HLT": "Infections NEC",
"LLT": "Adrenal gland abscess",
"HLGT": "Infections - pathogen unspecified",
"PT": "Adrenal gland abscess",
"SOC": "Infections and infestations"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal gland enlarged",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenomegaly",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal cortical necrosis",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal cortex necrosis",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal gland disorders NEC",
"LLT": "Adrenal cortex dysplasia",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal cortex dysplasia",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal cortical hypofunctions",
"LLT": "Adrenal insufficiency",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal insufficiency",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal cortical hypofunctions",
"LLT": "Adrenal insufficiency NOS",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal insufficiency",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal cortical hyperfunctions",
"LLT": "Adrenal androgen excess",
"HLGT": "Adrenal gland disorders",
"PT": "Adrenal androgen excess",
"SOC": "Endocrine disorders"
},
{
"HLT": "Adrenal cortical hyperfunctions",
"LLT": "Adrenal hypercorticism",
"HLGT": "Adrenal gland disorders",
"PT": "Hyperadrenocorticism",
"SOC": "Endocrine disorders"
}
]
And I want the data like it in below way as a tree
Expectation is like above image. also we can may use below prefix like
const prefix = [SOC,HLGT,HLT,PT,LLT];
We can also create data json structure like – parent and children
Like –
[
{
key: 'SOC',
value: 'Infections and infestations',
children: [
{
key: 'HLGT',
value: 'value one',
children: [
]
}
]
}
]
key value with children pairs as a tree. for exact result please refer the screen shot attached
I have tried it with many things but not bale to achive above image type of result.
2
Answers
You could group by the given keys and return an object with the wanted grouing for every level.
Check it.