Circle V2 API Docs
    Preparing search index...

    Function createSupabaseClient

    • Returns SupabaseClient<
          Database,
          "public",
          "public",
          {
              CompositeTypes: {
                  audit_filter_params: {
                      admission_date_end: string
                      | null;
                      admission_date_start: string | null;
                      archived: boolean | null;
                      auth_end_date: string | null;
                      auth_end_date_start: string | null;
                      auth_start_date: string | null;
                      auth_start_date_end: string | null;
                      case_ids: number[] | null;
                      date_end: string | null;
                      date_start: string | null;
                      entity_id: number | null;
                      facility_ids: string[] | null;
                      include_null_triggers: boolean | null;
                      is_patient_case: boolean | null;
                      latest_per_patient_template: boolean | null;
                      level_of_care_ids: number[] | null;
                      patient_creators: string[] | null;
                      patient_ids: number[] | null;
                      score_max: number | null;
                      score_min: number | null;
                      template_ids: number[] | null;
                      trigger_ids: string[] | null;
                  };
              };
              Enums: {
                  audit_question_type: "pass_fail"
                  | "summary";
                  audit_response_trail_marked_as_status: "pass" | "fail" | "not_applicable";
                  audit_status:
                      | "error"
                      | "pass"
                      | "fail"
                      | "needs_review"
                      | "pending"
                      | "in_progress"
                      | "not_started";
                  chart_review_trigger_type: "admission"
                  | "discharge"
                  | "utilization_end";
                  embedding_status:
                      | "processing"
                      | "failed"
                      | "pending"
                      | "parse"
                      | "extract"
                      | "completed";
                  external_document_type: | "kipu_evaluation"
                  | "kipu_consent_form"
                  | "kipu_ciwa_ar"
                  | "kipu_ciwa_b"
                  | "kipu_group_session"
                  | "lightningstep_formdata"
                  | "lightningstep_txplan"
                  | "kipu_vital_signs"
                  | "kipu_orthostatic_vital_signs"
                  | "kipu_patient_orders"
                  | "kipu_glucose_logs"
                  | "kipu_program_history"
                  | "kipu_diagnosis_history"
                  | "kipu_appointment"
                  | "lightningstep_admissions"
                  | "kipu_episode_outcome"
                  | "sunwave_form"
                  | "sunwave_diagnosis"
                  | "sunwave_group_note"
                  | "sunwave_program"
                  | "sunwave_lab_result"
                  | "sunwave_assessment"
                  | "emr_insurance_information";
                  form_annotation_types: "ai_prompt"
                  | "checkbox"
                  | "text"
                  | "contact";
                  form_types: "patient_chart" | "generated_form" | "emr_document";
                  icd_code_type: "icd" | "procedure" | "diagnosis";
                  insurance_status: "active" | "inactive";
                  integration_status: "error" | "active" | "inactive";
                  integration_type: "kipu" | "lightningstep" | "sunwave";
                  org_member_status: "active" | "inactive" | "pending_invite";
                  profile_type: "external" | "user";
                  subscription_status:
                      | "trial_ended"
                      | "trial_running"
                      | "active"
                      | "inactive";
                  user_actions: "pending"
                  | "addressed"
                  | "dismissed";
              };
              Functions: {
                  current_user_entity_ids: { Args: never; Returns: number[] };
                  get_filtered_audit_run_ids: {
                      Args: {
                          p_filters: {
                              admission_date_end: string | null;
                              admission_date_start: string | null;
                              archived: boolean | null;
                              auth_end_date: string | null;
                              auth_end_date_start: string | null;
                              auth_start_date: string | null;
                              auth_start_date_end: string | null;
                              case_ids: number[] | null;
                              date_end: string | null;
                              date_start: string | null;
                              entity_id: number | null;
                              facility_ids: string[] | null;
                              include_null_triggers: boolean | null;
                              is_patient_case: boolean | null;
                              latest_per_patient_template: boolean | null;
                              level_of_care_ids: number[] | null;
                              patient_creators: string[] | null;
                              patient_ids: number[] | null;
                              score_max: number | null;
                              score_min: number | null;
                              template_ids: number[] | null;
                              trigger_ids: string[] | null;
                          };
                          p_limit?: number;
                          p_offset?: number;
                          p_sort_by?: string;
                          p_sort_dir?: string;
                      };
                      Returns: {
                          audit_run_id: number;
                          pass_percentage: number;
                          total_count: number;
                      }[];
                  };
                  get_filtered_audit_run_scores: {
                      Args: {
                          p_filters: {
                              admission_date_end: string
                              | null;
                              admission_date_start: string | null;
                              archived: boolean | null;
                              auth_end_date: string | null;
                              auth_end_date_start: string | null;
                              auth_start_date: string | null;
                              auth_start_date_end: string | null;
                              case_ids: number[] | null;
                              date_end: string | null;
                              date_start: string | null;
                              entity_id: number | null;
                              facility_ids: string[] | null;
                              include_null_triggers: boolean | null;
                              is_patient_case: boolean | null;
                              latest_per_patient_template: boolean | null;
                              level_of_care_ids: number[] | null;
                              patient_creators: string[] | null;
                              patient_ids: number[] | null;
                              score_max: number | null;
                              score_min: number | null;
                              template_ids: number[] | null;
                              trigger_ids: string[] | null;
                          };
                      };
                      Returns: {
                          assistant_name: string;
                          audit_run_id: number;
                          audit_template_id: number;
                          auth_end_date: string;
                          auth_start_date: string;
                          case_type: boolean;
                          created_at: string;
                          effective_admitted_at: string;
                          facility_name: string;
                          level_of_care_name: string;
                          patient_id: number;
                          patient_name: string;
                          provider_name: string;
                          score: number;
                          trigger_name: string;
                      }[];
                  };
                  get_filtered_patient_groups: {
                      Args: {
                          p_filters: {
                              admission_date_end: string
                              | null;
                              admission_date_start: string | null;
                              archived: boolean | null;
                              auth_end_date: string | null;
                              auth_end_date_start: string | null;
                              auth_start_date: string | null;
                              auth_start_date_end: string | null;
                              case_ids: number[] | null;
                              date_end: string | null;
                              date_start: string | null;
                              entity_id: number | null;
                              facility_ids: string[] | null;
                              include_null_triggers: boolean | null;
                              is_patient_case: boolean | null;
                              latest_per_patient_template: boolean | null;
                              level_of_care_ids: number[] | null;
                              patient_creators: string[] | null;
                              patient_ids: number[] | null;
                              score_max: number | null;
                              score_min: number | null;
                              template_ids: number[] | null;
                              trigger_ids: string[] | null;
                          };
                          p_limit?: number;
                          p_offset?: number;
                          p_sort_by?: string;
                          p_sort_dir?: string;
                      };
                      Returns: {
                          patient_id: number;
                          patient_name: string;
                          run_count: number;
                          total_patient_count: number;
                      }[];
                  };
                  get_patient_case: {
                      Args: { _patient_id: number };
                      Returns: {
                          created_at: string;
                          created_by: string | null;
                          id: number;
                          is_patient_case: boolean;
                          patient_id: number | null;
                          status: string | null;
                          summary: string | null;
                          title: string | null;
                          updated_at: string | null;
                      };
                      SetofOptions: {
                          from: "*";
                          isOneToOne: true;
                          isSetofReturn: false;
                          to: "cases";
                      };
                  };
                  is_superadmin: { Args: never; Returns: boolean };
              };
              Tables: {
                  annotations: {
                      Insert: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          form_id?: number | null;
                          generated_by_ai?: boolean | null;
                          id?: string;
                          prompt?: string | null;
                          type: "ai_prompt" | "checkbox" | "text" | "contact";
                          updated_at?: string;
                      };
                      Relationships: [
                          {
                              columns: ["form_id"];
                              foreignKeyName: "annotations_form_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "forms";
                          },
                      ];
                      Row: {
                          created_at: string;
                          created_by: string
                          | null;
                          form_id: number | null;
                          generated_by_ai: boolean | null;
                          id: string;
                          prompt: string | null;
                          type: "ai_prompt" | "checkbox" | "text" | "contact";
                          updated_at: string;
                      };
                      Update: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          form_id?: number | null;
                          generated_by_ai?: boolean | null;
                          id?: string;
                          prompt?: string | null;
                          type?: "ai_prompt" | "checkbox" | "text" | "contact";
                          updated_at?: string;
                      };
                  };
                  annotations_contact_fields: {
                      Insert: {
                          annotation_id?: string;
                          contact_type_id?: string;
                          created_at?: string;
                          field_id?: string;
                          id?: string;
                      };
                      Relationships: [
                          {
                              columns: ["annotation_id"];
                              foreignKeyName: "annotations_contact_fields_annotation_id_fkey";
                              isOneToOne: true;
                              referencedColumns: ["id"];
                              referencedRelation: "annotations";
                          },
                          {
                              columns: ["contact_type_id"];
                              foreignKeyName: "annotations_contact_fields_contact_type_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["contact_type_id"];
                              referencedRelation: "contact_types";
                          },
                          {
                              columns: ["field_id"];
                              foreignKeyName: "annotations_contact_fields_field_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["field_id"];
                              referencedRelation: "contact_type_fields";
                          },
                      ];
                      Row: {
                          annotation_id: string;
                          contact_type_id: string;
                          created_at: string;
                          field_id: string;
                          id: string;
                      };
                      Update: {
                          annotation_id?: string;
                          contact_type_id?: string;
                          created_at?: string;
                          field_id?: string;
                          id?: string;
                      };
                  };
                  audit_question: {
                      Insert: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          id?: number;
                          org_id?: number | null;
                          question?: string | null;
                          question_order?: number | null;
                          question_type?: "pass_fail" | "summary";
                          share_with_org?: boolean | null;
                          shared_by?: string | null;
                          shared_with_entity_id?: number | null;
                          template_id?: number | null;
                          updated_at?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["org_id"];
                              foreignKeyName: "audit_question_org_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                          {
                              columns: ["template_id"];
                              foreignKeyName: "audit_question_template_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "audit_template";
                          },
                      ];
                      Row: {
                          created_at: string;
                          created_by: string
                          | null;
                          id: number;
                          org_id: number | null;
                          question: string | null;
                          question_order: number | null;
                          question_type: "pass_fail" | "summary";
                          share_with_org: boolean | null;
                          shared_by: string | null;
                          shared_with_entity_id: number | null;
                          template_id: number | null;
                          updated_at: string | null;
                      };
                      Update: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          id?: number;
                          org_id?: number | null;
                          question?: string | null;
                          question_order?: number | null;
                          question_type?: "pass_fail" | "summary";
                          share_with_org?: boolean | null;
                          shared_by?: string | null;
                          shared_with_entity_id?: number | null;
                          template_id?: number | null;
                          updated_at?: string | null;
                      };
                  };
                  audit_response: {
                      Insert: {
                          audit_question_id?: number
                          | null;
                          audit_run_id?: number | null;
                          context_sources?: Json[] | null;
                          created_at?: string;
                          created_by?: string | null;
                          icd_code?: Json[] | null;
                          id?: number;
                          question?: string | null;
                          question_ui?: string | null;
                          reason?: string[] | null;
                          recommendation?: string | null;
                          response?: string | null;
                          sessionId?: number | null;
                          sources?: Json[] | null;
                          status?: string | null;
                          user_action_status?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["audit_question_id"];
                              foreignKeyName: "audit_response_audit_question_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "audit_question";
                          },
                          {
                              columns: ["audit_run_id"];
                              foreignKeyName: "audit_response_audit_run_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "audit_runs";
                          },
                          {
                              columns: ["sessionId"];
                              foreignKeyName: "audit_response_sessionId_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "session";
                          },
                      ];
                      Row: {
                          audit_question_id: number
                          | null;
                          audit_run_id: number | null;
                          context_sources: Json[] | null;
                          created_at: string;
                          created_by: string | null;
                          icd_code: Json[] | null;
                          id: number;
                          question: string | null;
                          question_ui: string | null;
                          reason: string[] | null;
                          recommendation: string | null;
                          response: string | null;
                          sessionId: number | null;
                          sources: Json[] | null;
                          status: string | null;
                          user_action_status: string | null;
                      };
                      Update: {
                          audit_question_id?: number
                          | null;
                          audit_run_id?: number | null;
                          context_sources?: Json[] | null;
                          created_at?: string;
                          created_by?: string | null;
                          icd_code?: Json[] | null;
                          id?: number;
                          question?: string | null;
                          question_ui?: string | null;
                          reason?: string[] | null;
                          recommendation?: string | null;
                          response?: string | null;
                          sessionId?: number | null;
                          sources?: Json[] | null;
                          status?: string | null;
                          user_action_status?: string | null;
                      };
                  };
                  audit_response_trails: {
                      Insert: {
                          audit_response_id: number;
                          comment?: string
                          | null;
                          created_at?: string;
                          created_by?: string | null;
                          id?: string;
                          marked_as: "pass" | "fail" | "not_applicable";
                      };
                      Relationships: [
                          {
                              columns: ["audit_response_id"];
                              foreignKeyName: "audit_response_trails_audit_response_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "audit_response";
                          },
                      ];
                      Row: {
                          audit_response_id: number;
                          comment: string
                          | null;
                          created_at: string;
                          created_by: string | null;
                          id: string;
                          marked_as: "pass" | "fail" | "not_applicable";
                      };
                      Update: {
                          audit_response_id?: number;
                          comment?: string
                          | null;
                          created_at?: string;
                          created_by?: string | null;
                          id?: string;
                          marked_as?: "pass" | "fail" | "not_applicable";
                      };
                  };
                  audit_runs: {
                      Insert: {
                          archived?: boolean;
                          audit_template_id?: number
                          | null;
                          case_id?: number | null;
                          created_at?: string;
                          created_by?: string | null;
                          hidden?: boolean;
                          id?: number;
                          status?: string | null;
                          summary?: string | null;
                          trigger?: string | null;
                          triggered_at?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["audit_template_id"];
                              foreignKeyName: "audit_runs_audit_template_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "audit_template";
                          },
                          {
                              columns: ["case_id"];
                              foreignKeyName: "audit_runs_case_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "cases";
                          },
                          {
                              columns: ["trigger"];
                              foreignKeyName: "audit_runs_triggered_by_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "chart_review_template_triggers";
                          },
                      ];
                      Row: {
                          archived: boolean;
                          audit_template_id: number
                          | null;
                          case_id: number | null;
                          created_at: string;
                          created_by: string | null;
                          hidden: boolean;
                          id: number;
                          status: string | null;
                          summary: string | null;
                          trigger: string | null;
                          triggered_at: string | null;
                      };
                      Update: {
                          archived?: boolean;
                          audit_template_id?: number
                          | null;
                          case_id?: number | null;
                          created_at?: string;
                          created_by?: string | null;
                          hidden?: boolean;
                          id?: number;
                          status?: string | null;
                          summary?: string | null;
                          trigger?: string | null;
                          triggered_at?: string | null;
                      };
                  };
                  audit_template: {
                      Insert: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          custom_review_criteria_prompt?: string | null;
                          custom_summary_prompt?: string | null;
                          description?: string | null;
                          id?: number;
                          name?: string | null;
                          org_id?: number | null;
                          share_with_org?: boolean | null;
                          shared_by?: string | null;
                          shared_with_entity_id?: number | null;
                          updated_at?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["org_id"];
                              foreignKeyName: "audit_template_org_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          created_at: string;
                          created_by: string
                          | null;
                          custom_review_criteria_prompt: string | null;
                          custom_summary_prompt: string | null;
                          description: string | null;
                          id: number;
                          name: string | null;
                          org_id: number | null;
                          share_with_org: boolean | null;
                          shared_by: string | null;
                          shared_with_entity_id: number | null;
                          updated_at: string | null;
                      };
                      Update: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          custom_review_criteria_prompt?: string | null;
                          custom_summary_prompt?: string | null;
                          description?: string | null;
                          id?: number;
                          name?: string | null;
                          org_id?: number | null;
                          share_with_org?: boolean | null;
                          shared_by?: string | null;
                          shared_with_entity_id?: number | null;
                          updated_at?: string | null;
                      };
                  };
                  case_documents: {
                      Insert: {
                          case_id?: number
                          | null;
                          created_at?: string;
                          file_name?: string | null;
                          file_type?: string | null;
                          file_url?: string | null;
                          id?: number;
                          patient_id?: number | null;
                          session_id?: number | null;
                          uploaded_by?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["case_id"];
                              foreignKeyName: "case_documents_case_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "cases";
                          },
                          {
                              columns: ["patient_id"];
                              foreignKeyName: "case_documents_patient_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["patient_id"];
                              referencedRelation: "patient";
                          },
                          {
                              columns: ["session_id"];
                              foreignKeyName: "case_documents_session_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "session";
                          },
                      ];
                      Row: {
                          case_id: number
                          | null;
                          created_at: string;
                          file_name: string | null;
                          file_type: string | null;
                          file_url: string | null;
                          id: number;
                          patient_id: number | null;
                          session_id: number | null;
                          uploaded_by: string | null;
                      };
                      Update: {
                          case_id?: number
                          | null;
                          created_at?: string;
                          file_name?: string | null;
                          file_type?: string | null;
                          file_url?: string | null;
                          id?: number;
                          patient_id?: number | null;
                          session_id?: number | null;
                          uploaded_by?: string | null;
                      };
                  };
                  cases: {
                      Insert: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          id?: number;
                          is_patient_case?: boolean;
                          patient_id?: number | null;
                          status?: string | null;
                          summary?: string | null;
                          title?: string | null;
                          updated_at?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["patient_id"];
                              foreignKeyName: "cases_patient_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["patient_id"];
                              referencedRelation: "patient";
                          },
                      ];
                      Row: {
                          created_at: string;
                          created_by: string
                          | null;
                          id: number;
                          is_patient_case: boolean;
                          patient_id: number | null;
                          status: string | null;
                          summary: string | null;
                          title: string | null;
                          updated_at: string | null;
                      };
                      Update: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          id?: number;
                          is_patient_case?: boolean;
                          patient_id?: number | null;
                          status?: string | null;
                          summary?: string | null;
                          title?: string | null;
                          updated_at?: string | null;
                      };
                  };
                  chart_review_template_triggers: {
                      Insert: {
                          audit_template_id: number;
                          created_at?: string;
                          deleted?: boolean;
                          enabled?: boolean;
                          entity_id: number;
                          filters?: Json;
                          id?: string;
                          interval_seconds?: number
                          | null;
                          last_run_at?: string | null;
                          name: string;
                          time_after_trigger_seconds: number;
                          trigger_type?: "admission" | "discharge" | "utilization_end";
                          updated_at?: string;
                      };
                      Relationships: [
                          {
                              columns: ["audit_template_id"];
                              foreignKeyName: "chart_review_template_triggers_audit_template_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "audit_template";
                          },
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "chart_review_template_triggers_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          audit_template_id: number;
                          created_at: string;
                          deleted: boolean;
                          enabled: boolean;
                          entity_id: number;
                          filters: Json;
                          id: string;
                          interval_seconds: number
                          | null;
                          last_run_at: string | null;
                          name: string;
                          time_after_trigger_seconds: number;
                          trigger_type: "admission" | "discharge" | "utilization_end";
                          updated_at: string;
                      };
                      Update: {
                          audit_template_id?: number;
                          created_at?: string;
                          deleted?: boolean;
                          enabled?: boolean;
                          entity_id?: number;
                          filters?: Json;
                          id?: string;
                          interval_seconds?: number
                          | null;
                          last_run_at?: string | null;
                          name?: string;
                          time_after_trigger_seconds?: number;
                          trigger_type?: "admission" | "discharge" | "utilization_end";
                          updated_at?: string;
                      };
                  };
                  contact_field_values: {
                      Insert: {
                          contact_id?: string;
                          created_at?: string;
                          field_id?: string;
                          value?: string
                          | null;
                          value_id?: string;
                      };
                      Relationships: [
                          {
                              columns: ["contact_id"];
                              foreignKeyName: "contact_field_values_contact_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["contact_id"];
                              referencedRelation: "contacts";
                          },
                          {
                              columns: ["field_id"];
                              foreignKeyName: "contact_field_values_field_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["field_id"];
                              referencedRelation: "contact_type_fields";
                          },
                      ];
                      Row: {
                          contact_id: string;
                          created_at: string;
                          field_id: string;
                          value: string
                          | null;
                          value_id: string;
                      };
                      Update: {
                          contact_id?: string;
                          created_at?: string;
                          field_id?: string;
                          value?: string
                          | null;
                          value_id?: string;
                      };
                  };
                  contact_type_fields: {
                      Insert: {
                          contact_type?: string;
                          created_at?: string;
                          field_id?: string;
                          key?: string;
                      };
                      Relationships: [
                          {
                              columns: ["contact_type"];
                              foreignKeyName: "contact_fields_contact_type_fkey";
                              isOneToOne: false;
                              referencedColumns: ["contact_type_id"];
                              referencedRelation: "contact_types";
                          },
                      ];
                      Row: {
                          contact_type: string;
                          created_at: string;
                          field_id: string;
                          key: string;
                      };
                      Update: {
                          contact_type?: string;
                          created_at?: string;
                          field_id?: string;
                          key?: string;
                      };
                  };
                  contact_types: {
                      Insert: {
                          contact_type_id?: string;
                          created_at?: string;
                          created_by?: string;
                          org_id?: number
                          | null;
                          type?: string;
                      };
                      Relationships: [
                          {
                              columns: ["org_id"];
                              foreignKeyName: "contact_types_org_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          contact_type_id: string;
                          created_at: string;
                          created_by: string;
                          org_id: number
                          | null;
                          type: string;
                      };
                      Update: {
                          contact_type_id?: string;
                          created_at?: string;
                          created_by?: string;
                          org_id?: number
                          | null;
                          type?: string;
                      };
                  };
                  contacts: {
                      Insert: {
                          contact_id?: string;
                          contact_type?: string;
                          created_at?: string;
                          created_by?: string
                          | null;
                          org_id: number;
                      };
                      Relationships: [
                          {
                              columns: ["contact_type"];
                              foreignKeyName: "contacts_contact_type_fkey";
                              isOneToOne: false;
                              referencedColumns: ["contact_type_id"];
                              referencedRelation: "contact_types";
                          },
                          {
                              columns: ["org_id"];
                              foreignKeyName: "contacts_org_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          contact_id: string;
                          contact_type: string;
                          created_at: string;
                          created_by: string
                          | null;
                          org_id: number;
                      };
                      Update: {
                          contact_id?: string;
                          contact_type?: string;
                          created_at?: string;
                          created_by?: string
                          | null;
                          org_id?: number;
                      };
                  };
                  coordinates: {
                      Insert: {
                          annotations_id?: string
                          | null;
                          created_at?: string;
                          created_by?: string | null;
                          height?: string | null;
                          hPct?: string | null;
                          id?: number;
                          page?: string | null;
                          updated_at?: string | null;
                          value?: string | null;
                          width?: string | null;
                          wPct?: string | null;
                          x?: string | null;
                          xPct?: string | null;
                          y?: string | null;
                          yPct?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["annotations_id"];
                              foreignKeyName: "coordinates_annotations_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "annotations";
                          },
                      ];
                      Row: {
                          annotations_id: string
                          | null;
                          created_at: string;
                          created_by: string | null;
                          height: string | null;
                          hPct: string | null;
                          id: number;
                          page: string | null;
                          updated_at: string | null;
                          value: string | null;
                          width: string | null;
                          wPct: string | null;
                          x: string | null;
                          xPct: string | null;
                          y: string | null;
                          yPct: string | null;
                      };
                      Update: {
                          annotations_id?: string
                          | null;
                          created_at?: string;
                          created_by?: string | null;
                          height?: string | null;
                          hPct?: string | null;
                          id?: number;
                          page?: string | null;
                          updated_at?: string | null;
                          value?: string | null;
                          width?: string | null;
                          wPct?: string | null;
                          x?: string | null;
                          xPct?: string | null;
                          y?: string | null;
                          yPct?: string | null;
                      };
                  };
                  entity: {
                      Insert: {
                          company_name: string;
                          created_at?: string
                          | null;
                          created_by?: string | null;
                          entity_id?: number;
                      };
                      Relationships: [];
                      Row: {
                          company_name: string;
                          created_at: string | null;
                          created_by: string | null;
                          entity_id: number;
                      };
                      Update: {
                          company_name?: string;
                          created_at?: string
                          | null;
                          created_by?: string | null;
                          entity_id?: number;
                      };
                  };
                  entity_levels_of_care: {
                      Insert: {
                          created_at?: string;
                          entity_id: number;
                          facility_id?: string
                          | null;
                          id?: number;
                          name: string;
                          parent_level_of_care_id?: number | null;
                          updated_at?: string;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "entity_levels_of_care_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                          {
                              columns: ["facility_id"];
                              foreignKeyName: "entity_levels_of_care_facility_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "facilities";
                          },
                          {
                              columns: ["parent_level_of_care_id"];
                              foreignKeyName: "entity_levels_of_care_parent_level_of_care_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "entity_levels_of_care";
                          },
                      ];
                      Row: {
                          created_at: string;
                          entity_id: number;
                          facility_id: string
                          | null;
                          id: number;
                          name: string;
                          parent_level_of_care_id: number | null;
                          updated_at: string;
                      };
                      Update: {
                          created_at?: string;
                          entity_id?: number;
                          facility_id?: string
                          | null;
                          id?: number;
                          name?: string;
                          parent_level_of_care_id?: number | null;
                          updated_at?: string;
                      };
                  };
                  facilities: {
                      Insert: {
                          created_at?: string;
                          entity_id: number;
                          id?: string;
                          name: string;
                          timezone?: string
                          | null;
                          updated_at?: string;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "facilities_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          created_at: string;
                          entity_id: number;
                          id: string;
                          name: string;
                          timezone: string
                          | null;
                          updated_at: string;
                      };
                      Update: {
                          created_at?: string;
                          entity_id?: number;
                          id?: string;
                          name?: string;
                          timezone?: string
                          | null;
                          updated_at?: string;
                      };
                  };
                  form_answers: {
                      Insert: {
                          annotation_id: string;
                          citations?: Json;
                          context_sources?: Json;
                          coordinates_snapshot?: Json[]
                          | null;
                          created_at?: string | null;
                          font_size?: number | null;
                          id?: string;
                          prompt_snapshot?: string | null;
                          run_id: string;
                          status?: string | null;
                          updated_at?: string | null;
                          value?: Json[] | null;
                      };
                      Relationships: [
                          {
                              columns: ["annotation_id"];
                              foreignKeyName: "form_answers_annotation_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "annotations";
                          },
                          {
                              columns: ["run_id"];
                              foreignKeyName: "form_answers_run_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "form_runs";
                          },
                      ];
                      Row: {
                          annotation_id: string;
                          citations: Json;
                          context_sources: Json;
                          coordinates_snapshot: Json[]
                          | null;
                          created_at: string | null;
                          font_size: number | null;
                          id: string;
                          prompt_snapshot: string | null;
                          run_id: string;
                          status: string | null;
                          updated_at: string | null;
                          value: Json[] | null;
                      };
                      Update: {
                          annotation_id?: string;
                          citations?: Json;
                          context_sources?: Json;
                          coordinates_snapshot?: Json[]
                          | null;
                          created_at?: string | null;
                          font_size?: number | null;
                          id?: string;
                          prompt_snapshot?: string | null;
                          run_id?: string;
                          status?: string | null;
                          updated_at?: string | null;
                          value?: Json[] | null;
                      };
                  };
                  form_run_files: {
                      Insert: {
                          created_at?: string
                          | null;
                          file_type: string;
                          file_url: string;
                          id?: string;
                          mime_type?: string | null;
                          run_id: string;
                          size_bytes?: number | null;
                      };
                      Relationships: [
                          {
                              columns: ["run_id"];
                              foreignKeyName: "form_run_files_run_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "form_runs";
                          },
                      ];
                      Row: {
                          created_at: string
                          | null;
                          file_type: string;
                          file_url: string;
                          id: string;
                          mime_type: string | null;
                          run_id: string;
                          size_bytes: number | null;
                      };
                      Update: {
                          created_at?: string
                          | null;
                          file_type?: string;
                          file_url?: string;
                          id?: string;
                          mime_type?: string | null;
                          run_id?: string;
                          size_bytes?: number | null;
                      };
                  };
                  form_runs: {
                      Insert: {
                          created_at?: string
                          | null;
                          created_by?: string | null;
                          error_msg?: string | null;
                          finished_at?: string | null;
                          form_id: number;
                          id?: string;
                          patient_id?: number | null;
                          status?: string;
                          template_snapshot?: Json;
                          template_version?: number | null;
                      };
                      Relationships: [
                          {
                              columns: ["form_id"];
                              foreignKeyName: "form_runs_form_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "forms";
                          },
                      ];
                      Row: {
                          created_at: string
                          | null;
                          created_by: string | null;
                          error_msg: string | null;
                          finished_at: string | null;
                          form_id: number;
                          id: string;
                          patient_id: number | null;
                          status: string;
                          template_snapshot: Json;
                          template_version: number | null;
                      };
                      Update: {
                          created_at?: string
                          | null;
                          created_by?: string | null;
                          error_msg?: string | null;
                          finished_at?: string | null;
                          form_id?: number;
                          id?: string;
                          patient_id?: number | null;
                          status?: string;
                          template_snapshot?: Json;
                          template_version?: number | null;
                      };
                  };
                  forms: {
                      Insert: {
                          context?: string
                          | null;
                          created_at?: string;
                          created_by?: string | null;
                          file_name?: string | null;
                          file_type?: string | null;
                          file_url?: string | null;
                          id?: number;
                          org_id?: number | null;
                          share_with_org?: boolean;
                          shared_by?: string | null;
                          updated_at?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["org_id"];
                              foreignKeyName: "forms_org_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          context: string
                          | null;
                          created_at: string;
                          created_by: string | null;
                          file_name: string | null;
                          file_type: string | null;
                          file_url: string | null;
                          id: number;
                          org_id: number | null;
                          share_with_org: boolean;
                          shared_by: string | null;
                          updated_at: string | null;
                      };
                      Update: {
                          context?: string
                          | null;
                          created_at?: string;
                          created_by?: string | null;
                          file_name?: string | null;
                          file_type?: string | null;
                          file_url?: string | null;
                          id?: number;
                          org_id?: number | null;
                          share_with_org?: boolean;
                          shared_by?: string | null;
                          updated_at?: string | null;
                      };
                  };
                  forms_contact_types: {
                      Insert: {
                          contact_type_id?: string;
                          created_at?: string;
                          form_id: number;
                          id?: string;
                      };
                      Relationships: [
                          {
                              columns: ["contact_type_id"];
                              foreignKeyName: "forms_contact_types_contact_type_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["contact_type_id"];
                              referencedRelation: "contact_types";
                          },
                          {
                              columns: ["form_id"];
                              foreignKeyName: "forms_contact_types_form_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "forms";
                          },
                      ];
                      Row: {
                          contact_type_id: string;
                          created_at: string;
                          form_id: number;
                          id: string;
                      };
                      Update: {
                          contact_type_id?: string;
                          created_at?: string;
                          form_id?: number;
                          id?: string;
                      };
                  };
                  icd_codes: {
                      Insert: {
                          code: string;
                          code_type?: "icd"
                          | "procedure"
                          | "diagnosis";
                          created_at?: string;
                          description: string;
                          id?: number;
                          parent_icd_code_id?: number | null;
                      };
                      Relationships: [
                          {
                              columns: ["parent_icd_code_id"];
                              foreignKeyName: "icd_codes_parent_icd_code_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "icd_codes";
                          },
                      ];
                      Row: {
                          code: string;
                          code_type: "icd"
                          | "procedure"
                          | "diagnosis";
                          created_at: string;
                          description: string;
                          id: number;
                          parent_icd_code_id: number | null;
                      };
                      Update: {
                          code?: string;
                          code_type?: "icd"
                          | "procedure"
                          | "diagnosis";
                          created_at?: string;
                          description?: string;
                          id?: number;
                          parent_icd_code_id?: number | null;
                      };
                  };
                  integrations: {
                      Insert: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          credentials: Json;
                          entity_id: number;
                          facility_id?: string | null;
                          id?: string;
                          label?: string | null;
                          last_sync?: string | null;
                          status?: "error" | "active" | "inactive";
                          type: "kipu" | "lightningstep" | "sunwave";
                          updated_at?: string;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "integrations_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                          {
                              columns: ["facility_id"];
                              foreignKeyName: "integrations_facility_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "facilities";
                          },
                      ];
                      Row: {
                          created_at: string;
                          created_by: string
                          | null;
                          credentials: Json;
                          entity_id: number;
                          facility_id: string | null;
                          id: string;
                          label: string | null;
                          last_sync: string | null;
                          status: "error" | "active" | "inactive";
                          type: "kipu" | "lightningstep" | "sunwave";
                          updated_at: string;
                      };
                      Update: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          credentials?: Json;
                          entity_id?: number;
                          facility_id?: string | null;
                          id?: string;
                          label?: string | null;
                          last_sync?: string | null;
                          status?: "error" | "active" | "inactive";
                          type?: "kipu" | "lightningstep" | "sunwave";
                          updated_at?: string;
                      };
                  };
                  job_executions: {
                      Insert: {
                          completed_at?: string
                          | null;
                          enqueued_at?: string;
                          enqueued_id: string;
                          entity_id?: number | null;
                          expires_at?: string;
                          id?: number;
                          key: string;
                          payload?: Json;
                          started_at?: string | null;
                          status?: string;
                      };
                      Relationships: [];
                      Row: {
                          completed_at: string | null;
                          enqueued_at: string;
                          enqueued_id: string;
                          entity_id: number | null;
                          expires_at: string;
                          id: number;
                          key: string;
                          payload: Json;
                          started_at: string | null;
                          status: string;
                      };
                      Update: {
                          completed_at?: string
                          | null;
                          enqueued_at?: string;
                          enqueued_id?: string;
                          entity_id?: number | null;
                          expires_at?: string;
                          id?: number;
                          key?: string;
                          payload?: Json;
                          started_at?: string | null;
                          status?: string;
                      };
                  };
                  patient: {
                      Insert: {
                          address_city?: string
                          | null;
                          address_state?: string | null;
                          address_street1?: string | null;
                          address_street2?: string | null;
                          address_zipcode?: string | null;
                          created_at?: string;
                          created_by?: string | null;
                          dob?: string | null;
                          email?: string | null;
                          entity_id?: number | null;
                          external_patient_id?: string | null;
                          external_source?: "kipu" | "lightningstep" | "sunwave" | null;
                          facility_id?: string | null;
                          first_name?: string | null;
                          gender?: string | null;
                          intake_notes?: string | null;
                          last_name?: string | null;
                          last_updated_summary?: string | null;
                          patient_id?: number;
                          phone_mobile?: string | null;
                          primary_provider_id?: number | null;
                          status?: number | null;
                          summary?: Json;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "patient_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                          {
                              columns: ["facility_id"];
                              foreignKeyName: "patient_facility_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "facilities";
                          },
                          {
                              columns: ["primary_provider_id"];
                              foreignKeyName: "patient_primary_provider_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "profiles";
                          },
                      ];
                      Row: {
                          address_city: string
                          | null;
                          address_state: string | null;
                          address_street1: string | null;
                          address_street2: string | null;
                          address_zipcode: string | null;
                          created_at: string;
                          created_by: string | null;
                          dob: string | null;
                          email: string | null;
                          entity_id: number | null;
                          external_patient_id: string | null;
                          external_source: "kipu" | "lightningstep" | "sunwave" | null;
                          facility_id: string | null;
                          first_name: string | null;
                          gender: string | null;
                          intake_notes: string | null;
                          last_name: string | null;
                          last_updated_summary: string | null;
                          patient_id: number;
                          phone_mobile: string | null;
                          primary_provider_id: number | null;
                          status: number | null;
                          summary: Json;
                      };
                      Update: {
                          address_city?: string
                          | null;
                          address_state?: string | null;
                          address_street1?: string | null;
                          address_street2?: string | null;
                          address_zipcode?: string | null;
                          created_at?: string;
                          created_by?: string | null;
                          dob?: string | null;
                          email?: string | null;
                          entity_id?: number | null;
                          external_patient_id?: string | null;
                          external_source?: "kipu" | "lightningstep" | "sunwave" | null;
                          facility_id?: string | null;
                          first_name?: string | null;
                          gender?: string | null;
                          intake_notes?: string | null;
                          last_name?: string | null;
                          last_updated_summary?: string | null;
                          patient_id?: number;
                          phone_mobile?: string | null;
                          primary_provider_id?: number | null;
                          status?: number | null;
                          summary?: Json;
                      };
                  };
                  patient_admissions: {
                      Insert: {
                          admitted_at: string;
                          created_at?: string;
                          discharged_at?: string
                          | null;
                          external_admission_id?: string | null;
                          id?: number;
                          integration_id?: string | null;
                          last_sync?: string | null;
                          level_of_care_id?: number | null;
                          patient_id?: number | null;
                          updated_at?: string;
                      };
                      Relationships: [
                          {
                              columns: ["integration_id"];
                              foreignKeyName: "patient_admissions_integration_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "integrations";
                          },
                          {
                              columns: ["level_of_care_id"];
                              foreignKeyName: "patient_admissions_level_of_care_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "entity_levels_of_care";
                          },
                          {
                              columns: ["patient_id"];
                              foreignKeyName: "patient_admissions_patient_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["patient_id"];
                              referencedRelation: "patient";
                          },
                      ];
                      Row: {
                          admitted_at: string;
                          created_at: string;
                          discharged_at: string
                          | null;
                          external_admission_id: string | null;
                          id: number;
                          integration_id: string | null;
                          last_sync: string | null;
                          level_of_care_id: number | null;
                          patient_id: number | null;
                          updated_at: string;
                      };
                      Update: {
                          admitted_at?: string;
                          created_at?: string;
                          discharged_at?: string
                          | null;
                          external_admission_id?: string | null;
                          id?: number;
                          integration_id?: string | null;
                          last_sync?: string | null;
                          level_of_care_id?: number | null;
                          patient_id?: number | null;
                          updated_at?: string;
                      };
                  };
                  patient_charts: {
                      Insert: {
                          circle_metadata?: Json;
                          created_at?: string;
                          created_by?: string
                          | null;
                          embedding_count?: number | null;
                          embedding_err_msg?: string | null;
                          embedding_status?:
                              | "processing"
                              | "failed"
                              | "pending"
                              | "parse"
                              | "extract"
                              | "completed"
                              | null;
                          entity_id?: number
                          | null;
                          external_document_created_at?: string | null;
                          external_document_id?: string | null;
                          external_document_type?:
                              | "kipu_evaluation"
                              | "kipu_consent_form"
                              | "kipu_ciwa_ar"
                              | "kipu_ciwa_b"
                              | "kipu_group_session"
                              | "lightningstep_formdata"
                              | "lightningstep_txplan"
                              | "kipu_vital_signs"
                              | "kipu_orthostatic_vital_signs"
                              | "kipu_patient_orders"
                              | "kipu_glucose_logs"
                              | "kipu_program_history"
                              | "kipu_diagnosis_history"
                              | "kipu_appointment"
                              | "lightningstep_admissions"
                              | "kipu_episode_outcome"
                              | "sunwave_form"
                              | "sunwave_diagnosis"
                              | "sunwave_group_note"
                              | "sunwave_program"
                              | "sunwave_lab_result"
                              | "sunwave_assessment"
                              | "emr_insurance_information"
                              | null;
                          external_document_updated_at?: string
                          | null;
                          file_name?: string | null;
                          file_type?: "patient_chart" | "generated_form" | "emr_document" | null;
                          file_url?: string | null;
                          id?: number;
                          integration_id?: string | null;
                          is_ready?: boolean | null;
                          patient_id?: number | null;
                          raw_document?: Json;
                          run_id?: string | null;
                          sources?: Json;
                          updated_at?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "patient_charts_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                          {
                              columns: ["integration_id"];
                              foreignKeyName: "patient_charts_integration_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "integrations";
                          },
                          {
                              columns: ["patient_id"];
                              foreignKeyName: "patient_charts_patient_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["patient_id"];
                              referencedRelation: "patient";
                          },
                          {
                              columns: ["run_id"];
                              foreignKeyName: "patient_charts_run_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "form_runs";
                          },
                      ];
                      Row: {
                          circle_metadata: Json;
                          created_at: string;
                          created_by: string
                          | null;
                          embedding_count: number | null;
                          embedding_err_msg: string | null;
                          embedding_status:
                              | "processing"
                              | "failed"
                              | "pending"
                              | "parse"
                              | "extract"
                              | "completed"
                              | null;
                          entity_id: number
                          | null;
                          external_document_created_at: string | null;
                          external_document_id: string | null;
                          external_document_type:
                              | "kipu_evaluation"
                              | "kipu_consent_form"
                              | "kipu_ciwa_ar"
                              | "kipu_ciwa_b"
                              | "kipu_group_session"
                              | "lightningstep_formdata"
                              | "lightningstep_txplan"
                              | "kipu_vital_signs"
                              | "kipu_orthostatic_vital_signs"
                              | "kipu_patient_orders"
                              | "kipu_glucose_logs"
                              | "kipu_program_history"
                              | "kipu_diagnosis_history"
                              | "kipu_appointment"
                              | "lightningstep_admissions"
                              | "kipu_episode_outcome"
                              | "sunwave_form"
                              | "sunwave_diagnosis"
                              | "sunwave_group_note"
                              | "sunwave_program"
                              | "sunwave_lab_result"
                              | "sunwave_assessment"
                              | "emr_insurance_information"
                              | null;
                          external_document_updated_at: string
                          | null;
                          file_name: string | null;
                          file_type: "patient_chart" | "generated_form" | "emr_document" | null;
                          file_url: string | null;
                          id: number;
                          integration_id: string | null;
                          is_ready: boolean | null;
                          patient_id: number | null;
                          raw_document: Json;
                          run_id: string | null;
                          sources: Json;
                          updated_at: string | null;
                      };
                      Update: {
                          circle_metadata?: Json;
                          created_at?: string;
                          created_by?: string
                          | null;
                          embedding_count?: number | null;
                          embedding_err_msg?: string | null;
                          embedding_status?:
                              | "processing"
                              | "failed"
                              | "pending"
                              | "parse"
                              | "extract"
                              | "completed"
                              | null;
                          entity_id?: number
                          | null;
                          external_document_created_at?: string | null;
                          external_document_id?: string | null;
                          external_document_type?:
                              | "kipu_evaluation"
                              | "kipu_consent_form"
                              | "kipu_ciwa_ar"
                              | "kipu_ciwa_b"
                              | "kipu_group_session"
                              | "lightningstep_formdata"
                              | "lightningstep_txplan"
                              | "kipu_vital_signs"
                              | "kipu_orthostatic_vital_signs"
                              | "kipu_patient_orders"
                              | "kipu_glucose_logs"
                              | "kipu_program_history"
                              | "kipu_diagnosis_history"
                              | "kipu_appointment"
                              | "lightningstep_admissions"
                              | "kipu_episode_outcome"
                              | "sunwave_form"
                              | "sunwave_diagnosis"
                              | "sunwave_group_note"
                              | "sunwave_program"
                              | "sunwave_lab_result"
                              | "sunwave_assessment"
                              | "emr_insurance_information"
                              | null;
                          external_document_updated_at?: string
                          | null;
                          file_name?: string | null;
                          file_type?: "patient_chart" | "generated_form" | "emr_document" | null;
                          file_url?: string | null;
                          id?: number;
                          integration_id?: string | null;
                          is_ready?: boolean | null;
                          patient_id?: number | null;
                          raw_document?: Json;
                          run_id?: string | null;
                          sources?: Json;
                          updated_at?: string | null;
                      };
                  };
                  patient_charts_contacts: {
                      Insert: {
                          contact_id?: string;
                          contact_type_id: string;
                          created_at?: string;
                          id?: string;
                          patient_chart_id: number;
                      };
                      Relationships: [
                          {
                              columns: ["contact_id"];
                              foreignKeyName: "patient_charts_contacts_contact_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["contact_id"];
                              referencedRelation: "contacts";
                          },
                          {
                              columns: ["contact_type_id"];
                              foreignKeyName: "patient_charts_contacts_contact_type_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["contact_type_id"];
                              referencedRelation: "contact_types";
                          },
                          {
                              columns: ["patient_chart_id"];
                              foreignKeyName: "patient_charts_contacts_patient_chart_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "patient_charts";
                          },
                      ];
                      Row: {
                          contact_id: string;
                          contact_type_id: string;
                          created_at: string;
                          id: string;
                          patient_chart_id: number;
                      };
                      Update: {
                          contact_id?: string;
                          contact_type_id?: string;
                          created_at?: string;
                          id?: string;
                          patient_chart_id?: number;
                      };
                  };
                  patient_insurances: {
                      Insert: {
                          created_at?: string;
                          effective_date?: string
                          | null;
                          group_id?: string | null;
                          id?: number;
                          notes?: string | null;
                          patient_id: number;
                          payor_id: number;
                          plan_type?: string | null;
                          policy_number?: string | null;
                          priority?: number | null;
                          status?: "active" | "inactive";
                          subscriber_address_city?: string | null;
                          subscriber_address_country?: string | null;
                          subscriber_address_state?: string | null;
                          subscriber_address_street?: string | null;
                          subscriber_address_street2?: string | null;
                          subscriber_address_zip?: string | null;
                          subscriber_dob?: string | null;
                          subscriber_first_name?: string | null;
                          subscriber_gender?: string | null;
                          subscriber_last_name?: string | null;
                          subscriber_relationship?: string | null;
                          termination_date?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["patient_id"];
                              foreignKeyName: "patient_insurances_patient_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["patient_id"];
                              referencedRelation: "patient";
                          },
                          {
                              columns: ["payor_id"];
                              foreignKeyName: "patient_insurances_payor_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "payors";
                          },
                      ];
                      Row: {
                          created_at: string;
                          effective_date: string
                          | null;
                          group_id: string | null;
                          id: number;
                          notes: string | null;
                          patient_id: number;
                          payor_id: number;
                          plan_type: string | null;
                          policy_number: string | null;
                          priority: number | null;
                          status: "active" | "inactive";
                          subscriber_address_city: string | null;
                          subscriber_address_country: string | null;
                          subscriber_address_state: string | null;
                          subscriber_address_street: string | null;
                          subscriber_address_street2: string | null;
                          subscriber_address_zip: string | null;
                          subscriber_dob: string | null;
                          subscriber_first_name: string | null;
                          subscriber_gender: string | null;
                          subscriber_last_name: string | null;
                          subscriber_relationship: string | null;
                          termination_date: string | null;
                      };
                      Update: {
                          created_at?: string;
                          effective_date?: string
                          | null;
                          group_id?: string | null;
                          id?: number;
                          notes?: string | null;
                          patient_id?: number;
                          payor_id?: number;
                          plan_type?: string | null;
                          policy_number?: string | null;
                          priority?: number | null;
                          status?: "active" | "inactive";
                          subscriber_address_city?: string | null;
                          subscriber_address_country?: string | null;
                          subscriber_address_state?: string | null;
                          subscriber_address_street?: string | null;
                          subscriber_address_street2?: string | null;
                          subscriber_address_zip?: string | null;
                          subscriber_dob?: string | null;
                          subscriber_first_name?: string | null;
                          subscriber_gender?: string | null;
                          subscriber_last_name?: string | null;
                          subscriber_relationship?: string | null;
                          termination_date?: string | null;
                      };
                  };
                  patient_utilization_reviews: {
                      Insert: {
                          authorization_date?: string
                          | null;
                          authorization_number?: string | null;
                          created_at?: string;
                          end_date?: string | null;
                          entity_id: number;
                          external_utilization_review_id: string;
                          frequency?: string | null;
                          id?: string;
                          insurance?: string | null;
                          integration_id: string;
                          lcd: boolean;
                          level_of_care_id?: number | null;
                          next_care_level?: string | null;
                          next_care_level_date?: string | null;
                          next_review?: string | null;
                          number_of_days?: number | null;
                          patient_admission_id: number;
                          patient_id: number;
                          payor_id?: number | null;
                          start_date?: string | null;
                          status?: string | null;
                          updated_at?: string;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "patient_utilization_reviews_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                          {
                              columns: ["integration_id"];
                              foreignKeyName: "patient_utilization_reviews_integration_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "integrations";
                          },
                          {
                              columns: ["level_of_care_id"];
                              foreignKeyName: "patient_utilization_reviews_level_of_care_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "entity_levels_of_care";
                          },
                          {
                              columns: ["patient_admission_id"];
                              foreignKeyName: "patient_utilization_reviews_patient_admission_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "patient_admissions";
                          },
                          {
                              columns: ["patient_id"];
                              foreignKeyName: "patient_utilization_reviews_patient_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["patient_id"];
                              referencedRelation: "patient";
                          },
                          {
                              columns: ["payor_id"];
                              foreignKeyName: "patient_utilization_reviews_payor_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "payors";
                          },
                      ];
                      Row: {
                          authorization_date: string
                          | null;
                          authorization_number: string | null;
                          created_at: string;
                          end_date: string | null;
                          entity_id: number;
                          external_utilization_review_id: string;
                          frequency: string | null;
                          id: string;
                          insurance: string | null;
                          integration_id: string;
                          lcd: boolean;
                          level_of_care_id: number | null;
                          next_care_level: string | null;
                          next_care_level_date: string | null;
                          next_review: string | null;
                          number_of_days: number | null;
                          patient_admission_id: number;
                          patient_id: number;
                          payor_id: number | null;
                          start_date: string | null;
                          status: string | null;
                          updated_at: string;
                      };
                      Update: {
                          authorization_date?: string
                          | null;
                          authorization_number?: string | null;
                          created_at?: string;
                          end_date?: string | null;
                          entity_id?: number;
                          external_utilization_review_id?: string;
                          frequency?: string | null;
                          id?: string;
                          insurance?: string | null;
                          integration_id?: string;
                          lcd?: boolean;
                          level_of_care_id?: number | null;
                          next_care_level?: string | null;
                          next_care_level_date?: string | null;
                          next_review?: string | null;
                          number_of_days?: number | null;
                          patient_admission_id?: number;
                          patient_id?: number;
                          payor_id?: number | null;
                          start_date?: string | null;
                          status?: string | null;
                          updated_at?: string;
                      };
                  };
                  payors: {
                      Insert: { created_at?: string; id?: number; name?: string };
                      Relationships: [];
                      Row: { created_at: string; id: number; name: string };
                      Update: { created_at?: string; id?: number; name?: string };
                  };
                  pending_invites: {
                      Insert: {
                          email: string;
                          entity_id: number;
                          first_name?: string
                          | null;
                          id?: number;
                          is_confirmed?: boolean | null;
                          last_name?: string | null;
                          role_id: number;
                          title?: string | null;
                          user_id: string;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "pending_invites_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          email: string;
                          entity_id: number;
                          first_name: string
                          | null;
                          id: number;
                          is_confirmed: boolean | null;
                          last_name: string | null;
                          role_id: number;
                          title: string | null;
                          user_id: string;
                      };
                      Update: {
                          email?: string;
                          entity_id?: number;
                          first_name?: string
                          | null;
                          id?: number;
                          is_confirmed?: boolean | null;
                          last_name?: string | null;
                          role_id?: number;
                          title?: string | null;
                          user_id?: string;
                      };
                  };
                  permissions: {
                      Insert: {
                          description?: string
                          | null;
                          permission_id?: number;
                          permission_name: string;
                      };
                      Relationships: [];
                      Row: {
                          description: string | null;
                          permission_id: number;
                          permission_name: string;
                      };
                      Update: {
                          description?: string
                          | null;
                          permission_id?: number;
                          permission_name?: string;
                      };
                  };
                  profiles: {
                      Insert: {
                          clinic_size?: string
                          | null;
                          created_at?: string | null;
                          customer_id?: string | null;
                          email?: string | null;
                          expectations?: string | null;
                          external_system?: "kipu" | "lightningstep" | "sunwave" | null;
                          external_system_id?: string | null;
                          first_name?: string | null;
                          hear_about_us?: string | null;
                          id?: number;
                          is_superadmin?: boolean;
                          last_name?: string | null;
                          last_updated?: string | null;
                          price_id?: string | null;
                          profile_type?: "external" | "user";
                          session_limit?: number | null;
                          subscription_status?:
                              | "trial_ended"
                              | "trial_running"
                              | "active"
                              | "inactive"
                              | null;
                          title?: string
                          | null;
                          user_id?: string | null;
                          vertical?: string | null;
                      };
                      Relationships: [];
                      Row: {
                          clinic_size: string | null;
                          created_at: string | null;
                          customer_id: string | null;
                          email: string | null;
                          expectations: string | null;
                          external_system: "kipu" | "lightningstep" | "sunwave" | null;
                          external_system_id: string | null;
                          first_name: string | null;
                          hear_about_us: string | null;
                          id: number;
                          is_superadmin: boolean;
                          last_name: string | null;
                          last_updated: string | null;
                          price_id: string | null;
                          profile_type: "external" | "user";
                          session_limit: number | null;
                          subscription_status:
                              | "trial_ended"
                              | "trial_running"
                              | "active"
                              | "inactive"
                              | null;
                          title: string
                          | null;
                          user_id: string | null;
                          vertical: string | null;
                      };
                      Update: {
                          clinic_size?: string
                          | null;
                          created_at?: string | null;
                          customer_id?: string | null;
                          email?: string | null;
                          expectations?: string | null;
                          external_system?: "kipu" | "lightningstep" | "sunwave" | null;
                          external_system_id?: string | null;
                          first_name?: string | null;
                          hear_about_us?: string | null;
                          id?: number;
                          is_superadmin?: boolean;
                          last_name?: string | null;
                          last_updated?: string | null;
                          price_id?: string | null;
                          profile_type?: "external" | "user";
                          session_limit?: number | null;
                          subscription_status?:
                              | "trial_ended"
                              | "trial_running"
                              | "active"
                              | "inactive"
                              | null;
                          title?: string
                          | null;
                          user_id?: string | null;
                          vertical?: string | null;
                      };
                  };
                  role_permissions: {
                      Insert: { id?: number; permission_id: number; role_id: number };
                      Relationships: [
                          {
                              columns: ["permission_id"];
                              foreignKeyName: "role_permissions_permission_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["permission_id"];
                              referencedRelation: "permissions";
                          },
                          {
                              columns: ["role_id"];
                              foreignKeyName: "role_permissions_role_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["role_id"];
                              referencedRelation: "roles";
                          },
                      ];
                      Row: { id: number; permission_id: number; role_id: number };
                      Update: { id?: number; permission_id?: number; role_id?: number };
                  };
                  roles: {
                      Insert: {
                          description?: string
                          | null;
                          role_id?: number;
                          role_name: string;
                      };
                      Relationships: [];
                      Row: { description: string | null; role_id: number; role_name: string };
                      Update: {
                          description?: string | null;
                          role_id?: number;
                          role_name?: string;
                      };
                  };
                  saved_filters: {
                      Insert: {
                          column_visibility?: Json;
                          created_at?: string;
                          entity_id: number;
                          filters?: Json;
                          id?: string;
                          name?: string;
                          page_key: string;
                          updated_at?: string;
                          user_id: string;
                          view_mode?: string;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "saved_filters_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          column_visibility: Json;
                          created_at: string;
                          entity_id: number;
                          filters: Json;
                          id: string;
                          name: string;
                          page_key: string;
                          updated_at: string;
                          user_id: string;
                          view_mode: string;
                      };
                      Update: {
                          column_visibility?: Json;
                          created_at?: string;
                          entity_id?: number;
                          filters?: Json;
                          id?: string;
                          name?: string;
                          page_key?: string;
                          updated_at?: string;
                          user_id?: string;
                          view_mode?: string;
                      };
                  };
                  sections: {
                      Insert: {
                          body: string;
                          bullet_format?: boolean
                          | null;
                          created_by?: string | null;
                          id?: string;
                          last_updated?: string | null;
                          name: string;
                          optional: boolean;
                          order?: number | null;
                          template_id?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["template_id"];
                              foreignKeyName: "sections_template_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "templates";
                          },
                      ];
                      Row: {
                          body: string;
                          bullet_format: boolean
                          | null;
                          created_by: string | null;
                          id: string;
                          last_updated: string | null;
                          name: string;
                          optional: boolean;
                          order: number | null;
                          template_id: string | null;
                      };
                      Update: {
                          body?: string;
                          bullet_format?: boolean
                          | null;
                          created_by?: string | null;
                          id?: string;
                          last_updated?: string | null;
                          name?: string;
                          optional?: boolean;
                          order?: number | null;
                          template_id?: string | null;
                      };
                  };
                  session: {
                      Insert: {
                          ai_summarized_note?: string
                          | null;
                          as_summarized_note_type?: string | null;
                          audit_run_id?: number | null;
                          audit_status?:
                              | "error"
                              | "pass"
                              | "fail"
                              | "needs_review"
                              | "pending"
                              | "in_progress"
                              | "not_started"
                              | null;
                          case_id?: number
                          | null;
                          cpt_code?: Json[] | null;
                          created_at?: string;
                          created_by?: string | null;
                          dsm_code?: Json[] | null;
                          end_timestamp?: string;
                          error_msg?: string | null;
                          file_url?: string | null;
                          icd_code?: Json[] | null;
                          id?: number;
                          manual_entry?: boolean | null;
                          patient_id?: number | null;
                          private_note?: string | null;
                          progress_status?: string | null;
                          selected_template?: Json;
                          start_timestamp?: string;
                          transcript?: string | null;
                          updated_by?: number | null;
                      };
                      Relationships: [
                          {
                              columns: ["audit_run_id"];
                              foreignKeyName: "session_audit_run_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "audit_runs";
                          },
                          {
                              columns: ["case_id"];
                              foreignKeyName: "session_case_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "cases";
                          },
                          {
                              columns: ["patient_id"];
                              foreignKeyName: "session_patient_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["patient_id"];
                              referencedRelation: "patient";
                          },
                          {
                              columns: ["updated_by"];
                              foreignKeyName: "session_updated_by_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "profiles";
                          },
                      ];
                      Row: {
                          ai_summarized_note: string
                          | null;
                          as_summarized_note_type: string | null;
                          audit_run_id: number | null;
                          audit_status:
                              | "error"
                              | "pass"
                              | "fail"
                              | "needs_review"
                              | "pending"
                              | "in_progress"
                              | "not_started"
                              | null;
                          case_id: number
                          | null;
                          cpt_code: Json[] | null;
                          created_at: string;
                          created_by: string | null;
                          dsm_code: Json[] | null;
                          end_timestamp: string;
                          error_msg: string | null;
                          file_url: string | null;
                          icd_code: Json[] | null;
                          id: number;
                          manual_entry: boolean | null;
                          patient_id: number | null;
                          private_note: string | null;
                          progress_status: string | null;
                          selected_template: Json;
                          start_timestamp: string;
                          transcript: string | null;
                          updated_by: number | null;
                      };
                      Update: {
                          ai_summarized_note?: string
                          | null;
                          as_summarized_note_type?: string | null;
                          audit_run_id?: number | null;
                          audit_status?:
                              | "error"
                              | "pass"
                              | "fail"
                              | "needs_review"
                              | "pending"
                              | "in_progress"
                              | "not_started"
                              | null;
                          case_id?: number
                          | null;
                          cpt_code?: Json[] | null;
                          created_at?: string;
                          created_by?: string | null;
                          dsm_code?: Json[] | null;
                          end_timestamp?: string;
                          error_msg?: string | null;
                          file_url?: string | null;
                          icd_code?: Json[] | null;
                          id?: number;
                          manual_entry?: boolean | null;
                          patient_id?: number | null;
                          private_note?: string | null;
                          progress_status?: string | null;
                          selected_template?: Json;
                          start_timestamp?: string;
                          transcript?: string | null;
                          updated_by?: number | null;
                      };
                  };
                  teams: {
                      Insert: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          entity_id?: number | null;
                          id?: number;
                          name?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "teams_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          created_at: string;
                          created_by: string
                          | null;
                          entity_id: number | null;
                          id: number;
                          name: string | null;
                      };
                      Update: {
                          created_at?: string;
                          created_by?: string
                          | null;
                          entity_id?: number | null;
                          id?: number;
                          name?: string | null;
                      };
                  };
                  template_audit_templates: {
                      Insert: { audit_template_id: number; template_id: string };
                      Relationships: [
                          {
                              columns: ["audit_template_id"];
                              foreignKeyName: "template_audit_templates_audit_template_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "audit_template";
                          },
                          {
                              columns: ["template_id"];
                              foreignKeyName: "template_audit_templates_template_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "templates";
                          },
                      ];
                      Row: { audit_template_id: number; template_id: string };
                      Update: { audit_template_id?: number; template_id?: string };
                  };
                  templates: {
                      Insert: {
                          additional_ai_instructions?: string
                          | null;
                          check_cpt?: boolean | null;
                          check_demo?: boolean | null;
                          check_dsm_5?: boolean | null;
                          check_icd_10?: boolean | null;
                          created_by?: string | null;
                          created_by_circle?: boolean | null;
                          hidden_instructions?: string | null;
                          id?: string;
                          is_allow_bullet_points?: boolean | null;
                          is_unstructured_narrative?: boolean | null;
                          last_updated?: string | null;
                          last_used?: string | null;
                          original_template_id?: string | null;
                          shared_with_org_id?: number | null;
                          title: string;
                      };
                      Relationships: [
                          {
                              columns: ["original_template_id"];
                              foreignKeyName: "templates_original_template_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "templates";
                          },
                          {
                              columns: ["shared_with_org_id"];
                              foreignKeyName: "templates_shared_with_org_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                      ];
                      Row: {
                          additional_ai_instructions: string
                          | null;
                          check_cpt: boolean | null;
                          check_demo: boolean | null;
                          check_dsm_5: boolean | null;
                          check_icd_10: boolean | null;
                          created_by: string | null;
                          created_by_circle: boolean | null;
                          hidden_instructions: string | null;
                          id: string;
                          is_allow_bullet_points: boolean | null;
                          is_unstructured_narrative: boolean | null;
                          last_updated: string | null;
                          last_used: string | null;
                          original_template_id: string | null;
                          shared_with_org_id: number | null;
                          title: string;
                      };
                      Update: {
                          additional_ai_instructions?: string
                          | null;
                          check_cpt?: boolean | null;
                          check_demo?: boolean | null;
                          check_dsm_5?: boolean | null;
                          check_icd_10?: boolean | null;
                          created_by?: string | null;
                          created_by_circle?: boolean | null;
                          hidden_instructions?: string | null;
                          id?: string;
                          is_allow_bullet_points?: boolean | null;
                          is_unstructured_narrative?: boolean | null;
                          last_updated?: string | null;
                          last_used?: string | null;
                          original_template_id?: string | null;
                          shared_with_org_id?: number | null;
                          title?: string;
                      };
                  };
                  treatment_plan_sessions: {
                      Insert: {
                          created_at?: string;
                          created_by?: string;
                          id?: number;
                          session_id: number;
                          treatment_plan_id: number;
                      };
                      Relationships: [
                          {
                              columns: ["session_id"];
                              foreignKeyName: "treatment_plan_sessions_session_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "session";
                          },
                          {
                              columns: ["treatment_plan_id"];
                              foreignKeyName: "treatment_plan_sessions_treatment_plan_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "treatment_plans";
                          },
                      ];
                      Row: {
                          created_at: string;
                          created_by: string;
                          id: number;
                          session_id: number;
                          treatment_plan_id: number;
                      };
                      Update: {
                          created_at?: string;
                          created_by?: string;
                          id?: number;
                          session_id?: number;
                          treatment_plan_id?: number;
                      };
                  };
                  treatment_plans: {
                      Insert: {
                          assigned_at?: string
                          | null;
                          created_at?: string;
                          created_by?: string | null;
                          icd_code_id?: number | null;
                          id?: number;
                          metadata?: Json;
                          patient_id?: number | null;
                          raw_text?: string | null;
                          review_by?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["icd_code_id"];
                              foreignKeyName: "treatment_plans_icd_code_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "icd_codes";
                          },
                          {
                              columns: ["patient_id"];
                              foreignKeyName: "treatment_plans_patient_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["patient_id"];
                              referencedRelation: "patient";
                          },
                      ];
                      Row: {
                          assigned_at: string
                          | null;
                          created_at: string;
                          created_by: string | null;
                          icd_code_id: number | null;
                          id: number;
                          metadata: Json;
                          patient_id: number | null;
                          raw_text: string | null;
                          review_by: string | null;
                      };
                      Update: {
                          assigned_at?: string
                          | null;
                          created_at?: string;
                          created_by?: string | null;
                          icd_code_id?: number | null;
                          id?: number;
                          metadata?: Json;
                          patient_id?: number | null;
                          raw_text?: string | null;
                          review_by?: string | null;
                      };
                  };
                  user_entities: {
                      Insert: {
                          direct_reports?: string[]
                          | null;
                          entity_id: number;
                          id?: number;
                          role_id: number;
                          user_id: string;
                      };
                      Relationships: [
                          {
                              columns: ["entity_id"];
                              foreignKeyName: "user_entities_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["entity_id"];
                              referencedRelation: "entity";
                          },
                          {
                              columns: ["role_id"];
                              foreignKeyName: "user_entities_role_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["role_id"];
                              referencedRelation: "roles";
                          },
                      ];
                      Row: {
                          direct_reports: string[]
                          | null;
                          entity_id: number;
                          id: number;
                          role_id: number;
                          user_id: string;
                      };
                      Update: {
                          direct_reports?: string[]
                          | null;
                          entity_id?: number;
                          id?: number;
                          role_id?: number;
                          user_id?: string;
                      };
                  };
                  user_prompts: {
                      Insert: {
                          created_at?: string;
                          id?: number;
                          is_pinned?: boolean
                          | null;
                          prompt?: string | null;
                          user_id?: string | null;
                      };
                      Relationships: [];
                      Row: {
                          created_at: string;
                          id: number;
                          is_pinned: boolean | null;
                          prompt: string | null;
                          user_id: string | null;
                      };
                      Update: {
                          created_at?: string;
                          id?: number;
                          is_pinned?: boolean
                          | null;
                          prompt?: string | null;
                          user_id?: string | null;
                      };
                  };
                  user_teams: {
                      Insert: {
                          created_at?: string;
                          id?: number;
                          profile_id: number;
                          team_id: number;
                          user_entity_id?: number
                          | null;
                          user_id?: string | null;
                      };
                      Relationships: [
                          {
                              columns: ["profile_id"];
                              foreignKeyName: "user_teams_profile_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "profiles";
                          },
                          {
                              columns: ["team_id"];
                              foreignKeyName: "user_teams_team_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "teams";
                          },
                          {
                              columns: ["user_entity_id"];
                              foreignKeyName: "user_teams_user_entity_id_fkey";
                              isOneToOne: false;
                              referencedColumns: ["id"];
                              referencedRelation: "user_entities";
                          },
                      ];
                      Row: {
                          created_at: string;
                          id: number;
                          profile_id: number;
                          team_id: number;
                          user_entity_id: number
                          | null;
                          user_id: string | null;
                      };
                      Update: {
                          created_at?: string;
                          id?: number;
                          profile_id?: number;
                          team_id?: number;
                          user_entity_id?: number
                          | null;
                          user_id?: string | null;
                      };
                  };
              };
              Views: {};
          },
          { PostgrestVersion: "13.0.5" },
      >