Sam Edwards | Caiaimage | Getty Images

Many companies with large offices are now offering on-site or nearby medical offices for workers to access high-quality care. That's the case for all the large technology companies, like Facebook and Apple, which have clinics on campus to serve thousands of employees' medical needs. But something has changed in the past few years. Rather than continue to work with third-party companies to operate these clinics, a few technology companies -- most notably, Apple and Amazon — are branching out on their own. CNBC reported earlier this month that Amazon is launching a clinic in the coming months for a small number of workers, with a goal of expanding in early 2019. Apple, meanwhile, has been hiring like mad for its employee health clinics, which operate under a separate legal subsidiary called AC Wellness. So why are these companies getting into primary care? It's not their core competency, and it's not exactly a money-maker in the short-term. We talked to a group of health experts in the space to find out. Tweet

To control health costs

Companies that are looking to manage their out-of-control health costs are all coming to the same conclusion. To really make a dent, they need to get involved when it comes to the most important, and most human, part of health care. And that's the relationship between the patient and the primary care practitioner. A family doc can steer a patient to expensive specialists and to unnecessary tests and procedures, which adds to an employer's bottom line. Or they can help manage the patients' lifestyle, steer them to in-network specialists, and discourage them from taking expensive medicines they don't need. The latter can save an employer a lot of money in the long-run. "Employers generally have become extremely frustrated about the enormous expense of the healthcare system as well as the inconsistent, at best, quality experienced by their employees," explains Micah Weinberg, president of the Bay Area Council Economic Institute, a think tank focusing on local policy issues. "So seeing our two 'trillion dollar' companies making this investment is not shocking." (Both Amazon and Apple recently reached the elusive trillion-dollar market cap). "If you want something done right," he said, "you have to do it yourself."

To test new products without risking leaks

To get to their next trillion dollars, Apple and Amazon are realizing that they can't ignore opportunities in the health sector. But to get that right, they need to focus on the things they're good at. Amazon is focusing on its area of expertise: the supply chain. The company bought PillPack, an internet pharmacy, and it has a grocery delivery business through Whole Foods. It is also working with two other employers, J.P. Morgan and Berkshire Hathaway, on an initiative to reduce health care costs. Apple is taking a different approach in building health-tracking tools for the iPhone and Apple Watch. It has also made a number of small acquisitions in the space, including a medical record technology start-up called Gliimpse to help users access and aggregate their health information. But these are just the things that we know about. Undoubtedly, Apple and Amazon, which both have a strong focus on research and development, are thinking about new health-focused hardware and software products for the next decade. And where better to try them out than by talking to their doctors and garnering feedback from real patients (incidentally, their own workers)? It makes a lot of sense, health experts say, especially for tech companies that are notoriously obsessed with secrecy. "If Amazon and Apple had considered these clinics for internal use only, they would have likely outsourced to any of the number of clinics that offer on-site clinic services," said Nikhil Krishnan, a health-focused analyst with CB Insights, a market research firm. "The fact that Apple and Amazon are testing it in-house means they want to test the model with employees, iterate, and eventually release this product to their respective customers." Jami Doucette, president of Premise Health, a company that helps run employer medical clinics, agrees. "Both groups are using themselves as a test group to learn more quickly, work out the kinks more rapidly, and bring a solution to market in a shorter timeframe," Doucette said.

Money, money, money

It might be expensive to get employee health clinics up and running, but it might well prove to be an investment that pays off in the future. Weinberg from the Bay Area Council Economic Institute has seen tech companies try and fail to get into health care, if they assume there's a simple tech solution. Health care is "devilishly complicated," he says. In his experience, those that do succeed will be richly rewarded, while having an opportunity to make a difference. And one of the best ways to get there, says Weinberg, is to get into the business of both patient care and population health management, which includes tools to keep a population of patients as healthy as possible.