{
"_id" : "0289f117-54b7-451c-915c-c7948dbad22c",
"approvers" : [],
"reviewers" : [],
"cvoReviewers" : [],
"payer" : "medicaid",
"affiliationChildren" : [
{
"parentProviderEmailId" : "wy.providers [email protected]",
"provider" : {
"email" : "wy.providers [email protected]",
"firstName" : "si5",
"lastName" : "ind",
"providerId" : "628b7425d442284ba6c5d330",
"providerExternalId" : "65",
"portalType" : "PE_ADMIN",
"requestType" : "individual"
},
"providerDataId" : "78afa05a-a333-4633-8f17-c2b74a9e8ba6",
"mapping" : {
"lastName" : "ind",
"specialty" : "Waiver",
"primaryServiceAddress1" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"newPatient" : "false",
"gender" : "Male",
"provider_address" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"application_contact_email" : "wy.providers [email protected]",
"taxonomyDescription" : [
"Long Term Waiver"
],
"primaryServiceState" : "Wyoming",
"ssn" : "527-82-9927",
"summaryFirstName" : "si5",
"taxonomyId" : [
"251B00000X"
],
"primaryServiceFirstName" : "si5",
"riskLevelBasedOnScreeningScore" : "Low",
"signTitle" : "ind",
"mailingState" : "Wyoming",
"primaryServiceCountyCode" : "56021",
"primaryServiceCity" : "Cheyenne",
"primaryServicePhone" : "(456)456-4562",
"providerName" : "si5",
"primaryServiceZip" : "82009-4800",
"primaryServiceMiddleName" : "",
"zip" : "82009-4800",
"providerFullName" : "si5 ind",
"primaryServiceLastName" : "ind",
"primaryServiceEmail" : "wy.providers [email protected]",
"mailingCity" : "Cheyenne",
"summaryLastName" : "ind",
"isSummaryCheckbox" : true,
"dob" : "05/01/2022",
"mailingCountyCode" : "56021",
"sftpFlag" : "Y"
},
"effectiveDateStart" : ISODate("2022-06-07T00:00:00.000Z"),
"effectiveDateEnd" : ISODate("2022-11-01T00:00:00.000Z"),
"type" : "GROUP_TO_INDIVIDUAL",
"status" : "SIGNED",
"lastModifiedDate" : ISODate("2022-06-07T04:47:13.924Z"),
"reValidationDate" : ISODate("2023-05-24T00:00:00.728Z"),
"createdDate" : ISODate("2022-05-24T08:12:57.705Z"),
"serviceLocations" : {
"primary" : {
"addressLine1" : "5050 Powderhouse Rd",
"addressLine2" : "",
"city" : "Cheyenne",
"state" : "WY",
"zip" : "82009",
"countyCode" : "56021",
"county" : "Laramie",
"addedDate" : "2022-06-07T10:17:24 05:30"
}
},
"isAutoAffiliated" : false,
"_class" : "com.hhstechgroup.hummingbird.models.ProviderAffiliation"
},
{
"parentProviderEmailId" : "wy.providers [email protected]",
"provider" : {
"email" : "wy.providers [email protected]",
"firstName" : "si6",
"lastName" : "ind",
"providerId" : "628b7780d442284ba6c5d337",
"providerExternalId" : "66",
"portalType" : "PE_ADMIN",
"requestType" : "individual"
},
"providerDataId" : "41925991-e440-4c81-a232-31c63c94c9ee",
"mapping" : {
"lastName" : "ind",
"specialty" : "Waiver",
"primaryServiceAddress1" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"newPatient" : "false",
"gender" : "Male",
"provider_address" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"application_contact_email" : "wy.providers [email protected]",
"taxonomyDescription" : [
"Long Term Waiver"
],
"primaryServiceState" : "Wyoming",
"ssn" : "562-87-1998",
"summaryFirstName" : "si6",
"taxonomyId" : [
"251B00000X"
],
"primaryServiceFirstName" : "si6",
"riskLevelBasedOnScreeningScore" : "Low",
"signTitle" : "inds",
"mailingState" : "Wyoming",
"primaryServiceCountyCode" : "56021",
"primaryServiceCity" : "Cheyenne",
"primaryServicePhone" : "(527)290-9298",
"providerName" : "si6",
"primaryServiceZip" : "82009-4800",
"primaryServiceMiddleName" : "",
"zip" : "82009-4800",
"providerFullName" : "si6 ind",
"primaryServiceLastName" : "ind",
"primaryServiceEmail" : "wy.providers [email protected]",
"mailingCity" : "Cheyenne",
"summaryLastName" : "ind",
"isSummaryCheckbox" : true,
"dob" : "05/01/2022",
"mailingCountyCode" : "56021",
"sftpFlag" : "Y"
},
"effectiveDateStart" : ISODate("2022-06-07T00:00:00.000Z"),
"effectiveDateEnd" : ISODate("2022-09-01T00:00:00.000Z"),
"type" : "GROUP_TO_INDIVIDUAL",
"status" : "SIGNED",
"lastModifiedDate" : ISODate("2022-06-07T04:47:37.828Z"),
"reValidationDate" : ISODate("2023-05-24T00:00:00.696Z"),
"createdDate" : ISODate("2022-05-24T10:13:20.687Z"),
"serviceLocations" : {
"primary" : {
"addressLine1" : "5050 Powderhouse Rd",
"addressLine2" : "",
"city" : "Cheyenne",
"state" : "WY",
"zip" : "82009",
"countyCode" : "56021",
"county" : "Laramie",
"addedDate" : "2022-06-07T10:17:49 05:30"
}
},
"isAutoAffiliated" : false,
"_class" : "com.hhstechgroup.hummingbird.models.ProviderAffiliation"
},
{
"parentProviderEmailId" : "wy.providers [email protected]",
"provider" : {
"email" : "wy.providers [email protected]",
"firstName" : "si7",
"lastName" : "ind",
"providerId" : "628b794fb410d05f04afaa14",
"providerExternalId" : "67",
"portalType" : "PE_ADMIN",
"requestType" : "individual"
},
"providerDataId" : "a1b0d430-56f1-4c20-821b-3ef168704ea3",
"mapping" : {
"lastName" : "ind",
"specialty" : "Waiver",
"primaryServiceAddress1" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"newPatient" : "false",
"gender" : "Male",
"provider_address" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"application_contact_email" : "wy.providers [email protected]",
"taxonomyDescription" : [
"Long Term Waiver"
],
"primaryServiceState" : "Wyoming",
"ssn" : "452-64-5277",
"summaryFirstName" : "si7",
"taxonomyId" : [
"251B00000X"
],
"primaryServiceFirstName" : "si7",
"riskLevelBasedOnScreeningScore" : "Low",
"signTitle" : "ind",
"mailingState" : "Wyoming",
"primaryServiceCity" : "Cheyenne",
"primaryServiceCountyCode" : "56021",
"primaryServicePhone" : "(672)399-3793",
"providerName" : "si7",
"primaryServiceZip" : "82009-4800",
"zip" : "82009-4800",
"providerFullName" : "si7 ind",
"primaryServiceLastName" : "ind",
"primaryServiceEmail" : "wy.providers [email protected]",
"mailingCity" : "Cheyenne",
"summaryLastName" : "ind",
"isSummaryCheckbox" : true,
"dob" : "05/01/2022",
"mailingCountyCode" : "56021",
"sftpFlag" : "Y"
},
"effectiveDateStart" : ISODate("2022-06-07T00:00:00.000Z"),
"effectiveDateEnd" : ISODate("2022-12-31T00:00:00.000Z"),
"type" : "GROUP_TO_INDIVIDUAL",
"status" : "SIGNED",
"lastModifiedDate" : ISODate("2022-06-07T04:47:57.300Z"),
"reValidationDate" : ISODate("2023-05-24T00:00:00.544Z"),
"createdDate" : ISODate("2022-05-24T12:34:04.446Z"),
"serviceLocations" : {
"primary" : {
"addressLine1" : "5050 Powderhouse Rd",
"addressLine2" : "",
"city" : "Cheyenne",
"state" : "WY",
"zip" : "82009",
"countyCode" : "56021",
"county" : "Laramie",
"addedDate" : "2022-06-07T10:18:08 05:30"
}
},
"isAutoAffiliated" : false,
"_class" : "com.hhstechgroup.hummingbird.models.ProviderAffiliation"
},
{
"parentProviderEmailId" : "wy.providers [email protected]",
"provider" : {
"email" : "wy.providers [email protected]",
"firstName" : "P50",
"lastName" : "Pem",
"providerId" : "629ed1bacbc3d9017b9d7dc2",
"providerExternalId" : "126",
"portalType" : "PE_ADMIN",
"requestType" : "PEM"
},
"providerDataId" : "be24cad8-5171-4c8c-bc5a-b22a6d896ff7",
"mapping" : {
"website_address" : "",
"zip" : "82009-4800",
"lastName" : "Pem",
"providerFullName" : "P50 Pem",
"newPatient" : "false",
"gender" : "Male",
"provider_address" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"mailingCity" : "Cheyenne",
"application_contact_email" : "wy.providers [email protected]",
"mailingState" : "Wyoming",
"sftpFlag" : "N",
"providerName" : "P50"
},
"effectiveDateStart" : ISODate("2022-06-07T00:00:00.000Z"),
"effectiveDateEnd" : ISODate("2022-12-01T00:00:00.000Z"),
"type" : "GROUP_TO_PEM",
"status" : "SIGNED",
"lastModifiedDate" : ISODate("2022-06-07T04:48:21.781Z"),
"reValidationDate" : ISODate("2023-06-07T00:00:00.454Z"),
"createdDate" : ISODate("2022-06-07T04:41:43.451Z"),
"serviceLocations" : {
"primary" : {
"addressLine1" : "5050 Powderhouse Rd",
"addressLine2" : "",
"city" : "Cheyenne",
"state" : "WY",
"zip" : "82009",
"countyCode" : "56021",
"county" : "Laramie",
"addedDate" : "2022-06-07T10:18:32 05:30"
}
},
"isAutoAffiliated" : false,
"_class" : "com.hhstechgroup.hummingbird.models.ProviderAffiliation"
},
{
"parentProviderEmailId" : "wy.providers [email protected]",
"provider" : {
"email" : "wy.providers [email protected]",
"firstName" : "P51",
"lastName" : "Pem",
"providerId" : "629ed2efcbc3d9017b9d7dc9",
"providerExternalId" : "128",
"portalType" : "PE_ADMIN",
"requestType" : "PEM"
},
"providerDataId" : "c0d79d06-d8ec-4723-bc72-c8016a0922d0",
"mapping" : {
"zip" : "82009-4800",
"lastName" : "Pem",
"providerFullName" : "p51 Pem",
"newPatient" : "false",
"gender" : "Male",
"provider_address" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"mailingCity" : "Cheyenne",
"application_contact_email" : "wy.providers [email protected]",
"mailingState" : "Wyoming",
"sftpFlag" : "N",
"providerName" : "p51"
},
"effectiveDateStart" : ISODate("2022-06-07T00:00:00.000Z"),
"effectiveDateEnd" : ISODate("2022-10-01T00:00:00.000Z"),
"type" : "GROUP_TO_PEM",
"status" : "SIGNED",
"lastModifiedDate" : ISODate("2022-06-07T04:48:45.614Z"),
"reValidationDate" : ISODate("2023-06-07T00:00:00.435Z"),
"createdDate" : ISODate("2022-06-07T04:42:11.431Z"),
"serviceLocations" : {
"primary" : {
"addressLine1" : "5050 Powderhouse Rd",
"addressLine2" : "",
"city" : "Cheyenne",
"state" : "WY",
"zip" : "82009",
"countyCode" : "56021",
"county" : "Laramie",
"addedDate" : "2022-06-07T10:18:45 05:30"
}
},
"isAutoAffiliated" : false,
"_class" : "com.hhstechgroup.hummingbird.models.ProviderAffiliation"
}
],
"affiliationParents" : [],
"taxonomyDetails" : {},
"children" : [
{
"$ref" : "runtimeSections",
"$id" : "ecf92055-7ebb-4a76-bdc8-3fbf809336bf"
},
{
"$ref" : "runtimeSections",
"$id" : "1fab57a2-e759-4e3e-896f-0dfb4668b712"
},
{
"$ref" : "runtimeSections",
"$id" : "fe15668c-ec7b-423b-af1e-8e3e1d2307f2"
},
{
"$ref" : "runtimeSections",
"$id" : "f20c6a20-75e0-4fea-b327-5aa20ecb34ac"
},
{
"$ref" : "runtimeSections",
"$id" : "fc8eee6c-1a71-437d-8898-d3835e990042"
},
{
"$ref" : "runtimeSections",
"$id" : "083ac588-c349-41c9-b045-0140b2fda9cd"
},
{
"$ref" : "runtimeSections",
"$id" : "8e309413-6f38-435d-9dad-2f48d2a7c307"
},
{
"$ref" : "runtimeSections",
"$id" : "7cd3d254-c199-4bcd-b650-a4c93b07fcf3"
},
{
"$ref" : "runtimeSections",
"$id" : "41fb42b1-294f-4812-bd33-ebae6bfe762f"
},
{
"$ref" : "runtimeSections",
"$id" : "753e53bd-0c5e-4bf4-a11d-575f51284cca"
},
{
"$ref" : "runtimeSections",
"$id" : "670bba3a-ef6f-4e56-a3db-00f002781216"
},
{
"$ref" : "runtimeSections",
"$id" : "d1c6372c-905b-4551-80cd-efc96ab039cd"
},
{
"$ref" : "runtimeSections",
"$id" : "71a3eda4-798a-4310-8fe2-eb5a3d6844ea"
},
{
"$ref" : "runtimeSections",
"$id" : "26f0f9c0-359d-490d-8c2d-f3e1da57c8b5"
},
{
"$ref" : "runtimeSections",
"$id" : "f8687f54-233d-4dd5-a6b9-44734cd78177"
},
{
"$ref" : "runtimeSections",
"$id" : "89b5371d-bd24-4687-a6f3-470fe6055942"
},
{
"$ref" : "runtimeSections",
"$id" : "4fa3a7a0-15d4-472c-98b3-251da1d5ba38"
},
{
"$ref" : "runtimeSections",
"$id" : "6841928e-3568-41b9-be3f-a8ecd6f89d74"
}
],
"author" : {
"email" : "wy.providers [email protected]",
"firstName" : "g51",
"lastName" : "group",
"providerId" : "629ed151cbc3d9017b9d7dbf",
"providerExternalId" : "125",
"portalType" : "PE_ADMIN",
"requestType" : "group"
},
"requestId" : NumberLong(247),
"requestType" : "group",
"status" : {
"pe" : "APPROVED",
"iu" : "APPROVED",
"notes" : "",
"priority" : 16,
"rank" : "",
"screeningScore" : "98",
"screeningDate" : ISODate("2022-06-07T04:45:26.017Z"),
"screeningNote" : "",
"screeningReason" : "",
"scheduleDate" : "06/07/2022",
"scheduleReason" : "",
"retroActive" : "false",
"effectiveDate" : "2022-06-07",
"apvReason" : "Positive results ",
"statusChangedBy" : "internal.user.dyp [email protected]",
"futureActive" : false,
"_class" : "com.hhstechgroup.hummingbird.models.runtime.RequestStatus"
},
"createdDate" : ISODate("2022-06-07T04:18:44.221Z"),
"lastModifiedDate" : ISODate("2022-06-07T04:49:03.149Z"),
"submittedDate" : ISODate("2022-06-07T04:22:11.104Z"),
"statusChangedDate" : ISODate("2022-06-07T04:49:01.712Z"),
"deleted" : false,
"metadata" : {
"READY_FOR_SIGN_AGREEMENT_TIMESTAMP" : ISODate("2022-06-07T04:21:23.717Z"),
"AGGREMENT_PDF_ID" : "26318031da0390ea91f151f23d5523e1",
"APPLICATION_AGREEMENT_PDF_ID" : "26318031da0390ea91f151f23d553499",
"isAggrementSigned" : "true",
"READY_FOR_SIGN_TIMESTAMP" : ISODate("2022-06-07T04:21:36.902Z"),
"APPLICATION_ORIGINAL_PDF_ID" : "b37a296c204ee237655477a40f4ea741",
"signUpRequest" : {
"clientId" : "95c647d0be93e5deee5a8a44ecb97730",
"signatureRequestId" : "edb1b6f08b0ecc25ac04b120ca4ca3a45b131b06",
"signUrl" : "https://app.hellosign.com/editor/embeddedSign?signature_id=735345253d7d4689831b3c8181a49ee4&token=71fa1da4b91634c53911da1efa896eba",
"_class" : "com.hhstechgroup.hummingbird.models.SignUpRequest"
},
"APPLICATION_PDF_ID" : "26318031da0390ea91f151f23d558f55",
"SIGNED_USERS" : [
"wy.providers [email protected]"
]
},
"customSettings" : {
"Payment" : true,
"Provider_Agreement" : true,
"Sections" : true,
"Summary" : true,
"Secondary_Service_Location" : true,
"HelloSign" : true,
"Affiliation" : true
},
"mapping" : {
"groupName" : "g51 group",
"newPatient" : "false",
"providerFullName" : "g51 group",
"fein" : "78-9320938",
"mailingState" : "Wyoming",
"mailingCity" : "Cheyenne",
"zip" : "82009-4800",
"provider_address" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"mailingCountyCode" : "56021",
"specialty" : "Audiology",
"taxonomyDescription" : [
"Audiologist"
],
"taxonomyId" : [
"231H00000X"
],
"primaryServiceCity" : "Cheyenne",
"primaryServiceCountyCode" : "56021",
"primaryServiceAddress1" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"primaryServiceState" : "Wyoming",
"primaryServiceZip" : "82009-4800",
"primaryServiceFirstName" : "g51",
"primaryServiceMiddleName" : "",
"primaryServiceLastName" : "group",
"primaryServicePhone" : "(893)092-0928",
"primaryServiceEmail" : "wy.providers [email protected]",
"signTitle" : "group",
"sftpFlag" : "Y",
"riskLevelBasedOnScreeningScore" : "Low"
},
"sync" : {},
"assigneeHistory" : [],
"sslDeletedHistoryList" : [],
"changed" : "",
"count" : 0,
"affiliationCount" : 0,
"pendingDays" : NumberLong(0),
"templateId" : "provider_group",
"_class" : "com.hhstechgroup.hummingbird.models.Request",
"assignedBy" : "statusScheduler",
"assignedDate" : ISODate("2022-06-07T04:45:42.711Z"),
"assignee" : {
"email" : "internal.user.dyp [email protected]",
"firstName" : "Cindy",
"lastName" : "Duran",
"providerId" : "627bae1e51a23b326dcadeb4",
"portalType" : "IU",
"_class" : "com.hhstechgroup.hummingbird.models.UserVM"
}
}
I want to fetch a single record from "affiliationChildren" property of this document where "provider.email" is "wy.providers [email protected]". Need to fetch without using loop, can resolve using aggregation, Projections etc. Currently affiliation children set contains 5 records, I want to fetch only 1 record on the basis of provider.email property. The expected result will be:
{
"parentProviderEmailId" : "wy.providers [email protected]",
"provider" : {
"email" : "wy.providers [email protected]",
"firstName" : "si5",
"lastName" : "ind",
"providerId" : "628b7425d442284ba6c5d330",
"providerExternalId" : "65",
"portalType" : "PE_ADMIN",
"requestType" : "individual"
},
"providerDataId" : "78afa05a-a333-4633-8f17-c2b74a9e8ba6",
"mapping" : {
"lastName" : "ind",
"specialty" : "Waiver",
"primaryServiceAddress1" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"newPatient" : "false",
"gender" : "Male",
"provider_address" : "{\"line1\":\"5050 Powderhouse Rd\",\"streetNumber\":\"5050\",\"streetName\":\"Powderhouse Rd\",\"city\":\"Cheyenne\",\"state\":\"WY\",\"zipCode\":\"82009\",\"zipExtension\":\"4800\",\"county\":\"Laramie\",\"latitude\":41.16474,\"longitude\":-104.80925,\"countyCode\":\"56021\",\"text\":\"5050 Powderhouse Rd\",\"verified\":true,\"zipPlusFour\":\"82009-4800\"}",
"application_contact_email" : "wy.providers [email protected]",
"taxonomyDescription" : [
"Long Term Waiver"
],
"primaryServiceState" : "Wyoming",
"ssn" : "527-82-9927",
"summaryFirstName" : "si5",
"taxonomyId" : [
"251B00000X"
],
"primaryServiceFirstName" : "si5",
"riskLevelBasedOnScreeningScore" : "Low",
"signTitle" : "ind",
"mailingState" : "Wyoming",
"primaryServiceCountyCode" : "56021",
"primaryServiceCity" : "Cheyenne",
"primaryServicePhone" : "(456)456-4562",
"providerName" : "si5",
"primaryServiceZip" : "82009-4800",
"primaryServiceMiddleName" : "",
"zip" : "82009-4800",
"providerFullName" : "si5 ind",
"primaryServiceLastName" : "ind",
"primaryServiceEmail" : "wy.providers [email protected]",
"mailingCity" : "Cheyenne",
"summaryLastName" : "ind",
"isSummaryCheckbox" : true,
"dob" : "05/01/2022",
"mailingCountyCode" : "56021",
"sftpFlag" : "Y"
},
"effectiveDateStart" : ISODate("2022-06-07T00:00:00.000Z"),
"effectiveDateEnd" : ISODate("2022-11-01T00:00:00.000Z"),
"type" : "GROUP_TO_INDIVIDUAL",
"status" : "SIGNED",
"lastModifiedDate" : ISODate("2022-06-07T04:47:13.924Z"),
"reValidationDate" : ISODate("2023-05-24T00:00:00.728Z"),
"createdDate" : ISODate("2022-05-24T08:12:57.705Z"),
"serviceLocations" : {
"primary" : {
"addressLine1" : "5050 Powderhouse Rd",
"addressLine2" : "",
"city" : "Cheyenne",
"state" : "WY",
"zip" : "82009",
"countyCode" : "56021",
"county" : "Laramie",
"addedDate" : "2022-06-07T10:17:24 05:30"
}
},
"isAutoAffiliated" : false,
"_class" : "com.hhstechgroup.hummingbird.models.ProviderAffiliation"
}
CodePudding user response:
This will work:
db.collection.aggregate([
{
"$match": {
affiliationChildren: {
$elemMatch: {
"provider.email": "wy.providers [email protected]"
}
}
}
},
{
$project: {
affiliationChildren: {
$filter: {
input: "$affiliationChildren",
as: "children",
cond: {
$eq: [
"$$children.provider.email",
"wy.providers [email protected]"
]
}
}
},
_id: 0
}
},
{
"$unwind": "$affiliationChildren"
},
{
"$replaceRoot": {
"newRoot": "$affiliationChildren"
}
}
])
Here's the playground link.
This is the java equivalent of the above query:
import java.util.Arrays;
import com.mongodb.client.AggregateIterable;
import org.bson.Document;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
public class Sample {
public static void main(String[] args) {
MongoClient mongoClient = new MongoClient(
new MongoClientURI(
"mongodb://localhost:27017/"
)
);
MongoDatabase database = mongoClient.getDatabase("StackOverflow");
MongoCollection<Document> collection = database.getCollection("sample");
AggregateIterable<Document> result = collection.aggregate(Arrays.asList(new Document("$match",
new Document("affiliationChildren",
new Document("$elemMatch",
new Document("provider.email", "wy.providers [email protected]")))),
new Document("$project",
new Document("affiliationChildren",
new Document("$filter",
new Document("input", "$affiliationChildren")
.append("as", "children")
.append("cond",
new Document("$eq", Arrays.asList("$$children.provider.email", "wy.providers [email protected]")))))
.append("_id", 0L)),
new Document("$unwind",
new Document("path", "$affiliationChildren")),
new Document("$replaceRoot",
new Document("newRoot", "$affiliationChildren"))));
}
}
CodePudding user response:
I trying to resolve my issue, finally got the solution with this query I got my expected result.
I already had a set of entities id which I am travrsing as entityId. with the help of entityid fetched the main document and with the aggregation query got the affiliationchildren andfrom affiliationChildren now I am fetching 2 objects of affiliationChildren with provided emailIds = individualEmail,pemAffiliationEmail.
Criteria criteria = Criteria.where("_id").is(entityId);
criteria.and("affiliationChildren.provider.email").in(Arrays.asList(individualEmail,pemAffiliationEmail));
GroupOperation groupOperation = Aggregation.group("_id", "requestType").push(AFFILIATION_CHILDREN).as(AFFILIATION_CHILDREN);
Aggregation aggregation = null;
aggregation = Aggregation.newAggregation(
unwind("affiliationChildren"),
match(criteria),
groupOperation
);
final AggregationResults<ProviderData> aggregateResult = mongoOperations.aggregate(aggregation, PROVIDERS_DATA, ProviderData.class);
providerDataList = aggregateResult.getMappedResults();