# Reading Data

This section contains information about methods for reading data from the CDR.

# Diff Operation

The `$diff` operation can be used to generate a differential between two versions of a resource, or even two different resources of the same type.

Differentials generated by this operation are in [FHIRPath Patch](/content/docs/fhir_standard/fhir_patch.html) format.

In generated differentials, where a value has changed (i.e. a **replace** operation), an additional part value will be present on the given operation called `previousValue`. This part shows the value as it was in the _from_ version of the resource.

# Diff Instance

When the $diff operation is invoked at the instance level (meaning it is invoked on a specific resource ID), it will compare two versions of the given resource.

## Parameters

- `fromVersion=[versionId]`: ( _optional_) If specified, compare using this version as the source. If not specified, the immediately previous version will be compared.
- `includeMeta=true`: ( _optional_) If specified, changes to Resource.meta will be included in the diff. This element is omitted by default.

To invoke:

```http
GET http://fhir.example.com/baseR4/Patient/123/$diff
```

Copy

The server will produce a response resembling the following:

```json
{
  "resourceType": "Parameters",
  "parameter": [ {\
    "name": "operation",\
    "part": [ {\
      "name": "type",\
      "valueCode": "replace"\
    }, {\
      "name": "path",\
      "valueString": "Patient.name.family"\
    }, {\
      "name": "previousValue",\
      "valueId": "Smyth"\
    }, {\
      "name": "value",\
      "valueId": "SmithB"\
    } ]\
  } ]
}
```

Copy

# Diff Type

When the $diff operation is invoked at the type level (meaning it is invoked on a resource type but not on an individual instance), it will compare two different resources of the same type.

## Parameters

- `from=[reference]`: Specifies the source of the comparison. The value must include a resource type and a resource ID, and can optionally include a version, e.g. `Patient/123` or `Patient/123/_history/2`.
- `to=[reference]`: Specifies the target of the comparison. The value must include a resource type and a resource ID, and can optionally include a version, e.g. `Patient/123` or `Patient/123/_history/2`.
- `includeMeta=true`: ( _optional_) If specified, changes to Resource.meta will be included in the diff. This element is omitted by default.

To invoke:

```http
GET http://fhir.example.com/baseR4/$diff?from=Patient/1&to=Patient/2
```

Copy

The server will produce a response resembling the following:

```json
{
  "resourceType": "Parameters",
  "parameter": [ {\
    "name": "operation",\
    "part": [ {\
      "name": "type",\
      "valueCode": "replace"\
    }, {\
      "name": "path",\
      "valueString": "Patient.id"\
    }, {\
      "name": "previousValue",\
      "valueId": "1"\
    }, {\
      "name": "value",\
      "valueId": "2"\
    } ]\
  } ]
}
```

Copy

# $everything operation

