"He said, 'Just so you know, we've looked at your medical records and we feel you're taking medications inappropriately," Ryan Pyle said.

Ryan Pyle is a Utah firefighter paramedic who was charged with prescription drug fraud after local police made a warrantless search into the state's controlled substance database in 2013.

>> Read more trending stories

When police had no suspects or probable cause for a theft of morphine from several fire stations, they looked into the prescription drug records of all fire department employees. Officers pinged Pyle and assistant fire chief Marlon Jones for drug fraud, but they never made any arrest in the morphine theft.

Charges against Pyle and Jones were later dismissed, but according to state law at the time, those police officers were fully within their right to search medical records without first obtaining a warrant.

And it turns out that type of warrantless search happens more often than you might think.

Pyle's case prompted Scripps News journalists to investigate the practice. The investigation revealed there are 31 states that allow investigators to look at a prescription records database without a warrant.

There are some hoops to jump through, but not many. For example, Scripps discovered West Virginia only requires officers to acknowledge they have an investigation. Indiana officials only need to provide a case number.

Between January 2014 and December 2015, Indiana law enforcement made 50,447 searches in the state's database, second only to Texas law enforcement, which made 57,447.

In those two years, at least 344,921 searches of prescription databases were made in states that don't require warrants — that's more than six times the number made in states that do require warrants or some other form of authorization.