Well, you don't end up having to query their DB directly, you can do it via standardized IHE ITI XDS/XCA over a network like CareQuality. There are startups like Particle that can do it as a SaaS.
Full disclosure, I was an early employee and wrote the first integrations, so I'm likely not the right person to ask. https://www.particlehealth.com/ should have details.