The HAPI-FHIR server supports the [Patient/$everything operation](http://hl7.org/fhir/operation-patient-everything.html) and accepts all the IN parameters defined in the documentation. Additionally, Smile CDR allows you to provide an `_id` parameter, in order to filter the set of patients you wish to get everything for. The following requests are all equivalent, and these example queries fetch everything for Patient/1, Patient/2 and Patient/3:

1. Using a GET.

```http
GET [base]/Patient/$everything?_id=1,2,3
```

Copy

2. Using a GET with alternate \_id parameter style.

```http
GET [base]/Patient/$everything?_id=1&_id=2&_id=3
```

Copy

4. Using a POST.

```http
POST [base]/Patient/$everything
```

Copy

```json
{
   "resourceType": "Parameters",
   "parameter": [ {\
      "name": "_id",\
      "valueString": "1"\
   }, {\
      "name": "_id",\
      "valueString": "2"\
   },{\
      "name": "_id",\
      "valueString": "3"\
   }\
   ]
}
```

Copy

5. Making 3 individual instance-level $everything operation calls.

```http
GET [base]/Patient/1/$everything
GET [base]/Patient/2/$everything
GET [base]/Patient/3/$everything
```

Copy

Below is a table containing all the possible resources the `$everything` command can return:

| Resource List |
| --- |
| Account |
| AdverseEvent |
| AllergyIntolerance |
| Appointment |
| AppointmentResponse |
| AuditEvent |
| Basic |
| BodyStructure |
| CarePlan |
| CareTeam |
| ChargeItem |
| Claim |
| ClaimResponse |
| ClinicalImpression |
| Communication |
| CommunicationRequest |
| Composition |
| Condition |
| Consent |
| Coverage |
| CoverageEligibilityRequest |
| CoverageEligibilityResponse |
| DetectedIssue |
| Device |
| DeviceRequest |
| DeviceUseStatement |
| DiagnosticReport |
| DocumentManifest |
| DocumentReference |
| Encounter |
| EnrollmentRequest |
| EpisodeOfCare |
| ExplanationOfBenefit |
| FamilyMemberHistory |
| Flag |
| Goal |
| Group |
| ImagingStudy |
| Immunization |
| ImmunizationEvaluation |
| ImmunizationRecommendation |
| Invoice |
| List |
| MeasureReport |
| Media |
| Medication |
| MedicationAdministration |
| MedicationDispense |
| MedicationRequest |
| MedicationStatement |
| MolecularSequence |
| NutritionOrder |
| Observation |
| Organization |
| Person |
| Practitioner |
| Procedure |
| Provenance |
| QuestionnaireResponse |
| RelatedPerson |
| RequestGroup |
| ResearchSubject |
| RiskAssessment |
| Schedule |
| ServiceRequest |
| Specimen |
| SupplyDelivery |
| SupplyRequest |
| VisionPrescription |

[Creating Data](/content/docs/fhir_repository/creating_data.html)

Reading Data

FHIR Storage

[FHIR Storage Modules](/content/docs/fhir_repository/fhir_storage_modules.html)
[FHIR Endpoint Module](/content/docs/fhir_repository/fhir_endpoint_module.html)
[FHIRWeb Console](/content/docs/fhir_repository/fhirweb_console.html)
[OpenAPI / Swagger Support](/content/docs/fhir_repository/openapi_swagger.html)
[FHIR Endpoint Customization](/content/docs/fhir_repository/fhir_endpoint_customization.html)
[Resource IDs](/content/docs/fhir_repository/resource_ids.html)
[Search Parameters](/content/docs/fhir_repository/search_parameters.html)
[Search Parameter Features](/content/docs/fhir_repository/search_parameter_features.html)
[Phonetic Search Parameters](/content/docs/fhir_repository/search_parameter_phonetic.html)
[Search Parameter Tuning](/content/docs/fhir_repository/search_parameter_tuning.html)
[Search Parameter Reindexing](/content/docs/fhir_repository/search_parameter_reindexing.html)
[Searching for Data](/content/docs/fhir_repository/searching_data.html)
[Creating Data](/content/docs/fhir_repository/creating_data.html)
[Reading Data](/content/docs/fhir_repository/reading_data.html)
[Updating Data](/content/docs/fhir_repository/updating_data.html)
[Deleting Data](/content/docs/fhir_repository/deleting_data.html)
[Binary Data](/content/docs/fhir_repository/binary_data.html)
[External Object Storage](/content/docs/fhir_repository/external_object_storage.html)
[Externalized Resource Body Storage](/content/docs/fhir_repository/externalized_resource_body_storage.html)
[Request Tracing and Provenance](/content/docs/fhir_repository/tracing_and_provenance.html)
[Resource Versions and Versioned References](/content/docs/fhir_repository/resource_versions_and_versioned_references.html)
[Tags, Profiles, and Security Labels](/content/docs/fhir_repository/tags_profiles_and_labels.html)
[Partitioning and Multitenancy](/content/docs/fhir_repository/partitioning.html)
[Patient ID Partitioning Modes](/content/docs/fhir_repository/patient_id_partitioning.html)
[Custom Resource Types](/content/docs/fhir_repository/custom_resource_types.html)
[Batch and Scheduled Jobs](/content/docs/fhir_repository/batch_and_scheduled_jobs.html)
[Tokenization](/content/docs/fhir_repository/tokenization.html)
[Bulk Resource Modification](/content/docs/fhir_repository/bulk_modification.html)

[Updating Data](/content/docs/fhir_repository/updating_data.html)
