SPOKANE, Wash. -

Newly unsealed search warrants show a Sacred Heart employee suspected of stealing as many as a quarter of a million prescription painkillers was able to bypass detection of his alleged thefts by using a computer system for tracking medications that allowed for manipulation of drug stocks.

In fact, it wasn't until other pharmacy technicians noticed drugs were missing and did a physical "hard count" of their stocks did they realize there were massive amounts of drugs being stolen from the pharmacy.

As a result of the Spokane Police Department investigation into Paul Martsin, the DEA has joined the investigation into how so many prescription drugs were taken from Sacred Heart Medical Center and no one caught the thefts for nearly four years, while the  Washington State Department of Health has  launched a separate investigation into Martsin's actions and his alleged thefts from the pharmacy during the same time frame.

Martsin, 24, a licensed pharmacy technician at the hospital's outpatient pharmacy was arrested Wednesday after secret surveillance cameras caught him stealing 1,000 painkillers from the pharmacy.

Investigators believe that Martsin was involved in manipulation of the pharmacy's inventory of hydrocodone and codeine syrup as well as ordering drugs at the same time shortages in their stocks were identified.

The ease with which he was able to avoid detection lies within the system Sacred Heart's pharmacy uses to order pharmaceuticals.

The pharmacy uses two software programs to order and track stocks on-hand. One of them, dubbed QSI, tracks orders, amount of drugs in stock and dispensing of inventory. The program automatically orders more pharmaceuticals when stocks fall below a certain level. The system, however, does not track the number of drugs being ordered with the actual number of drugs being dispensed.

Furthermore, the amount of drugs in stock can be manipulated to show low quantities of drugs on hand, triggering an automated order from the wholesaler, and the computer system does not warn pharmacists if more drugs are coming into the pharmacy than those being dispensed.

Additionally, the program was set up so that each user had their own unique username and password to track orders with the exception of summer interns. Those interns were given a group username and password -- student for username and student for password -- which allowed for anyone to gain access to the system and manipulate the stocks of drugs on hand, triggering automated orders, without being traced back to an individual user. The student intern login information was common knowledge throughout the pharmacy staff.

It wasn't until two pharmacists noticed a physical discrepancy in stocks of hydrocodone and conducted a physical "hard count" of their inventories on May 13. Between May 13 and May May 17 they found that 726 hydrocodone pills had gone missing. Tracking the roster of personnel working during that period they found Martsin was working on both May 16 and 17.

Pharmacists then went back into the system and reviewed orders to the middle of 2012 and found that between the amount of hydrocodone ordered and dispensed they were missing approximately 230 bottles of hydrocodone. Each bottle contained 500 pills, meaning there were approximately 115,000 pills missing from their inventory.

As detectives zeroed in on Martsin as a suspect, fellow employees told investigators that while most employees sought more hours to work, Martsin had been asking instead for more time off, which seemed unusual to the person who did personnel scheduling for the pharmacy. Martsin was told on one occasion by a fellow employee to take care of scanning hydrocodone inventory as it arrived from the wholesaler; Martsin later told that person he had forgotten to scan them into the pharmacy stocks. During that same time period, in April of this year, Martsin was suspected of placing hydrocodone orders, and one pharmacist noted that Martsin had come in on May 25, his day off. That same day a large quantity of hydrocodone was ordered from the pharmacy and detectives believe Martsin placed that order.

It was at this point in their investigation that detectives, working with the director of security for Sacred Heart Medical Center, decided to install surveillance cameras in the pharmacy to see if they could catch any hydrocodone being pilfered from the pharmacy stocks. At the same time, hospital staff decided they would conduct a hard count of their drug stocks on a daily basis until they were able to identify the thief stealing from the pharmacy. They also wanted to upgrade the login system for student interns, but detectives warned them against that in order to avoid tipping the thief off.

With the surveillance cameras rolling, authorities were able to track employee movements in the pharmacy and, on May 27, observed Martsin grabbing a bottle of hydrocodone pills, shaking it, them removing it from the camera's view. He returned into view seconds later appearing to screw the lid back on the bottle. A subsequent check of stocks revealed the pharmacy was short by 45 hydrocodone pills that day.

On July 8, a review of surveillance video caught Martsin coming into work early, was observed removing bupreorphine film strips, a drug used to treat opiate addiction, from the pharmacy stocks and placed them in his personal backpack shortly before the beginning of his shift. He then logged into a computer and used it for several moments before logging in to work for the day at the beginning of his shift. A check later in the day confirmed the stocks of Bupreorphine film strips had been manually modified by 45.

The following day, more surveillance video was reviewed and again Martsin was observed before his shift taking bottles of suboxone and codeine cough syrup from pharmacy stocks, placed the items in his backpack, which he then moved to his locker, and then went to a computer terminal and worked on it for several moments. A pharmacy supervisor later confirmed that the stocks for suboxone and codeine cough syrup were both manually altered.

Investigators continued digging and found a correlation between the days that Martsin was working in the pharmacy and discrepancies in drug stocks or excess orders of hydrocodone. They found that, during the first quarter of 2013, 67,138 pills were stolen from the pharmacy, or approximately 745 a day. They went back and found a pattern of drug shortages that went all the way back to 2009.

Pharmacists indicated that consuming 745 pills in a day would be fatal, detectives began looking into Martsin's financial records. Martsin had told other employees that he had been traveling to Las Vegas and was a fan of playing Black Jack, and during their surveillance of him outside the hospital they saw him go into the Black Pearl Restaurant and Card Room in Spokane Valley. The Washington State Gambling Commission was brought into the investigation and they uncovered that Martsin had lost a total of $10,820 between January and May of this year, while the hospital reported his total income for the same period was $11,668.93. During the same period he was able to purchase a 1999 Mercedes Benz for $5,000 in cash and, in December 2012, purchased a 2013 Chevy Equinox with a $1,500 down payment.

Factoring in his gambling losses, car purchases and rent for the first part of this year, but not including other miscellaneous living expenses, Martsin was living at a loss of $586 for the first three months of the year, during which 67,138 hydrocodone pills disappeared from hospital stocks.

Martsin made his first court appearance Thursday and, because he does not have a criminal record, was released on his own recognizance.

Sacred Heart Medical Center reports it has changed its system for inventory management in its pharmacy in the wake of the Martsin investigation.