## Hl7Segment.getComponent() method

Returns an HL7 component by field index and component index.

This is a shortcut for `getField(field).getComponent(component)`.

Note that both indexes are 1-based, not 0-based.

For example, to get the first component, use `getComponent(1, 1)`. This aligns with HL7 component names such as MSH.9.2.

**Signature:**

```typescript
getComponent(fieldIndex: number, component: number, subcomponent?: number, repetition?: number): string;
```

## Parameters

| Parameter  | Type   | Description                                  |
|------------|--------|----------------------------------------------|
| fieldIndex | number | The HL7 field index.                        |
| component   | number | The component index.                        |
| subcomponent | number | _(Optional)_ Optional subcomponent index.   |
| repetition  | number | _(Optional)_ Optional repetition index.     |

**Returns:**

string

The string value of the specified component.

- [Hl7Segment.getComponent() method](/content/docs/sdk/core.hl7segment.getcomponent#hl7segmentgetcomponent-method/index.html)  
- [Parameters](/content/docs/sdk/core.hl7segment.getcomponent#parameters/index.html)
