# Hospitals: pharma hospitals

The pharma hospitals commands, with each dataset's columns, units and source credit.

A US hospital in the registry of the Centers for Medicare & Medicaid Services (CMS), keyed on its Certification Number, with its type, ownership, beds, own geocoded coordinate, bed and facility-change history and the trial sites that match it.

Id: A CMS Certification Number (CCN), the six-character Medicare provider id the web page address carries (/hospitals/<ccn>). Every hospital dataset takes this same id in its ccn column. A retired CCN that has one merge-candidate successor is accepted and answers its successor with a redirect. Matching is exact.

## Commands

| Command | Reads |
| --- | --- |
| pharma hospitals list | Hospitals |
| pharma hospitals get <id> | One hospital and the datasets reachable from it |
| pharma hospitals get <id> hospital-beds-yearly | Hospital beds by year |
| pharma hospitals get <id> hospital-facility-changes | Hospital facility changes |
| pharma hospitals get <id> investigator-hospitals | Investigator hospital affiliations |
| pharma hospitals get <id> site-hospitals | Site hospitals |

Every command takes the paging, sorting and output flags described on the CLI page; the CLI prints the source credit with every result.

- [Pharma Observatory CLI](https://pharmaobservatory.com/cli)

## Hospitals

**Command**

```sh
pharma hospitals list
```

The hospitals object type's primary dataset: one row per US hospital in the registry of the Centers for Medicare & Medicaid Services (CMS), keyed on its CMS Certification Number (CCN), with type, ownership, beds, teaching status, emergency services and its own geocoded coordinate. A hospital that never hosted a trial is included.

One row per: CMS hospital (CMS Certification Number). Key columns: `ccn`.

Source: CMS hospital registry, US Centers for Medicare & Medicaid Services (Public domain); Amazon Location Service (AWS Service Terms); Dartmouth Atlas Data (Dartmouth Atlas Data Terms of Use)

| Column | Type | Unit | Description |
| --- | --- | --- | --- |
| ccn | text |  | CMS Certification Number, the six-character Medicare provider id the hospital page address carries. |
| hospital_name | text |  | The hospital's facility name in the CMS registry. |
| city | text |  | The hospital's city. |
| state | text |  | The hospital's two-letter state or territory code. |
| bed_count | integer | beds | Certified bed count in the latest registry file. Null when the file has no bed record. |
| hospital_type | text |  | The CMS hospital type. |
| ownership | text |  | The CMS ownership category. |
| is_teaching | boolean |  | Whether the hospital is a teaching hospital. |
| emergency_services | text |  | Whether the hospital provides emergency services, as CMS files it. Null where CMS left it blank. |
| latitude | numeric | degrees | Latitude of the hospital's own coordinate. Null exactly when geocode_method is unmatched. |
| longitude | numeric | degrees | Longitude of the hospital's own coordinate. Null exactly when geocode_method is unmatched. |
| geocode_method | text |  | How the coordinate was placed: als (Amazon Location Service address match), zip_centroid (coarse ZIP-code centroid) or unmatched (no coordinate). |
| hrr_num | integer |  | Dartmouth Atlas Hospital Referral Region number. Null when hrr_match is not zip. |
| hrr_name | text |  | The Hospital Referral Region, named for its hub city and state. The hub state can differ from the hospital's own state. |
| hsa_num | integer |  | Dartmouth Atlas Hospital Service Area number. Null when hrr_match is not zip. |
| hsa_name | text |  | The Hospital Service Area, named for its hub city and state. |
| hrr_match | text |  | zip (region found by ZIP), territory_uncovered (the Atlas does not cover US territories) or zip_unmatched (a mainland ZIP absent from the 2019 crosswalk). |

## Hospital beds by year

**Command**

```sh
pharma hospitals get <id> hospital-beds-yearly
```

The certified bed count of a US hospital in the Provider of Services (POS) file history of the Centers for Medicare & Medicaid Services (CMS), one row per CMS Certification Number and calendar year.

One row per: hospital (CCN) and calendar year. Key columns: `ccn`, `year`.

Source: CMS hospital registry, US Centers for Medicare & Medicaid Services (Public domain)

| Column | Type | Unit | Description |
| --- | --- | --- | --- |
| ccn | text |  | CMS Certification Number of the hospital. |
| year | integer | calendar year | The calendar year. |
| bed_count | integer | beds | Certified bed count that year. |
| is_teaching | boolean |  | Whether the hospital was a teaching hospital that year. |
| pos_vintage | text |  | The Provider of Services file vintage the row comes from. |
| as_of | date |  | The as-of date of that file. |

## Hospital facility changes

**Command**

```sh
pharma hospitals get <id> hospital-facility-changes
```

The change events of a US hospital across the Provider of Services (POS) file history of the Centers for Medicare & Medicaid Services (CMS): a rename, an appearance or disappearance of its CMS Certification Number, and merge or split candidates. One row per hospital, date and change type.

One row per: change event (CCN, as-of date, change type). Key columns: `ccn`, `as_of`, `change_type`.

Source: CMS hospital registry, US Centers for Medicare & Medicaid Services (Public domain)

| Column | Type | Unit | Description |
| --- | --- | --- | --- |
| ccn | text |  | CMS Certification Number of the hospital the event is about. |
| as_of | date |  | The quarter-end date the change was detected at. |
| change_type | text |  | rename (same CCN, new provider name), appeared (CCN enters the series after its start), disappeared (CCN leaves it before its end), merge_candidate (a retired CCN with one successor) or split_candidate (a retired CCN with several). |
| from_value | text |  | The provider name before the change (rename), or the last name of the retired CCN (disappeared, merge and split candidates). Null on appeared. |
| to_value | text |  | The provider name after the change (rename), the first name of the new CCN (appeared, merge and split candidates). Null on disappeared. |
| related_ccn | text |  | The nearest later CCN that shares the retired CCN's normalised name, city and state. Set on merge_candidate and split_candidate rows. |
| successor_ccn | text |  | The CCN that absorbed the retired one. Set on merge_candidate rows only; null on split_candidate, where more than one CCN matches. |

## Investigator hospital affiliations

**Command**

```sh
pharma hospitals get <id> investigator-hospitals
```

The CMS hospitals an investigator is affiliated with, one row per investigator and hospital, from the CMS facility affiliation file keyed on the person's NPI.

One row per: resolved investigator and CMS hospital. Key columns: `investigator_person_id`, `ccn`.

Source: CMS Care Compare (Doctors and Clinicians national file and facility affiliations), US Centers for Medicare & Medicaid Services (Public domain); CMS hospital registry, US Centers for Medicare & Medicaid Services (Public domain); NPPES NPI Registry, US Centers for Medicare & Medicaid Services (Public domain)

| Column | Type | Unit | Description |
| --- | --- | --- | --- |
| investigator_person_id | text |  | The investigator's resolved person key, the id in the web page address (/people/<id>). The entry key of the investigators object type. |
| ccn | text |  | CMS Certification Number, the six-character Medicare provider id the hospital page address carries. |
| hospital_name | text |  | The hospital's facility name in the CMS directory. |
| city | text |  | The hospital's city in the CMS directory. |
| state | text |  | The hospital's state in the CMS directory. |
| facility_types | text[] |  | The CMS facility types of the affiliation. |

## Site hospitals

**Command**

```sh
pharma hospitals get <id> site-hospitals
```

The US hospital a site record matches in the hospital registry of the Centers for Medicare & Medicaid Services (CMS), one row per matched site, with the hospital's type, ownership and beds.

One row per: site matched to a CMS hospital. Key columns: `site_id`.

Source: CMS hospital registry, US Centers for Medicare & Medicaid Services (Public domain); Amazon Location Service (AWS Service Terms)

| Column | Type | Unit | Description |
| --- | --- | --- | --- |
| site_id | text |  | The site key: one facility spelling from the registry. |
| ccn | text |  | CMS Certification Number of the matched hospital. |
| hospital_name | text |  | The hospital's name in the CMS registry. |
| hospital_type | text |  | The CMS hospital type. |
| ownership | text |  | The CMS ownership category. |
| bed_count | integer | beds | Certified bed count in the latest registry file. |
| is_teaching | boolean |  | Whether the hospital is a teaching hospital. |
| hospital_latitude | numeric | degrees | Latitude of the hospital. |
| hospital_longitude | numeric | degrees | Longitude of the hospital. |
| geocode_method | text |  | How the hospital's coordinate was placed. |
| ccn_n_trials | bigint | trials | Registered trials across the hospital's matched site records. |
| ccn_n_site_variants | bigint | site records | Site records matched to the same hospital. |
| is_primary_site | boolean |  | True for the matched site record with the most trials for this hospital. |
