Add conditional query to Program model

* Updates Program API controller to use it (v3 only)
* Cleans up some tests