I want to use HKStatisticsQuery to read the Active Energy Burned from HealthKit

I have requested the access from the HealthKit by below code

let calorieCount = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.activeEnergyBurned)!

and it working perfectly but not able to read the data using Query after reading the documentation I have found out HKStatisticsQuery is used for Query

    func CaloriesBurned() {

        let activeEnergy = HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned)!

        let startDate = Calendar.current.date(byAdding: .day,value: -7, to: Date())

        let predicate = HKQuery.predicateForSamples(withStart: startDate, end: Date(), options: .strictStartDate)

        let query = HKStatisticsQuery(quantityType: activeEnergy, quantitySamplePredicate: predicate,completionHandler: <#T##(HKStatisticsQuery, HKStatistics?, Error?) -> Void#>))

    }

but I don't understand what should be written in completion handler in above code to read the active Energy Burned

I have read already documentation if anyone has sample code to read energy burned or sample code on how to use HKStatisticsQuery

I suggest adding an input method of how calories are burned i.e then active energy burned would be diverted to the method of usage as well as time and date of start all out put variables added with predetermined estimated weight charted in a cause and effect manner with a if than cause and effective outcome

I want to use HKStatisticsQuery to read the Active Energy Burned from HealthKit
 
 
Q