diff --git a/lib/auth/client.ts b/lib/auth/client.ts index 0091edf..8197a52 100644 --- a/lib/auth/client.ts +++ b/lib/auth/client.ts @@ -5,7 +5,7 @@ */ import { createBrowserClient } from '@supabase/ssr' -import type { Database } from '@/lib/database.types' +import type { Database } from '@/lib/supabase/database.types' /** * Create Supabase client for browser/client-side use diff --git a/lib/auth/server.ts b/lib/auth/server.ts index 8d8a300..85a2fae 100644 --- a/lib/auth/server.ts +++ b/lib/auth/server.ts @@ -6,7 +6,7 @@ import { createServerClient } from '@supabase/ssr' import { cookies } from 'next/headers' -import type { Database } from '@/lib/database.types' +import type { Database } from '@/lib/supabase/database.types' /** * Create Supabase client for server-side use diff --git a/lib/database.types.ts b/lib/database.types.ts deleted file mode 100644 index 6cfcba7..0000000 --- a/lib/database.types.ts +++ /dev/null @@ -1,1611 +0,0 @@ -export type Json = - | string - | number - | boolean - | null - | { [key: string]: Json | undefined } - | Json[] - -export type Database = { - // Allows to automatically instantiate createClient with right options - // instead of createClient(URL, KEY) - __InternalSupabase: { - PostgrestVersion: "13.0.5" - } - public: { - Tables: { - ai_events: { - Row: { - client_id: string | null - created_at: string - duration_ms: number - id: string - kind: string - note_id: string | null - request: Json - response: Json - } - Insert: { - client_id?: string | null - created_at?: string - duration_ms?: number - id?: string - kind: string - note_id?: string | null - request?: Json - response?: Json - } - Update: { - client_id?: string | null - created_at?: string - duration_ms?: number - id?: string - kind?: string - note_id?: string | null - request?: Json - response?: Json - } - Relationships: [ - { - foreignKeyName: "ai_events_client_id_fkey" - columns: ["client_id"] - isOneToOne: false - referencedRelation: "clients" - referencedColumns: ["id"] - }, - { - foreignKeyName: "ai_events_note_id_fkey" - columns: ["note_id"] - isOneToOne: false - referencedRelation: "intake_notes" - referencedColumns: ["id"] - }, - ] - } - anamneses: { - Row: { - anamnese_date: string - anamnese_type: - | "psychiatrisch" - | "sociaal" - | "medisch" - | "familie" - | "ontwikkeling" - | "overig" - content: string - created_at: string | null - created_by: string | null - id: string - intake_id: string - notes: string | null - updated_at: string | null - } - Insert: { - anamnese_date?: string - anamnese_type: - | "psychiatrisch" - | "sociaal" - | "medisch" - | "familie" - | "ontwikkeling" - | "overig" - content: string - created_at?: string | null - created_by?: string | null - id?: string - intake_id: string - notes?: string | null - updated_at?: string | null - } - Update: { - anamnese_date?: string - anamnese_type?: - | "psychiatrisch" - | "sociaal" - | "medisch" - | "familie" - | "ontwikkeling" - | "overig" - content?: string - created_at?: string | null - created_by?: string | null - id?: string - intake_id?: string - notes?: string | null - updated_at?: string | null - } - Relationships: [ - { - foreignKeyName: "anamneses_created_by_fkey" - columns: ["created_by"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - { - foreignKeyName: "anamneses_intake_id_fkey" - columns: ["intake_id"] - isOneToOne: false - referencedRelation: "intakes" - referencedColumns: ["id"] - }, - ] - } - care_plans: { - Row: { - activities: Json | null - addresses_condition_ids: string[] | null - based_on_anamneses: string[] | null - based_on_examinations: string[] | null - based_on_intake_id: string | null - based_on_risk_assessments: string[] | null - author_id: string | null - care_team_ids: string[] | null - category_code: string | null - category_display: string | null - contributor_ids: string[] | null - created_at: string | null - created_date: string | null - description: string | null - encounter_id: string | null - goals: Json | null - id: string - identifier: string | null - intent: string - note: string | null - patient_id: string - period_end: string | null - period_start: string | null - status: Database["public"]["Enums"]["careplan_status"] - title: string - updated_at: string | null - } - Insert: { - activities?: Json | null - addresses_condition_ids?: string[] | null - based_on_anamneses?: string[] | null - based_on_examinations?: string[] | null - based_on_intake_id?: string | null - based_on_risk_assessments?: string[] | null - author_id?: string | null - care_team_ids?: string[] | null - category_code?: string | null - category_display?: string | null - contributor_ids?: string[] | null - created_at?: string | null - created_date?: string | null - description?: string | null - encounter_id?: string | null - goals?: Json | null - id?: string - identifier?: string | null - intent?: string - note?: string | null - patient_id: string - period_end?: string | null - period_start?: string | null - status?: Database["public"]["Enums"]["careplan_status"] - title: string - updated_at?: string | null - } - Update: { - activities?: Json | null - addresses_condition_ids?: string[] | null - based_on_anamneses?: string[] | null - based_on_examinations?: string[] | null - based_on_intake_id?: string | null - based_on_risk_assessments?: string[] | null - author_id?: string | null - care_team_ids?: string[] | null - category_code?: string | null - category_display?: string | null - contributor_ids?: string[] | null - created_at?: string | null - created_date?: string | null - description?: string | null - encounter_id?: string | null - goals?: Json | null - id?: string - identifier?: string | null - intent?: string - note?: string | null - patient_id?: string - period_end?: string | null - period_start?: string | null - status?: Database["public"]["Enums"]["careplan_status"] - title?: string - updated_at?: string | null - } - Relationships: [ - { - foreignKeyName: "care_plans_author_id_fkey" - columns: ["author_id"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - { - foreignKeyName: "care_plans_encounter_id_fkey" - columns: ["encounter_id"] - isOneToOne: false - referencedRelation: "encounters" - referencedColumns: ["id"] - }, - { - foreignKeyName: "care_plans_patient_id_fkey" - columns: ["patient_id"] - isOneToOne: false - referencedRelation: "patients" - referencedColumns: ["id"] - }, - { - foreignKeyName: "care_plans_based_on_intake_id_fkey" - columns: ["based_on_intake_id"] - isOneToOne: false - referencedRelation: "intakes" - referencedColumns: ["id"] - }, - ] - } - clients: { - Row: { - birth_date: string - created_at: string - first_name: string - id: string - last_name: string - updated_at: string - } - Insert: { - birth_date: string - created_at?: string - first_name: string - id?: string - last_name: string - updated_at?: string - } - Update: { - birth_date?: string - created_at?: string - first_name?: string - id?: string - last_name?: string - updated_at?: string - } - Relationships: [] - } - conditions: { - Row: { - abatement_age: number | null - abatement_datetime: string | null - asserter_id: string | null - body_site_code: string | null - body_site_display: string | null - category: string - clinical_status: Database["public"]["Enums"]["condition_clinical_status"] - code_code: string - code_display: string - code_system: string - created_at: string | null - encounter_id: string | null - id: string - identifier: string | null - note: string | null - onset_age: number | null - onset_datetime: string | null - patient_id: string - recorded_date: string - recorder_id: string | null - severity_code: string | null - severity_display: string | null - updated_at: string | null - verification_status: Database["public"]["Enums"]["condition_verification_status"] - } - Insert: { - abatement_age?: number | null - abatement_datetime?: string | null - asserter_id?: string | null - body_site_code?: string | null - body_site_display?: string | null - category?: string - clinical_status?: Database["public"]["Enums"]["condition_clinical_status"] - code_code: string - code_display: string - code_system?: string - created_at?: string | null - encounter_id?: string | null - id?: string - identifier?: string | null - note?: string | null - onset_age?: number | null - onset_datetime?: string | null - patient_id: string - recorded_date?: string - recorder_id?: string | null - severity_code?: string | null - severity_display?: string | null - updated_at?: string | null - verification_status?: Database["public"]["Enums"]["condition_verification_status"] - } - Update: { - abatement_age?: number | null - abatement_datetime?: string | null - asserter_id?: string | null - body_site_code?: string | null - body_site_display?: string | null - category?: string - clinical_status?: Database["public"]["Enums"]["condition_clinical_status"] - code_code?: string - code_display?: string - code_system?: string - created_at?: string | null - encounter_id?: string | null - id?: string - identifier?: string | null - note?: string | null - onset_age?: number | null - onset_datetime?: string | null - patient_id?: string - recorded_date?: string - recorder_id?: string | null - severity_code?: string | null - severity_display?: string | null - updated_at?: string | null - verification_status?: Database["public"]["Enums"]["condition_verification_status"] - } - Relationships: [ - { - foreignKeyName: "conditions_asserter_id_fkey" - columns: ["asserter_id"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - { - foreignKeyName: "conditions_encounter_id_fkey" - columns: ["encounter_id"] - isOneToOne: false - referencedRelation: "encounters" - referencedColumns: ["id"] - }, - { - foreignKeyName: "conditions_patient_id_fkey" - columns: ["patient_id"] - isOneToOne: false - referencedRelation: "patients" - referencedColumns: ["id"] - }, - { - foreignKeyName: "conditions_recorder_id_fkey" - columns: ["recorder_id"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - ] - } - demo_users: { - Row: { - access_level: string - created_at: string - expires_at: string | null - id: string - last_login_at: string | null - notes: string | null - updated_at: string - usage_count: number | null - user_id: string | null - } - Insert: { - access_level?: string - created_at?: string - expires_at?: string | null - id?: string - last_login_at?: string | null - notes?: string | null - updated_at?: string - usage_count?: number | null - user_id?: string | null - } - Update: { - access_level?: string - created_at?: string - expires_at?: string | null - id?: string - last_login_at?: string | null - notes?: string | null - updated_at?: string - usage_count?: number | null - user_id?: string | null - } - Relationships: [] - } - encounters: { - Row: { - admission_source: string | null - class_code: string - class_display: string - created_at: string | null - discharge_disposition: string | null - id: string - identifier: string | null - intake_id: string | null - intake_note_id: string | null - notes: string | null - organization_id: string | null - patient_id: string - period_end: string | null - period_start: string - practitioner_id: string | null - priority_code: string | null - priority_display: string | null - reason_code: string[] | null - reason_display: string[] | null - status: Database["public"]["Enums"]["encounter_status"] - type_code: string - type_display: string - updated_at: string | null - } - Insert: { - admission_source?: string | null - class_code: string - class_display: string - created_at?: string | null - discharge_disposition?: string | null - id?: string - identifier?: string | null - intake_id?: string | null - intake_note_id?: string | null - notes?: string | null - organization_id?: string | null - patient_id: string - period_end?: string | null - period_start: string - practitioner_id?: string | null - priority_code?: string | null - priority_display?: string | null - reason_code?: string[] | null - reason_display?: string[] | null - status?: Database["public"]["Enums"]["encounter_status"] - type_code: string - type_display: string - updated_at?: string | null - } - Update: { - admission_source?: string | null - class_code?: string - class_display?: string - created_at?: string | null - discharge_disposition?: string | null - id?: string - identifier?: string | null - intake_id?: string | null - intake_note_id?: string | null - notes?: string | null - organization_id?: string | null - patient_id?: string - period_end?: string | null - period_start?: string - practitioner_id?: string | null - priority_code?: string | null - priority_display?: string | null - reason_code?: string[] | null - reason_display?: string[] | null - status?: Database["public"]["Enums"]["encounter_status"] - type_code?: string - type_display?: string - updated_at?: string | null - } - Relationships: [ - { - foreignKeyName: "encounters_intake_note_id_fkey" - columns: ["intake_note_id"] - isOneToOne: false - referencedRelation: "intake_notes" - referencedColumns: ["id"] - }, - { - foreignKeyName: "encounters_intake_id_fkey" - columns: ["intake_id"] - isOneToOne: false - referencedRelation: "intakes" - referencedColumns: ["id"] - }, - { - foreignKeyName: "encounters_organization_id_fkey" - columns: ["organization_id"] - isOneToOne: false - referencedRelation: "organizations" - referencedColumns: ["id"] - }, - { - foreignKeyName: "encounters_patient_id_fkey" - columns: ["patient_id"] - isOneToOne: false - referencedRelation: "patients" - referencedColumns: ["id"] - }, - { - foreignKeyName: "encounters_practitioner_id_fkey" - columns: ["practitioner_id"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - ] - } - intakes: { - Row: { - created_at: string | null - department: string - end_date: string | null - id: string - kindcheck_data: Json | null - notes: string | null - patient_id: string - psychologist_id: string | null - start_date: string - status: string - title: string - treatment_advice: Json | null - updated_at: string | null - } - Insert: { - created_at?: string | null - department: string - end_date?: string | null - id?: string - kindcheck_data?: Json | null - notes?: string | null - patient_id: string - psychologist_id?: string | null - start_date?: string - status?: string - title: string - treatment_advice?: Json | null - updated_at?: string | null - } - Update: { - created_at?: string | null - department?: string - end_date?: string | null - id?: string - kindcheck_data?: Json | null - notes?: string | null - patient_id?: string - psychologist_id?: string | null - start_date?: string - status?: string - title?: string - treatment_advice?: Json | null - updated_at?: string | null - } - Relationships: [ - { - foreignKeyName: "intakes_patient_id_fkey" - columns: ["patient_id"] - isOneToOne: false - referencedRelation: "patients" - referencedColumns: ["id"] - }, - { - foreignKeyName: "intakes_psychologist_id_fkey" - columns: ["psychologist_id"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - ] - } - intake_notes: { - Row: { - author: string | null - client_id: string - content_json: Json - content_text: string | null - created_at: string - id: string - tag: string | null - title: string | null - updated_at: string - } - Insert: { - author?: string | null - client_id: string - content_json?: Json - content_text?: string | null - created_at?: string - id?: string - tag?: string | null - title?: string | null - updated_at?: string - } - Update: { - author?: string | null - client_id?: string - content_json?: Json - content_text?: string | null - created_at?: string - id?: string - tag?: string | null - title?: string | null - updated_at?: string - } - Relationships: [ - { - foreignKeyName: "intake_notes_client_id_fkey" - columns: ["client_id"] - isOneToOne: false - referencedRelation: "clients" - referencedColumns: ["id"] - }, - ] - } - examinations: { - Row: { - created_at: string | null - created_by: string | null - document_url: string | null - examination_date: string - examination_type: - | "bloedonderzoek" - | "neuropsychologisch" - | "psychodiagnostiek" - | "iq_test" - | "persoonlijkheid" - | "medisch" - | "overig" - findings: string - id: string - intake_id: string - notes: string | null - performed_by: string | null - reason: string | null - updated_at: string | null - } - Insert: { - created_at?: string | null - created_by?: string | null - document_url?: string | null - examination_date?: string - examination_type: - | "bloedonderzoek" - | "neuropsychologisch" - | "psychodiagnostiek" - | "iq_test" - | "persoonlijkheid" - | "medisch" - | "overig" - findings: string - id?: string - intake_id: string - notes?: string | null - performed_by?: string | null - reason?: string | null - updated_at?: string | null - } - Update: { - created_at?: string | null - created_by?: string | null - document_url?: string | null - examination_date?: string - examination_type?: - | "bloedonderzoek" - | "neuropsychologisch" - | "psychodiagnostiek" - | "iq_test" - | "persoonlijkheid" - | "medisch" - | "overig" - findings?: string - id?: string - intake_id?: string - notes?: string | null - performed_by?: string | null - reason?: string | null - updated_at?: string | null - } - Relationships: [ - { - foreignKeyName: "examinations_created_by_fkey" - columns: ["created_by"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - { - foreignKeyName: "examinations_intake_id_fkey" - columns: ["intake_id"] - isOneToOne: false - referencedRelation: "intakes" - referencedColumns: ["id"] - }, - ] - } - observations: { - Row: { - body_site: string | null - category: string - code_code: string - code_display: string - code_system: string - created_at: string | null - effective_datetime: string - encounter_id: string | null - id: string - identifier: string | null - interpretation_code: string | null - interpretation_display: string | null - issued: string | null - method_code: string | null - method_display: string | null - note: string | null - patient_id: string - performer_id: string | null - reference_range_high: number | null - reference_range_low: number | null - reference_range_text: string | null - status: Database["public"]["Enums"]["observation_status"] - value_boolean: boolean | null - value_codeable_concept: Json | null - value_quantity_comparator: string | null - value_quantity_unit: string | null - value_quantity_value: number | null - value_string: string | null - value_type: string - } - Insert: { - body_site?: string | null - category: string - code_code: string - code_display: string - code_system: string - created_at?: string | null - effective_datetime: string - encounter_id?: string | null - id?: string - identifier?: string | null - interpretation_code?: string | null - interpretation_display?: string | null - issued?: string | null - method_code?: string | null - method_display?: string | null - note?: string | null - patient_id: string - performer_id?: string | null - reference_range_high?: number | null - reference_range_low?: number | null - reference_range_text?: string | null - status?: Database["public"]["Enums"]["observation_status"] - value_boolean?: boolean | null - value_codeable_concept?: Json | null - value_quantity_comparator?: string | null - value_quantity_unit?: string | null - value_quantity_value?: number | null - value_string?: string | null - value_type: string - } - Update: { - body_site?: string | null - category?: string - code_code?: string - code_display?: string - code_system?: string - created_at?: string | null - effective_datetime?: string - encounter_id?: string | null - id?: string - identifier?: string | null - interpretation_code?: string | null - interpretation_display?: string | null - issued?: string | null - method_code?: string | null - method_display?: string | null - note?: string | null - patient_id?: string - performer_id?: string | null - reference_range_high?: number | null - reference_range_low?: number | null - reference_range_text?: string | null - status?: Database["public"]["Enums"]["observation_status"] - value_boolean?: boolean | null - value_codeable_concept?: Json | null - value_quantity_comparator?: string | null - value_quantity_unit?: string | null - value_quantity_value?: number | null - value_string?: string | null - value_type?: string - } - Relationships: [ - { - foreignKeyName: "observations_encounter_id_fkey" - columns: ["encounter_id"] - isOneToOne: false - referencedRelation: "encounters" - referencedColumns: ["id"] - }, - { - foreignKeyName: "observations_patient_id_fkey" - columns: ["patient_id"] - isOneToOne: false - referencedRelation: "patients" - referencedColumns: ["id"] - }, - { - foreignKeyName: "observations_performer_id_fkey" - columns: ["performer_id"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - ] - } - organizations: { - Row: { - active: boolean | null - address_city: string | null - address_country: string | null - address_line: string[] | null - address_postal_code: string | null - alias: string[] | null - created_at: string | null - id: string - identifier_agb: string | null - identifier_kvk: string | null - name: string - telecom_email: string | null - telecom_phone: string | null - telecom_website: string | null - type_code: string | null - type_display: string | null - updated_at: string | null - } - Insert: { - active?: boolean | null - address_city?: string | null - address_country?: string | null - address_line?: string[] | null - address_postal_code?: string | null - alias?: string[] | null - created_at?: string | null - id?: string - identifier_agb?: string | null - identifier_kvk?: string | null - name: string - telecom_email?: string | null - telecom_phone?: string | null - telecom_website?: string | null - type_code?: string | null - type_display?: string | null - updated_at?: string | null - } - Update: { - active?: boolean | null - address_city?: string | null - address_country?: string | null - address_line?: string[] | null - address_postal_code?: string | null - alias?: string[] | null - created_at?: string | null - id?: string - identifier_agb?: string | null - identifier_kvk?: string | null - name?: string - telecom_email?: string | null - telecom_phone?: string | null - telecom_website?: string | null - type_code?: string | null - type_display?: string | null - updated_at?: string | null - } - Relationships: [] - } - patients: { - Row: { - active: boolean | null - address_city: string | null - address_country: string | null - address_line: string[] | null - address_postal_code: string | null - birth_date: string - created_at: string | null - emergency_contact_name: string | null - emergency_contact_phone: string | null - emergency_contact_relationship: string | null - gender: Database["public"]["Enums"]["gender_type"] - general_practitioner_agb: string | null - general_practitioner_name: string | null - id: string - identifier_bsn: string | null - identifier_client_number: string | null - is_john_doe: boolean | null - insurance_company: string | null - insurance_number: string | null - name_family: string - name_given: string[] - name_prefix: string | null - name_use: string | null - telecom_email: string | null - telecom_phone: string | null - status: Database["public"]["Enums"]["episode_status"] - updated_at: string | null - } - Insert: { - active?: boolean | null - address_city?: string | null - address_country?: string | null - address_line?: string[] | null - address_postal_code?: string | null - birth_date: string - created_at?: string | null - emergency_contact_name?: string | null - emergency_contact_phone?: string | null - emergency_contact_relationship?: string | null - gender: Database["public"]["Enums"]["gender_type"] - general_practitioner_agb?: string | null - general_practitioner_name?: string | null - id?: string - identifier_bsn?: string | null - identifier_client_number?: string | null - is_john_doe?: boolean | null - insurance_company?: string | null - insurance_number?: string | null - name_family: string - name_given: string[] - name_prefix?: string | null - name_use?: string | null - telecom_email?: string | null - telecom_phone?: string | null - status?: Database["public"]["Enums"]["episode_status"] - updated_at?: string | null - } - Update: { - active?: boolean | null - address_city?: string | null - address_country?: string | null - address_line?: string[] | null - address_postal_code?: string | null - birth_date?: string - created_at?: string | null - emergency_contact_name?: string | null - emergency_contact_phone?: string | null - emergency_contact_relationship?: string | null - gender?: Database["public"]["Enums"]["gender_type"] - general_practitioner_agb?: string | null - general_practitioner_name?: string | null - id?: string - identifier_bsn?: string | null - identifier_client_number?: string | null - is_john_doe?: boolean | null - insurance_company?: string | null - insurance_number?: string | null - name_family?: string - name_given?: string[] - name_prefix?: string | null - name_use?: string | null - telecom_email?: string | null - telecom_phone?: string | null - status?: Database["public"]["Enums"]["episode_status"] - updated_at?: string | null - } - Relationships: [] - } - practitioners: { - Row: { - active: boolean | null - created_at: string | null - id: string - identifier_agb: string | null - identifier_big: string | null - name_family: string - name_given: string[] - name_prefix: string | null - name_suffix: string | null - qualification: string[] | null - telecom_email: string | null - telecom_phone: string | null - updated_at: string | null - user_id: string | null - } - Insert: { - active?: boolean | null - created_at?: string | null - id?: string - identifier_agb?: string | null - identifier_big?: string | null - name_family: string - name_given: string[] - name_prefix?: string | null - name_suffix?: string | null - qualification?: string[] | null - telecom_email?: string | null - telecom_phone?: string | null - updated_at?: string | null - user_id?: string | null - } - Update: { - active?: boolean | null - created_at?: string | null - id?: string - identifier_agb?: string | null - identifier_big?: string | null - name_family?: string - name_given?: string[] - name_prefix?: string | null - name_suffix?: string | null - qualification?: string[] | null - telecom_email?: string | null - telecom_phone?: string | null - updated_at?: string | null - user_id?: string | null - } - Relationships: [] - } - risk_assessments: { - Row: { - assessment_date: string - created_at: string | null - created_by: string | null - id: string - intake_id: string - measures: string | null - notes: string | null - rationale: string - risk_level: "laag" | "gemiddeld" | "hoog" | "zeer_hoog" - risk_type: - | "suicidaliteit" - | "agressie" - | "zelfverwaarlozing" - | "middelenmisbruik" - | "verward_gedrag" - | "overig" - updated_at: string | null - evaluation_date: string | null - } - Insert: { - assessment_date?: string - created_at?: string | null - created_by?: string | null - id?: string - intake_id: string - measures?: string | null - notes?: string | null - rationale: string - risk_level?: "laag" | "gemiddeld" | "hoog" | "zeer_hoog" - risk_type: - | "suicidaliteit" - | "agressie" - | "zelfverwaarlozing" - | "middelenmisbruik" - | "verward_gedrag" - | "overig" - updated_at?: string | null - evaluation_date?: string | null - } - Update: { - assessment_date?: string - created_at?: string | null - created_by?: string | null - id?: string - intake_id?: string - measures?: string | null - notes?: string | null - rationale?: string - risk_level?: "laag" | "gemiddeld" | "hoog" | "zeer_hoog" - risk_type?: - | "suicidaliteit" - | "agressie" - | "zelfverwaarlozing" - | "middelenmisbruik" - | "verward_gedrag" - | "overig" - updated_at?: string | null - evaluation_date?: string | null - } - Relationships: [ - { - foreignKeyName: "risk_assessments_created_by_fkey" - columns: ["created_by"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - { - foreignKeyName: "risk_assessments_intake_id_fkey" - columns: ["intake_id"] - isOneToOne: false - referencedRelation: "intakes" - referencedColumns: ["id"] - }, - ] - } - problem_profiles: { - Row: { - category: string - client_id: string - created_at: string - id: string - remarks: string | null - severity: string - source_note_id: string | null - updated_at: string - } - Insert: { - category: string - client_id: string - created_at?: string - id?: string - remarks?: string | null - severity: string - source_note_id?: string | null - updated_at?: string - } - Update: { - category?: string - client_id?: string - created_at?: string - id?: string - remarks?: string | null - severity?: string - source_note_id?: string | null - updated_at?: string - } - Relationships: [ - { - foreignKeyName: "problem_profiles_client_id_fkey" - columns: ["client_id"] - isOneToOne: false - referencedRelation: "clients" - referencedColumns: ["id"] - }, - { - foreignKeyName: "problem_profiles_source_note_id_fkey" - columns: ["source_note_id"] - isOneToOne: false - referencedRelation: "intake_notes" - referencedColumns: ["id"] - }, - ] - } - screening_activities: { - Row: { - activity_text: string - created_at: string | null - created_by: string | null - created_by_name: string | null - id: string - screening_id: string - } - Insert: { - activity_text: string - created_at?: string | null - created_by?: string | null - created_by_name?: string | null - id?: string - screening_id: string - } - Update: { - activity_text?: string - created_at?: string | null - created_by?: string | null - created_by_name?: string | null - id?: string - screening_id?: string - } - Relationships: [ - { - foreignKeyName: "screening_activities_created_by_fkey" - columns: ["created_by"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - { - foreignKeyName: "screening_activities_screening_id_fkey" - columns: ["screening_id"] - isOneToOne: false - referencedRelation: "screenings" - referencedColumns: ["id"] - }, - ] - } - screening_documents: { - Row: { - document_type: string | null - file_name: string - file_path: string | null - file_size: number | null - file_type: string | null - id: string - screening_id: string - uploaded_at: string | null - uploaded_by: string | null - uploaded_by_name: string | null - } - Insert: { - document_type?: string | null - file_name: string - file_path?: string | null - file_size?: number | null - file_type?: string | null - id?: string - screening_id: string - uploaded_at?: string | null - uploaded_by?: string | null - uploaded_by_name?: string | null - } - Update: { - document_type?: string | null - file_name?: string - file_path?: string | null - file_size?: number | null - file_type?: string | null - id?: string - screening_id?: string - uploaded_at?: string | null - uploaded_by?: string | null - uploaded_by_name?: string | null - } - Relationships: [ - { - foreignKeyName: "screening_documents_screening_id_fkey" - columns: ["screening_id"] - isOneToOne: false - referencedRelation: "screenings" - referencedColumns: ["id"] - }, - { - foreignKeyName: "screening_documents_uploaded_by_fkey" - columns: ["uploaded_by"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - ] - } - screenings: { - Row: { - created_at: string | null - decision: "geschikt" | "niet_geschikt" | null - decision_by: string | null - decision_date: string | null - decision_department: string | null - decision_notes: string | null - id: string - patient_id: string - request_for_help: string | null - updated_at: string | null - } - Insert: { - created_at?: string | null - decision?: "geschikt" | "niet_geschikt" | null - decision_by?: string | null - decision_date?: string | null - decision_department?: string | null - decision_notes?: string | null - id?: string - patient_id: string - request_for_help?: string | null - updated_at?: string | null - } - Update: { - created_at?: string | null - decision?: "geschikt" | "niet_geschikt" | null - decision_by?: string | null - decision_date?: string | null - decision_department?: string | null - decision_notes?: string | null - id?: string - patient_id?: string - request_for_help?: string | null - updated_at?: string | null - } - Relationships: [ - { - foreignKeyName: "screenings_decision_by_fkey" - columns: ["decision_by"] - isOneToOne: false - referencedRelation: "practitioners" - referencedColumns: ["id"] - }, - { - foreignKeyName: "screenings_patient_id_fkey" - columns: ["patient_id"] - isOneToOne: false - referencedRelation: "patients" - referencedColumns: ["id"] - }, - ] - } - treatment_plans: { - Row: { - client_id: string - created_at: string - created_by: string | null - id: string - plan: Json - published_at: string | null - status: string - updated_at: string - version: number - } - Insert: { - client_id: string - created_at?: string - created_by?: string | null - id?: string - plan?: Json - published_at?: string | null - status?: string - updated_at?: string - version?: number - } - Update: { - client_id?: string - created_at?: string - created_by?: string | null - id?: string - plan?: Json - published_at?: string | null - status?: string - updated_at?: string - version?: number - } - Relationships: [ - { - foreignKeyName: "treatment_plans_client_id_fkey" - columns: ["client_id"] - isOneToOne: false - referencedRelation: "clients" - referencedColumns: ["id"] - }, - ] - } - } - Views: { - active_intakes_overview: { - Row: { - birth_date: string | null - contact_count: number | null - department: string | null - diagnosis_count: number | null - end_date: string | null - id: string | null - name_family: string | null - name_given: string[] | null - psychologist_name: string | null - start_date: string | null - status: string | null - title: string | null - } - Relationships: [] - } - } - Functions: { - get_demo_access_level: { - Args: { check_user_id: string } - Returns: string - } - hook_check_duplicate_email: { Args: { event: Json }; Returns: Json } - is_demo_user: { Args: { check_user_id: string }; Returns: boolean } - } - Enums: { - careplan_status: - | "draft" - | "active" - | "on-hold" - | "revoked" - | "completed" - | "entered-in-error" - | "unknown" - condition_clinical_status: - | "active" - | "recurrence" - | "relapse" - | "inactive" - | "remission" - | "resolved" - | "unknown" - condition_verification_status: - | "unconfirmed" - | "provisional" - | "differential" - | "confirmed" - | "refuted" - | "entered-in-error" - encounter_status: - | "planned" - | "in-progress" - | "on-hold" - | "completed" - | "cancelled" - | "entered-in-error" - | "unknown" - episode_status: "planned" | "active" | "finished" | "cancelled" - gender_type: "male" | "female" | "other" | "unknown" - observation_status: - | "registered" - | "preliminary" - | "final" - | "amended" - | "corrected" - | "cancelled" - | "entered-in-error" - | "unknown" - } - CompositeTypes: { - [_ in never]: never - } - } -} - -type DatabaseWithoutInternals = Omit - -type DefaultSchema = DatabaseWithoutInternals[Extract] - -export type Tables< - DefaultSchemaTableNameOrOptions extends - | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"]) - | { schema: keyof DatabaseWithoutInternals }, - TableName extends DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals - } - ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & - DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"]) - : never = never, -> = DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals -} - ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] & - DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends { - Row: infer R - } - ? R - : never - : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] & - DefaultSchema["Views"]) - ? (DefaultSchema["Tables"] & - DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends { - Row: infer R - } - ? R - : never - : never - -export type TablesInsert< - DefaultSchemaTableNameOrOptions extends - | keyof DefaultSchema["Tables"] - | { schema: keyof DatabaseWithoutInternals }, - TableName extends DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals - } - ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] - : never = never, -> = DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals -} - ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Insert: infer I - } - ? I - : never - : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] - ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { - Insert: infer I - } - ? I - : never - : never - -export type TablesUpdate< - DefaultSchemaTableNameOrOptions extends - | keyof DefaultSchema["Tables"] - | { schema: keyof DatabaseWithoutInternals }, - TableName extends DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals - } - ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] - : never = never, -> = DefaultSchemaTableNameOrOptions extends { - schema: keyof DatabaseWithoutInternals -} - ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends { - Update: infer U - } - ? U - : never - : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"] - ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends { - Update: infer U - } - ? U - : never - : never - -export type Enums< - DefaultSchemaEnumNameOrOptions extends - | keyof DefaultSchema["Enums"] - | { schema: keyof DatabaseWithoutInternals }, - EnumName extends DefaultSchemaEnumNameOrOptions extends { - schema: keyof DatabaseWithoutInternals - } - ? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"] - : never = never, -> = DefaultSchemaEnumNameOrOptions extends { - schema: keyof DatabaseWithoutInternals -} - ? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName] - : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"] - ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions] - : never - -export type CompositeTypes< - PublicCompositeTypeNameOrOptions extends - | keyof DefaultSchema["CompositeTypes"] - | { schema: keyof DatabaseWithoutInternals }, - CompositeTypeName extends PublicCompositeTypeNameOrOptions extends { - schema: keyof DatabaseWithoutInternals - } - ? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"] - : never = never, -> = PublicCompositeTypeNameOrOptions extends { - schema: keyof DatabaseWithoutInternals -} - ? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName] - : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"] - ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions] - : never - -export const Constants = { - public: { - Enums: { - careplan_status: [ - "draft", - "active", - "on-hold", - "revoked", - "completed", - "entered-in-error", - "unknown", - ], - condition_clinical_status: [ - "active", - "recurrence", - "relapse", - "inactive", - "remission", - "resolved", - "unknown", - ], - condition_verification_status: [ - "unconfirmed", - "provisional", - "differential", - "confirmed", - "refuted", - "entered-in-error", - ], - encounter_status: [ - "planned", - "in-progress", - "on-hold", - "completed", - "cancelled", - "entered-in-error", - "unknown", - ], - episode_status: ["planned", "active", "finished", "cancelled"], - gender_type: ["male", "female", "other", "unknown"], - observation_status: [ - "registered", - "preliminary", - "final", - "amended", - "corrected", - "cancelled", - "entered-in-error", - "unknown", - ], - }, - }, -} as const diff --git a/lib/fhir/transforms/patient.ts b/lib/fhir/transforms/patient.ts index 5b360ee..0952968 100644 --- a/lib/fhir/transforms/patient.ts +++ b/lib/fhir/transforms/patient.ts @@ -3,7 +3,7 @@ * Convert between Database rows and FHIR Patient resources */ -import type { Tables, TablesInsert } from '../../database.types'; +import type { Tables, TablesInsert } from '../../supabase/database.types'; import type { FHIRPatient } from '../types'; type PatientRow = Tables<'patients'>; diff --git a/lib/fhir/transforms/practitioner.ts b/lib/fhir/transforms/practitioner.ts index 31afdc5..d374703 100644 --- a/lib/fhir/transforms/practitioner.ts +++ b/lib/fhir/transforms/practitioner.ts @@ -3,7 +3,7 @@ * Convert between Database rows and FHIR Practitioner resources */ -import type { Tables, TablesInsert } from '../../database.types'; +import type { Tables, TablesInsert } from '../../supabase/database.types'; import type { FHIRPractitioner } from '../types'; type PractitionerRow = Tables<'practitioners'>; diff --git a/lib/supabase/database.types.ts b/lib/supabase/database.types.ts index 29f073b..a6e88e6 100644 --- a/lib/supabase/database.types.ts +++ b/lib/supabase/database.types.ts @@ -12,6 +12,31 @@ export type Database = { __InternalSupabase: { PostgrestVersion: "13.0.5" } + graphql_public: { + Tables: { + [_ in never]: never + } + Views: { + [_ in never]: never + } + Functions: { + graphql: { + Args: { + extensions?: Json + operationName?: string + query?: string + variables?: Json + } + Returns: Json + } + } + Enums: { + [_ in never]: never + } + CompositeTypes: { + [_ in never]: never + } + } public: { Tables: { ai_events: { @@ -1535,6 +1560,9 @@ export type CompositeTypes< : never export const Constants = { + graphql_public: { + Enums: {}, + }, public: { Enums: { careplan_status: [ diff --git a/lib/types/client.ts b/lib/types/client.ts index 2d39c5c..50adb81 100644 --- a/lib/types/client.ts +++ b/lib/types/client.ts @@ -4,7 +4,7 @@ * Type definitions for client-related data structures */ -import { Database } from '@/lib/database.types'; +import { Database } from '@/lib/supabase/database.types'; // Base client type from database export type Client = Database['public']['Tables']['clients']['Row'];