# FhirResource.Builder

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 16](https://developer.android.com/sdkExtensions)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/health/connect/datatypes/FhirResource.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                 ||
| ↳ | [android.health.connect.datatypes.FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#) |

Builder class for[FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource).

## Summary

|                                                                                                                                                                                                                                                                                              Public constructors                                                                                                                                                                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#Builder(android.health.connect.datatypes.FhirResource))`(`other:` `[FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource)`)` Constructs a clone of the other[FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource)instance.                                                                                                                                                     |
| [Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#Builder(android.health.connect.datatypes.FhirResource.Builder))`(`other:` `[FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#)`)` Constructs a clone of the other[FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#).                                                                                                                   |
| [Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#Builder(kotlin.Int,%20kotlin.String,%20kotlin.String))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `id:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `data:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Constructs a new[FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#)instance. |

|                                                                                                                                                                                                        Public methods                                                                                                                                                                                                        ||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource)                  | [build](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#build())`()` Returns a new instance of[FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource)with the specified parameters. |
| [FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#) | [setData](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#setData(kotlin.String))`(`data:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Sets the FHIR resource data in JSON representation.      |
| [FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#) | [setId](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#setId(kotlin.String))`(`id:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Sets the FHIR resource ID.                                     |
| [FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#) | [setType](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#setType(kotlin.Int))`(`type:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the FHIR resource type.                                      |

## Public constructors

### Builder

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 16](https://developer.android.com/sdkExtensions)  

```
Builder(other: FhirResource)
```

Constructs a clone of the other[FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource)instance.

|                                                                    Parameters                                                                     ||
|---------|------------------------------------------------------------------------------------------------------------------------------------------|
| `other` | [FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource):This value cannot be`null`. |

### Builder

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 16](https://developer.android.com/sdkExtensions)  

```
Builder(other: FhirResource.Builder)
```

Constructs a clone of the other[FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#).

|                                                                             Parameters                                                                             ||
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `other` | [FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#):This value cannot be`null`. |

### Builder

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 16](https://developer.android.com/sdkExtensions)  

```
Builder(
    type: Int, 
    id: String, 
    data: String)
```

Constructs a new[FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#)instance.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The FHIR resource type extracted from the "resourceType" field in`data`. Value is[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_IMMUNIZATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_IMMUNIZATION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_ALLERGY_INTOLERANCE](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_ALLERGY_INTOLERANCE:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_OBSERVATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_OBSERVATION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_CONDITION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_CONDITION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_PROCEDURE](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_PROCEDURE:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_MEDICATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_MEDICATION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_MEDICATION_REQUEST](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_MEDICATION_REQUEST:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_MEDICATION_STATEMENT](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_MEDICATION_STATEMENT:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_PATIENT](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_PATIENT:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_PRACTITIONER](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_PRACTITIONER:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_PRACTITIONER_ROLE](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_PRACTITIONER_ROLE:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_ENCOUNTER](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_ENCOUNTER:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_LOCATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_LOCATION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_ORGANIZATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_ORGANIZATION:kotlin.Int), or android.health.connect.datatypes.FhirResource.FHIR_RESOURCE_TYPE_DEVICE |
| `id`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The FHIR resource ID extracted from the "id" field in`data`. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `data` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The FHIR resource data in JSON representation. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |

|                                               Exceptions                                                ||
|--------------------------------------|-------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | if the provided FHIR resource`type`is not a valid supported type. |

## Public methods

### build

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 16](https://developer.android.com/sdkExtensions)  

```
fun build(): FhirResource
```

Returns a new instance of[FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource)with the specified parameters.

|                                                                  Return                                                                   ||
|--------------------------------------------------------------------------------------------------------------|-----------------------------|
| [FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource) | This value cannot be`null`. |

### setData

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 16](https://developer.android.com/sdkExtensions)  

```
fun setData(data: String): FhirResource.Builder
```

Sets the FHIR resource data in JSON representation.

|                                                      Parameters                                                      ||
|--------|--------------------------------------------------------------------------------------------------------------|
| `data` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

|                                                                           Return                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#) | This value cannot be`null`. |

### setId

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 16](https://developer.android.com/sdkExtensions)  

```
fun setId(id: String): FhirResource.Builder
```

Sets the FHIR resource ID. This is extracted from the "id" field in`data`. This is NOT a unique identifier among all[FhirResource](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource)s.

|                                                     Parameters                                                     ||
|------|--------------------------------------------------------------------------------------------------------------|
| `id` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

|                                                                           Return                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#) | This value cannot be`null`. |

### setType

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 16](https://developer.android.com/sdkExtensions)  

```
fun setType(type: Int): FhirResource.Builder
```

Sets the FHIR resource type. This is extracted from the "resourceType" field in`data`.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   ||
|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):Value is[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_IMMUNIZATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_IMMUNIZATION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_ALLERGY_INTOLERANCE](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_ALLERGY_INTOLERANCE:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_OBSERVATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_OBSERVATION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_CONDITION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_CONDITION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_PROCEDURE](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_PROCEDURE:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_MEDICATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_MEDICATION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_MEDICATION_REQUEST](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_MEDICATION_REQUEST:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_MEDICATION_STATEMENT](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_MEDICATION_STATEMENT:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_PATIENT](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_PATIENT:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_PRACTITIONER](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_PRACTITIONER:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_PRACTITIONER_ROLE](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_PRACTITIONER_ROLE:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_ENCOUNTER](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_ENCOUNTER:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_LOCATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_LOCATION:kotlin.Int),[android.health.connect.datatypes.FhirResource#FHIR_RESOURCE_TYPE_ORGANIZATION](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource#FHIR_RESOURCE_TYPE_ORGANIZATION:kotlin.Int), or android.health.connect.datatypes.FhirResource.FHIR_RESOURCE_TYPE_DEVICE |

|                                                                           Return                                                                           ||
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [FhirResource.Builder](https://developer.android.com/reference/kotlin/android/health/connect/datatypes/FhirResource.Builder#) | This value cannot be`null`. |

|                                               Exceptions                                                ||
|--------------------------------------|-------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | if the provided FHIR resource`type`is not a valid supported type. |