B2B-85: add order xml generation (#8)

* B2B-85: add order xml generation

* some fixes after merge

---------

Co-authored-by: Helena <helena@Helenas-MacBook-Pro.local>
This commit is contained in:
Helena
2025-06-09 15:58:50 +03:00
committed by GitHub
parent d49bfcfcfd
commit 5a1040b888
14 changed files with 582 additions and 99 deletions

View File

@@ -50,24 +50,27 @@ export type Database = {
}
sync_entries: {
Row: {
changed_by_role: string | null
changed_by_role: string
comment: string | null
created_at: string
id: number
operation: string | null
operation: string
status: string
}
Insert: {
changed_by_role?: string | null
changed_by_role: string
comment?: string | null
created_at?: string
id?: number
operation?: string | null
operation: string
status: string
}
Update: {
changed_by_role?: string | null
changed_by_role?: string
comment?: string | null
created_at?: string
id?: number
operation?: string | null
operation?: string
status?: string
}
Relationships: []
@@ -224,7 +227,7 @@ export type Database = {
analysis_name_lab: string | null
created_at: string
id: number
order: number | null
order: number
parent_analysis_element_id: number
tehik_loinc_name: string | null
tehik_short_loinc: string | null
@@ -236,7 +239,7 @@ export type Database = {
analysis_name_lab?: string | null
created_at?: string
id?: number
order?: number | null
order: number
parent_analysis_element_id: number
tehik_loinc_name?: string | null
tehik_short_loinc?: string | null
@@ -248,7 +251,7 @@ export type Database = {
analysis_name_lab?: string | null
created_at?: string
id?: number
order?: number | null
order?: number
parent_analysis_element_id?: number
tehik_loinc_name?: string | null
tehik_short_loinc?: string | null
@@ -266,42 +269,42 @@ export type Database = {
}
analysis_elements: {
Row: {
analysis_id_oid: string | null
analysis_id_oid: string
analysis_id_original: string
analysis_name_lab: string | null
created_at: string
id: number
material_groups: Json[] | null
order: number | null
order: number
parent_analysis_group_id: number
tehik_loinc_name: string | null
tehik_short_loinc: string | null
tehik_loinc_name: string
tehik_short_loinc: string
updated_at: string | null
}
Insert: {
analysis_id_oid?: string | null
analysis_id_oid: string
analysis_id_original: string
analysis_name_lab?: string | null
created_at?: string
id?: number
material_groups?: Json[] | null
order?: number | null
order: number
parent_analysis_group_id: number
tehik_loinc_name?: string | null
tehik_short_loinc?: string | null
tehik_loinc_name: string
tehik_short_loinc: string
updated_at?: string | null
}
Update: {
analysis_id_oid?: string | null
analysis_id_oid?: string
analysis_id_original?: string
analysis_name_lab?: string | null
created_at?: string
id?: number
material_groups?: Json[] | null
order?: number | null
order?: number
parent_analysis_group_id?: number
tehik_loinc_name?: string | null
tehik_short_loinc?: string | null
tehik_loinc_name?: string
tehik_short_loinc?: string
updated_at?: string | null
}
Relationships: [
@@ -318,29 +321,53 @@ export type Database = {
Row: {
created_at: string
id: number
name: string | null
order: number | null
name: string
order: number
original_id: string
updated_at: string | null
}
Insert: {
created_at?: string
id?: number
name?: string | null
order?: number | null
name: string
order: number
original_id: string
updated_at?: string | null
}
Update: {
created_at?: string
id?: number
name?: string | null
order?: number | null
name?: string
order?: number
original_id?: string
updated_at?: string | null
}
Relationships: []
}
analysis_orders: {
Row: {
analysis_group_ids: number[] | null
created_at: string
id: string
status: Database["public"]["Enums"]["analysis_order_status"]
user_id: string
}
Insert: {
analysis_group_ids?: number[] | null
created_at?: string
id: string
status: Database["public"]["Enums"]["analysis_order_status"]
user_id: string
}
Update: {
analysis_group_ids?: number[] | null
created_at?: string
id?: string
status?: Database["public"]["Enums"]["analysis_order_status"]
user_id?: string
}
Relationships: []
}
billing_customers: {
Row: {
account_id: string
@@ -1111,6 +1138,13 @@ export type Database = {
}
}
Enums: {
analysis_order_status:
| "QUEUED"
| "ON_HOLD"
| "PROCESSING"
| "COMPLETED"
| "REJECTED"
| "CANCELLED"
app_permissions:
| "roles.manage"
| "billing.manage"
@@ -1257,6 +1291,14 @@ export const Constants = {
},
public: {
Enums: {
analysis_order_status: [
"QUEUED",
"ON_HOLD",
"PROCESSING",
"COMPLETED",
"REJECTED",
"CANCELLED",
],
app_permissions: [
"roles.manage",
"billing.manage",

View File

@@ -0,0 +1,91 @@
create type "public"."analysis_order_status" as enum ('QUEUED', 'ON_HOLD', 'PROCESSING', 'COMPLETED', 'REJECTED', 'CANCELLED');
create table "public"."analysis_orders" (
"id" uuid not null,
"analysis_element_ids" bigint[],
"analysis_ids" bigint[],
"user_id" uuid not null,
"status" public.analysis_order_status not null,
"created_at" timestamp with time zone not null default now()
);
alter table "public"."analysis_orders" enable row level security;
CREATE UNIQUE INDEX analysis_orders_pkey ON public.analysis_orders USING btree (id);
alter table "public"."analysis_orders" add constraint "analysis_orders_pkey" PRIMARY KEY using index "analysis_orders_pkey";
alter table "public"."analysis_orders" add constraint "analysis_orders_id_fkey" FOREIGN KEY (id) REFERENCES auth.users(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
alter table "public"."analysis_orders" validate constraint "analysis_orders_id_fkey";
grant delete on table "public"."analysis_orders" to "authenticated";
grant insert on table "public"."analysis_orders" to "authenticated";
grant references on table "public"."analysis_orders" to "authenticated";
grant select on table "public"."analysis_orders" to "authenticated";
grant trigger on table "public"."analysis_orders" to "authenticated";
grant truncate on table "public"."analysis_orders" to "authenticated";
grant update on table "public"."analysis_orders" to "authenticated";
grant delete on table "public"."analysis_orders" to "service_role";
grant insert on table "public"."analysis_orders" to "service_role";
grant references on table "public"."analysis_orders" to "service_role";
grant select on table "public"."analysis_orders" to "service_role";
grant trigger on table "public"."analysis_orders" to "service_role";
grant truncate on table "public"."analysis_orders" to "service_role";
grant update on table "public"."analysis_orders" to "service_role";
create policy "analysis_all"
on "public"."analysis_orders"
as permissive
for all
to authenticated, service_role
using (true);
create policy "analysis_select"
on "public"."analyses"
as permissive
for select
to public
using (true);
create policy "analysis_elements_select"
on "public"."analysis_elements"
as permissive
for select
to public
using (true);
create policy "analysis_groups_select"
on "public"."analysis_groups"
as permissive
for select
to public
using (true);
-- Drop previously created unnecessary indices
drop index if exists "public"."analysis_elements_original_id_key";
drop index if exists "public"."analysis_original_id_key";
-- Remove nullable from previously added fields
alter table "public"."analyses" alter column "order" set not null;
alter table "public"."analysis_elements" alter column "analysis_id_oid" set not null;
alter table "public"."analysis_elements" alter column "order" set not null;
alter table "public"."analysis_groups" alter column "name" set not null;
alter table "public"."analysis_groups" alter column "order" set not null;
alter table "public"."analysis_elements" alter column "tehik_loinc_name" set not null;
alter table "public"."analysis_elements" alter column "tehik_short_loinc" set not null;