import {z} from 'zod' export type BulkExportGcsDestination = {uriPrefix?: string | undefined}; export type AccessDeterminationLogConfig = {logLevel?: ('LOG_LEVEL_UNSPECIFIED' | 'DISABLED' | 'MINIMUM' | 'VERBOSE') | undefined}; export type ConsentHeaderHandling = {profile?: ('SCOPE_PROFILE_UNSPECIFIED' | 'PERMIT_EMPTY_SCOPE' | 'REQUIRED_ON_READ') | undefined}; export type ConsentConfig = {accessDeterminationLogConfig?: AccessDeterminationLogConfig | undefined, accessEnforced?: boolean | undefined, consentHeaderHandling?: ConsentHeaderHandling | undefined, enforcedAdminConsents?: Array | undefined, version?: ('CONSENT_ENFORCEMENT_VERSION_UNSPECIFIED' | 'V1') | undefined}; export type NotificationConfig = {pubsubTopic?: string | undefined, sendForBulkImport?: boolean | undefined}; export type FhirNotificationConfig = {pubsubTopic?: string | undefined, sendFullResource?: boolean | undefined, sendPreviousResourceOnDelete?: boolean | undefined}; export type TimePartitioning = {expirationMs?: unknown | undefined, type?: ('PARTITION_TYPE_UNSPECIFIED' | 'HOUR' | 'DAY' | 'MONTH' | 'YEAR') | undefined}; export type SchemaConfig = {lastUpdatedPartitionConfig?: TimePartitioning | undefined, recursiveStructureDepth?: unknown | undefined, schemaType?: ('SCHEMA_TYPE_UNSPECIFIED' | 'ANALYTICS' | 'ANALYTICS_V2') | undefined}; export type GoogleCloudHealthcareV1FhirBigQueryDestination = {datasetUri?: string | undefined, force?: boolean | undefined, schemaConfig?: SchemaConfig | undefined, writeDisposition?: ('WRITE_DISPOSITION_UNSPECIFIED' | 'WRITE_EMPTY' | 'WRITE_TRUNCATE' | 'WRITE_APPEND') | undefined}; export type TagFilterList = {tags?: Array | undefined}; export type DicomConfig = {filterProfile?: ('TAG_FILTER_PROFILE_UNSPECIFIED' | 'MINIMAL_KEEP_LIST_PROFILE' | 'ATTRIBUTE_CONFIDENTIALITY_BASIC_PROFILE' | 'KEEP_ALL_PROFILE' | 'DEIDENTIFY_TAG_CONTENTS') | undefined, keepList?: TagFilterList | undefined, removeList?: TagFilterList | undefined, skipIdRedaction?: boolean | undefined}; export type FieldMetadata = {action?: ('ACTION_UNSPECIFIED' | 'TRANSFORM' | 'INSPECT_AND_TRANSFORM' | 'DO_NOT_TRANSFORM') | undefined, paths?: Array | undefined}; export type FhirConfig = {defaultKeepExtensions?: boolean | undefined, fieldMetadataList?: Array | undefined}; export type CustomRegex = {groupIndexes?: Array | undefined, pattern?: string | undefined}; export type ImageConfig = {customRegexes?: Array | undefined, textRedactionMode?: ('TEXT_REDACTION_MODE_UNSPECIFIED' | 'REDACT_ALL_TEXT' | 'REDACT_SENSITIVE_TEXT' | 'REDACT_NO_TEXT') | undefined}; export type CharacterMaskConfig = {maskingCharacter?: string | undefined}; export type KmsWrappedCryptoKey = {cryptoKey?: string | undefined, wrappedKey?: string | undefined}; export type CryptoHashConfig = {cryptoKey?: string | undefined, kmsWrapped?: KmsWrappedCryptoKey | undefined}; export type DateShiftConfig = {cryptoKey?: string | undefined, kmsWrapped?: KmsWrappedCryptoKey | undefined}; export type RedactConfig = Record; export type ReplaceWithInfoTypeConfig = Record; export type InfoTypeTransformation = {characterMaskConfig?: CharacterMaskConfig | undefined, cryptoHashConfig?: CryptoHashConfig | undefined, dateShiftConfig?: DateShiftConfig | undefined, infoTypes?: Array | undefined, redactConfig?: RedactConfig | undefined, replaceWithInfoTypeConfig?: ReplaceWithInfoTypeConfig | undefined}; export type TextConfig = {additionalTransformations?: Array | undefined, excludeInfoTypes?: Array | undefined, transformations?: Array | undefined}; export type DeidentifyConfig = {dicom?: DicomConfig | undefined, fhir?: FhirConfig | undefined, image?: ImageConfig | undefined, text?: TextConfig | undefined, useRegionalDataProcessing?: boolean | undefined}; export type DeidentifiedStoreDestination = {config?: DeidentifyConfig | undefined, store?: string | undefined}; export type StreamConfig = {bigqueryDestination?: GoogleCloudHealthcareV1FhirBigQueryDestination | undefined, deidentifiedStoreDestination?: DeidentifiedStoreDestination | undefined, resourceTypes?: Array | undefined}; export type ValidationConfig = {disableFhirpathValidation?: boolean | undefined, disableProfileValidation?: boolean | undefined, disableReferenceTypeValidation?: boolean | undefined, disableRequiredFieldValidation?: boolean | undefined, enableFhirpathProfileValidation?: boolean | undefined, enabledImplementationGuides?: Array | undefined}; export type FhirStore = {bulkExportGcsDestination?: BulkExportGcsDestination | undefined, complexDataTypeReferenceParsing?: ('COMPLEX_DATA_TYPE_REFERENCE_PARSING_UNSPECIFIED' | 'DISABLED' | 'ENABLED') | undefined, consentConfig?: ConsentConfig | undefined, defaultSearchHandlingStrict?: boolean | undefined, disableReferentialIntegrity?: boolean | undefined, disableResourceVersioning?: boolean | undefined, enableUpdateCreate?: boolean | undefined, labels?: {[key: string]: string} | undefined, name?: string | undefined, notificationConfig?: NotificationConfig | undefined, notificationConfigs?: Array | undefined, streamConfigs?: Array | undefined, validationConfig?: ValidationConfig | undefined, version?: ('VERSION_UNSPECIFIED' | 'DSTU2' | 'STU3' | 'R4' | 'R5') | undefined}; export type CreateApiV1ProjectsProjectsIdLocationsLocationsIdDatasetsDatasetsIdFhirStoresArgs = {projectsId: string, locationsId: string, datasetsId: string, fhirStoreId?: string | undefined, body: FhirStore}; export type CreateApiV1ProjectsProjectsIdLocationsLocationsIdDatasetsDatasetsIdFhirStoresOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const bulkExportGcsDestination = z.object({uriPrefix: z.string().optional()}); export const accessDeterminationLogConfig = z.object({logLevel: z.enum(["LOG_LEVEL_UNSPECIFIED", "DISABLED", "MINIMUM", "VERBOSE"]).optional()}); export const consentHeaderHandling = z.object({profile: z.enum(["SCOPE_PROFILE_UNSPECIFIED", "PERMIT_EMPTY_SCOPE", "REQUIRED_ON_READ"]).optional()}); export const consentConfig = z.object({accessDeterminationLogConfig: accessDeterminationLogConfig.optional(), accessEnforced: z.boolean().optional(), consentHeaderHandling: consentHeaderHandling.optional(), enforcedAdminConsents: z.array(z.string()).optional(), version: z.enum(["CONSENT_ENFORCEMENT_VERSION_UNSPECIFIED", "V1"]).optional()}); export const notificationConfig = z.object({pubsubTopic: z.string().optional(), sendForBulkImport: z.boolean().optional()}); export const fhirNotificationConfig = z.object({pubsubTopic: z.string().optional(), sendFullResource: z.boolean().optional(), sendPreviousResourceOnDelete: z.boolean().optional()}); export const timePartitioning = z.object({expirationMs: z.string().optional(), type: z.enum(["PARTITION_TYPE_UNSPECIFIED", "HOUR", "DAY", "MONTH", "YEAR"]).optional()}); export const schemaConfig = z.object({lastUpdatedPartitionConfig: timePartitioning.optional(), recursiveStructureDepth: z.string().optional(), schemaType: z.enum(["SCHEMA_TYPE_UNSPECIFIED", "ANALYTICS", "ANALYTICS_V2"]).optional()}); export const googleCloudHealthcareV1FhirBigQueryDestination = z.object({datasetUri: z.string().optional(), force: z.boolean().optional(), schemaConfig: schemaConfig.optional(), writeDisposition: z.enum(["WRITE_DISPOSITION_UNSPECIFIED", "WRITE_EMPTY", "WRITE_TRUNCATE", "WRITE_APPEND"]).optional()}); export const tagFilterList = z.object({tags: z.array(z.string()).optional()}); export const dicomConfig = z.object({filterProfile: z.enum(["TAG_FILTER_PROFILE_UNSPECIFIED", "MINIMAL_KEEP_LIST_PROFILE", "ATTRIBUTE_CONFIDENTIALITY_BASIC_PROFILE", "KEEP_ALL_PROFILE", "DEIDENTIFY_TAG_CONTENTS"]).optional(), keepList: tagFilterList.optional(), removeList: tagFilterList.optional(), skipIdRedaction: z.boolean().optional()}); export const fieldMetadata = z.object({action: z.enum(["ACTION_UNSPECIFIED", "TRANSFORM", "INSPECT_AND_TRANSFORM", "DO_NOT_TRANSFORM"]).optional(), paths: z.array(z.string()).optional()}); export const fhirConfig = z.object({defaultKeepExtensions: z.boolean().optional(), fieldMetadataList: z.array(fieldMetadata).optional()}); export const customRegex = z.object({groupIndexes: z.array(z.number().int()).optional(), pattern: z.string().optional()}); export const imageConfig = z.object({customRegexes: z.array(customRegex).optional(), textRedactionMode: z.enum(["TEXT_REDACTION_MODE_UNSPECIFIED", "REDACT_ALL_TEXT", "REDACT_SENSITIVE_TEXT", "REDACT_NO_TEXT"]).optional()}); export const characterMaskConfig = z.object({maskingCharacter: z.string().optional()}); export const kmsWrappedCryptoKey = z.object({cryptoKey: z.string().optional(), wrappedKey: z.string().optional()}); export const cryptoHashConfig = z.object({cryptoKey: z.string().optional(), kmsWrapped: kmsWrappedCryptoKey.optional()}); export const dateShiftConfig = z.object({cryptoKey: z.string().optional(), kmsWrapped: kmsWrappedCryptoKey.optional()}); export const redactConfig = z.object({}); export const replaceWithInfoTypeConfig = z.object({}); export const infoTypeTransformation = z.object({characterMaskConfig: characterMaskConfig.optional(), cryptoHashConfig: cryptoHashConfig.optional(), dateShiftConfig: dateShiftConfig.optional(), infoTypes: z.array(z.string()).optional(), redactConfig: redactConfig.optional(), replaceWithInfoTypeConfig: replaceWithInfoTypeConfig.optional()}); export const textConfig = z.object({additionalTransformations: z.array(infoTypeTransformation).optional(), excludeInfoTypes: z.array(z.string()).optional(), transformations: z.array(infoTypeTransformation).optional()}); export const deidentifyConfig = z.object({dicom: dicomConfig.optional(), fhir: fhirConfig.optional(), image: imageConfig.optional(), text: textConfig.optional(), useRegionalDataProcessing: z.boolean().optional()}); export const deidentifiedStoreDestination = z.object({config: deidentifyConfig.optional(), store: z.string().optional()}); export const streamConfig = z.object({bigqueryDestination: googleCloudHealthcareV1FhirBigQueryDestination.optional(), deidentifiedStoreDestination: deidentifiedStoreDestination.optional(), resourceTypes: z.array(z.string()).optional()}); export const validationConfig = z.object({disableFhirpathValidation: z.boolean().optional(), disableProfileValidation: z.boolean().optional(), disableReferenceTypeValidation: z.boolean().optional(), disableRequiredFieldValidation: z.boolean().optional(), enableFhirpathProfileValidation: z.boolean().optional(), enabledImplementationGuides: z.array(z.string()).optional()}); export const fhirStore = z.object({bulkExportGcsDestination: bulkExportGcsDestination.optional(), complexDataTypeReferenceParsing: z.enum(["COMPLEX_DATA_TYPE_REFERENCE_PARSING_UNSPECIFIED", "DISABLED", "ENABLED"]).optional(), consentConfig: consentConfig.optional(), defaultSearchHandlingStrict: z.boolean().optional(), disableReferentialIntegrity: z.boolean().optional(), disableResourceVersioning: z.boolean().optional(), enableUpdateCreate: z.boolean().optional(), labels: z.record(z.string(), z.string()).optional(), name: z.string().optional(), notificationConfig: notificationConfig.optional(), notificationConfigs: z.array(fhirNotificationConfig).optional(), streamConfigs: z.array(streamConfig).optional(), validationConfig: validationConfig.optional(), version: z.enum(["VERSION_UNSPECIFIED", "DSTU2", "STU3", "R4", "R5"]).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Creates a new FHIR store within the parent dataset. * * POST /v1/projects/{projectsId}/locations/{locationsId}/datasets/{datasetsId}/fhirStores * * Also accepts auth: Oauth2 + Oauth2c */ export const createApiV1ProjectsProjectsIdLocationsLocationsIdDatasetsDatasetsIdFhirStores = async (args: CreateApiV1ProjectsProjectsIdLocationsLocationsIdDatasetsDatasetsIdFhirStoresArgs, options?: CreateApiV1ProjectsProjectsIdLocationsLocationsIdDatasetsDatasetsIdFhirStoresOptions) => { const {baseUrl = "https://healthcare.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.fhirStoreId != null) query.append("fhirStoreId", String(args.fhirStoreId)) if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/projects/${encodeURIComponent(String(args.projectsId))}/locations/${encodeURIComponent(String(args.locationsId))}/datasets/${encodeURIComponent(String(args.datasetsId))}/fhirStores${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(fhirStore, await res.json()) };