feat(MED-131): handle analysis order
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user