# Procedure

Source: https://www.flexpa.com/docs/fhir/procedure
Description: Procedure is the FHIR resource for actions performed on a patient. How Flexpa returns Procedures from EHRs and claims, with examples.

[**Procedure**](https://www.hl7.org/fhir/procedure.html) is a FHIR resource that represents an action that is or was performed on or for a patient. This can be a physical intervention like a surgery or operation, or less invasive like counseling, physiotherapy, or diagnostic procedures.

Procedure resources document what was done, when it was done, who performed it, and how it was coded. They are essential for understanding a patient's surgical and procedural history, tracking care delivery, and supporting utilization management and quality measurement workflows.

Procedure data is available from health insurers (derived from claims), medical record systems (from provider EHRs), and nationwide exchanges (via TEFCA). Procedures are coded with **CPT**, **HCPCS**, **ICD-10-PCS**, and **SNOMED CT** code systems.

Flexpa makes procedure data available as FHIR resources conforming to the [US Core STU 6.1 Procedure Profile](http://hl7.org/fhir/us/core/STU6.1/StructureDefinition-us-core-procedure.html) to support communicating [USCDI v3](https://www.healthit.gov/isa/united-states-core-data-interoperability-uscdi#uscdi-v3) data. Data types used in this reference are defined in the [FHIR R4 Data Types](https://hl7.org/fhir/R4/datatypes.html) specification.

*FHIR API*

```bash
https://api.flexpa.com/fhir/Procedure
```

```bash
https://api.flexpa.com/fhir/Procedure/[id]
```

```bash
https://api.flexpa.com/fhir/Patient/$everything
```

New to FHIR?

Related

## Schema

The FHIR R4 [**Procedure**](https://hl7.org/fhir/R4/procedure.html) resource represents an activity performed on, with, or for a patient as part of the provision of care. The [US Core Procedure Profile](http://hl7.org/fhir/us/core/STU6.1/StructureDefinition-us-core-procedure.html) constrains this resource to ensure consistent representation across US healthcare systems.

Procedures are structured around the core question of **what** was done, **when** it was performed, **who** performed it, and **why**. The `code` element is the central data point, representing the specific procedure using standard medical coding systems.

**Elements**

- `meta` (Meta):
Metadata about the resource. See also [Tags](https://www.flexpa.com/docs/records#tags) defined by Flexpa.

  - `lastUpdated` (instant):
The last time the procedure was updated in the Endpoint's system of record

- `status` (code):
The status of the procedure

- `code` (CodeableConcept):
The specific procedure performed. Bound to the [US Core Procedure Codes](http://hl7.org/fhir/us/core/STU6.1/ValueSet-us-core-procedure-code.html) value set (extensible), which includes CPT, HCPCS, SNOMED CT, and ICD-10-PCS codes.

- `subject` (Reference(Patient)):
Reference to the [Patient](https://www.flexpa.com/docs/fhir/patient) on whom the procedure was performed

- `encounter` (Reference(Encounter)):
Reference to the [Encounter](https://www.flexpa.com/docs/fhir/encounter) during which the procedure was performed

- `performedDateTime` (dateTime):
When the procedure was performed as a single point in time - mutually exclusive with `performedPeriod`

- `performedPeriod` (Period):
When the procedure was performed as a time range - mutually exclusive with `performedDateTime`

  - `start` (dateTime):
Starting time of the procedure

  - `end` (dateTime):
End time of the procedure

- `performer` (BackboneElement[]):
The people who performed the procedure

  - `function` (CodeableConcept):
The type of involvement of the performer in the procedure

  - `actor` (Reference(Practitioner|PractitionerRole|Organization)):
The practitioner who was involved in the procedure

  - `onBehalfOf` (Reference(Organization)):
Organization the performer was acting for

- `reasonCode` (CodeableConcept[]):
Coded reason why the procedure was performed

- `reasonReference` (Reference(Condition|Observation|Procedure|DiagnosticReport)[]):
Reference to the justification for the procedure, such as a [Condition](https://www.flexpa.com/docs/fhir/condition) that was being treated

- `bodySite` (CodeableConcept[]):
Target body sites for the procedure

*Procedure Example*

```json
{
  "resourceType": "Procedure",
  "id": "3255ee92-6ac7-6bca-9c11-e9ba988bb239",
  "meta": {
    "lastUpdated": "2024-03-15T10:30:00Z",
    "profile": [
      "http://hl7.org/fhir/us/core/StructureDefinition/us-core-procedure"
    ]
  },
  "status": "completed",
  "code": {
    "coding": [
      {
        "system": "http://www.ama-assn.org/go/cpt",
        "code": "27447",
        "display": "Arthroplasty, knee, condyle and plateau"
      }
    ],
    "text": "Total knee replacement"
  },
  "subject": {
    "reference": "Patient/example"
  },
  "encounter": {
    "reference": "Encounter/example"
  },
  "performedDateTime": "2024-01-15",
  "performer": [
    {
      "function": {
        "coding": [
          {
            "system": "http://snomed.info/sct",
            "code": "304292004",
            "display": "Surgeon"
          }
        ]
      },
      "actor": {
        "identifier": {
          "system": "http://hl7.org/fhir/sid/us-npi",
          "value": "1234567890"
        },
        "display": "Dr. Robert Johnson, MD"
      }
    }
  ],
  "reasonCode": [
    {
      "coding": [
        {
          "system": "http://hl7.org/fhir/sid/icd-10-cm",
          "code": "M17.12",
          "display": "Unilateral primary osteoarthritis, left knee"
        }
      ]
    }
  ],
  "bodySite": [
    {
      "coding": [
        {
          "system": "http://snomed.info/sct",
          "code": "72696002",
          "display": "Knee region structure"
        }
      ]
    }
  ]
}
```

#### Example FHIRPaths

| Data Point | FHIRPath Expression |
| --- | --- |
| Procedure CPT codes | `code.coding.where(system = 'http://www.ama-assn.org/go/cpt')` |
| Procedure HCPCS codes | `code.coding.where(system = 'https://www.cms.gov/Medicare/Coding/HCPCSReleaseCodeSets')` |
| Procedure ICD-10-PCS codes | `code.coding.where(system = 'http://www.cms.gov/Medicare/Coding/ICD10')` |
| All procedure codes | `code.coding` |
| Procedure date (with fallback) | `(performedDateTime \| performedPeriod.start \| performedPeriod.end).first()` |
| Performer NPI | `performer.actor.identifier.where(system = 'http://hl7.org/fhir/sid/us-npi')` |
| Reason codes (ICD-10-CM) | `reasonCode.coding.where(system = 'http://hl7.org/fhir/sid/icd-10-cm')` |
| Body site | `bodySite.coding` |

## API

### Read

A read is the most basic operation in FHIR. It allows you to retrieve the current version of a single resource by its ID.

For a full list of available Resources, please refer to the [FHIR Resources documentation](https://www.flexpa.com/docs/fhir/introduction).

**Request headers**

- `Authorization` (string):
An `Authorization: Bearer` header value must presented with a [Patient Access Token](#patient-access-token) or an [Application Access Token](#application-access-token)

**Request path parameters**

- `identifier` (string):
The identifier of the resource to be retrieved - used in the last part of the URL path segment

**Error codes**

- `transient` (429 status code):
The API is expected to return a 429 status code until the data is ready to be retrieved.
This error is returned by the API while in the [initial sync period](https://www.flexpa.com/docs/records#sync-job-states). Most syncs complete in under a minute, but patients with large record sets on slower endpoints can take several minutes.

You will need to implement retry logic to handle this error. If you are using the [Node SDK](https://flexpa.com/docs/records/node-sdk) which we demonstrate in our [Quickstart guide](https://www.flexpa.com/docs/guides/quickstart), retry logic is already built in and you don't need to implement it yourself.

- `processing` (422 status code): The API is expected to return a 422 when Flexpa fails to synchronize any resources from the Endpoint for the requested Patient. Please re-authorize or reach out to support.

*Request*

```bash
ACCESS_TOKEN=patient-access-token

curl https://api.flexpa.com/fhir/Procedure/3255ee92-6ac7-6bca-9c11-e9ba988bb239 \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```

```js
const ACCESS_TOKEN="patient-access-token"

const response = await fetch("https://api.flexpa.com/fhir/Procedure/3255ee92-6ac7-6bca-9c11-e9ba988bb239", {
  headers: {
    "content-type": "application/json",
    "authorization": `Bearer ${ACCESS_TOKEN}`,
  },
});

const resource = await response.json();
```

---

### Search

Searches on Flexpa API follow the RESTful style of the FHIR specification by submitting a GET HTTP request to the base URL of the resource with parameters to define the exact search criteria to filter the response.

**Request headers**

- `Authorization` (string):
An `Authorization: Bearer` header value must presented with a [Patient Access Token](#patient-access-token) or an [Application Access Token](#application-access-token)

**Search parameters**

**Note:**
Flexpa supports all Procedure `SearchParameter` values defined in the [FHIR R4 specification](https://www.hl7.org/fhir/R4/procedure.html#search)

- `_id` (token):
The logical ID of the resource

- `patient` (reference):
Search by subject - a patient

- `date` (date):
When the procedure was performed

- `code` (token):
A code to identify a procedure

- `status` (token):
Current status of the procedure

- `identifier` (token):
A unique identifier for a procedure

- `encounter` (reference):
Encounter created as part of

- `performer` (reference):
The reference to the practitioner

- `reason-code` (token):
Coded reason procedure performed

- `reason-reference` (reference):
The justification that the procedure was performed

**Error codes**

- `transient` (429 status code):
The API is expected to return a 429 status code until the data is ready to be retrieved.
This error is returned by the API while in the [initial sync period](https://www.flexpa.com/docs/records#sync-job-states). Most syncs complete in under a minute, but patients with large record sets on slower endpoints can take several minutes.

You will need to implement retry logic to handle this error. If you are using the [Node SDK](https://flexpa.com/docs/records/node-sdk) which we demonstrate in our [Quickstart guide](https://www.flexpa.com/docs/guides/quickstart), retry logic is already built in and you don't need to implement it yourself.

- `processing` (422 status code): The API is expected to return a 422 when Flexpa fails to synchronize any resources from the Endpoint for the requested Patient. Please re-authorize or reach out to support.

*Request*

```bash
ACCESS_TOKEN=patient-access-token

curl https://api.flexpa.com/fhir/Procedure \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```

```js
const ACCESS_TOKEN="patient-access-token"

const response = await fetch("https://api.flexpa.com/fhir/Procedure", {
  headers: {
    "content-type": "application/json",
    "authorization": `Bearer ${ACCESS_TOKEN}`,
  },
});

const resource = await response.json();
```
