feat(MED-131): handle analysis order

This commit is contained in:
2025-08-04 11:53:04 +03:00
parent 08950896e5
commit 91f6dd11be
10 changed files with 310 additions and 140 deletions

View File

@@ -1,6 +1,13 @@
import type { Tables } from '@/packages/supabase/src/database.types';
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
import type { IUuringElement } from "./medipost.types";
type AnalysesWithGroupsAndElements = ({
analysis_elements: Tables<{ schema: 'medreport' }, 'analysis_elements'> & {
analysis_groups: Tables<{ schema: 'medreport' }, 'analysis_groups'>;
};
} & Tables<{ schema: 'medreport' }, 'analyses'>)[];
export const createAnalysis = async (
analysis: IUuringElement,
insertedAnalysisElementId: number,
@@ -97,3 +104,13 @@ export const createMedusaSyncSuccessEntry = async () => {
status: 'SUCCESS',
});
}
export async function getAnalyses({ ids }: { ids: number[] }): Promise<AnalysesWithGroupsAndElements> {
const { data } = await getSupabaseServerAdminClient()
.schema('medreport')
.from('analyses')
.select(`*, analysis_elements(*, analysis_groups(*))`)
.in('id', ids);
return data as unknown as AnalysesWithGroupsAndElements;
}