The medicine, an antipsychotic drug, has a sensor that will show doctors whether and when patients are taking it. Other medicines will follow, experts say.