Merge branch 'develop' into add-eslint

This commit is contained in:
Danel Kungla
2025-09-23 10:56:41 +03:00
7 changed files with 118 additions and 53 deletions

View File

@@ -29,7 +29,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '1744-2',
},
},
@@ -49,7 +49,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '1920-8',
},
},
@@ -69,7 +69,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '1988-5',
},
},
@@ -89,7 +89,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '57747-8',
},
},
@@ -109,7 +109,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '2276-4',
},
},
@@ -129,7 +129,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '14771-0',
},
},
@@ -149,7 +149,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: false,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '59156-0',
},
},
@@ -169,7 +169,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: true,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '59156-0',
},
},
@@ -189,7 +189,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '13955-0',
},
},
@@ -209,7 +209,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '14646-4',
},
},
@@ -229,7 +229,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '2000-8',
},
},
@@ -249,7 +249,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '59158-6',
},
},
@@ -269,7 +269,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '14647-2',
},
},
@@ -289,7 +289,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '14682-9',
},
},
@@ -309,7 +309,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '22748-8',
},
},
@@ -329,7 +329,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '58805-3',
},
},
@@ -349,7 +349,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '2601-3',
},
},
@@ -370,7 +370,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '70204-3',
},
},
@@ -390,7 +390,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '14798-3',
},
},
@@ -411,7 +411,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '14927-8',
},
},
@@ -431,7 +431,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '3016-3',
},
},
@@ -451,7 +451,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '22664-7',
},
},
@@ -471,7 +471,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '50561-0',
},
},
@@ -492,7 +492,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '60493-4',
},
},
@@ -512,7 +512,7 @@ const big1: AnalysisTestResponse = {
responseValueIsWithinNorm: true,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '60025-4',
},
},
@@ -538,7 +538,7 @@ const big2: AnalysisTestResponse = {
responseValueIsWithinNorm: null,
normLowerIncluded: false,
normUpperIncluded: false,
status: '4',
status: 4,
analysisElementOriginalId: '1988-5',
},
},
@@ -558,6 +558,8 @@ const big2: AnalysisTestResponse = {
responseValue: 150,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '718-7',
},
{
@@ -570,6 +572,8 @@ const big2: AnalysisTestResponse = {
responseValue: 45,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '4544-3',
},
{
@@ -582,6 +586,8 @@ const big2: AnalysisTestResponse = {
responseValue: 5,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '6690-2',
},
{
@@ -594,6 +600,8 @@ const big2: AnalysisTestResponse = {
responseValue: 5,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '789-8',
},
{
@@ -606,6 +614,8 @@ const big2: AnalysisTestResponse = {
responseValue: 85,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '787-2',
},
{
@@ -618,6 +628,8 @@ const big2: AnalysisTestResponse = {
responseValue: 30,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '785-6',
},
{
@@ -630,6 +642,8 @@ const big2: AnalysisTestResponse = {
responseValue: 355,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '786-4',
},
{
@@ -642,6 +656,8 @@ const big2: AnalysisTestResponse = {
responseValue: 15,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '788-0',
},
{
@@ -654,6 +670,8 @@ const big2: AnalysisTestResponse = {
responseValue: 255,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '777-3',
},
{
@@ -666,6 +684,8 @@ const big2: AnalysisTestResponse = {
responseValue: 0.2,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '51637-7',
},
{
@@ -678,6 +698,8 @@ const big2: AnalysisTestResponse = {
responseValue: 10,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '32623-1',
},
{
@@ -690,6 +712,8 @@ const big2: AnalysisTestResponse = {
responseValue: 15,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '32207-3',
},
{
@@ -702,6 +726,8 @@ const big2: AnalysisTestResponse = {
responseValue: 0.05,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '704-7',
},
{
@@ -714,6 +740,8 @@ const big2: AnalysisTestResponse = {
responseValue: 0.05,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '711-2',
},
{
@@ -726,6 +754,8 @@ const big2: AnalysisTestResponse = {
responseValue: 5,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '751-8',
},
{
@@ -738,6 +768,8 @@ const big2: AnalysisTestResponse = {
responseValue: 0.5,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '742-7',
},
{
@@ -750,6 +782,8 @@ const big2: AnalysisTestResponse = {
responseValue: 1.5,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '731-0',
},
{
@@ -762,6 +796,8 @@ const big2: AnalysisTestResponse = {
responseValue: 0,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '51584-1',
},
{
@@ -774,6 +810,8 @@ const big2: AnalysisTestResponse = {
responseValue: 0,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '38518-7',
},
{
@@ -782,8 +820,12 @@ const big2: AnalysisTestResponse = {
normStatus: 0,
responseTime: '2025-09-12 14:02:04',
responseValue: 0,
normUpper: null,
normLower: null,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '771-6',
},
{
@@ -792,8 +834,12 @@ const big2: AnalysisTestResponse = {
normStatus: 0,
responseTime: '2025-09-12 14:02:04',
responseValue: 0,
normUpper: null,
normLower: null,
normLowerIncluded: false,
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
analysisElementOriginalId: '58413-6',
},
],
@@ -807,7 +853,7 @@ const big2: AnalysisTestResponse = {
normUpperIncluded: false,
responseValueIsNegative: false,
responseValueIsWithinNorm: false,
status: '4',
status: 4,
analysisElementOriginalId: '57021-8',
},
},
@@ -828,7 +874,7 @@ const big2: AnalysisTestResponse = {
normUpperIncluded: false,
responseValueIsNegative: false,
responseValueIsWithinNorm: false,
status: '5',
status: 5,
analysisElementOriginalId: '43583-4',
},
},
@@ -850,7 +896,7 @@ const big2: AnalysisTestResponse = {
normUpperIncluded: false,
responseValueIsNegative: null,
responseValueIsWithinNorm: null,
status: '4',
status: 4,
analysisElementOriginalId: '60493-4',
},
},

View File

@@ -181,8 +181,12 @@ async function sendAnalysisPackageOrderEmail({
partnerLocationName,
language,
});
console.info(`Successfully sent analysis package order email to ${email}`);
} catch (error) {
console.error('Failed to send email', error);
console.error(
`Failed to send analysis package order email to ${email}`,
error,
);
}
}

View File

@@ -51,27 +51,29 @@ export async function upsertMedipostActionLog({
medipostExternalOrderId?: string | null;
medipostPrivateMessageId?: string | null;
}) {
const { data } = await getSupabaseServerAdminClient()
const recordData = {
action,
xml,
has_analysis_results: hasAnalysisResults,
medusa_order_id: medusaOrderId,
response_xml: responseXml,
has_error: hasError,
medipost_external_order_id: medipostExternalOrderId,
medipost_private_message_id: medipostPrivateMessageId,
};
const query = getSupabaseServerAdminClient()
.schema('medreport')
.from('medipost_actions')
.upsert(
{
action,
xml,
has_analysis_results: hasAnalysisResults,
medusa_order_id: medusaOrderId,
response_xml: responseXml,
has_error: hasError,
medipost_external_order_id: medipostExternalOrderId,
medipost_private_message_id: medipostPrivateMessageId,
},
{
onConflict: 'medipost_private_message_id',
ignoreDuplicates: false,
},
)
.select('id')
.throwOnError();
.from('medipost_actions');
const { data } = medipostPrivateMessageId
? await query
.upsert(recordData, {
onConflict: 'medipost_private_message_id',
ignoreDuplicates: false,
})
.select('id')
.throwOnError()
: await query.insert(recordData).select('id').throwOnError();
const medipostActionId = data?.[0]?.id;
if (!medipostActionId) {

View File

@@ -369,6 +369,7 @@ export async function readPrivateMessageResponse({
const hasInvalidOrderId = isNaN(analysisOrderId);
if (hasInvalidOrderId || !messageResponse || !patientPersonalCode) {
console.error(`Invalid order id or message response or patient personal code, medipostExternalOrderId=${medipostExternalOrderId}, privateMessageId=${privateMessageId}`);
await upsertMedipostActionLog({
action: 'sync_analysis_results_from_medipost',
xml: privateMessageXml,
@@ -415,6 +416,7 @@ export async function readPrivateMessageResponse({
order: analysisOrder,
});
console.info(`Successfully synced analysis results from Medipost message privateMessageId=${privateMessageId}`);
await upsertMedipostActionLog({
action: 'sync_analysis_results_from_medipost',
xml: privateMessageXml,
@@ -571,6 +573,7 @@ export async function sendOrderToMedipost({
isMedipostError,
errorMessage: e.response,
});
console.error(`Failed to send order to Medipost, medusaOrderId=${medusaOrderId}, error=${e.response}`);
await upsertMedipostActionLog({
action: 'send_order_to_medipost',
xml: orderXml,
@@ -580,6 +583,7 @@ export async function sendOrderToMedipost({
hasError: true,
});
} else {
console.error(`Failed to send order to Medipost, medusaOrderId=${medusaOrderId}, error=${e}`);
await logMedipostDispatch({
medusaOrderId,
isSuccess: false,
@@ -596,6 +600,7 @@ export async function sendOrderToMedipost({
throw e;
}
console.info(`Successfully sent order to Medipost, medusaOrderId=${medusaOrderId}`);
await logMedipostDispatch({
medusaOrderId,
isSuccess: true,

View File

@@ -9,8 +9,6 @@ import { z } from 'zod';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
import { requireUserInServerComponent } from '../server/require-user-in-server-component';
const env = () =>
z
.object({

View File

@@ -355,7 +355,7 @@ export async function medusaLoginOrRegister(
return await medusaLogin(email, password);
} catch (registerError) {
console.error(
'Failed to create Medusa account for user with email=${email}',
`Failed to create Medusa account for user with email=${email}`,
registerError,
);
throw medusaError(registerError);

View File

@@ -0,0 +1,10 @@
create table if not exists medreport.ai_responses (
id uuid unique not null default extensions.uuid_generate_v4 (),
account_id uuid references medreport.accounts(id) on delete cascade not null,
prompt_name varchar(50) not null,
prompt_id varchar(50) not null,
input jsonb not null,
response jsonb not null,
created_at timestamp with time zone not null default now(),
latest_data_change timestamp with time zone not null
);