feat(MED-105): update sending test analysis results
This commit is contained in:
@@ -218,12 +218,9 @@ export async function readPrivateMessageResponse({
|
||||
privateMessage.messageId,
|
||||
);
|
||||
const messageResponse = privateMessageContent?.Saadetis?.Vastus;
|
||||
const medusaOrderId = privateMessageContent?.Saadetis?.Tellimus?.ValisTellimuseId;
|
||||
const medusaOrderId = privateMessageContent?.Saadetis?.Tellimus?.ValisTellimuseId || messageResponse?.ValisTellimuseId;
|
||||
|
||||
if (!messageResponse) {
|
||||
if (medusaOrderId === 'order_01K2JSJXR5XVNRWEAGB199RCKP') {
|
||||
console.info("messageResponse", JSON.stringify(privateMessageContent, null, 2));
|
||||
}
|
||||
throw new Error(`Private message response has no results yet for order=${medusaOrderId}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ export async function composeOrderTestResponseXML({
|
||||
// 1 – Järjekorras, 2 – Ootel, 3 - Töös, 4 – Lõpetatud,
|
||||
// 5 – Tagasi lükatud, 6 – Tühistatud.
|
||||
const orderStatus = 4;
|
||||
const orderNumber = 'TSU000001200';
|
||||
const orderNumber = orderId;
|
||||
|
||||
const allAnalysisElementsForGroups = analysisElements?.filter((element) => {
|
||||
return analysisGroups.some((group) => group.id === element.analysis_groups.id);
|
||||
@@ -153,7 +153,7 @@ export async function composeOrderTestResponseXML({
|
||||
|
||||
const lower = getRandomInt(0, 100);
|
||||
const upper = getRandomInt(lower + 1, 500);
|
||||
const result = getRandomInt(lower, upper);
|
||||
const result = getRandomInt(lower - Math.floor(lower * 0.1), upper + Math.floor(upper * 0.1));
|
||||
addedIds.add(relatedAnalysisElement.id);
|
||||
return (`
|
||||
<UuringuGrupp>
|
||||
@@ -175,7 +175,7 @@ export async function composeOrderTestResponseXML({
|
||||
<VastuseAeg>${formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss')}</VastuseAeg>
|
||||
<NormYlem kaasaarvatud=\"EI\">${upper}</NormYlem>
|
||||
<NormAlum kaasaarvatud=\"EI\">${lower}</NormAlum>
|
||||
<NormiStaatus>0</NormiStaatus>
|
||||
<NormiStaatus>${result < lower ? 1 : (result > upper ? 1 : 0)}</NormiStaatus>
|
||||
<ProoviJarjenumber>1</ProoviJarjenumber>
|
||||
</UuringuVastus>
|
||||
</UuringuElement>
|
||||
|
||||
@@ -108,7 +108,33 @@ export async function getAnalysisOrders({
|
||||
}: {
|
||||
orderStatus?: Tables<{ schema: 'medreport' }, 'analysis_orders'>['status'];
|
||||
} = {}) {
|
||||
const query = getSupabaseServerClient()
|
||||
const client = getSupabaseServerClient();
|
||||
|
||||
const {
|
||||
data: { user },
|
||||
} = await client.auth.getUser();
|
||||
if (!user) {
|
||||
throw new Error('Unauthorized');
|
||||
}
|
||||
|
||||
const query = client
|
||||
.schema('medreport')
|
||||
.from('analysis_orders')
|
||||
.select('*')
|
||||
.eq("user_id", user.id)
|
||||
if (orderStatus) {
|
||||
query.eq('status', orderStatus);
|
||||
}
|
||||
const orders = await query.order('created_at', { ascending: false }).throwOnError();
|
||||
return orders.data;
|
||||
}
|
||||
|
||||
export async function getAnalysisOrdersAdmin({
|
||||
orderStatus,
|
||||
}: {
|
||||
orderStatus?: Tables<{ schema: 'medreport' }, 'analysis_orders'>['status'];
|
||||
} = {}) {
|
||||
const query = getSupabaseServerAdminClient()
|
||||
.schema('medreport')
|
||||
.from('analysis_orders')
|
||||
.select('*')
|
||||
|
||||
Reference in New Issue
Block a user