# UpsertMedicalResourceRequest

Artifact: [androidx.health.connect:connect-client](https://developer.android.com/jetpack/androidx/releases/health-connect) [View Source](https://cs.android.com/search?q=file:androidx/health/connect/client/request/UpsertMedicalResourceRequest.kt+class:androidx.health.connect.client.request.UpsertMedicalResourceRequest) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

*** ** * ** ***

<br />

```
@ExperimentalPersonalHealthRecordApi
public final class UpsertMedicalResourceRequest
```

<br />

*** ** * ** ***

A request class for both inserting and updating `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResource`s.

From `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#dataSourceId()`, fhir resource type and fhir resource ID extracted from `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#data()`, a `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResourceId` will be constructed. If there already exists a `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResource` with that `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResourceId` in Health Connect, then that `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResource` will be updated, otherwise a new `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResource` will be inserted.

The data representation follows the [Fast Healthcare Interoperability Resources (FHIR)](https://hl7.org/fhir/) standard.

This feature is dependent on the version of HealthConnect installed on the device. To check if it's available call `https://developer.android.com/reference/androidx/health/connect/client/HealthConnectFeatures#getFeatureStatus(kotlin.Int)` and pass `https://developer.android.com/reference/androidx/health/connect/client/HealthConnectFeatures#FEATURE_PERSONAL_HEALTH_RECORD()` as an argument.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#UpsertMedicalResourceRequest(kotlin.String,androidx.health.connect.client.records.FhirVersion,kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html dataSourceId, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/records/FhirVersion fhirVersion, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html data )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#getData()()` The FHIR resource data in JSON representation. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#getDataSourceId()()` The ID of an **existing** `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalDataSource` where the data being inserted comes from. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/records/FhirVersion` | `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#getFhirVersion()()` The FHIR version being used for `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#data()`. |
| `int` | `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#toString()()` |

## Public constructors

### UpsertMedicalResourceRequest

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
public UpsertMedicalResourceRequest(
    @NonNull String dataSourceId,
    @NonNull FhirVersion fhirVersion,
    @NonNull String data
)
```

## Public methods

### equals

```
public boolean equals(Object other)
```

### getData

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
public final @NonNull String getData()
```

The FHIR resource data in JSON representation.

### getDataSourceId

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
public final @NonNull String getDataSourceId()
```

The ID of an **existing** `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalDataSource` where the data being inserted comes from.

### getFhirVersion

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

```
public final @NonNull FhirVersion getFhirVersion()
```

The FHIR version being used for `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#data()`. This must match `https://developer.android.com/reference/androidx/health/connect/client/request/UpsertMedicalResourceRequest#dataSourceId()`'s `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalDataSource#fhirVersion()`.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```