Database

[{insuredId:1,treatmentInfo:[{amount:1},{amount:2}]},{insuredId:1,treatmentInfo:[{amount:3},{amount:4}]},{insuredId:2,treatmentInfo:[{amount:1},{amount:2}]}]

Query

db.collection.aggregate([{"$addFields":{"totalAmount":{"$sum":"$treatmentInfo.amount"}}},{"$group":{"_id":"$insuredId","numberOfClaims":{"$sum":1},"amount":{"$sum":"$totalAmount"}}}])

Result