The Centers for Medicare and Medicaid (CMS) recently released Medicare provider enrollment data contained in the “Provider Enrollment, Chain, and Ownership System” or “PECOS”. CMS will release updates of these new public data about every quarter. The Medicare Enrollment data are useful because not only because they show if a provider participates in Medicare, but also organizational affiliations. For example, doctor A serves Medicare patients at hospital X and clinic Y. At clinic Y, doctors that take Medicare are doctors A, B, C, etc. This kind of information is useful to state Medicaid agencies, health plans, and the general public. This article explains how I created an API out of this public data.

Background on the Data Format

You can read all about the data here but the short version is that is the data are divided into three flat files: a base file containing basic demographic information, an (incomplete) address file, , and a reassignment file. In Medicare/PECOS terms, a reassignment is when a health provider reassigns the benefit to another party. Often practitioners are not paid by Medicare directly, but instead opt to “reassign” the benefit to an organization, such as a hospital, which is often where the provider receives his or her salary. This reassignment is indicative of an affiliation or work relationship.

Processing the Data

To make the PECOS data more accessible, the three flat files must be transformed. I first converted the three flat files into three MongoDB collections using the command-line utility “” found in  json-data-tools. After I indexed certain fields for speed, I wrote a custom script to sort through the data and yield two new MongoDB collections called “combined_organizations” and “combined_individuals”. Then using the RESTful API framework Djmongo as the RESTful Application server responsible for exposing the new data, voilà, I have a functioning RESTful API for Medicare providers. All the input required is the NPI number for the organization or individual in the URL.

Using the API

As an example, we can determine that “Leslie Crytser”, with the NPI of 1205824083, is enrolled with Medicare with two organizations, “Stony Point Surgery Center, LLC”, and “West End Anesthesia Group”. Here is an example using Leslie’s NPI:

And on the flip side, we can see which providers are setup to bill Medicare through a particular institution such as, “Stony Point Surgery Center, LLC”, with the NPI of 1255498457, using the following RESTful URL:


While functional, this PECOS API is still a work in progress. I plan to add address data and convert the documents into proper  FHIR resources. Currently, the address data only contain city, state, and zip code. I hope CMS decides to release the address line information in the future. After some further updates, I plan to make available the script that creates these files possibly within the Provider Data Tools package or elsewhere.

A final item to note is that just because a provider/institution is included in the PECOS data, doesn’t necessarily mean that any services were provided via Medicare. PECOS enrollments/re-enrollments work on a 5-year schedule; therefore the provider/institution may not currently be accepting Medicare patients.

I hope the health information ecosystem finds this somewhat useful. Feedback welcome.