Say I have a list of medical objects, where I want to select all objects that have a category of "MEDICATION" and also have a "Trait", which is an array of Objects, for specifically the term "NEGATION". For example:
[
{
Score: 0.9978850483894348,
Text: 'prozac',
Category: 'MEDICATION',
Type: 'BRAND_NAME',
Traits: [
{
Name: "SIGN"
},
{
Name: "NEGATION"
}
]
},
{
Text: "pulmonary embolism",
Category: "MEDICAL_CONDITION",
Type: "DX_NAME",
Traits: [
{
Name: "DIAGNOSIS",
Score: 0.9635574817657471
} ]
Normally for a filter I could select all objects that are medications quite easily with:
Object.filter( obj => obj.Category === "MEDICATION" )
But how would I select all objects with Medication, and also Trait with object where Name === NEGATION?
The nested array throws me off.
Thank you!