I recently created a website and I'm struggling with searching through multidimensional arrays or objects (I'm not sure what the difference is).
Prior to adding the year and month, I was able to access them directly by using array[id][field].
Can someone guide me on how to implement search within nested structures in a multidimensional array?
I attempted to pre-set the year and month with additional fields in the interface, but it ended up looking confusing and bizarre.
{
"2018": {
"Aug": {
"1": {
"id": 1,
"appeal_date": "2018-08-24",
"city_of_residence": "aaa",
"patient_name": "John",
"patient_age": 62,
"coordinator": "aaa",
"source": "aaa",
"birth_date": "1956-06-30",
"contact_person_name": "",
"contact_person_role": "",
"contact_person_phones": [
"",
""
],
"diagnosis": "aasasd",
"status": "9",
"departure_date": "2016-02-18",
"arrival_date": "2020-01-23",
"patient_phones": [
"",
""
],
"editable": true
}
}
},
"2019": {
"Oct": {
"65": {
"id": 65,
"appeal_date": "2019-10-18",
"city_of_residence": "asfsac",
"patient_name": "asvsas",
"patient_age": 62,
"coordinator": "",
"source": "asfasfa",
"birth_date": "1956-06-30",
"contact_person_name": "",
"contact_person_role": "",
"contact_person_phones": "",
"diagnosis": "assdbcx",
"status": "1",
"departure_date": "",
"arrival_date": "",
"patient_phones": "",
"editable": true
}
},
"Jun": {
"64": {
"id": 64,
"appeal_date": "2019-06-04",
"city_of_residence": "afsfsa",
"patient_name": "asvac",
"patient_age": 62,
"coordinator": "",
"source": "agwdawdawd",
"birth_date": "1956-06-30",
"contact_person_name": "",
"contact_person_role": "",
"contact_person_phones": "",
"diagnosis": "agsags",
"status": "1",
"departure_date": "",
"arrival_date": "",
"patient_phones": "",
"editable": true
}
}
}
}
All I need is to update some fields within the correct object.
patients[2019]['Oct'][65]['diagnosis'] = 'aaaaa'
Something like this, but there might be instances where the patient isn't in the specific month mentioned.
I would prefer the functionality to look like this:
patients.nestingSearchByKey(65)['diagnosis'] = 'aaaaa'
The identifiers are unique and do not repeat.
Apologies for any language errors. Any suggestions are greatly appreciated.