Showing posts with label geocode. Show all posts
Showing posts with label geocode. Show all posts

January 12, 2023

Helping Patients Find Care: Calculating for "Near Me"

Our CarePrecise Gold™ and CarePrecise Platinum™ customers have been wild about the geographic lookup of healthcare providers since we first introduced geographic radius search more than ten years ago in our CP ListMaker™ software. It's not a hard thing to do, and I'll show you how it works so you can use it in your own applications!

 All you need is a Zip Code® table that incudes longitude and latitude for the center of each zip if you want a rough estimation of distance (included in CarePrecise Gold and Platinum), or you can purchase our SelectGeo database that has the rooftop-level latitude/longitude pair ("geocode") for every U.S. healthcare provider's address.

The code we offer here is also included in CP ListMaker as open source, and it relies on some of the built-in functions available in VBA: the Sin() and Cos() math functions (sine and cosine), and a few others like the Abs() function (returns the absolute of a number).  All of the build-in functions can be found fully described at

You can use the first function, CalcDistance(), to just return the distance between two points, or along with the others to list all of the spots in a miles radius from a central point. If you want to see only all of the physicians located within a radius, you would first create a query that filters for just physician locations. 

The Calculations

The magic happens with just three little Visual Basic for Application functions, shown below, which are pretty easily converted to VB or other code. After you create the CalcDistance() function, you send it the latitude and longitude of both locations, and it calculates the distance between them. 

Here's the VB/VBA code (shown as used in a Microsoft Access module)...


This function calculates the distance between latitude/longitude pairs, and returns it in miles.

Public Function CalcDistance(lat1, lon1, lat2, lon2) As Variant

'This function calculates the distance between two latitude/longitude pairs.

Dim theta

Dim dist As Double

theta = lon1 - lon2

dist = Sin(deg2rad(lat1)) * Sin(deg2rad(lat2)) + Cos(deg2rad(lat1)) * Cos(deg2rad(lat2)) * Cos(deg2rad(theta))

If dist > 0 Then

    dist = dist - 0.00000000000001

End If

dist = acos(dist)

dist = rad2deg(dist)

dist = dist * 69.09

CalcDistance = dist

End Function

The Radius Functions

Use these functions to return the points of interest within a radius from a central point:

Public Function acos(Rad)

  If CDbl(Abs(Rad)) <> 1 Then

  acos = (pi / 2) - Atn(Rad / Sqr(1 - Rad * Rad))

  ElseIf Rad = -1 Then

    acos = pi

  End If

End Function

Public Function deg2rad(Deg)

    deg2rad = CDbl(Deg * pi / 180)

End Function

Public Function rad2deg(Rad)

    rad2deg = CDbl(Rad * 180 / pi)

End Function

Geocoding Applications

One of the most common applications of this code, used in tandem with our healthcare provider databases, is in web apps that help patients find nearby providers. CarePrecise physician, hospital and clinic data powers many online applications and services – some may be familiar to you (we maintain NDAs with our clients so we won't list them here).

Once a patient has chosen a nearby provider, the CalcDistance() function is used to say just how far away it is. Integration with Google Maps or another mapping API can then map the route using the coordinates from our SelectGeo database. 

This is some of the hardest working code out there, and the uses abound. Play with it!

Note: CarePrecise does not offer technical support on the open source code we publish. We put all of our efforts into supporting our data products! To get a copy of CP ListMaker, complete with center-zip geocodes for all U.S. zips, you can either purchase CarePrecise Gold, Platinum, which have include data on all HIPAA-covered U.S. healthcare providers, or just the CP ListMaker add-on (with no provider data).
- Michael

January 6, 2023

Point of Interest Hooks for All U.S. Healthcare Providers

There's a new world of data available from a new class of vendors that can be linked together by the establishment of a universal Point of Interest code that pegs the physical location (the "where") and in some cases even encodes the business name (the "who"). In CarePrecise provider databases, POI-encoded facility information identifies essentially every facility in the U.S. healthcare system, and makes it connectable to other datasets. 

Visitor Traffic Reporting

Want to know how much visitor traffic a given doctor's office gets in a week? That data is available from third party sources, and can be linked in to the CarePrecise provider data using the Placekey™ POI code that CarePrecise appends to almost every* address in the NPI Registry and beyond.

Placekey Integration

CarePrecise invested heavily in creating a system that updates approximately 8 million healthcare provider POI records every month, keeping up with changes in address, new providers, and dropping deactivated providers. Furthermore, CarePrecise keeps historical data for every month, so that location changes can be tracked over time. 

Note: CarePrecise also provides a separate database, Select Geo, that contains latitude and longitude for every geocode-compatible U.S. healthcare provider location in the federal National Provider Identifier registry. This is used in applications that calculate distances and travel time between provider locations, and between patients and prospective providers, such as doctor-finder sites.

The addition of Placekey to CarePrecise data enables a clearer view into healthcare sites — clinics, physician offices, outpatient facilities, hospitals, and the whole panoply of facility types. Because CarePrecise links individual practitioners to their affiliated practice group businesses and the hospitals they are affiliated with, rich patterns emerge when connecting CarePrecise provider networks data to visitor traffic and revenues data. 

Competitive Healthcare, Meet a New Challenge

Whereas the healthcare industry is aggressively competitive, with organizations suppressing intelligence to the fullest extent possible, these new business intelligence pathways represent an unprecedented level of visibility into provider practices vis a vis their patient volumes. Reasonable, actionable assumptions can be made on practices' patient base—despite their closely-held business information—when cross-referenced with the demographic, psychographic, and economic data available on visitor traffic.

*Not all address fields can be parsed to produce a Placekey code or geocode; in particular, street addresses in Puerto Rico use so many non-normalized (GPS readable) addresses. Even CarePrecise's proprietary CoLoCode (uniform address code) has difficulty with many such addresses, though GPS compatibility is not a factor in creation of the CoLoCode.