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