Toggle button attached to list items

App CCD digital

Hi, I have a list item of patients wich is growing constantly so I placed a searchbar on top to filter the list by patient name but I also placed a toggle button to hide all the patients that finished their treatments in order to see the active ones only.
The searchbar works fine but the toggle list is giving me a couple of problems. I could get it to work by itself but cant get it to work in unison with the searchbar. Can I have them both attached to the same list items?
The second problem I am having is that when I toggle it on and go to the details page, when I update or cancel and return to the list, it is always toggle off, it does not persist.
Any help is appreciated. Thanks!

Regarding the first one you can do it within one formula depending on what your data structure is:
I had a similar case with forum post when I search and/or filter by users own posts only.
You can do it as a nested if + select as an outcome (I am sure there are better ways).