Search is a complicated thing to implement, so I cannot help you with that logic directly.
Please do take a look at the
Spark server, where search has been implemented already. In Spark the search is performed against a database, which indexes search values for performance.
If you do not care about performance, you could take your list of Patient resources and iterate through them, inspecting the fields your client wants to search on.
So for example if the client wants a search on Patient Name, those values would be in the Patient.Name.Family and/or Patient.Name.Given. Both these are lists, so you'll have to check within those lists as well. So you could do something like this for each Patient in your list:
foreach (var name in pat.Name)
{
foreach (var fam in name.Family)
{
// check if fam matches searchstring
// and add Patient to your searchset Bundle if it does
}
foreach (var given in name.Given)
{
// also check of there are matches here
}
}
But I would not recommend for performance reasons, if your list is a large one.
If you're not a .Net person, but perhaps more into Java, you could also check out the
HAPI FHIR server for ideas about implementing a server.