# MedicalResourceId

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/records/MedicalResourceId.kt+class:androidx.health.connect.client.records.MedicalResourceId) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/health-connect#1.1.0)

*** ** * ** ***


```
@ExperimentalPersonalHealthRecordApi
class MedicalResourceId
```

<br />

*** ** * ** ***

A class to represent a unique identifier of a medical resource.

This class contains a set of properties that together represent a unique identifier of a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResource`.

The medical resource 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/kotlin/androidx/health/connect/client/HealthConnectFeatures#getFeatureStatus(kotlin.Int)` and pass `https://developer.android.com/reference/kotlin/androidx/health/connect/client/HealthConnectFeatures#FEATURE_PERSONAL_HEALTH_RECORD()` as an argument. An `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` would be thrown if the feature is not available.

## Summary

| ### Public companion functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId#fromFhirReference(kotlin.String,kotlin.String)(dataSourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, fhirReference: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId` instance from `dataSourceId` and `fhirReference`. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId#MedicalResourceId(kotlin.String,kotlin.Int,kotlin.String)( dataSourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, fhirResourceType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, fhirResourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html )` |

| ### Public functions |
|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId#hashCode()()` |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId#toString()()` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId#dataSourceId()` The ID of the `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalDataSource` where the data comes from. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId#fhirResourceId()` The ID of the FHIR resource. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId#fhirResourceType()` The type of the FHIR resource. |

## Public companion functions

### fromFhirReference

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

```
fun fromFhirReference(dataSourceId: String, fhirReference: String): MedicalResourceId
```

Creates a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalResourceId` instance from `dataSourceId` and `fhirReference`.

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

| Parameters |
|---|---|
| `dataSourceId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Represents ID of a `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalDataSource` where the data comes from. |
| `fhirReference: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The FHIR reference string typically extracted from the "reference" field in one FHIR resource (source), pointing to another FHIR resource (target) within the same data source, for example "Patient/034AB16". |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the provided `dataSourceId` is not a valid ID, the referenced resource type is not a valid `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/FhirResource` type supported by Health Connect, or `fhirReference` does not match with the pattern of `$fhir_resource_type/$fhir_resource_id`, where the FHIR resource type should align with the resource list in [the official FHIR website](https://build.fhir.org/resourcelist.html), and the FHIR resource ID should also follow the pattern described in [the official FHIR datatypes](https://build.fhir.org/datatypes.html#id). |

## Public constructors

### MedicalResourceId

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

```
MedicalResourceId(
    dataSourceId: String,
    fhirResourceType: Int,
    fhirResourceId: String
)
```

## Public functions

### equals

```
open operator fun equals(other: Any?): Boolean
```

### hashCode

```
open fun hashCode(): Int
```

### toString

```
open fun toString(): String
```

## Public properties

### dataSourceId

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

```
val dataSourceId: String
```

The ID of the `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalDataSource` where the data comes from.

### fhirResourceId

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

```
val fhirResourceId: String
```

The ID of the FHIR resource. This must be unique per `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/MedicalDataSource`.

### fhirResourceType

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

```
val fhirResourceType: Int
```

The type of the FHIR resource. It should be one of the values in `https://developer.android.com/reference/kotlin/androidx/health/connect/client/records/FhirResource.Companion.FhirResourceType`.

Value is one of the following:

- `1`
- `2`
- `3`
- `4`
- `5`
- `6`
- `7`
- `8`
- `9`
- `10`
- `11`
- `12`
- `13`
- `14`

<br />