1import type * as healthlake from "@distilled.cloud/aws/healthlake";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Role } from "../IAM/Role.ts";
5import type { FHIRDatastore } from "./FHIRDatastore.ts";
6
7/**
8 * `StartFHIRExportJob` request with `DatastoreId` injected from the bound
9 * data store and `DataAccessRoleArn` defaulting to the bound role.
10 */
11export interface StartFHIRExportJobRequest extends Omit<
12 healthlake.StartFHIRExportJobRequest,
13 "DatastoreId" | "DataAccessRoleArn"
14> {
15 /**
16 * IAM role AWS HealthLake assumes to write the exported FHIR NDJSON to
17 * the output S3 location.
18 * @default the data-access role bound via `StartFHIRExportJob(datastore, role)`
19 */
20 DataAccessRoleArn?: string;
21}
22
23/**
24 * Runtime binding for the `StartFHIRExportJob` operation (IAM action
25 * `healthlake:StartFHIRExportJob`), scoped to one {@link FHIRDatastore}.
26 *
27 * Starts a bulk export of the bound data store's FHIR R4 resources to S3 as
28 * NDJSON. The binding is constructed with the data store and the
29 * **data-access role** (the IAM role HealthLake assumes to write
30 * `OutputDataConfig.S3Configuration.S3Uri`, encrypted with its `KmsKeyId`;
31 * the role's trust policy must allow `healthlake.amazonaws.com`). The role's
32 * ARN is injected as `DataAccessRoleArn` on every runtime request and the
33 * host is granted `iam:PassRole` on it alongside
34 * `healthlake:StartFHIRExportJob` on the data store. Track the job with
35 * {@link DescribeFHIRExportJob}. Provide the implementation with
36 * `Effect.provide(AWS.HealthLake.StartFHIRExportJobHttp)`.
37 *
38 * ### Exporting FHIR Data
39 * **Example:** Start a Bulk FHIR Export Job
40 * ```typescript
41 * // deploy time — bind the data store and the HealthLake data-access role
42 * const startExport = yield* HealthLake.StartFHIRExportJob(datastore, dataAccessRole);
43 *
44 * // runtime
45 * const job = yield* startExport({
46 * OutputDataConfig: {
47 * S3Configuration: {
48 * S3Uri: "s3://my-bucket/fhir-export/",
49 * KmsKeyId: kmsKeyArn,
50 * },
51 * },
52 * });
53 * // job.JobId, job.JobStatus === "SUBMITTED"
54 * ```
55 *
56 * @binding
57 */
58export interface StartFHIRExportJob extends Binding.Service<
59 StartFHIRExportJob,
60 "AWS.HealthLake.StartFHIRExportJob",
61 (
62 datastore: FHIRDatastore,
63 dataAccessRole: Role,
64 ) => Effect.Effect<
65 (
66 request: StartFHIRExportJobRequest,
67 ) => Effect.Effect<
68 healthlake.StartFHIRExportJobResponse,
69 healthlake.StartFHIRExportJobError
70 >
71 >
72> {}
73export const StartFHIRExportJob = Binding.Service<StartFHIRExportJob>(
74 "AWS.HealthLake.StartFHIRExportJob",
75);