# 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
public final 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/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/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. 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 constructors |
|---|
| `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResourceId#MedicalResourceId(kotlin.String,kotlin.Int,kotlin.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html dataSourceId, int fhirResourceType, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html fhirResourceId )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResourceId#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResourceId` | `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResourceId#fromFhirReference(kotlin.String,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/java/lang/String.html fhirReference )` Creates a `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResourceId` instance from `dataSourceId` and `fhirReference`. |
| `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/records/MedicalResourceId#getDataSourceId()()` The ID of the `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalDataSource` where the data comes from. |
| `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/records/MedicalResourceId#getFhirResourceId()()` The ID of the FHIR resource. |
| `final int` | `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResourceId#getFhirResourceType()()` The type of the FHIR resource. |
| `int` | `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalResourceId#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/records/MedicalResourceId#toString()()` |

## Public constructors

### MedicalResourceId

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

```
public MedicalResourceId(
    @NonNull String dataSourceId,
    int fhirResourceType,
    @NonNull String fhirResourceId
)
```

## Public methods

### equals

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

### fromFhirReference

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

```
public static final @NonNull MedicalResourceId fromFhirReference(
    @NonNull String dataSourceId,
    @NonNull String fhirReference
)
```

Creates a `https://developer.android.com/reference/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/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.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html dataSourceId` | Represents ID of a `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalDataSource` where the data comes from. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html fhirReference` | 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/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). |

### 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 the `https://developer.android.com/reference/androidx/health/connect/client/records/MedicalDataSource` where the data comes from.

### getFhirResourceId

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

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

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

### getFhirResourceType

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

```
public final int getFhirResourceType()
```

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

### hashCode

```
public int hashCode()
```

### toString

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