A sensor system called MEDIC can continuously measure levels of medication and illegal drugs in human blood.

It’s every doctor’s dream—a small, wearable sensor that can monitor levels of, say, the heart drug digoxin in a patient’s blood, and make sure that he or she gets just the right amount of medication 24 hours a day.

But the MEDIC biosensor, developed by researchers at the University of California, Santa Barbara (UCSB), can be easily reconfigured to test a person’s blood for just about any substance, including illegal drugs. In fact, the new technology builds on previous research by UCSB mechanical engineer Dr. Hyongsok (Tom) Soh on a microchip that can continuously screen blood for cocaine.

Learn More About the Signs of Drug Abuse and Available Treatments »

Soh says that MEDIC could help take the guesswork out of dosing for prescription drugs. Soh and his team published the results of their initial experiments late last month in the journal Science Translational Medicine.

“Such technology would enable truly personalized medicine, wherein therapeutic agents could be tailored with optimal doses for each patient to maximize efficacy and minimize side effects,” Soh’s team wrote in the study.

But some online critics say that, taken to its logical endpoint, his technology could be used by police, government agents, or even overzealous employers to drug test people on an ongoing basis.

Soh hopes to scale the technology down to a wearable size, which would make constant remote monitoring a possibility.

MEDIC, or the microfluidic electrochemical detector for in vivo continuous monitoring, consists of a small sensor lined with shape-changing probes that are switched “on” in the presence of whatever substance they’ve been designed to detect.

The device provides a digital read-out of the concentration of the target drug in a patient’s blood over time. The sensor probes can be switched out at any point to test for different chemicals.

Read More: A Personal Blood-Testing Laboratory Under Your Skin »

“To demonstrate the system’s versatility, we measured therapeutic in vivo concentrations of doxorubicin (a chemotherapeutic) and kanamycin (an antibiotic) in live rats and in human whole blood for several hours with high sensitivity and specificity,” the study authors wrote.

High sensitivity and specificity mean that the sensor can detect even small amounts of the target drug in a person’s system, without generating many false positives.

Much more work must be done before the MEDIC sensor makes it to market, including extensive testing in humans. Whether the technology represents a leap forward for precision medicine, or for intrusive surveillance, will be a matter of time and perspective.

Read On: Blood Pressure Implant Triggered by Pleasure Could Replace Daily Pills »