Home > database >  Complex aggregate queries, and guide, please
Complex aggregate queries, and guide, please

Time:09-25

Exclusion1=list (self. Dw [' CQM2018]. Aggregate ([
{' $match: {" _id ": {' $' in: denom_id}}},
{' $project: {' ClinicID: 1, 'PatientID: 1,
'Depression_diagnosis: 1,' Bipolar_Diagnosis: 1, 'Depression_Screening_Encounter_Codes: 1}},
{' $unwind: {' path ':' $Depression_diagnosis', 'preserveNullAndEmptyArrays: True}},
{' $unwind: {' path ':' $Bipolar_Diagnosis', 'preserveNullAndEmptyArrays: True}},
{' $unwind: {' path ':' $Depression_Screening_Encounter_Codes'}},
{' $project: {' ClinicID: 1, 'PatientID: 1,
'compare1.c: {' $cond: {:' if '{' $gt: [' $Depression_diagnosis. DOS, None]},' then ': {' $lte: [' $Depression_diagnosis. DOS' and '$Depression_Screening_Encounter_Codes. DOS']}, 'else' : False}},
'compare2: {' $cond: {:' if '{' $gt: [' $Bipolar_Diagnosis. DOS, None]},' then ': {' $lte: [' $Bipolar_Diagnosis. DOS' and '$Depression_Screening_Encounter_Codes. DOS']}, 'else' : False}},
}},
${' $match: {' or ': [{' compare1.c: True}, {" compare2 ": True}]}},
))

If the compare1.c here, compare2 has dozens of similar, is there any easy way, demand is found to meet any of the many conditions of a data

CodePudding user response:

"Mongo calculation difficulty sums up" a part of this article is about the group aggregation
  • Related