Filtering on a property of the first element in a Nested property array

We have the following document structure :

"Document" : {
"arvTreatmentStarted" : "started",
"followUps" : [
{
"followUpDate" : "2012-01-01",
"arvDrugs" : {
"dispenseDoseQuantity" : "30",
"dispenseDoseDaysSupply" : "144"
},
"followUpStatus" : "Alive on ART"
},
{
"followUpDate" : "2013-01-01",
"arvDrugs" : {
"dispenseDoseQuantity" : "30",
"dispenseDoseDaysSupply" : "144"
},
"followUpStatus" : "Alive on ART"
}
]
}

This document contains a nested property called Follow Ups which is an array of objects. In these objects there is a property called followUpDate .

Business Rule : We need to find the first Follow Up in the follow ups array and check if it's followUpDate is within a particular range and if it is not, exclude the whole Document from the search result set.

As an example if we had the date range 2013 - 2014

  • It would include the Document in the result set because the query would consider the followUpDate for the second Follow Up in the list as valid.
  • However this should not happen according to the Business rule as the First Follow up has a followUpDate that is not within the date range.

Below is the sample of our nested query

Yes interesting question, I would be interesting in hearing the answers that anyone could come up with

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.