useUrineTests
Use useUrineTests() to load urine-analysis observations and map them to urine measurement data in a React component.
Before you use it
Render the component below OvokProvider and keep it in a client-side React component. The hook uses the configured client to search for urine-analysis observations.
Inputs
useUrineTests() takes no arguments. It always searches the urine-analysis measurement category. It does not accept a patient or date filter.
If the screen needs patient or period filtering, use useObservations and select the urine-analysis category there.
Return value
The hook returns the same fields as useObservations:
| Field | Meaning |
|---|---|
measurements | Mapped urine-analysis measurements. Each record can include recorded time, optional analyte values, and coded urine values. |
observations | The original observation resources returned by the search, as a read-only list. |
loading | Whether the search is still in progress. |
error | An Error when the search reports a failure; otherwise undefined. |
When the search succeeds with no matching data, the measurement and observation lists are empty after loading completes. Check error to distinguish an empty result from a failed search.
Urine measurement values
Mapped records can contain optional numeric analyte values. Values may be absent when the source data did not provide them. The measurement type requires a urineValues array, but the current save workflow uses the numeric fields to create analyte observations; it does not serialize arbitrary entries from that array. Keep the returned observations when the screen needs the original resource details.
Present returned values with their units and labels. This hook does not interpret a urine test or provide a diagnosis. See the urine analysis type page for field units and mapping details.
Example
Use the shared search states before rendering the mapped urine values:
import { useUrineTests } from '@ovok/core';
export function UrineTestSummary() {
const { measurements, loading, error } = useUrineTests();
if (loading) return <p>Loading urine tests…</p>;
if (error) return <p role="alert">{error.message}</p>;
if (measurements.length === 0) return <p>No urine tests found.</p>;
return (
<ul>
{measurements.map((measurement, index) => (
<li key={index}>
pH: {measurement.ph ?? 'Unavailable'}; protein: {measurement.pro ?? 'Unavailable'}
</li>
))}
</ul>
);
}
Related pages
- Generated API reference for the narrowed urine measurement return type.
- React applications
- useObservations
- Measurements and health data