> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clinikapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# LabResultsWidget

> Lab report ordering widget with LOINC codes and category support.

# LabResultsWidget

Orders lab reports (FHIR DiagnosticReport) with LOINC coding, category classification, and effective date/period support.

## Usage

```tsx theme={null}
import { LabResultsWidget } from '@clinikapi/react';

<LabResultsWidget
  proxyUrl="/api/clinik"
  patientId="pt_abc123"
  theme="light"
/>
```

## Props

| Prop        | Type                | Required | Description       |
| ----------- | ------------------- | -------- | ----------------- |
| `proxyUrl`  | `string`            | Yes      | Backend proxy URL |
| `patientId` | `string`            | Yes      | Patient ID        |
| `theme`     | `'light' \| 'dark'` | No       | Color theme       |

## Features

* Lab order creation with LOINC codes
* Category classification (LAB, RAD, PAT)
* Status tracking (registered → preliminary → final)
* Support for `effectiveDateTime` and `effectivePeriod`
* `basedOn` references to ServiceRequest orders
* Media/image attachments
* Conclusion text and coded findings
* Linked observation results (`resultIds`)
* Specimen references
* Attached documents (`presentedForm`)

## Proxy Action

The widget sends `labs.create` with:

```json theme={null}
{
  "action": "labs.create",
  "data": {
    "patientId": "pt_abc123",
    "status": "preliminary",
    "code": {
      "system": "http://loinc.org",
      "code": "24331-1",
      "display": "Lipid Panel"
    },
    "category": "LAB",
    "effectiveDateTime": "2025-01-15T10:30:00Z"
  }
}
```

## Categories

| Code  | Description |
| ----- | ----------- |
| `LAB` | Laboratory  |
| `RAD` | Radiology   |
| `PAT` | Pathology   |

## Reading Lab Results

For displaying lab results, your proxy should return enriched data:

```ts theme={null}
// Proxy endpoint for reading labs
const { data } = await clinik.labs.read(labId, {
  include: ['Observation'],
});
// Returns: report with linked observations, conclusion, effectivePeriod, etc.
```
