import { useCallback } from 'react'; import type { Observation } from 'fhir/r4'; import { environment } from '../environments/environment.ts'; import { useHttpService } from './HttpService.tsx'; import type { SaveTransport } from '../utils/saveOperation'; import type { NativeVitalEntry } from '../pages/DashboardPage/ClinicianOverviewPage/vitalsCatalog'; // A reading entered by the person who took it goes to the native vital route, which builds the Observation itself and // records where the author said it came from. The patient is named in the query, as the route admits it. The save that // sends it hands its transport, so a request prepared for one patient, visit or viewer is never sent under another. export const useNativeVitalService = () => { const { post } = useHttpService(); const recordVital = useCallback( (patientId: string, entry: NativeVitalEntry, transport?: SaveTransport) => post(`${environment.orgAuthorizationApi}/native-vital?subject=${encodeURIComponent(`Patient/${patientId}`)}`, entry, { ...transport }), [post], ); return { recordVital }; };